diff --git a/Minecraft.Assets/Windows64Media/loc/en-EN/strings.lang b/Minecraft.Assets/Windows64Media/loc/en-EN/strings.lang
index 752552227..2a3a90f32 100644
--- a/Minecraft.Assets/Windows64Media/loc/en-EN/strings.lang
+++ b/Minecraft.Assets/Windows64Media/loc/en-EN/strings.lang
@@ -4760,6 +4760,9 @@ Would you like to unlock the full game?
Food
+
+ Search Items
+
Structures
diff --git a/Minecraft.Assets/Windows64Media/loc/stringsGeneric.xml b/Minecraft.Assets/Windows64Media/loc/stringsGeneric.xml
index 36b521dd0..ec3b88e28 100644
--- a/Minecraft.Assets/Windows64Media/loc/stringsGeneric.xml
+++ b/Minecraft.Assets/Windows64Media/loc/stringsGeneric.xml
@@ -1,4 +1,4 @@
-
+
New Downloadable Content is available! Access it from the Minecraft Store button on the Main Menu.
@@ -6044,6 +6044,10 @@ Would you like to unlock the full game now?
Food
+
+ Search Items
+
+
Structures
@@ -8811,4 +8815,4 @@ All Ender Chests in a world are linked. Items placed into an Ender Chest are acc
Cure
-
\ No newline at end of file
+
diff --git a/Minecraft.Client/Level/ServerLevel.cpp b/Minecraft.Client/Level/ServerLevel.cpp
index 025190b7f..1b8ec2782 100644
--- a/Minecraft.Client/Level/ServerLevel.cpp
+++ b/Minecraft.Client/Level/ServerLevel.cpp
@@ -1112,13 +1112,13 @@ std::shared_ptr ServerLevel::explode(std::shared_ptr source,
}
if (player->distanceToSqr(x, y, z) < 64 * 64) {
- Vec3* knockbackVec = explosion->getHitPlayerKnockback(player);
+ Vec3 knockbackVec = explosion->getHitPlayerKnockback(player);
// app.DebugPrintf("Sending %s with knockback (%f,%f,%f)\n",
// knockbackOnly?"knockbackOnly":"allExplosion",knockbackVec->x,knockbackVec->y,knockbackVec->z);
// If the player is not the primary on the system, then we only
// want to send info for the knockback
player->connection->send(std::shared_ptr(
- new ExplodePacket(x, y, z, r, &explosion->toBlow, knockbackVec,
+ new ExplodePacket(x, y, z, r, &explosion->toBlow, &knockbackVec,
knockbackOnly)));
sentTo.push_back(player);
}
@@ -1584,4 +1584,4 @@ void ServerLevel::flagEntitiesToBeRemoved(unsigned int* flags,
if (chunkMap) {
chunkMap->flagEntitiesToBeRemoved(flags, removedFound);
}
-}
\ No newline at end of file
+}
diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp
index 1e9a1c954..d939bafc6 100644
--- a/Minecraft.Client/Minecraft.cpp
+++ b/Minecraft.Client/Minecraft.cpp
@@ -724,7 +724,6 @@ void Minecraft::run()
// try { // 4J - removed try/catch
// if (minecraftApplet != null && !minecraftApplet.isActive()) break; // 4J - removed
AABB::resetPool();
- Vec3::resetPool();
// if (parent == NULL && Display.isCloseRequested()) { // 4J - removed
// stop();
@@ -1281,7 +1280,6 @@ void Minecraft::run_middle() {
// if (minecraftApplet != null &&
// !minecraftApplet.isActive()) break; // 4J - removed
AABB::resetPool();
- Vec3::resetPool();
// if (parent == NULL && Display.isCloseRequested()) {
// // 4J - removed
@@ -2223,7 +2221,6 @@ void Minecraft::emergencySave() {
// 4J - lots of try/catches removed here, and garbage collector things
levelRenderer->clear();
AABB::clearPool();
- Vec3::clearPool();
setLevel(NULL);
}
@@ -2400,7 +2397,6 @@ void Minecraft::levelTickUpdateFunc(void* pParam) {
void Minecraft::levelTickThreadInitFunc() {
AABB::CreateNewThreadStorage();
- Vec3::CreateNewThreadStorage();
Compression::UseDefaultThreadStorage();
}
@@ -2750,7 +2746,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
// 4J-PB - Call the useItemOn with the TestOnly flag set
bool bUseItemOn = gameMode->useItemOn(
player, level, itemInstance, x, y, z, face,
- hitResult->pos, true);
+ &hitResult->pos, true);
/* 4J-Jev:
* Moved this here so we have item tooltips to
@@ -3900,7 +3896,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
bool usedItem = false;
gameMode->useItemOn(player, level, nullptr, hitResult->x,
hitResult->y, hitResult->z, 0,
- hitResult->pos, false, &usedItem);
+ &hitResult->pos, false, &usedItem);
} else {
ui.PlayUISFX(eSFX_Press);
app.LoadCrafting2x2Menu(iPad, player);
diff --git a/Minecraft.Client/MinecraftServer.cpp b/Minecraft.Client/MinecraftServer.cpp
index a08f48ac9..17019e984 100644
--- a/Minecraft.Client/MinecraftServer.cpp
+++ b/Minecraft.Client/MinecraftServer.cpp
@@ -315,7 +315,6 @@ int MinecraftServer::runPostUpdate(void* lpParam) {
Entity::useSmallIds(); // This thread can end up spawning entities as
// resources
AABB::CreateNewThreadStorage();
- Vec3::CreateNewThreadStorage();
Compression::UseDefaultThreadStorage();
Level::enableLightingCache();
Tile::CreateNewThreadStorage();
@@ -365,7 +364,6 @@ int MinecraftServer::runPostUpdate(void* lpParam) {
// #endif //__PS3__
Tile::ReleaseThreadStorage();
AABB::ReleaseThreadStorage();
- Vec3::ReleaseThreadStorage();
Level::destroyLightingCache();
ShutdownManager::HasFinished(ShutdownManager::ePostProcessThread);
@@ -1651,7 +1649,6 @@ void MinecraftServer::tick() {
}
AABB::resetPool();
- Vec3::resetPool();
tickCount++;
diff --git a/Minecraft.Client/Network/ClientConnection.cpp b/Minecraft.Client/Network/ClientConnection.cpp
index ab03b3403..8494759de 100644
--- a/Minecraft.Client/Network/ClientConnection.cpp
+++ b/Minecraft.Client/Network/ClientConnection.cpp
@@ -1,5 +1,7 @@
#include "../Platform/stdafx.h"
#include "ClientConnection.h"
+#include
+#include
#include "../Level/MultiPlayerLevel.h"
#include "../Player/MultiPlayerLocalPlayer.h"
#include "../GameState/StatsCounter.h"
@@ -43,7 +45,6 @@
#include "../MinecraftServer.h"
#include "../ClientConstants.h"
#include "../../Minecraft.World/Util/SoundTypes.h"
-#include "../../Minecraft.World/Util/BasicTypeContainers.h"
#include "../Textures/Packs/TexturePackRepository.h"
#ifdef _XBOX
#include "../Platform/Common/XUI/XUI_Scene_Trading.h"
@@ -2171,12 +2172,11 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) {
// Check this friend against each player, if we find them we
// have at least one friend
for (int j = 0; j < g_NetworkManager.GetPlayerCount(); j++) {
- Platform::String ^ xboxUserId =
- ref new Platform::String(
- g_NetworkManager.GetPlayerByIndex(j)
- ->GetUID()
- .toString()
- .data());
+ Platform::String ^ xboxUserId = ref new Platform::String(
+ g_NetworkManager.GetPlayerByIndex(j)
+ ->GetUID()
+ .toString()
+ .data());
if (friendsXuid == xboxUserId) {
isAtLeastOneFriend = true;
break;
@@ -2279,8 +2279,8 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) {
// down, because they are trying to lock the incoming critsec when
// it's already locked by this thread
// Minecraft::GetInstance()->connectionDisconnected(
- // m_userIndex , reason ); done = true; connection->flush();
- // connection->close(reason);
+ // m_userIndex , reason ); done = true;
+ // connection->flush(); connection->close(reason);
// app.SetAction(m_userIndex,eAppAction_ExitPlayer);
// 4J-PB - doing this instead
@@ -4050,7 +4050,8 @@ void ClientConnection::handleUpdateAttributes(
// are we passing in MIN_NORMAL (Java's smallest non-zero value
// conforming to IEEE Standard 754 (?)) and MAX_VALUE
instance = attributes->registerAttribute(new RangedAttribute(
- attribute->getId(), 0, Double::MIN_NORMAL, Double::MAX_VALUE));
+ attribute->getId(), 0, std::numeric_limits::min(),
+ std::numeric_limits::max()));
}
instance->setBaseValue(attribute->getBase());
@@ -4105,4 +4106,4 @@ ClientConnection::DeferredEntityLinkPacket::DeferredEntityLinkPacket(
std::shared_ptr packet) {
m_recievedTick = GetTickCount();
m_packet = packet;
-}
\ No newline at end of file
+}
diff --git a/Minecraft.Client/Network/PlayerConnection.cpp b/Minecraft.Client/Network/PlayerConnection.cpp
index 0e5038d86..9f5e861e8 100644
--- a/Minecraft.Client/Network/PlayerConnection.cpp
+++ b/Minecraft.Client/Network/PlayerConnection.cpp
@@ -1551,7 +1551,8 @@ void PlayerConnection::handlePlayerAbilities(
// StringBuilder result = new StringBuilder();
// for (String candidate : server.getAutoCompletions(player,
-//packet.getMessage())) { if (result.length() > 0) result.append("\0");
+// packet.getMessage())) { if (result.length() > 0)
+// result.append("\0");
// result.append(candidate);
// }
diff --git a/Minecraft.Client/Platform/Common/Consoles_App.cpp b/Minecraft.Client/Platform/Common/Consoles_App.cpp
index f85d56632..34bec9010 100644
--- a/Minecraft.Client/Platform/Common/Consoles_App.cpp
+++ b/Minecraft.Client/Platform/Common/Consoles_App.cpp
@@ -4706,7 +4706,6 @@ int CMinecraftApp::SignoutExitWorldThreadProc(void* lpParameter) {
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
// as we don't tick the main thread whilst this thread is running
AABB::UseDefaultThreadStorage();
- Vec3::UseDefaultThreadStorage();
Compression::UseDefaultThreadStorage();
// app.SetGameStarted(false);
@@ -6332,7 +6331,7 @@ int CMinecraftApp::WarningTrialTexturePackReturned(
DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack();
const char *pchPackName=wstringtofilename(pDLCPack->getName());
app.DebugPrintf("Texture Pack - %s\n",pchPackName);
- SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo((char *)pchPackName);
+ SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo((char *)pchPackName);
if(pSONYDLCInfo!=NULL)
{
@@ -6353,14 +6352,14 @@ int CMinecraftApp::WarningTrialTexturePackReturned(
#if defined __ORBIS__ || defined __PSVITA__ || defined __PS3__
if(app.CheckForEmptyStore(iPad)==false)
#endif
- {
+ {
if(app.DLCAlreadyPurchased(chSkuID))
{
app.DownloadAlreadyPurchased(chSkuID);
}
else
{
- app.Checkout(chSkuID);
+ app.Checkout(chSkuID);
}
}
}
@@ -7698,7 +7697,6 @@ int CMinecraftApp::RemoteSaveThreadProc(void* lpParameter) {
// The game should be stopped while we are doing this, but the connections
// ticks may try to create some AABB's or Vec3's
AABB::UseDefaultThreadStorage();
- Vec3::UseDefaultThreadStorage();
Compression::UseDefaultThreadStorage();
// 4J-PB - Xbox 360 - 163153 - [CRASH] TU17: Code: Multiplayer: During the
@@ -10355,4 +10353,4 @@ std::wstring CMinecraftApp::getRootPath(std::uint32_t packId,
void CMinecraftApp::SetReachedMainMenu() { m_hasReachedMainMenu = true; }
bool CMinecraftApp::HasReachedMainMenu() { return m_hasReachedMainMenu; }
-#endif
\ No newline at end of file
+#endif
diff --git a/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.cpp b/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.cpp
index e7f25cf69..b2304fbdd 100644
--- a/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.cpp
+++ b/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.cpp
@@ -12,7 +12,7 @@
ApplySchematicRuleDefinition::ApplySchematicRuleDefinition(
LevelGenerationOptions* levelGenOptions) {
m_levelGenOptions = levelGenOptions;
- m_location = Vec3::newPermanent(0, 0, 0);
+ m_location = Vec3(0, 0, 0);
m_locationBox = NULL;
m_totalBlocksChanged = 0;
m_totalBlocksChangedLighting = 0;
@@ -26,7 +26,6 @@ ApplySchematicRuleDefinition::~ApplySchematicRuleDefinition() {
app.DebugPrintf("Deleting ApplySchematicRuleDefinition.\n");
if (!m_completed) m_levelGenOptions->releaseSchematicFile(m_schematicName);
m_schematic = NULL;
- delete m_location;
}
void ApplySchematicRuleDefinition::writeAttributes(DataOutputStream* dos,
@@ -36,11 +35,11 @@ void ApplySchematicRuleDefinition::writeAttributes(DataOutputStream* dos,
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_filename);
dos->writeUTF(m_schematicName);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x);
- dos->writeUTF(_toString(m_location->x));
+ dos->writeUTF(_toString(m_location.x));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y);
- dos->writeUTF(_toString(m_location->y));
+ dos->writeUTF(_toString(m_location.y));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z);
- dos->writeUTF(_toString(m_location->z));
+ dos->writeUTF(_toString(m_location.z));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_rot);
switch (m_rotation) {
@@ -76,19 +75,19 @@ void ApplySchematicRuleDefinition::addAttribute(
m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
}
} else if (attributeName.compare(L"x") == 0) {
- m_location->x = _fromString(attributeValue);
- if (((int)abs(m_location->x)) % 2 != 0) m_location->x -= 1;
+ m_location.x = _fromString(attributeValue);
+ if (((int)abs(m_location.x)) % 2 != 0) m_location.x -= 1;
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
// x=%f\n",m_location->x);
} else if (attributeName.compare(L"y") == 0) {
- m_location->y = _fromString(attributeValue);
- if (((int)abs(m_location->y)) % 2 != 0) m_location->y -= 1;
- if (m_location->y < 0) m_location->y = 0;
+ m_location.y = _fromString(attributeValue);
+ if (((int)abs(m_location.y)) % 2 != 0) m_location.y -= 1;
+ if (m_location.y < 0) m_location.y = 0;
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
// y=%f\n",m_location->y);
} else if (attributeName.compare(L"z") == 0) {
- m_location->z = _fromString(attributeValue);
- if (((int)abs(m_location->z)) % 2 != 0) m_location->z -= 1;
+ m_location.z = _fromString(attributeValue);
+ if (((int)abs(m_location.z)) % 2 != 0) m_location.z -= 1;
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
// z=%f\n",m_location->z);
} else if (attributeName.compare(L"rot") == 0) {
@@ -133,23 +132,23 @@ void ApplySchematicRuleDefinition::updateLocationBox() {
m_locationBox = AABB::newPermanent(0, 0, 0, 0, 0, 0);
- m_locationBox->x0 = m_location->x;
- m_locationBox->y0 = m_location->y;
- m_locationBox->z0 = m_location->z;
+ m_locationBox->x0 = m_location.x;
+ m_locationBox->y0 = m_location.y;
+ m_locationBox->z0 = m_location.z;
- m_locationBox->y1 = m_location->y + m_schematic->getYSize();
+ m_locationBox->y1 = m_location.y + m_schematic->getYSize();
switch (m_rotation) {
case ConsoleSchematicFile::eSchematicRot_90:
case ConsoleSchematicFile::eSchematicRot_270:
- m_locationBox->x1 = m_location->x + m_schematic->getZSize();
- m_locationBox->z1 = m_location->z + m_schematic->getXSize();
+ m_locationBox->x1 = m_location.x + m_schematic->getZSize();
+ m_locationBox->z1 = m_location.z + m_schematic->getXSize();
break;
case ConsoleSchematicFile::eSchematicRot_0:
case ConsoleSchematicFile::eSchematicRot_180:
default:
- m_locationBox->x1 = m_location->x + m_schematic->getXSize();
- m_locationBox->z1 = m_location->z + m_schematic->getZSize();
+ m_locationBox->x1 = m_location.x + m_schematic->getXSize();
+ m_locationBox->z1 = m_location.z + m_schematic->getZSize();
break;
};
}
@@ -251,4 +250,4 @@ void ApplySchematicRuleDefinition::reset() {
m_totalBlocksChanged = 0;
m_totalBlocksChangedLighting = 0;
m_completed = false;
-}
\ No newline at end of file
+}
diff --git a/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.h b/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.h
index e3c5b425f..283c19586 100644
--- a/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.h
+++ b/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.h
@@ -13,7 +13,7 @@ private:
LevelGenerationOptions* m_levelGenOptions;
std::wstring m_schematicName;
ConsoleSchematicFile* m_schematic;
- Vec3* m_location;
+ Vec3 m_location;
AABB* m_locationBox;
ConsoleSchematicFile::ESchematicRotation m_rotation;
int m_dimension;
@@ -51,4 +51,4 @@ public:
* Reset any state to how it should be before a new game.
*/
void reset();
-};
\ No newline at end of file
+};
diff --git a/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.cpp b/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.cpp
index 04d7015c9..217a7ffb8 100644
--- a/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.cpp
+++ b/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.cpp
@@ -155,8 +155,8 @@ void ConsoleSchematicFile::load(DataInputStream* dis) {
// app.DebugPrintf(1,"Loaded entity type %d at
// (%f,%f,%f)\n",(int)type,x,y,z);
#endif
- m_entities.push_back(std::pair(
- Vec3::newPermanent(x, y, z), (CompoundTag*)eTag->copy()));
+ m_entities.push_back(std::pair(
+ Vec3(x, y, z), (CompoundTag*)eTag->copy()));
}
}
delete tag;
@@ -463,8 +463,8 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk* chunk, AABB* chunkBox,
schematicCoordToChunkCoord(destinationBox, te->x, te->z, rot, targetX,
targetZ);
- Vec3* pos = Vec3::newTemp(targetX, targetY, targetZ);
- if (chunkBox->containsIncludingLowerBound(pos)) {
+ Vec3 pos(targetX, targetY, targetZ);
+ if (chunkBox->containsIncludingLowerBound(&pos)) {
std::shared_ptr teCopy = chunk->getTileEntity(
(int)targetX & 15, (int)targetY & 15, (int)targetZ & 15);
@@ -500,19 +500,18 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk* chunk, AABB* chunkBox,
}
}
for (AUTO_VAR(it, m_entities.begin()); it != m_entities.end();) {
- Vec3* source = it->first;
+ Vec3 source = it->first;
- double targetX = source->x;
- double targetY = source->y + destinationBox->y0;
- double targetZ = source->z;
- schematicCoordToChunkCoord(destinationBox, source->x, source->z, rot,
+ double targetX = source.x;
+ double targetY = source.y + destinationBox->y0;
+ double targetZ = source.z;
+ schematicCoordToChunkCoord(destinationBox, source.x, source.z, rot,
targetX, targetZ);
// Add 0.01 as the AABB::contains function returns false if a value is
// <= the lower bound
- Vec3* pos =
- Vec3::newTemp(targetX + 0.01, targetY + 0.01, targetZ + 0.01);
- if (!chunkBox->containsIncludingLowerBound(pos)) {
+ Vec3 pos(targetX + 0.01, targetY + 0.01, targetZ + 0.01);
+ if (!chunkBox->containsIncludingLowerBound(&pos)) {
++it;
continue;
}
@@ -800,8 +799,8 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, byteArray* data,
// if (xs * ys * zs == LevelChunk::BLOCKS_LENGTH)
//{
// byteArray blockData = byteArray(data->data + blocksP,
- //Level::CHUNK_TILE_COUNT); chunk->getBlockData(blockData); blocksP +=
- //blockData.length;
+ // Level::CHUNK_TILE_COUNT); chunk->getBlockData(blockData);
+ // blocksP += blockData.length;
// byteArray dataData = byteArray(data->data + dataP, 16384);
// chunk->getBlockLightData(dataData);
diff --git a/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.h b/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.h
index 1990328a8..adf862a0b 100644
--- a/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.h
+++ b/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.h
@@ -54,7 +54,7 @@ public:
private:
int m_xSize, m_ySize, m_zSize;
std::vector > m_tileEntities;
- std::vector > m_entities;
+ std::vector > m_entities;
public:
byteArray m_data;
diff --git a/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp b/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp
index a26addc80..3b18a50e4 100644
--- a/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp
+++ b/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp
@@ -948,7 +948,6 @@ int CGameNetworkManager::RunNetworkGameThreadProc(void* lpParameter) {
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
// as we don't tick the main thread whilst this thread is running
AABB::UseDefaultThreadStorage();
- Vec3::UseDefaultThreadStorage();
Compression::UseDefaultThreadStorage();
Tile::CreateNewThreadStorage();
@@ -1008,7 +1007,6 @@ int CGameNetworkManager::ServerThreadProc(void* lpParameter) {
SetThreadName(-1, "Minecraft Server thread");
AABB::CreateNewThreadStorage();
- Vec3::CreateNewThreadStorage();
Compression::UseDefaultThreadStorage();
OldChunkStorage::UseDefaultThreadStorage();
Entity::useSmallIds();
@@ -1022,7 +1020,6 @@ int CGameNetworkManager::ServerThreadProc(void* lpParameter) {
Tile::ReleaseThreadStorage();
AABB::ReleaseThreadStorage();
- Vec3::ReleaseThreadStorage();
Level::destroyLightingCache();
if (lpParameter != NULL) delete (NetworkGameInitData*)lpParameter;
@@ -1034,7 +1031,6 @@ int CGameNetworkManager::ExitAndJoinFromInviteThreadProc(void* lpParam) {
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
// as we don't tick the main thread whilst this thread is running
AABB::UseDefaultThreadStorage();
- Vec3::UseDefaultThreadStorage();
Compression::UseDefaultThreadStorage();
// app.SetGameStarted(false);
@@ -1187,7 +1183,6 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc(void* lpParam) {
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
// as we don't tick the main thread whilst this thread is running
AABB::UseDefaultThreadStorage();
- Vec3::UseDefaultThreadStorage();
Compression::UseDefaultThreadStorage();
Minecraft* pMinecraft = Minecraft::GetInstance();
diff --git a/Minecraft.Client/Platform/Common/Tutorial/AreaConstraint.cpp b/Minecraft.Client/Platform/Common/Tutorial/AreaConstraint.cpp
index ddd57b539..016cc71ff 100644
--- a/Minecraft.Client/Platform/Common/Tutorial/AreaConstraint.cpp
+++ b/Minecraft.Client/Platform/Common/Tutorial/AreaConstraint.cpp
@@ -25,8 +25,8 @@ AreaConstraint::~AreaConstraint() {
bool AreaConstraint::isConstraintSatisfied(int iPad) {
Minecraft* minecraft = Minecraft::GetInstance();
- return messageArea->contains(minecraft->localplayers[iPad]->getPos(1)) ==
- contains;
+ Vec3 ipad_player = minecraft->localplayers[iPad]->getPos(1);
+ return messageArea->contains(&ipad_player) == contains;
}
bool AreaConstraint::isConstraintRestrictive(int iPad) {
@@ -37,15 +37,15 @@ bool AreaConstraint::canMoveToPosition(double xo, double yo, double zo,
double xt, double yt, double zt) {
if (!m_restrictsMovement) return true;
- Vec3* targetPos = Vec3::newTemp(xt, yt, zt);
+ Vec3 targetPos(xt, yt, zt);
Minecraft* minecraft = Minecraft::GetInstance();
- if (movementArea->contains(targetPos) == contains) {
+ if (movementArea->contains(&targetPos) == contains) {
return true;
}
- Vec3* origPos = Vec3::newTemp(xo, yo, zo);
+ Vec3 origPos(xo, yo, zo);
- double currDist = origPos->distanceTo(movementArea);
- double targetDist = targetPos->distanceTo(movementArea);
+ double currDist = origPos.distanceTo(movementArea);
+ double targetDist = targetPos.distanceTo(movementArea);
return targetDist < currDist;
}
diff --git a/Minecraft.Client/Platform/Common/Tutorial/AreaHint.cpp b/Minecraft.Client/Platform/Common/Tutorial/AreaHint.cpp
index 729b361d0..87dc976bf 100644
--- a/Minecraft.Client/Platform/Common/Tutorial/AreaHint.cpp
+++ b/Minecraft.Client/Platform/Common/Tutorial/AreaHint.cpp
@@ -24,10 +24,11 @@ AreaHint::~AreaHint() { delete area; }
int AreaHint::tick() {
Minecraft* minecraft = Minecraft::GetInstance();
+ Vec3 player_pos = minecraft->player->getPos(1);
+
if ((m_displayState == e_Tutorial_State_Any ||
m_tutorial->getCurrentState() == m_displayState) &&
- m_hintNeeded &&
- area->contains(minecraft->player->getPos(1)) == contains) {
+ m_hintNeeded && area->contains(&player_pos) == contains) {
if (m_completeState == e_Tutorial_State_None) {
m_hintNeeded = false;
} else if (m_tutorial->isStateCompleted(m_completeState)) {
diff --git a/Minecraft.Client/Platform/Common/Tutorial/ChangeStateConstraint.cpp b/Minecraft.Client/Platform/Common/Tutorial/ChangeStateConstraint.cpp
index 9d8d75e1d..e1f93eecb 100644
--- a/Minecraft.Client/Platform/Common/Tutorial/ChangeStateConstraint.cpp
+++ b/Minecraft.Client/Platform/Common/Tutorial/ChangeStateConstraint.cpp
@@ -85,9 +85,9 @@ void ChangeStateConstraint::tick(int iPad) {
break;
}
}
+ Vec3 ipad_player = minecraft->localplayers[iPad]->getPos(1);
if (!m_bHasChanged && inASourceState &&
- movementArea->contains(minecraft->localplayers[iPad]->getPos(1)) ==
- contains) {
+ movementArea->contains(&ipad_player) == contains) {
m_bHasChanged = true;
m_changedFromState = m_tutorial->getCurrentState();
m_tutorial->changeTutorialState(m_targetState);
@@ -125,8 +125,7 @@ void ChangeStateConstraint::tick(int iPad) {
}
}
} else if (m_bHasChanged &&
- movementArea->contains(
- minecraft->localplayers[iPad]->getPos(1)) != contains) {
+ movementArea->contains(&ipad_player) != contains) {
m_bHasChanged = false;
m_tutorial->changeTutorialState(m_changedFromState);
diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp
index 28a3773b4..2f609340b 100644
--- a/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp
+++ b/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp
@@ -469,6 +469,11 @@ void IUIScene_CreativeMenu::staticCtor() {
ITEM(Item::carrotGolden_Id)
ITEM(Item::pumpkinPie_Id)
+// 4jcraft: Search
+#ifdef ENABLE_JAVA_GUIS
+ DEF(eCreativeInventory_Search)
+#endif
+
// Tools, Armour and Weapons (Complete)
DEF(eCreativeInventory_ToolsArmourWeapons)
ITEM(Item::compass_Id)
@@ -856,6 +861,13 @@ void IUIScene_CreativeMenu::staticCtor() {
specs[eCreativeInventoryTab_Food] =
new TabSpec(L"Food", IDS_GROUPNAME_FOOD, 1, foodGroup);
+// 4jcraft
+#ifdef ENABLE_JAVA_GUIS
+ ECreative_Inventory_Groups searchGroup[] = {eCreativeInventory_Search};
+ specs[eCreativeInventoryTab_Search] =
+ new TabSpec(L"Search Items", IDS_GROUPNAME_SEARCH, 1, searchGroup);
+#endif
+
ECreative_Inventory_Groups toolsGroup[] = {
eCreativeInventory_ToolsArmourWeapons};
specs[eCreativeInventoryTab_ToolsWeaponsArmor] =
@@ -898,7 +910,7 @@ IUIScene_CreativeMenu::IUIScene_CreativeMenu() {
m_bCarryingCreativeItem = false;
m_creativeSlotX = m_creativeSlotY = m_inventorySlotX = m_inventorySlotY = 0;
- // 4J JEV - Settup Tabs
+ // 4J JEV - Setup Tabs
for (int i = 0; i < eCreativeInventoryTab_COUNT; i++) {
m_tabDynamicPos[i] = 0;
m_tabPage[i] = 0;
@@ -1523,4 +1535,4 @@ void IUIScene_CreativeMenu::BuildFirework(
}
list->push_back(firework);
-}
+}
\ No newline at end of file
diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.h b/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.h
index 02967ac5a..fc2cb071e 100644
--- a/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.h
+++ b/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.h
@@ -7,20 +7,24 @@ class SimpleContainer;
class IUIScene_CreativeMenu : public virtual IUIScene_AbstractContainerMenu {
public:
- // 4J Stu - These map directly to the tabs seenon the screen
+ // 4J Stu - These map directly to the tabs seen on the screen
enum ECreativeInventoryTabs {
eCreativeInventoryTab_BuildingBlocks = 0,
eCreativeInventoryTab_Decorations,
eCreativeInventoryTab_RedstoneAndTransport,
eCreativeInventoryTab_Materials,
eCreativeInventoryTab_Food,
+// 4jcraft: java search tab
+#ifdef ENABLE_JAVA_GUIS
+ eCreativeInventoryTab_Search,
+#endif
eCreativeInventoryTab_ToolsWeaponsArmor,
eCreativeInventoryTab_Brewing,
eCreativeInventoryTab_Misc,
eCreativeInventoryTab_COUNT,
};
- // 4J Stu - These are logical groupings of items, and be be combined for
+ // 4J Stu - These are logical groupings of items, and are combined for
// tabs on-screen
enum ECreative_Inventory_Groups {
eCreativeInventory_BuildingBlocks,
@@ -29,6 +33,10 @@ public:
eCreativeInventory_Transport,
eCreativeInventory_Materials,
eCreativeInventory_Food,
+// 4jcraft
+#ifdef ENABLE_JAVA_GUIS
+ eCreativeInventory_Search,
+#endif
eCreativeInventory_ToolsArmourWeapons,
eCreativeInventory_Brewing,
eCreativeInventory_Potions_Basic,
@@ -97,7 +105,7 @@ public:
virtual void loopClick(int slotIndex, int buttonNum, bool quickKeyHeld,
std::shared_ptr player) {} // do nothing
}* itemPickerMenu;
-
+
// 4jcraft: changed these two from public to protected for the java UI
static std::vector >
categoryGroups[eCreativeInventoryGroupsCount];
@@ -148,4 +156,4 @@ protected:
static void BuildFirework(std::vector >* list,
uint8_t type, int color, int sulphur,
bool flicker, bool trail, int fadeColor = -1);
-};
\ No newline at end of file
+};
diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp
index 65d52d39a..f5c3d4d11 100644
--- a/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp
+++ b/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp
@@ -381,7 +381,6 @@ int IUIScene_PauseMenu::SaveWorldThreadProc(void* lpParameter) {
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
// as we don't tick the main thread whilst this thread is running
AABB::UseDefaultThreadStorage();
- Vec3::UseDefaultThreadStorage();
Compression::UseDefaultThreadStorage();
Minecraft* pMinecraft = Minecraft::GetInstance();
@@ -419,7 +418,6 @@ int IUIScene_PauseMenu::ExitWorldThreadProc(void* lpParameter) {
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
// as we don't tick the main thread whilst this thread is running
AABB::UseDefaultThreadStorage();
- Vec3::UseDefaultThreadStorage();
Compression::UseDefaultThreadStorage();
// app.SetGameStarted(false);
diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DebugSetCamera.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_DebugSetCamera.cpp
index 89e872eb9..af850cb67 100644
--- a/Minecraft.Client/Platform/Common/UI/UIScene_DebugSetCamera.cpp
+++ b/Minecraft.Client/Platform/Common/UI/UIScene_DebugSetCamera.cpp
@@ -19,13 +19,13 @@ UIScene_DebugSetCamera::UIScene_DebugSetCamera(int iPad, void* initData,
Minecraft* pMinecraft = Minecraft::GetInstance();
if (pMinecraft != NULL) {
- Vec3* vec = pMinecraft->localplayers[playerNo]->getPos(1.0);
+ Vec3 vec = pMinecraft->localplayers[playerNo]->getPos(1.0);
- currentPosition->m_camX = vec->x;
+ currentPosition->m_camX = vec.x;
currentPosition->m_camY =
- vec->y -
+ vec.y -
1.62; // pMinecraft->localplayers[playerNo]->getHeadHeight();
- currentPosition->m_camZ = vec->z;
+ currentPosition->m_camZ = vec.z;
currentPosition->m_yRot = pMinecraft->localplayers[playerNo]->yRot;
currentPosition->m_elev = pMinecraft->localplayers[playerNo]->xRot;
diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_Death.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_Death.cpp
index 7902b427a..20dff7cae 100644
--- a/Minecraft.Client/Platform/Common/XUI/XUI_Death.cpp
+++ b/Minecraft.Client/Platform/Common/XUI/XUI_Death.cpp
@@ -220,7 +220,6 @@ HRESULT CScene_Death::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled) {
int CScene_Death::RespawnThreadProc(void* lpParameter) {
AABB::UseDefaultThreadStorage();
- Vec3::UseDefaultThreadStorage();
Compression::UseDefaultThreadStorage();
size_t iPad = (size_t)lpParameter;
@@ -246,4 +245,4 @@ HRESULT CScene_Death::OnCustomMessage_Splitscreenplayer(bool bJoining,
bHandled = true;
return app.AdjustSplitscreenScene_PlayerChanged(m_hObj, &m_OriginalPosition,
m_iPad, bJoining);
-}
\ No newline at end of file
+}
diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_PauseMenu.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_PauseMenu.cpp
index d77644991..5ce88755d 100644
--- a/Minecraft.Client/Platform/Common/XUI/XUI_PauseMenu.cpp
+++ b/Minecraft.Client/Platform/Common/XUI/XUI_PauseMenu.cpp
@@ -1074,7 +1074,6 @@ int UIScene_PauseMenu::SaveWorldThreadProc(LPVOID lpParameter) {
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
// as we don't tick the main thread whilst this thread is running
AABB::UseDefaultThreadStorage();
- Vec3::UseDefaultThreadStorage();
Compression::UseDefaultThreadStorage();
Minecraft* pMinecraft = Minecraft::GetInstance();
@@ -1107,7 +1106,6 @@ int UIScene_PauseMenu::ExitWorldThreadProc(void* lpParameter) {
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
// as we don't tick the main thread whilst this thread is running
AABB::UseDefaultThreadStorage();
- Vec3::UseDefaultThreadStorage();
Compression::UseDefaultThreadStorage();
// app.SetGameStarted(false);
@@ -1326,4 +1324,4 @@ void UIScene_PauseMenu::_ExitWorld(LPVOID lpParameter) {
void UIScene_PauseMenu::SetIgnoreInput(bool ignoreInput) {
m_bIgnoreInput = ignoreInput;
-}
\ No newline at end of file
+}
diff --git a/Minecraft.Client/Platform/Durango/Durango_Minecraft.cpp b/Minecraft.Client/Platform/Durango/Durango_Minecraft.cpp
index dff64785d..e7f5179c4 100644
--- a/Minecraft.Client/Platform/Durango/Durango_Minecraft.cpp
+++ b/Minecraft.Client/Platform/Durango/Durango_Minecraft.cpp
@@ -795,7 +795,6 @@ void oldWinMainInit() {
Tesselator::CreateNewThreadStorage(1024 * 1024);
// Initialise TLS for AABB and Vec3 pools, for this main thread
AABB::CreateNewThreadStorage();
- Vec3::CreateNewThreadStorage();
OldChunkStorage::CreateNewThreadStorage();
Level::enableLightingCache();
Tile::CreateNewThreadStorage();
@@ -1143,9 +1142,6 @@ void oldWinMainTick() {
}
// Fix for #7318 - Title crashes after short soak in the leaderboards menu
- // A memory leak was caused because the icon renderer kept creating new
- // Vec3's because the pool wasn't reset
- Vec3::resetPool();
}
#ifdef MEMORY_TRACKING
diff --git a/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp b/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp
index 4daca7e16..290b4626e 100644
--- a/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp
+++ b/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp
@@ -857,7 +857,6 @@ return -1;
Tesselator::CreateNewThreadStorage(1024 * 1024);
// Initialise TLS for AABB and Vec3 pools, for this main thread
AABB::CreateNewThreadStorage();
- Vec3::CreateNewThreadStorage();
Compression::CreateNewThreadStorage();
OldChunkStorage::CreateNewThreadStorage();
Level::enableLightingCache();
@@ -1092,9 +1091,6 @@ PIXEndNamedEvent();
}
// Fix for #7318 - Title crashes after short soak in the leaderboards
- // menu A memory leak was caused because the icon renderer kept creating
- // new Vec3's because the pool wasn't reset
- Vec3::resetPool();
} // end game loop
// Graceful shutdown: destroy GL context and GLFW before any C++ dtors run.
diff --git a/Minecraft.Client/Platform/Orbis/Orbis_Minecraft.cpp b/Minecraft.Client/Platform/Orbis/Orbis_Minecraft.cpp
index 7dfd2c385..84e6fbf12 100644
--- a/Minecraft.Client/Platform/Orbis/Orbis_Minecraft.cpp
+++ b/Minecraft.Client/Platform/Orbis/Orbis_Minecraft.cpp
@@ -1040,7 +1040,6 @@ void RegisterAwardsWithProfileManager() {
}
int StartMinecraftThreadProc(void* lpParameter) {
- Vec3::UseDefaultThreadStorage();
AABB::UseDefaultThreadStorage();
Tesselator::CreateNewThreadStorage(1024 * 1024);
RenderManager.InitialiseContext();
@@ -1378,7 +1377,6 @@ int main(int argc, const char* argv[]) {
Tesselator::CreateNewThreadStorage(1024 * 1024);
// Initialise TLS for AABB and Vec3 pools, for this main thread
AABB::CreateNewThreadStorage();
- Vec3::CreateNewThreadStorage();
Compression::CreateNewThreadStorage();
OldChunkStorage::CreateNewThreadStorage();
Level::enableLightingCache();
@@ -1737,9 +1735,6 @@ int main(int argc, const char* argv[]) {
app.PatchAvailableDialogTick();
// Fix for #7318 - Title crashes after short soak in the leaderboards
- // menu A memory leak was caused because the icon renderer kept creating
- // new Vec3's because the pool wasn't reset
- Vec3::resetPool();
}
// Free resources, unregister custom classes, and exit.
diff --git a/Minecraft.Client/Platform/PS3/PS3Extras/boost_1_53_0/boost/spirit/home/lex/lexer/lexertl/lexer.hpp b/Minecraft.Client/Platform/PS3/PS3Extras/boost_1_53_0/boost/spirit/home/lex/lexer/lexertl/lexer.hpp
index 0f8af55d0..f73cb4e09 100644
--- a/Minecraft.Client/Platform/PS3/PS3Extras/boost_1_53_0/boost/spirit/home/lex/lexer/lexertl/lexer.hpp
+++ b/Minecraft.Client/Platform/PS3/PS3Extras/boost_1_53_0/boost/spirit/home/lex/lexer/lexertl/lexer.hpp
@@ -27,373 +27,359 @@
#include
-namespace boost { namespace spirit { namespace lex { namespace lexertl
-{
- ///////////////////////////////////////////////////////////////////////////
- namespace detail
- {
- ///////////////////////////////////////////////////////////////////////
- // The must_escape function checks if the given character value needs
- // to be preceded by a backslash character to disable its special
- // meaning in the context of a regular expression
- ///////////////////////////////////////////////////////////////////////
- template
- inline bool must_escape(Char c)
- {
- // FIXME: more needed?
- switch (c) {
- case '+': case '/': case '*': case '?':
- case '|':
- case '(': case ')':
- case '[': case ']':
- case '{': case '}':
- case '.':
- case '^': case '$':
- case '\\':
- case '"':
- return true;
+namespace boost {
+namespace spirit {
+namespace lex {
+namespace lexertl {
+///////////////////////////////////////////////////////////////////////////
+namespace detail {
+///////////////////////////////////////////////////////////////////////
+// The must_escape function checks if the given character value needs
+// to be preceded by a backslash character to disable its special
+// meaning in the context of a regular expression
+///////////////////////////////////////////////////////////////////////
+template
+inline bool must_escape(Char c) {
+ // FIXME: more needed?
+ switch (c) {
+ case '+':
+ case '/':
+ case '*':
+ case '?':
+ case '|':
+ case '(':
+ case ')':
+ case '[':
+ case ']':
+ case '{':
+ case '}':
+ case '.':
+ case '^':
+ case '$':
+ case '\\':
+ case '"':
+ return true;
- default:
- break;
- }
- return false;
- }
+ default:
+ break;
+ }
+ return false;
+}
- ///////////////////////////////////////////////////////////////////////
- // The escape function returns the string representation of the given
- // character value, possibly escaped with a backslash character, to
- // allow it being safely used in a regular expression definition.
- ///////////////////////////////////////////////////////////////////////
- template
- inline std::basic_string escape(Char ch)
- {
- std::basic_string result(1, ch);
- if (detail::must_escape(ch))
- {
- typedef typename std::basic_string::size_type size_type;
- result.insert((size_type)0, 1, '\\');
- }
- return result;
- }
+///////////////////////////////////////////////////////////////////////
+// The escape function returns the string representation of the given
+// character value, possibly escaped with a backslash character, to
+// allow it being safely used in a regular expression definition.
+///////////////////////////////////////////////////////////////////////
+template
+inline std::basic_string escape(Char ch) {
+ std::basic_string result(1, ch);
+ if (detail::must_escape(ch)) {
+ typedef typename std::basic_string::size_type size_type;
+ result.insert((size_type)0, 1, '\\');
+ }
+ return result;
+}
- ///////////////////////////////////////////////////////////////////////
- //
- ///////////////////////////////////////////////////////////////////////
- inline boost::lexer::regex_flags map_flags(unsigned int flags)
- {
- unsigned int retval = boost::lexer::none;
- if (flags & match_flags::match_not_dot_newline)
- retval |= boost::lexer::dot_not_newline;
- if (flags & match_flags::match_icase)
- retval |= boost::lexer::icase;
+///////////////////////////////////////////////////////////////////////
+//
+///////////////////////////////////////////////////////////////////////
+inline boost::lexer::regex_flags map_flags(unsigned int flags) {
+ unsigned int retval = boost::lexer::none;
+ if (flags & match_flags::match_not_dot_newline)
+ retval |= boost::lexer::dot_not_newline;
+ if (flags & match_flags::match_icase) retval |= boost::lexer::icase;
- return boost::lexer::regex_flags(retval);
- }
+ return boost::lexer::regex_flags(retval);
+}
+} // namespace detail
+
+///////////////////////////////////////////////////////////////////////////
+template
+bool generate_static(Lexer const&,
+ std::basic_ostream&,
+ typename Lexer::char_type const*, F);
+
+///////////////////////////////////////////////////////////////////////////
+//
+// Every lexer type to be used as a lexer for Spirit has to conform to
+// the following public interface:
+//
+// typedefs:
+// iterator_type The type of the iterator exposed by this lexer.
+// token_type The type of the tokens returned from the exposed
+// iterators.
+//
+// functions:
+// default constructor
+// Since lexers are instantiated as base classes
+// only it might be a good idea to make this
+// constructor protected.
+// begin, end Return a pair of iterators, when dereferenced
+// returning the sequence of tokens recognized in
+// the input stream given as the parameters to the
+// begin() function.
+// add_token Should add the definition of a token to be
+// recognized by this lexer.
+// clear Should delete all current token definitions
+// associated with the given state of this lexer
+// object.
+//
+// template parameters:
+// Iterator The type of the iterator used to access the
+// underlying character stream.
+// Token The type of the tokens to be returned from the
+// exposed token iterator.
+// Functor The type of the InputPolicy to use to instantiate
+// the multi_pass iterator type to be used as the
+// token iterator (returned from begin()/end()).
+//
+///////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+//
+// The lexer class is a implementation of a Spirit.Lex lexer on
+// top of Ben Hanson's lexertl library as outlined above (For more
+// information about lexertl go here: http://www.benhanson.net/lexertl.html).
+//
+// This class is supposed to be used as the first and only template
+// parameter while instantiating instances of a lex::lexer class.
+//
+///////////////////////////////////////////////////////////////////////////
+template ,
+ typename Iterator = typename Token::iterator_type,
+ typename Functor = functor >
+class lexer {
+private:
+ struct dummy {
+ void true_() {}
+ };
+ typedef void (dummy::*safe_bool)();
+
+ static std::size_t const all_states_id = static_cast(-2);
+
+public:
+ operator safe_bool() const { return initialized_dfa_ ? &dummy::true_ : 0; }
+
+ typedef
+ typename boost::detail::iterator_traits::value_type char_type;
+ typedef std::basic_string string_type;
+
+ typedef boost::lexer::basic_rules basic_rules_type;
+
+ // Every lexer type to be used as a lexer for Spirit has to conform to
+ // a public interface .
+ typedef Token token_type;
+ typedef typename Token::id_type id_type;
+ typedef iterator iterator_type;
+
+private:
+ // this type is purely used for the iterator_type construction below
+ struct iterator_data_type {
+ typedef typename Functor::semantic_actions_type semantic_actions_type;
+
+ iterator_data_type(
+ boost::lexer::basic_state_machine const& sm,
+ boost::lexer::basic_rules const& rules,
+ semantic_actions_type const& actions)
+ : state_machine_(sm), rules_(rules), actions_(actions) {}
+
+ boost::lexer::basic_state_machine const& state_machine_;
+ boost::lexer::basic_rules const& rules_;
+ semantic_actions_type const& actions_;
+
+ private:
+ // silence MSVC warning C4512: assignment operator could not be
+ // generated
+ iterator_data_type& operator=(iterator_data_type const&);
+ };
+
+public:
+ // Return the start iterator usable for iterating over the generated
+ // tokens.
+ iterator_type begin(Iterator& first, Iterator const& last,
+ char_type const* initial_state = 0) const {
+ if (!init_dfa()) // never minimize DFA for dynamic lexers
+ return iterator_type();
+
+ iterator_data_type iterator_data(state_machine_, rules_, actions_);
+ return iterator_type(iterator_data, first, last, initial_state);
}
- ///////////////////////////////////////////////////////////////////////////
- template
- bool generate_static(Lexer const&
- , std::basic_ostream&
- , typename Lexer::char_type const*, F);
+ // Return the end iterator usable to stop iterating over the generated
+ // tokens.
+ iterator_type end() const { return iterator_type(); }
- ///////////////////////////////////////////////////////////////////////////
- //
- // Every lexer type to be used as a lexer for Spirit has to conform to
- // the following public interface:
- //
- // typedefs:
- // iterator_type The type of the iterator exposed by this lexer.
- // token_type The type of the tokens returned from the exposed
- // iterators.
- //
- // functions:
- // default constructor
- // Since lexers are instantiated as base classes
- // only it might be a good idea to make this
- // constructor protected.
- // begin, end Return a pair of iterators, when dereferenced
- // returning the sequence of tokens recognized in
- // the input stream given as the parameters to the
- // begin() function.
- // add_token Should add the definition of a token to be
- // recognized by this lexer.
- // clear Should delete all current token definitions
- // associated with the given state of this lexer
- // object.
- //
- // template parameters:
- // Iterator The type of the iterator used to access the
- // underlying character stream.
- // Token The type of the tokens to be returned from the
- // exposed token iterator.
- // Functor The type of the InputPolicy to use to instantiate
- // the multi_pass iterator type to be used as the
- // token iterator (returned from begin()/end()).
- //
- ///////////////////////////////////////////////////////////////////////////
+protected:
+ // Lexer instances can be created by means of a derived class only.
+ lexer(unsigned int flags)
+ : flags_(detail::map_flags(flags)),
+ rules_(flags_),
+ initialized_dfa_(false) {}
- ///////////////////////////////////////////////////////////////////////////
- //
- // The lexer class is a implementation of a Spirit.Lex lexer on
- // top of Ben Hanson's lexertl library as outlined above (For more
- // information about lexertl go here: http://www.benhanson.net/lexertl.html).
- //
- // This class is supposed to be used as the first and only template
- // parameter while instantiating instances of a lex::lexer class.
- //
- ///////////////////////////////////////////////////////////////////////////
- template
- , typename Iterator = typename Token::iterator_type
- , typename Functor = functor >
- class lexer
- {
- private:
- struct dummy { void true_() {} };
- typedef void (dummy::*safe_bool)();
+public:
+ // interface for token definition management
+ std::size_t add_token(char_type const* state, char_type tokendef,
+ std::size_t token_id, char_type const* targetstate) {
+ add_state(state);
+ initialized_dfa_ = false;
+ if (state == all_states())
+ return rules_.add(state, detail::escape(tokendef), token_id,
+ rules_.dot());
- static std::size_t const all_states_id = static_cast(-2);
+ if (0 == targetstate)
+ targetstate = state;
+ else
+ add_state(targetstate);
+ return rules_.add(state, detail::escape(tokendef), token_id,
+ targetstate);
+ }
+ std::size_t add_token(char_type const* state, string_type const& tokendef,
+ std::size_t token_id, char_type const* targetstate) {
+ add_state(state);
+ initialized_dfa_ = false;
+ if (state == all_states())
+ return rules_.add(state, tokendef, token_id, rules_.dot());
- public:
- operator safe_bool() const
- { return initialized_dfa_ ? &dummy::true_ : 0; }
+ if (0 == targetstate)
+ targetstate = state;
+ else
+ add_state(targetstate);
+ return rules_.add(state, tokendef, token_id, targetstate);
+ }
- typedef typename boost::detail::iterator_traits::value_type
- char_type;
- typedef std::basic_string string_type;
+ // interface for pattern definition management
+ void add_pattern(char_type const* state, string_type const& name,
+ string_type const& patterndef) {
+ add_state(state);
+ rules_.add_macro(name.c_str(), patterndef);
+ initialized_dfa_ = false;
+ }
- typedef boost::lexer::basic_rules basic_rules_type;
+ boost::lexer::rules const& get_rules() const { return rules_; }
- // Every lexer type to be used as a lexer for Spirit has to conform to
- // a public interface .
- typedef Token token_type;
- typedef typename Token::id_type id_type;
- typedef iterator iterator_type;
+ void clear(char_type const* state) {
+ std::size_t s = rules_.state(state);
+ if (boost::lexer::npos != s) rules_.clear(state);
+ initialized_dfa_ = false;
+ }
+ std::size_t add_state(char_type const* state) {
+ if (state == all_states()) return all_states_id;
- private:
- // this type is purely used for the iterator_type construction below
- struct iterator_data_type
- {
- typedef typename Functor::semantic_actions_type semantic_actions_type;
-
- iterator_data_type(
- boost::lexer::basic_state_machine const& sm
- , boost::lexer::basic_rules const& rules
- , semantic_actions_type const& actions)
- : state_machine_(sm), rules_(rules), actions_(actions)
- {}
-
- boost::lexer::basic_state_machine const& state_machine_;
- boost::lexer::basic_rules const& rules_;
- semantic_actions_type const& actions_;
-
- private:
- // silence MSVC warning C4512: assignment operator could not be generated
- iterator_data_type& operator= (iterator_data_type const&);
- };
-
- public:
- // Return the start iterator usable for iterating over the generated
- // tokens.
- iterator_type begin(Iterator& first, Iterator const& last
- , char_type const* initial_state = 0) const
- {
- if (!init_dfa()) // never minimize DFA for dynamic lexers
- return iterator_type();
-
- iterator_data_type iterator_data(state_machine_, rules_, actions_);
- return iterator_type(iterator_data, first, last, initial_state);
- }
-
- // Return the end iterator usable to stop iterating over the generated
- // tokens.
- iterator_type end() const
- {
- return iterator_type();
- }
-
- protected:
- // Lexer instances can be created by means of a derived class only.
- lexer(unsigned int flags)
- : flags_(detail::map_flags(flags))
- , rules_(flags_)
- , initialized_dfa_(false)
- {}
-
- public:
- // interface for token definition management
- std::size_t add_token(char_type const* state, char_type tokendef,
- std::size_t token_id, char_type const* targetstate)
- {
- add_state(state);
- initialized_dfa_ = false;
- if (state == all_states())
- return rules_.add(state, detail::escape(tokendef), token_id, rules_.dot());
-
- if (0 == targetstate)
- targetstate = state;
- else
- add_state(targetstate);
- return rules_.add(state, detail::escape(tokendef), token_id, targetstate);
- }
- std::size_t add_token(char_type const* state, string_type const& tokendef,
- std::size_t token_id, char_type const* targetstate)
- {
- add_state(state);
- initialized_dfa_ = false;
- if (state == all_states())
- return rules_.add(state, tokendef, token_id, rules_.dot());
-
- if (0 == targetstate)
- targetstate = state;
- else
- add_state(targetstate);
- return rules_.add(state, tokendef, token_id, targetstate);
- }
-
- // interface for pattern definition management
- void add_pattern (char_type const* state, string_type const& name,
- string_type const& patterndef)
- {
- add_state(state);
- rules_.add_macro(name.c_str(), patterndef);
+ std::size_t stateid = rules_.state(state);
+ if (boost::lexer::npos == stateid) {
+ stateid = rules_.add_state(state);
initialized_dfa_ = false;
}
+ return stateid;
+ }
+ string_type initial_state() const { return string_type(rules_.initial()); }
+ string_type all_states() const { return string_type(rules_.all_states()); }
- boost::lexer::rules const& get_rules() const { return rules_; }
-
- void clear(char_type const* state)
- {
- std::size_t s = rules_.state(state);
- if (boost::lexer::npos != s)
- rules_.clear(state);
- initialized_dfa_ = false;
- }
- std::size_t add_state(char_type const* state)
- {
- if (state == all_states())
- return all_states_id;
-
- std::size_t stateid = rules_.state(state);
- if (boost::lexer::npos == stateid) {
- stateid = rules_.add_state(state);
- initialized_dfa_ = false;
- }
- return stateid;
- }
- string_type initial_state() const
- {
- return string_type(rules_.initial());
- }
- string_type all_states() const
- {
- return string_type(rules_.all_states());
- }
-
- // Register a semantic action with the given id
- template
- void add_action(std::size_t unique_id, std::size_t state, F act)
- {
- // If you see an error here stating add_action is not a member of
- // fusion::unused_type then you are probably having semantic actions
- // attached to at least one token in the lexer definition without
- // using the lex::lexertl::actor_lexer<> as its base class.
- typedef typename Functor::wrap_action_type wrapper_type;
- if (state == all_states_id) {
- // add the action to all known states
- typedef typename
- basic_rules_type::string_size_t_map::value_type
+ // Register a semantic action with the given id
+ template
+ void add_action(std::size_t unique_id, std::size_t state, F act) {
+ // If you see an error here stating add_action is not a member of
+ // fusion::unused_type then you are probably having semantic actions
+ // attached to at least one token in the lexer definition without
+ // using the lex::lexertl::actor_lexer<> as its base class.
+ typedef typename Functor::wrap_action_type wrapper_type;
+ if (state == all_states_id) {
+ // add the action to all known states
+ typedef typename basic_rules_type::string_size_t_map::value_type
state_type;
- std::size_t states = rules_.statemap().size();
- BOOST_FOREACH(state_type const& s, rules_.statemap()) {
- for (std::size_t j = 0; j < states; ++j)
- actions_.add_action(unique_id + j, s.second, wrapper_type::call(act));
- }
- }
- else {
- actions_.add_action(unique_id, state, wrapper_type::call(act));
+ std::size_t states = rules_.statemap().size();
+ BOOST_FOREACH (state_type const& s, rules_.statemap()) {
+ for (std::size_t j = 0; j < states; ++j)
+ actions_.add_action(unique_id + j, s.second,
+ wrapper_type::call(act));
}
+ } else {
+ actions_.add_action(unique_id, state, wrapper_type::call(act));
}
-// template
-// void add_action(std::size_t unique_id, char_type const* state, F act)
-// {
-// typedef typename Functor::wrap_action_type wrapper_type;
-// actions_.add_action(unique_id, add_state(state), wrapper_type::call(act));
-// }
+ }
+ // template
+ // void add_action(std::size_t unique_id, char_type const* state, F
+ // act)
+ // {
+ // typedef typename Functor::wrap_action_type wrapper_type;
+ // actions_.add_action(unique_id, add_state(state),
+ // wrapper_type::call(act));
+ // }
- // We do not minimize the state machine by default anymore because
- // Ben said: "If you can afford to generate a lexer at runtime, there
- // is little point in calling minimise."
- // Go figure.
- bool init_dfa(bool minimize = false) const
- {
- if (!initialized_dfa_) {
- state_machine_.clear();
- typedef boost::lexer::basic_generator generator;
- generator::build (rules_, state_machine_);
- if (minimize)
- generator::minimise (state_machine_);
+ // We do not minimize the state machine by default anymore because
+ // Ben said: "If you can afford to generate a lexer at runtime, there
+ // is little point in calling minimise."
+ // Go figure.
+ bool init_dfa(bool minimize = false) const {
+ if (!initialized_dfa_) {
+ state_machine_.clear();
+ typedef boost::lexer::basic_generator generator;
+ generator::build(rules_, state_machine_);
+ if (minimize) generator::minimise(state_machine_);
#if defined(BOOST_SPIRIT_LEXERTL_DEBUG)
- boost::lexer::debug::dump(state_machine_, std::cerr);
+ boost::lexer::debug::dump(state_machine_, std::cerr);
#endif
- initialized_dfa_ = true;
+ initialized_dfa_ = true;
-// // release memory held by rules description
-// basic_rules_type rules;
-// rules.init_state_info(rules_); // preserve states
-// std::swap(rules, rules_);
- }
- return true;
+ // // release memory held by rules description
+ // basic_rules_type rules;
+ // rules.init_state_info(rules_); // preserve
+ // states std::swap(rules, rules_);
}
+ return true;
+ }
- private:
- // lexertl specific data
- mutable boost::lexer::basic_state_machine state_machine_;
- boost::lexer::regex_flags flags_;
- /*mutable*/ basic_rules_type rules_;
+private:
+ // lexertl specific data
+ mutable boost::lexer::basic_state_machine state_machine_;
+ boost::lexer::regex_flags flags_;
+ /*mutable*/ basic_rules_type rules_;
- typename Functor::semantic_actions_type actions_;
- mutable bool initialized_dfa_;
+ typename Functor::semantic_actions_type actions_;
+ mutable bool initialized_dfa_;
- // generator functions must be able to access members directly
- template
- friend bool generate_static(Lexer const&
- , std::basic_ostream&
- , typename Lexer::char_type const*, F);
- };
+ // generator functions must be able to access members directly
+ template
+ friend bool generate_static(Lexer const&,
+ std::basic_ostream&,
+ typename Lexer::char_type const*, F);
+};
- ///////////////////////////////////////////////////////////////////////////
- //
- // The actor_lexer class is another implementation of a Spirit.Lex
- // lexer on top of Ben Hanson's lexertl library as outlined above (For
- // more information about lexertl go here:
- // http://www.benhanson.net/lexertl.html).
- //
- // The only difference to the lexer class above is that token_def
- // definitions may have semantic (lexer) actions attached while being
- // defined:
- //
- // int w;
- // token_def word = "[^ \t\n]+";
- // self = word[++ref(w)]; // see example: word_count_lexer
- //
- // This class is supposed to be used as the first and only template
- // parameter while instantiating instances of a lex::lexer class.
- //
- ///////////////////////////////////////////////////////////////////////////
- template
- , typename Iterator = typename Token::iterator_type
- , typename Functor = functor >
- class actor_lexer : public lexer
- {
- protected:
- // Lexer instances can be created by means of a derived class only.
- actor_lexer(unsigned int flags)
- : lexer(flags) {}
- };
+///////////////////////////////////////////////////////////////////////////
+//
+// The actor_lexer class is another implementation of a Spirit.Lex
+// lexer on top of Ben Hanson's lexertl library as outlined above (For
+// more information about lexertl go here:
+// http://www.benhanson.net/lexertl.html).
+//
+// The only difference to the lexer class above is that token_def
+// definitions may have semantic (lexer) actions attached while being
+// defined:
+//
+// int w;
+// token_def word = "[^ \t\n]+";
+// self = word[++ref(w)]; // see example: word_count_lexer
+//
+// This class is supposed to be used as the first and only template
+// parameter while instantiating instances of a lex::lexer class.
+//
+///////////////////////////////////////////////////////////////////////////
+template ,
+ typename Iterator = typename Token::iterator_type,
+ typename Functor =
+ functor >
+class actor_lexer : public lexer {
+protected:
+ // Lexer instances can be created by means of a derived class only.
+ actor_lexer(unsigned int flags) : lexer(flags) {}
+};
-}}}}
+} // namespace lexertl
+} // namespace lex
+} // namespace spirit
+} // namespace boost
#endif
diff --git a/Minecraft.Client/Platform/PS3/PS3_Minecraft.cpp b/Minecraft.Client/Platform/PS3/PS3_Minecraft.cpp
index 2582fd0cc..e2200c8a8 100644
--- a/Minecraft.Client/Platform/PS3/PS3_Minecraft.cpp
+++ b/Minecraft.Client/Platform/PS3/PS3_Minecraft.cpp
@@ -1211,7 +1211,6 @@ int main() {
Tesselator::CreateNewThreadStorage(1024 * 1024);
// Initialise TLS for AABB and Vec3 pools, for this main thread
AABB::CreateNewThreadStorage();
- Vec3::CreateNewThreadStorage();
OldChunkStorage::CreateNewThreadStorage();
Level::enableLightingCache();
Tile::CreateNewThreadStorage();
@@ -1547,7 +1546,6 @@ int main() {
// Fix for #7318 - Title crashes after short soak in the leaderboards
// menu A memory leak was caused because the icon renderer kept creating
// new Vec3's because the pool wasn't reset
- Vec3::resetPool();
}
// Free resources, unregister custom classes, and exit.
diff --git a/Minecraft.Client/Platform/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp b/Minecraft.Client/Platform/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp
index 2beca98b9..a7df253e1 100644
--- a/Minecraft.Client/Platform/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp
+++ b/Minecraft.Client/Platform/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp
@@ -1,6 +1,5 @@
#include "stdafx.h"
-
#ifdef SN_TARGET_PS3_SPU
#include
#include
@@ -10,25 +9,24 @@
#include |
#include
#include "../Common/spu_assert.h"
-#endif // SN_TARGET_PS3_SPU
+#endif // SN_TARGET_PS3_SPU
#include "Tesselator_SPU.h"
static const bool sc_verbose = false;
-// #include "../../../../../Minecraft.World/Util/BasicTypeContainers.h"
// #include "../../../../../Minecraft.World/IO/Streams/FloatBuffer.h"
// #include "../../../../../Minecraft.World/IO/Streams/IntBuffer.h"
// #include "../../../../../Minecraft.World/IO/Streams/ByteBuffer.h"
#ifdef SN_TARGET_PS3_SPU
-const int GL_LINES = 4;//C4JRender::PRIMITIVE_TYPE_LINE_LIST;
-const int GL_LINE_STRIP = 5;//C4JRender::PRIMITIVE_TYPE_LINE_STRIP;
-const int GL_QUADS = 3;//C4JRender::PRIMITIVE_TYPE_QUAD_LIST;
-const int GL_TRIANGLE_FAN = 2;//C4JRender::PRIMITIVE_TYPE_TRIANGLE_FAN;
-const int GL_TRIANGLE_STRIP = 1;//C4JRender::PRIMITIVE_TYPE_TRIANGLE_STRIP;
+const int GL_LINES = 4; // C4JRender::PRIMITIVE_TYPE_LINE_LIST;
+const int GL_LINE_STRIP = 5; // C4JRender::PRIMITIVE_TYPE_LINE_STRIP;
+const int GL_QUADS = 3; // C4JRender::PRIMITIVE_TYPE_QUAD_LIST;
+const int GL_TRIANGLE_FAN = 2; // C4JRender::PRIMITIVE_TYPE_TRIANGLE_FAN;
+const int GL_TRIANGLE_STRIP = 1; // C4JRender::PRIMITIVE_TYPE_TRIANGLE_STRIP;
-#endif
+#endif
bool Tesselator_SPU::TRIANGLE_MODE = false;
// bool Tesselator_SPU::USE_VBO = false;
@@ -50,128 +48,110 @@ int normal;
*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// taken from http://my.safaribooksonline.com/book/programming/opengl/9780321563835/gl-half-float-oes/app01lev1sec2
+// taken from
+// http://my.safaribooksonline.com/book/programming/opengl/9780321563835/gl-half-float-oes/app01lev1sec2
// -15 stored using a single precision bias of 127
-const unsigned int HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP = 0x38000000;
+const unsigned int HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP = 0x38000000;
// max exponent value in single precision that will be converted
// to Inf or Nan when stored as a half-float
-const unsigned int HALF_FLOAT_MAX_BIASED_EXP_AS_SINGLE_FP_EXP = 0x47800000;
+const unsigned int HALF_FLOAT_MAX_BIASED_EXP_AS_SINGLE_FP_EXP = 0x47800000;
// 255 is the max exponent biased value
-const unsigned int FLOAT_MAX_BIASED_EXP = (0xFF << 23);
+const unsigned int FLOAT_MAX_BIASED_EXP = (0xFF << 23);
-const unsigned int HALF_FLOAT_MAX_BIASED_EXP = (0x1F << 10);
+const unsigned int HALF_FLOAT_MAX_BIASED_EXP = (0x1F << 10);
-typedef unsigned short hfloat;
+typedef unsigned short hfloat;
-hfloat convertFloatToHFloat(float f)
-{
- unsigned int x = *(unsigned int *)&f;
- unsigned int sign = (unsigned short)(x >> 31);
- unsigned int mantissa;
- unsigned int exp;
- hfloat hf;
+hfloat convertFloatToHFloat(float f) {
+ unsigned int x = *(unsigned int*)&f;
+ unsigned int sign = (unsigned short)(x >> 31);
+ unsigned int mantissa;
+ unsigned int exp;
+ hfloat hf;
- // get mantissa
- mantissa = x & ((1 << 23) - 1);
- // get exponent bits
- exp = x & FLOAT_MAX_BIASED_EXP;
- if (exp >= HALF_FLOAT_MAX_BIASED_EXP_AS_SINGLE_FP_EXP)
- {
- // check if the original single precision float number is a NaN
- if (mantissa && (exp == FLOAT_MAX_BIASED_EXP))
- {
- // we have a single precision NaN
- mantissa = (1 << 23) - 1;
- }
- else
- {
- // 16-bit half-float representation stores number as Inf
- mantissa = 0;
- }
- hf = (((hfloat)sign) << 15) | (hfloat)(HALF_FLOAT_MAX_BIASED_EXP) |
- (hfloat)(mantissa >> 13);
- }
- // check if exponent is <= -15
- else if (exp <= HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP)
- {
+ // get mantissa
+ mantissa = x & ((1 << 23) - 1);
+ // get exponent bits
+ exp = x & FLOAT_MAX_BIASED_EXP;
+ if (exp >= HALF_FLOAT_MAX_BIASED_EXP_AS_SINGLE_FP_EXP) {
+ // check if the original single precision float number is a NaN
+ if (mantissa && (exp == FLOAT_MAX_BIASED_EXP)) {
+ // we have a single precision NaN
+ mantissa = (1 << 23) - 1;
+ } else {
+ // 16-bit half-float representation stores number as Inf
+ mantissa = 0;
+ }
+ hf = (((hfloat)sign) << 15) | (hfloat)(HALF_FLOAT_MAX_BIASED_EXP) |
+ (hfloat)(mantissa >> 13);
+ }
+ // check if exponent is <= -15
+ else if (exp <= HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP) {
+ // store a denorm half-float value or zero
+ exp = (HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP - exp) >> 23;
+ mantissa >>= (14 + exp);
- // store a denorm half-float value or zero
- exp = (HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP - exp) >> 23;
- mantissa >>= (14 + exp);
+ hf = (((hfloat)sign) << 15) | (hfloat)(mantissa);
+ } else {
+ hf =
+ (((hfloat)sign) << 15) |
+ (hfloat)((exp - HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP) >> 13) |
+ (hfloat)(mantissa >> 13);
+ }
- hf = (((hfloat)sign) << 15) | (hfloat)(mantissa);
- }
- else
- {
- hf = (((hfloat)sign) << 15) |
- (hfloat)((exp - HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP) >> 13) |
- (hfloat)(mantissa >> 13);
- }
-
- return hf;
+ return hf;
}
-float convertHFloatToFloat(hfloat hf)
-{
- unsigned int sign = (unsigned int)(hf >> 15);
- unsigned int mantissa = (unsigned int)(hf & ((1 << 10) - 1));
- unsigned int exp = (unsigned int)(hf & HALF_FLOAT_MAX_BIASED_EXP);
- unsigned int f;
+float convertHFloatToFloat(hfloat hf) {
+ unsigned int sign = (unsigned int)(hf >> 15);
+ unsigned int mantissa = (unsigned int)(hf & ((1 << 10) - 1));
+ unsigned int exp = (unsigned int)(hf & HALF_FLOAT_MAX_BIASED_EXP);
+ unsigned int f;
- if (exp == HALF_FLOAT_MAX_BIASED_EXP)
- {
- // we have a half-float NaN or Inf
- // half-float NaNs will be converted to a single precision NaN
- // half-float Infs will be converted to a single precision Inf
- exp = FLOAT_MAX_BIASED_EXP;
- if (mantissa)
- mantissa = (1 << 23) - 1; // set all bits to indicate a NaN
- }
- else if (exp == 0x0)
- {
- // convert half-float zero/denorm to single precision value
- if (mantissa)
- {
- mantissa <<= 1;
- exp = HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP;
- // check for leading 1 in denorm mantissa
- while ((mantissa & (1 << 10)) == 0)
- {
- // for every leading 0, decrement single precision exponent by 1
- // and shift half-float mantissa value to the left
- mantissa <<= 1;
- exp -= (1 << 23);
- }
- // clamp the mantissa to 10-bits
- mantissa &= ((1 << 10) - 1);
- // shift left to generate single-precision mantissa of 23-bits
- mantissa <<= 13;
- }
- }
- else
- {
- // shift left to generate single-precision mantissa of 23-bits
- mantissa <<= 13;
- // generate single precision biased exponent value
- exp = (exp << 13) + HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP;
- }
+ if (exp == HALF_FLOAT_MAX_BIASED_EXP) {
+ // we have a half-float NaN or Inf
+ // half-float NaNs will be converted to a single precision NaN
+ // half-float Infs will be converted to a single precision Inf
+ exp = FLOAT_MAX_BIASED_EXP;
+ if (mantissa)
+ mantissa = (1 << 23) - 1; // set all bits to indicate a NaN
+ } else if (exp == 0x0) {
+ // convert half-float zero/denorm to single precision value
+ if (mantissa) {
+ mantissa <<= 1;
+ exp = HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP;
+ // check for leading 1 in denorm mantissa
+ while ((mantissa & (1 << 10)) == 0) {
+ // for every leading 0, decrement single precision exponent by 1
+ // and shift half-float mantissa value to the left
+ mantissa <<= 1;
+ exp -= (1 << 23);
+ }
+ // clamp the mantissa to 10-bits
+ mantissa &= ((1 << 10) - 1);
+ // shift left to generate single-precision mantissa of 23-bits
+ mantissa <<= 13;
+ }
+ } else {
+ // shift left to generate single-precision mantissa of 23-bits
+ mantissa <<= 13;
+ // generate single precision biased exponent value
+ exp = (exp << 13) + HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP;
+ }
- f = (sign << 31) | exp | mantissa;
- return *((float *)&f);
+ f = (sign << 31) | exp | mantissa;
+ return *((float*)&f);
}
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
// DWORD Tesselator_SPU::tlsIdx = TlsAlloc();
-//
-Tesselator_SPU *Tesselator_SPU::getInstance()
-{
- return NULL;
-// return (Tesselator_SPU *)TlsGetValue(tlsIdx);
+//
+Tesselator_SPU* Tesselator_SPU::getInstance() {
+ return NULL;
+ // return (Tesselator_SPU *)TlsGetValue(tlsIdx);
}
// void Tesselator_SPU::CreateNewThreadStorage(int bytes)
@@ -180,129 +160,131 @@ Tesselator_SPU *Tesselator_SPU::getInstance()
// TlsSetValue(tlsIdx, instance);
// }
-
-
- void Tesselator_SPU::end()
- {
-// // if (!tesselating) throw new IllegalStateException("Not tesselating!"); // 4J - removed
-// tesselating = false;
-// if (vertices > 0)
-// {
-// // 4J - a lot of stuff taken out here for fiddling round with enable client states etc.
-// // that don't matter for our renderer
-// if (!hasColor)
-// {
-// // 4J - TEMP put in fixed vertex colors if we don't have any, until we have a shader that can cope without them
-// unsigned int *pColData = (unsigned int *)_array->data;
-// pColData += 5;
-// for( int i = 0; i < vertices; i++ )
-// {
-// *pColData = 0xffffffff;
-// pColData += 8;
-// }
-// }
-// if (mode == GL_QUADS && TRIANGLE_MODE)
-// {
-// // glDrawArrays(GL_TRIANGLES, 0, vertices); // 4J - changed for xbox
-// #ifdef _XBOX
-// RenderManager.DrawVertices(D3DPT_TRIANGLELIST,vertices,_array->data,
-// useCompactFormat360?C4JRender::VERTEX_TYPE_PS3_TS2_CS1:C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1,
-// useProjectedTexturePixelShader?C4JRender::PIXEL_SHADER_TYPE_PROJECTION:C4JRender::PIXEL_SHADER_TYPE_STANDARD);
-// #else
-// RenderManager.DrawVertices(C4JRender::PRIMITIVE_TYPE_TRIANGLE_LIST,vertices,_array->data,
-// useCompactFormat360?C4JRender::VERTEX_TYPE_COMPRESSED:C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1,
-// useProjectedTexturePixelShader?C4JRender::PIXEL_SHADER_TYPE_PROJECTION:C4JRender::PIXEL_SHADER_TYPE_STANDARD);
-// #endif
-// }
-// else
-// {
-// // glDrawArrays(mode, 0, vertices); // 4J - changed for xbox
-// // For compact vertices, the vertexCount has to be calculated from the amount of data written, as
-// // we insert extra fake vertices to encode supplementary data for more awkward quads that have non
-// // axis aligned UVs (eg flowing lava/water)
-// #ifdef _XBOX
-// int vertexCount = vertices;
-// if( useCompactFormat360 )
-// {
-// vertexCount = p / 2;
-// RenderManager.DrawVertices((D3DPRIMITIVETYPE)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_PS3_TS2_CS1, C4JRender::PIXEL_SHADER_TYPE_STANDARD);
-// }
-// else
-// {
-// if( useProjectedTexturePixelShader )
-// {
-// RenderManager.DrawVertices((D3DPRIMITIVETYPE)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN, C4JRender::PIXEL_SHADER_TYPE_PROJECTION);
-// }
-// else
-// {
-// RenderManager.DrawVertices((D3DPRIMITIVETYPE)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, C4JRender::PIXEL_SHADER_TYPE_STANDARD);
-// }
-// }
-// #else
-// int vertexCount = vertices;
-// if( useCompactFormat360 )
-// {
-// RenderManager.DrawVertices((C4JRender::ePrimitiveType)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_COMPRESSED, C4JRender::PIXEL_SHADER_TYPE_STANDARD);
-// }
-// else
-// {
-// if( useProjectedTexturePixelShader )
-// {
-// RenderManager.DrawVertices((C4JRender::ePrimitiveType)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN, C4JRender::PIXEL_SHADER_TYPE_PROJECTION);
-// }
-// else
-// {
-// RenderManager.DrawVertices((C4JRender::ePrimitiveType)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, C4JRender::PIXEL_SHADER_TYPE_STANDARD);
-// }
-// }
-// #endif
-// }
-// glDisableClientState(GL_VERTEX_ARRAY);
-// if (hasTexture) glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-// if (hasColor) glDisableClientState(GL_COLOR_ARRAY);
-// if (hasNormal) glDisableClientState(GL_NORMAL_ARRAY);
-// }
-//
-// clear();
+void Tesselator_SPU::end() {
+ // // if (!tesselating) throw new IllegalStateException("Not
+ // tesselating!"); // 4J - removed
+ // tesselating = false;
+ // if (vertices > 0)
+ // {
+ // // 4J - a lot of stuff taken out here for fiddling round with
+ // enable client states etc.
+ // // that don't matter for our renderer
+ // if (!hasColor)
+ // {
+ // // 4J - TEMP put in fixed vertex colors if we don't have
+ // any, until we have a shader that can cope without them
+ // unsigned int *pColData = (unsigned int *)_array->data;
+ // pColData += 5; for( int i = 0; i < vertices; i++ )
+ // {
+ // *pColData = 0xffffffff;
+ // pColData += 8;
+ // }
+ // }
+ // if (mode == GL_QUADS && TRIANGLE_MODE)
+ // {
+ // // glDrawArrays(GL_TRIANGLES, 0, vertices); // 4J - changed
+ // for xbox
+ // #ifdef _XBOX
+ // RenderManager.DrawVertices(D3DPT_TRIANGLELIST,vertices,_array->data,
+ // useCompactFormat360?C4JRender::VERTEX_TYPE_PS3_TS2_CS1:C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1,
+ // useProjectedTexturePixelShader?C4JRender::PIXEL_SHADER_TYPE_PROJECTION:C4JRender::PIXEL_SHADER_TYPE_STANDARD);
+ // #else
+ // RenderManager.DrawVertices(C4JRender::PRIMITIVE_TYPE_TRIANGLE_LIST,vertices,_array->data,
+ // useCompactFormat360?C4JRender::VERTEX_TYPE_COMPRESSED:C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1,
+ // useProjectedTexturePixelShader?C4JRender::PIXEL_SHADER_TYPE_PROJECTION:C4JRender::PIXEL_SHADER_TYPE_STANDARD);
+ // #endif
+ // }
+ // else
+ // {
+ // // glDrawArrays(mode, 0, vertices); // 4J - changed for xbox
+ // // For compact vertices, the vertexCount has to be
+ // calculated from the amount of data written, as
+ // // we insert extra fake vertices to encode supplementary
+ // data for more awkward quads that have non
+ // // axis aligned UVs (eg flowing lava/water)
+ // #ifdef _XBOX
+ // int vertexCount = vertices;
+ // if( useCompactFormat360 )
+ // {
+ // vertexCount = p / 2;
+ // RenderManager.DrawVertices((D3DPRIMITIVETYPE)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_PS3_TS2_CS1,
+ // C4JRender::PIXEL_SHADER_TYPE_STANDARD);
+ // }
+ // else
+ // {
+ // if( useProjectedTexturePixelShader )
+ // {
+ // RenderManager.DrawVertices((D3DPRIMITIVETYPE)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN,
+ // C4JRender::PIXEL_SHADER_TYPE_PROJECTION);
+ // }
+ // else
+ // {
+ // RenderManager.DrawVertices((D3DPRIMITIVETYPE)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1,
+ // C4JRender::PIXEL_SHADER_TYPE_STANDARD);
+ // }
+ // }
+ // #else
+ // int vertexCount = vertices;
+ // if( useCompactFormat360 )
+ // {
+ // RenderManager.DrawVertices((C4JRender::ePrimitiveType)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_COMPRESSED,
+ // C4JRender::PIXEL_SHADER_TYPE_STANDARD);
+ // }
+ // else
+ // {
+ // if( useProjectedTexturePixelShader )
+ // {
+ // RenderManager.DrawVertices((C4JRender::ePrimitiveType)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN,
+ // C4JRender::PIXEL_SHADER_TYPE_PROJECTION);
+ // }
+ // else
+ // {
+ // RenderManager.DrawVertices((C4JRender::ePrimitiveType)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1,
+ // C4JRender::PIXEL_SHADER_TYPE_STANDARD);
+ // }
+ // }
+ // #endif
+ // }
+ // glDisableClientState(GL_VERTEX_ARRAY);
+ // if (hasTexture) glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ // if (hasColor) glDisableClientState(GL_COLOR_ARRAY);
+ // if (hasNormal) glDisableClientState(GL_NORMAL_ARRAY);
+ // }
+ //
+ // clear();
}
-void Tesselator_SPU::clear()
-{
+void Tesselator_SPU::clear() {
vertices = 0;
p = 0;
count = 0;
}
-void Tesselator_SPU::begin()
-{
+void Tesselator_SPU::begin() {
begin(GL_QUADS);
- bounds.reset();
-}
-
-void Tesselator_SPU::useProjectedTexture(bool enable)
-{
- useProjectedTexturePixelShader = enable;
+ bounds.reset();
}
-void Tesselator_SPU::useCompactVertices(bool enable)
-{
- useCompactFormat360 = enable;
+void Tesselator_SPU::useProjectedTexture(bool enable) {
+ useProjectedTexturePixelShader = enable;
}
-bool Tesselator_SPU::setMipmapEnable(bool enable)
-{
- bool prev = mipmapEnable;
- mipmapEnable = enable;
- return prev;
+void Tesselator_SPU::useCompactVertices(bool enable) {
+ useCompactFormat360 = enable;
}
-void Tesselator_SPU::begin(int mode)
-{
- /* // 4J - removed
- if (tesselating) {
- throw new IllegalStateException("Already tesselating!");
- } */
+bool Tesselator_SPU::setMipmapEnable(bool enable) {
+ bool prev = mipmapEnable;
+ mipmapEnable = enable;
+ return prev;
+}
+
+void Tesselator_SPU::begin(int mode) {
+ /* // 4J - removed
+if (tesselating) {
+ throw new IllegalStateException("Already tesselating!");
+} */
tesselating = true;
clear();
@@ -310,40 +292,32 @@ void Tesselator_SPU::begin(int mode)
hasNormal = false;
hasColor = false;
hasTexture = false;
- hasTexture2 = false;
+ hasTexture2 = false;
_noColor = false;
}
-void Tesselator_SPU::tex(float u, float v)
-{
+void Tesselator_SPU::tex(float u, float v) {
hasTexture = true;
this->u = u;
this->v = v;
}
-void Tesselator_SPU::tex2(int tex2)
-{
+void Tesselator_SPU::tex2(int tex2) {
hasTexture2 = true;
- this->_tex2 = tex2;
+ this->_tex2 = tex2;
}
-void Tesselator_SPU::color(float r, float g, float b)
-{
- color((int) (r * 255), (int) (g * 255), (int) (b * 255));
+void Tesselator_SPU::color(float r, float g, float b) {
+ color((int)(r * 255), (int)(g * 255), (int)(b * 255));
}
-void Tesselator_SPU::color(float r, float g, float b, float a)
-{
- color((int) (r * 255), (int) (g * 255), (int) (b * 255), (int) (a * 255));
+void Tesselator_SPU::color(float r, float g, float b, float a) {
+ color((int)(r * 255), (int)(g * 255), (int)(b * 255), (int)(a * 255));
}
-void Tesselator_SPU::color(int r, int g, int b)
-{
- color(r, g, b, 255);
-}
+void Tesselator_SPU::color(int r, int g, int b) { color(r, g, b, 255); }
-void Tesselator_SPU::color(int r, int g, int b, int a)
-{
+void Tesselator_SPU::color(int r, int g, int b, int a) {
if (_noColor) return;
if (r > 255) r = 255;
@@ -356,48 +330,54 @@ void Tesselator_SPU::color(int r, int g, int b, int a)
if (a < 0) a = 0;
hasColor = true;
- // 4J - removed little-endian option
+ // 4J - removed little-endian option
col = (r << 24) | (g << 16) | (b << 8) | (a);
}
-void Tesselator_SPU::color(uint8_t r, uint8_t g, uint8_t b)
-{
- color(r & 0xff, g & 0xff, b & 0xff);
+void Tesselator_SPU::color(uint8_t r, uint8_t g, uint8_t b) {
+ color(r & 0xff, g & 0xff, b & 0xff);
}
-void Tesselator_SPU::vertexUV(float x, float y, float z, float u, float v)
-{
+void Tesselator_SPU::vertexUV(float x, float y, float z, float u, float v) {
tex(u, v);
vertex(x, y, z);
}
-// Pack the 4 vertices of a quad up into a compact format. This is structured as 8 bytes per vertex,
-// arranged in blocks of 4 vertices per quad. Currently this is (one letter per nyblle):
+// Pack the 4 vertices of a quad up into a compact format. This is structured as
+// 8 bytes per vertex, arranged in blocks of 4 vertices per quad. Currently this
+// is (one letter per nyblle):
//
// cccc xxyy zzll rgbi (vertex 0)
// umin xxyy zzll rgbi (vertex 1)
// vmin xxyy zzll rgbi (vertex 2)
// udvd xxyy zzll rgbi (vertex 3)
//
-// where: cccc is a 15-bit (5 bits per x/y/z) origin position / offset for the whole quad. Each
-// component is unsigned, and offset by 16 so has a range 0 to 31 actually representing -16 to 15
-// xx,yy,zz are 8-bit deltas from this origin to each vertex. These are unsigned 1.7 fixed point, ie
+// where: cccc is a 15-bit (5 bits per x/y/z) origin position / offset
+// for the whole quad. Each
+// component is unsigned, and offset by 16
+// so has a range 0 to 31 actually representing -16 to 15
+// xx,yy,zz are 8-bit deltas from this origin to each vertex. These are
+// unsigned 1.7 fixed point, ie
// representing a range of 0 to 1.9921875
// rgb is 4:4:4 RGB
-// umin, vmin are 3:13 unsigned fixed point UVs reprenting the min u and v required by the quad
-// ud,vd are 8-bit unsigned fixed pont UV deltas, which can be added to umin/vmin to get umax, vmax
-// and therefore define the 4 corners of an axis aligned UV mapping
-// i is a code per vertex that indicates which of umin/umax should be used for u, and which
-// of vmin/vmax should be used for v for this vertex. The coding is:
-// 0 - u = umin, v = vmin
-// 1 - u = umin, v = vmax
-// 2 - u = umax, v = vmin
-// 3 - u = umax, v = vmax
-// 4 - not axis aligned, use uv stored in the vertex data 4 on from this one
-// ll is an 8-bit (4 bit per u/v) index into the current lighting texture
+// umin, vmin are 3:13 unsigned fixed point UVs reprenting the min u and
+// v required by the quad ud,vd are 8-bit unsigned fixed pont
+// UV deltas, which can be added to umin/vmin to get umax, vmax
+// and therefore define the 4 corners of
+// an axis aligned UV mapping
+// i is a code per vertex that indicates which of umin/umax
+// should be used for u, and which
+// of vmin/vmax should be used for v for
+// this vertex. The coding is: 0 - u =
+// umin, v = vmin 1 - u = umin, v
+// = vmax 2 - u = umax, v = vmin
+// 3 - u = umax, v = vmax 4 - not
+// axis aligned, use uv stored in the vertex data 4 on from this one ll
+// is an 8-bit (4 bit per u/v) index into the current lighting texture
//
-// For quads that don't have axis aligned UVs (ie have a code for 4 in i as described above) the 8 byte vertex
-// is followed by a further 8 bytes which have explicit UVs defined for each vertex:
+// For quads that don't have axis aligned UVs (ie have a code for 4 in i as
+// described above) the 8 byte vertex is followed by a further 8 bytes which
+// have explicit UVs defined for each vertex:
//
// 0000 0000 uuuu vvvv (vertex 0)
// 0000 0000 uuuu vvvv (vertex 1)
@@ -405,392 +385,377 @@ void Tesselator_SPU::vertexUV(float x, float y, float z, float u, float v)
// 0000 0000 uuuu vvvv (vertex 3)
//
-void Tesselator_SPU::packCompactQuad()
-{
- // Offset x/y/z by 16 so that we can deal with a -16 -> 16 range
- for( int i = 0; i < 4; i++ )
- {
- m_ix[i] += 16 * 128;
- m_iy[i] += 16 * 128;
- m_iz[i] += 16 * 128;
- }
- // Find min x/y/z
- unsigned int minx = m_ix[0];
- unsigned int miny = m_iy[0];
- unsigned int minz = m_iz[0];
- for( int i = 1; i < 4; i++ )
- {
- if( m_ix[i] < minx ) minx = m_ix[i];
- if( m_iy[i] < miny ) miny = m_iy[i];
- if( m_iz[i] < minz ) minz = m_iz[i];
- }
- // Everything has been scaled by a factor of 128 to get it into an int, and so
- // the minimum now should be in the range of (0->32) * 128. Get the base x/y/z
- // that our quad will be referenced from now, which can be stored in 5 bits
- unsigned int basex = ( minx >> 7 );
- unsigned int basey = ( miny >> 7 );
- unsigned int basez = ( minz >> 7 );
- // If the min is 32, then this whole quad must be in that plane - make the min 15 instead so
- // we can still offset from that with our delta to get to the exact edge
- if( basex == 32 ) basex = 31;
- if( basey == 32 ) basey = 31;
- if( basez == 32 ) basez = 31;
- // Now get deltas to each vertex - these have an 8-bit range so they can span a
- // full unit range from the base position
- for( int i = 0; i < 4; i++ )
- {
- m_ix[i] -= basex << 7;
- m_iy[i] -= basey << 7;
- m_iz[i] -= basez << 7;
- }
- // Now write the data out
- unsigned int *data = (unsigned int *)&_array->data[p];
-
- for( int i = 0; i < 4; i++ )
- {
- data[i * 2 + 0] = ( m_ix[i] << 8 ) | ( m_iy[i] );
- data[i * 2 + 1] = ( m_iz[i] << 24 ) | ( m_clr[i] );
- }
- data[0] |= ( basex << 26 ) | ( basey << 21 )| ( basez << 16 );
+void Tesselator_SPU::packCompactQuad() {
+ // Offset x/y/z by 16 so that we can deal with a -16 -> 16 range
+ for (int i = 0; i < 4; i++) {
+ m_ix[i] += 16 * 128;
+ m_iy[i] += 16 * 128;
+ m_iz[i] += 16 * 128;
+ }
+ // Find min x/y/z
+ unsigned int minx = m_ix[0];
+ unsigned int miny = m_iy[0];
+ unsigned int minz = m_iz[0];
+ for (int i = 1; i < 4; i++) {
+ if (m_ix[i] < minx) minx = m_ix[i];
+ if (m_iy[i] < miny) miny = m_iy[i];
+ if (m_iz[i] < minz) minz = m_iz[i];
+ }
+ // Everything has been scaled by a factor of 128 to get it into an int, and
+ // so the minimum now should be in the range of (0->32) * 128. Get the base
+ // x/y/z that our quad will be referenced from now, which can be stored in 5
+ // bits
+ unsigned int basex = (minx >> 7);
+ unsigned int basey = (miny >> 7);
+ unsigned int basez = (minz >> 7);
+ // If the min is 32, then this whole quad must be in that plane - make the
+ // min 15 instead so we can still offset from that with our delta to get to
+ // the exact edge
+ if (basex == 32) basex = 31;
+ if (basey == 32) basey = 31;
+ if (basez == 32) basez = 31;
+ // Now get deltas to each vertex - these have an 8-bit range so they can
+ // span a full unit range from the base position
+ for (int i = 0; i < 4; i++) {
+ m_ix[i] -= basex << 7;
+ m_iy[i] -= basey << 7;
+ m_iz[i] -= basez << 7;
+ }
+ // Now write the data out
+ unsigned int* data = (unsigned int*)&_array->data[p];
- // Now process UVs. First find min & max U & V
- unsigned int minu = m_u[0];
- unsigned int minv = m_v[0];
- unsigned int maxu = m_u[0];
- unsigned int maxv = m_v[0];
+ for (int i = 0; i < 4; i++) {
+ data[i * 2 + 0] = (m_ix[i] << 8) | (m_iy[i]);
+ data[i * 2 + 1] = (m_iz[i] << 24) | (m_clr[i]);
+ }
+ data[0] |= (basex << 26) | (basey << 21) | (basez << 16);
- for( int i = 1; i < 4; i++ )
- {
- if( m_u[i] < minu ) minu = m_u[i];
- if( m_v[i] < minv ) minv = m_v[i];
- if( m_u[i] > maxu ) maxu = m_u[i];
- if( m_v[i] > maxv ) maxv = m_v[i];
- }
- // In nearly all cases, all our UVs should be axis aligned for this quad. So the only values they should
- // have in each dimension should be the min/max. We're going to store:
- // (1) minu/maxu (16 bits each, only actuall needs to store 14 bits to get a 0 to 2 range for each
- // (2) du/dv ( ie maxu-minu, maxv-minv) - 8 bits each, to store a range of 0 to 15.9375 texels. This
- // should be enough to map the full UV range of a single 16x16 region of the terrain texture, since
- // we always pull UVs in by 1/16th of their range at the sides
- unsigned int du = maxu - minu;
- unsigned int dv = maxv - minv;
- if( du > 255 ) du = 255;
- if( dv > 255 ) dv = 255;
- // Check if this quad has UVs that can be referenced this way. This should only happen for flowing water
- // and lava, where the texture coordinates are rotated for the top surface of the tile.
- bool axisAligned = true;
- for( int i = 0; i < 4; i++ )
- {
- if(! ( ( ( m_u[i] == minu ) || ( m_u[i] == maxu ) ) &&
- ( ( m_v[i] == minv ) || ( m_v[i] == maxv ) ) ) )
- {
- axisAligned = false;
- }
- }
+ // Now process UVs. First find min & max U & V
+ unsigned int minu = m_u[0];
+ unsigned int minv = m_v[0];
+ unsigned int maxu = m_u[0];
+ unsigned int maxv = m_v[0];
- if( axisAligned )
- {
- // Now go through each vertex, and work out which of the min/max should be used for each dimension,
- // and store
- for( int i = 0; i < 4; i++ )
- {
- unsigned int code = 0;
- if( m_u[i] == maxu ) code |= 2;
- if( m_v[i] == maxv ) code |= 1;
- data[i * 2 + 1] |= code;
- data[i * 2 + 1] |= m_t2[i] << 16;
- }
- // Finally, store the minu/minv/du/dv
- data[1 * 2 + 0] |= minu << 16;
- data[2 * 2 + 0] |= minv << 16;
- data[3 * 2 + 0] |= ( du << 24 | dv << 16 );
+ for (int i = 1; i < 4; i++) {
+ if (m_u[i] < minu) minu = m_u[i];
+ if (m_v[i] < minv) minv = m_v[i];
+ if (m_u[i] > maxu) maxu = m_u[i];
+ if (m_v[i] > maxv) maxv = m_v[i];
+ }
+ // In nearly all cases, all our UVs should be axis aligned for this quad. So
+ // the only values they should have in each dimension should be the min/max.
+ // We're going to store: (1) minu/maxu (16 bits each, only actuall needs to
+ // store 14 bits to get a 0 to 2 range for each (2) du/dv ( ie maxu-minu,
+ // maxv-minv) - 8 bits each, to store a range of 0 to 15.9375 texels. This
+ // should be enough to map the full UV range of a single 16x16 region of the
+ // terrain texture, since we always pull UVs in by 1/16th of their range at
+ // the sides
+ unsigned int du = maxu - minu;
+ unsigned int dv = maxv - minv;
+ if (du > 255) du = 255;
+ if (dv > 255) dv = 255;
+ // Check if this quad has UVs that can be referenced this way. This should
+ // only happen for flowing water and lava, where the texture coordinates are
+ // rotated for the top surface of the tile.
+ bool axisAligned = true;
+ for (int i = 0; i < 4; i++) {
+ if (!(((m_u[i] == minu) || (m_u[i] == maxu)) &&
+ ((m_v[i] == minv) || (m_v[i] == maxv)))) {
+ axisAligned = false;
+ }
+ }
- incData(4 * 2);
- }
- else
- {
- // The UVs aren't axis aligned - store them in the next 4 vertices. These will be indexed from
- // our base vertices because we'll set a special code (4) for the UVs. They won't be drawn as actual
- // verts when these extra vertices go through the vertex shader, because we'll make sure that
- // they get interpreted as a zero area quad and so they'll be quickly eliminated from rendering post-tranform
+ if (axisAligned) {
+ // Now go through each vertex, and work out which of the min/max should
+ // be used for each dimension, and store
+ for (int i = 0; i < 4; i++) {
+ unsigned int code = 0;
+ if (m_u[i] == maxu) code |= 2;
+ if (m_v[i] == maxv) code |= 1;
+ data[i * 2 + 1] |= code;
+ data[i * 2 + 1] |= m_t2[i] << 16;
+ }
+ // Finally, store the minu/minv/du/dv
+ data[1 * 2 + 0] |= minu << 16;
+ data[2 * 2 + 0] |= minv << 16;
+ data[3 * 2 + 0] |= (du << 24 | dv << 16);
- for( int i = 0; i < 4; i++ )
- {
- data[i * 2 + 1] |= ( 4 ); // The special code to indicate they need further data to be fetched
- data[i * 2 + 1] |= m_t2[i] << 16;
- data[8 + i * 2] = 0; // This includes x/y coordinate of each vert as (0,0) so they will be interpreted as a zero area quad
- data[9 + i * 2] = m_u[i] << 16 | m_v[i];
- }
+ incData(4 * 2);
+ } else {
+ // The UVs aren't axis aligned - store them in the next 4 vertices.
+ // These will be indexed from our base vertices because we'll set a
+ // special code (4) for the UVs. They won't be drawn as actual verts
+ // when these extra vertices go through the vertex shader, because we'll
+ // make sure that they get interpreted as a zero area quad and so
+ // they'll be quickly eliminated from rendering post-tranform
- // Extra 8 bytes required
- incData(8 * 2);
- }
+ for (int i = 0; i < 4; i++) {
+ data[i * 2 + 1] |= (4); // The special code to indicate they need
+ // further data to be fetched
+ data[i * 2 + 1] |= m_t2[i] << 16;
+ data[8 + i * 2] =
+ 0; // This includes x/y coordinate of each vert as (0,0) so
+ // they will be interpreted as a zero area quad
+ data[9 + i * 2] = m_u[i] << 16 | m_v[i];
+ }
+
+ // Extra 8 bytes required
+ incData(8 * 2);
+ }
}
-void Tesselator_SPU::vertex(float x, float y, float z)
-{
- bounds.addVert(x+xo, y+yo, z+zo); // 4J MGH - added
- count++;
+void Tesselator_SPU::vertex(float x, float y, float z) {
+ bounds.addVert(x + xo, y + yo, z + zo); // 4J MGH - added
+ count++;
- // Signal to pixel shader whether to use mipmapping or not, by putting u into > 1 range if it is to be disabled
- float uu = mipmapEnable ? u : (u + 1.0f);
+ // Signal to pixel shader whether to use mipmapping or not, by putting u
+ // into > 1 range if it is to be disabled
+ float uu = mipmapEnable ? u : (u + 1.0f);
- // 4J - this format added for 360 to keep memory size of tesselated tiles down -
- // see comments in packCompactQuad() for exact format
- if( useCompactFormat360 )
- {
- unsigned int ucol = (unsigned int)col;
+ // 4J - this format added for 360 to keep memory size of tesselated tiles
+ // down - see comments in packCompactQuad() for exact format
+ if (useCompactFormat360) {
+ unsigned int ucol = (unsigned int)col;
#ifdef _XBOX
- // Pack as 4:4:4 RGB_
- unsigned short packedcol = (((col & 0xf0000000 ) >> 16 ) |
- ((col & 0x00f00000 ) >> 12 ) |
- ((col & 0x0000f000 ) >> 8 ));
- int ipackedcol = ((int)packedcol) & 0xffff; // 0 to 65535 range
+ // Pack as 4:4:4 RGB_
+ unsigned short packedcol =
+ (((col & 0xf0000000) >> 16) | ((col & 0x00f00000) >> 12) |
+ ((col & 0x0000f000) >> 8));
+ int ipackedcol = ((int)packedcol) & 0xffff; // 0 to 65535 range
- int quadIdx = vertices % 4;
- m_ix[ quadIdx ] = (unsigned int)((x + xo) * 128.0f);
- m_iy[ quadIdx ] = (unsigned int)((y + yo) * 128.0f);
- m_iz[ quadIdx ] = (unsigned int)((z + zo) * 128.0f);
- m_clr[ quadIdx ] = (unsigned int)ipackedcol;
- m_u[ quadIdx ] = (int)(uu * 4096.0f);
- m_v[ quadIdx ] = (int)(v * 4096.0f);
- m_t2[ quadIdx ] = ( ( _tex2 & 0x00f00000 ) >> 20 ) | ( _tex2 & 0x000000f0 );
- if( quadIdx == 3 )
- {
- packCompactQuad();
- }
+ int quadIdx = vertices % 4;
+ m_ix[quadIdx] = (unsigned int)((x + xo) * 128.0f);
+ m_iy[quadIdx] = (unsigned int)((y + yo) * 128.0f);
+ m_iz[quadIdx] = (unsigned int)((z + zo) * 128.0f);
+ m_clr[quadIdx] = (unsigned int)ipackedcol;
+ m_u[quadIdx] = (int)(uu * 4096.0f);
+ m_v[quadIdx] = (int)(v * 4096.0f);
+ m_t2[quadIdx] = ((_tex2 & 0x00f00000) >> 20) | (_tex2 & 0x000000f0);
+ if (quadIdx == 3) {
+ packCompactQuad();
+ }
#else
- unsigned short packedcol = ((col & 0xf8000000 ) >> 16 ) |
- ((col & 0x00fc0000 ) >> 13 ) |
- ((col & 0x0000f800 ) >> 11 );
- int ipackedcol = ((int)packedcol) & 0xffff; // 0 to 65535 range
+ unsigned short packedcol = ((col & 0xf8000000) >> 16) |
+ ((col & 0x00fc0000) >> 13) |
+ ((col & 0x0000f800) >> 11);
+ int ipackedcol = ((int)packedcol) & 0xffff; // 0 to 65535 range
- ipackedcol -= 32768; // -32768 to 32767 range
- ipackedcol &= 0xffff;
+ ipackedcol -= 32768; // -32768 to 32767 range
+ ipackedcol &= 0xffff;
- int16_t* pShortData = (int16_t*)&_array->data[p];
+ int16_t* pShortData = (int16_t*)&_array->data[p];
#ifdef __PS3__
-#define INT_ROUND(x) (int)(floorf(x+0.5))
- float tex2U = ((int16_t*)&_tex2)[1] + 8;
- float tex2V = ((int16_t*)&_tex2)[0] + 8;
- float colVal1 = ((col&0xff000000)>>24)/256.0f;
- float colVal2 = ((col&0x00ff0000)>>16)/256.0f;
- float colVal3 = ((col&0x0000ff00)>>8)/256.0f;
+#define INT_ROUND(x) (int)(floorf(x + 0.5))
+ float tex2U = ((int16_t*)&_tex2)[1] + 8;
+ float tex2V = ((int16_t*)&_tex2)[0] + 8;
+ float colVal1 = ((col & 0xff000000) >> 24) / 256.0f;
+ float colVal2 = ((col & 0x00ff0000) >> 16) / 256.0f;
+ float colVal3 = ((col & 0x0000ff00) >> 8) / 256.0f;
- // pShortData[0] = convertFloatToHFloat(x + xo);
- // pShortData[1] = convertFloatToHFloat(y + yo);
- // pShortData[2] = convertFloatToHFloat(z + zo);
- // pShortData[3] = convertFloatToHFloat(uu);
- // pShortData[4] = convertFloatToHFloat(tex2U + colVal1);
- // pShortData[5] = convertFloatToHFloat(tex2V + colVal2);
- // pShortData[6] = convertFloatToHFloat(colVal3);
- // pShortData[7] = convertFloatToHFloat(v);
+ // pShortData[0] = convertFloatToHFloat(x + xo);
+ // pShortData[1] = convertFloatToHFloat(y + yo);
+ // pShortData[2] = convertFloatToHFloat(z + zo);
+ // pShortData[3] = convertFloatToHFloat(uu);
+ // pShortData[4] = convertFloatToHFloat(tex2U + colVal1);
+ // pShortData[5] = convertFloatToHFloat(tex2V + colVal2);
+ // pShortData[6] = convertFloatToHFloat(colVal3);
+ // pShortData[7] = convertFloatToHFloat(v);
- pShortData[0] = ((INT_ROUND((x + xo ) * 1024.0f))&0xffff);
- pShortData[1] = ((INT_ROUND((y + yo ) * 1024.0f))&0xffff);
- pShortData[2] = ((INT_ROUND((z + zo ) * 1024.0f))&0xffff);
- pShortData[3] = ipackedcol;
- pShortData[4] = ((INT_ROUND(uu * 8192.0f))&0xffff);
- pShortData[5] = ((INT_ROUND(v * 8192.0f))&0xffff);
- pShortData[6] = ((INT_ROUND(tex2U * (8192.0f/256.0f)))&0xffff);
- pShortData[7] = ((INT_ROUND(tex2V * (8192.0f/256.0f)))&0xffff);
- incData(4);
+ pShortData[0] = ((INT_ROUND((x + xo) * 1024.0f)) & 0xffff);
+ pShortData[1] = ((INT_ROUND((y + yo) * 1024.0f)) & 0xffff);
+ pShortData[2] = ((INT_ROUND((z + zo) * 1024.0f)) & 0xffff);
+ pShortData[3] = ipackedcol;
+ pShortData[4] = ((INT_ROUND(uu * 8192.0f)) & 0xffff);
+ pShortData[5] = ((INT_ROUND(v * 8192.0f)) & 0xffff);
+ pShortData[6] = ((INT_ROUND(tex2U * (8192.0f / 256.0f))) & 0xffff);
+ pShortData[7] = ((INT_ROUND(tex2V * (8192.0f / 256.0f))) & 0xffff);
+ incData(4);
#else
- pShortData[0] = (((int)((x + xo ) * 1024.0f))&0xffff);
- pShortData[1] = (((int)((y + yo ) * 1024.0f))&0xffff);
- pShortData[2] = (((int)((z + zo ) * 1024.0f))&0xffff);
- pShortData[3] = ipackedcol;
- pShortData[4] = (((int)(uu * 8192.0f))&0xffff);
- pShortData[5] = (((int)(v * 8192.0f))&0xffff);
- pShortData[6] = ((int16_t*)&_tex2)[0];
- pShortData[7] = ((int16_t*)&_tex2)[1];
- incData(4);
+ pShortData[0] = (((int)((x + xo) * 1024.0f)) & 0xffff);
+ pShortData[1] = (((int)((y + yo) * 1024.0f)) & 0xffff);
+ pShortData[2] = (((int)((z + zo) * 1024.0f)) & 0xffff);
+ pShortData[3] = ipackedcol;
+ pShortData[4] = (((int)(uu * 8192.0f)) & 0xffff);
+ pShortData[5] = (((int)(v * 8192.0f)) & 0xffff);
+ pShortData[6] = ((int16_t*)&_tex2)[0];
+ pShortData[7] = ((int16_t*)&_tex2)[1];
+ incData(4);
#endif
#endif
- vertices++;
+ vertices++;
#ifdef _XBOX
- if (vertices % 4 == 0 && ( ( p >= size - 8 * 2 ) || ( ( p / 2 ) >= 65532 ) ) ) // Max 65535 verts in D3D, so 65532 is the last point at the end of a quad to catch it
+ if (vertices % 4 == 0 &&
+ ((p >= size - 8 * 2) ||
+ ((p / 2) >=
+ 65532))) // Max 65535 verts in D3D, so 65532 is the last point at
+ // the end of a quad to catch it
#else
- if (vertices % 4 == 0 && ( ( p >= size - 4 * 4 ) || ( ( p / 4 ) >= 65532 ) ) ) // Max 65535 verts in D3D, so 65532 is the last point at the end of a quad to catch it
+ if (vertices % 4 == 0 &&
+ ((p >= size - 4 * 4) ||
+ ((p / 4) >=
+ 65532))) // Max 65535 verts in D3D, so 65532 is the last point at
+ // the end of a quad to catch it
#endif
- {
-// end();
- tesselating = true;
- }
- }
- else
- {
- if (mode == GL_QUADS && TRIANGLE_MODE && count % 4 == 0)
- {
- for (int i = 0; i < 2; i++)
- {
- int offs = 8 * (3 - i);
- if (hasTexture)
- {
- _array->data[p + 3] = _array->data[p - offs + 3];
- _array->data[p + 4] = _array->data[p - offs + 4];
- }
- if (hasColor)
- {
- _array->data[p + 5] = _array->data[p - offs + 5];
- }
+ {
+ // end();
+ tesselating = true;
+ }
+ } else {
+ if (mode == GL_QUADS && TRIANGLE_MODE && count % 4 == 0) {
+ for (int i = 0; i < 2; i++) {
+ int offs = 8 * (3 - i);
+ if (hasTexture) {
+ _array->data[p + 3] = _array->data[p - offs + 3];
+ _array->data[p + 4] = _array->data[p - offs + 4];
+ }
+ if (hasColor) {
+ _array->data[p + 5] = _array->data[p - offs + 5];
+ }
- _array->data[p + 0] = _array->data[p - offs + 0];
- _array->data[p + 1] = _array->data[p - offs + 1];
- _array->data[p + 2] = _array->data[p - offs + 2];
+ _array->data[p + 0] = _array->data[p - offs + 0];
+ _array->data[p + 1] = _array->data[p - offs + 1];
+ _array->data[p + 2] = _array->data[p - offs + 2];
- vertices++;
- incData(8);
- }
- }
+ vertices++;
+ incData(8);
+ }
+ }
- if (hasTexture)
- {
- float *fdata = (float *)(_array->data + p + 3);
- *fdata++ = uu;
- *fdata++ = v;
- }
- if (hasColor)
- {
- _array->data[p + 5] = col;
- }
- if (hasNormal)
- {
- _array->data[p + 6] = _normal;
- }
- if (hasTexture2)
- {
+ if (hasTexture) {
+ float* fdata = (float*)(_array->data + p + 3);
+ *fdata++ = uu;
+ *fdata++ = v;
+ }
+ if (hasColor) {
+ _array->data[p + 5] = col;
+ }
+ if (hasNormal) {
+ _array->data[p + 6] = _normal;
+ }
+ if (hasTexture2) {
#ifdef _XBOX
- _array->data[p + 7] = ( ( _tex2 >> 16 ) & 0xffff ) | ( _tex2 << 16 );
+ _array->data[p + 7] = ((_tex2 >> 16) & 0xffff) | (_tex2 << 16);
#else
#ifdef __PS3__
- int16_t tex2U = ((int16_t*)&_tex2)[1] + 8;
- int16_t tex2V = ((int16_t*)&_tex2)[0] + 8;
- int16_t* pShortArray = (int16_t*)&_array->data[p + 7];
- pShortArray[0] = tex2U;
- pShortArray[1] = tex2V;
+ int16_t tex2U = ((int16_t*)&_tex2)[1] + 8;
+ int16_t tex2V = ((int16_t*)&_tex2)[0] + 8;
+ int16_t* pShortArray = (int16_t*)&_array->data[p + 7];
+ pShortArray[0] = tex2U;
+ pShortArray[1] = tex2V;
#else
- _array->data[p + 7] = _tex2;
+ _array->data[p + 7] = _tex2;
#endif
#endif
- }
- else
- {
- // -512 each for u/v will mean that the renderer will use global settings (set via
- // RenderManager.StateSetVertexTextureUV) rather than these local ones
- *(unsigned int *)(&_array->data[p + 7]) = 0xfe00fe00;
- }
+ } else {
+ // -512 each for u/v will mean that the renderer will use global
+ // settings (set via RenderManager.StateSetVertexTextureUV) rather
+ // than these local ones
+ *(unsigned int*)(&_array->data[p + 7]) = 0xfe00fe00;
+ }
- float *fdata = (float *)(_array->data + p);
- *fdata++ = (x + xo);
- *fdata++ = (y + yo);
- *fdata++ = (z + zo);
- incData(8);
+ float* fdata = (float*)(_array->data + p);
+ *fdata++ = (x + xo);
+ *fdata++ = (y + yo);
+ *fdata++ = (z + zo);
+ incData(8);
- vertices++;
- if (vertices % 4 == 0 && p >= size - 8 * 4)
- {
-// end();
- tesselating = true;
- }
- }
+ vertices++;
+ if (vertices % 4 == 0 && p >= size - 8 * 4) {
+ // end();
+ tesselating = true;
+ }
+ }
}
-void Tesselator_SPU::color(int c)
-{
+void Tesselator_SPU::color(int c) {
int r = ((c >> 16) & 255);
int g = ((c >> 8) & 255);
int b = ((c) & 255);
color(r, g, b);
}
-void Tesselator_SPU::color(int c, int alpha)
-{
+void Tesselator_SPU::color(int c, int alpha) {
int r = ((c >> 16) & 255);
int g = ((c >> 8) & 255);
int b = ((c) & 255);
color(r, g, b, alpha);
}
-void Tesselator_SPU::noColor()
-{
- _noColor = true;
-}
+void Tesselator_SPU::noColor() { _noColor = true; }
-void Tesselator_SPU::normal(float x, float y, float z)
-{
+void Tesselator_SPU::normal(float x, float y, float z) {
hasNormal = true;
- uint8_t xx = (uint8_t) (x * 127);
- uint8_t yy = (uint8_t) (y * 127);
- uint8_t zz = (uint8_t) (z * 127);
+ uint8_t xx = (uint8_t)(x * 127);
+ uint8_t yy = (uint8_t)(y * 127);
+ uint8_t zz = (uint8_t)(z * 127);
_normal = (xx & 0xff) | ((yy & 0xff) << 8) | ((zz & 0xff) << 16);
}
-void Tesselator_SPU::offset(float xo, float yo, float zo)
-{
+void Tesselator_SPU::offset(float xo, float yo, float zo) {
this->xo = xo;
this->yo = yo;
this->zo = zo;
}
-void Tesselator_SPU::addOffset(float x, float y, float z)
-{
+void Tesselator_SPU::addOffset(float x, float y, float z) {
xo += x;
yo += y;
zo += z;
}
-void Tesselator_SPU::incData( int numInts )
-{
- p+=numInts;
+void Tesselator_SPU::incData(int numInts) {
+ p += numInts;
#ifdef SN_TARGET_PS3_SPU
- if(p > 4096)
- {
- int dmaSize = p*4;
- unsigned int dmaTag = 2;
- void* src = _array->data;
- uintptr_t dest = (uintptr_t)(((char*)m_PPUArray) + m_PPUOffset);
- if(sc_verbose)
- spu_print("Tesselator : DMA SPU->PPU : 0x%08x -> 0x%08x : size : %d bytes\n", (unsigned int)src, (unsigned int)dest, dmaSize);
- cellDmaLargePut(src, dest, dmaSize, dmaTag, 0, 0);
- cellDmaWaitTagStatusAll(1 << dmaTag);
+ if (p > 4096) {
+ int dmaSize = p * 4;
+ unsigned int dmaTag = 2;
+ void* src = _array->data;
+ uintptr_t dest = (uintptr_t)(((char*)m_PPUArray) + m_PPUOffset);
+ if (sc_verbose)
+ spu_print(
+ "Tesselator : DMA SPU->PPU : 0x%08x -> 0x%08x : size : %d "
+ "bytes\n",
+ (unsigned int)src, (unsigned int)dest, dmaSize);
+ cellDmaLargePut(src, dest, dmaSize, dmaTag, 0, 0);
+ cellDmaWaitTagStatusAll(1 << dmaTag);
-// int copySize = (p-4096);
-// for(int i=0;idata[i] = _array->data[4096+i];
- //p -= 4096;
- p=0;
- m_PPUOffset += dmaSize;//16384;
- }
-#endif // SN_TARGET_PS3_SPU
+ // int copySize = (p-4096);
+ // for(int i=0;idata[i] = _array->data[4096+i];
+ // p -= 4096;
+ p = 0;
+ m_PPUOffset += dmaSize; // 16384;
+ }
+#endif // SN_TARGET_PS3_SPU
}
-void Tesselator_SPU::endData()
-{
+void Tesselator_SPU::endData() {
#ifdef SN_TARGET_PS3_SPU
- int dmaSize = p*4;
- unsigned int dmaTag = 2;
- void* src = _array->data;
- uintptr_t dest = (uintptr_t)(((char*)m_PPUArray) + m_PPUOffset);
- if(sc_verbose)
- spu_print("Tesselator : DMA SPU->PPU : 0x%08x -> 0x%08x : size : %d bytes\n", (unsigned int)src, (unsigned int)dest, dmaSize);
- cellDmaLargePut(src, dest, dmaSize, dmaTag, 0, 0);
- cellDmaWaitTagStatusAll(1 << dmaTag);
- if(sc_verbose)
- spu_print("endData - Tesselator : DMA SPU->PPU complete : %d verts, %d bytes in total\n", vertices, m_PPUOffset+ dmaSize);
- p=0;
- m_PPUOffset += dmaSize;
-#else // SN_TARGET_PS3_SPU
- m_PPUOffset = p*4;
+ int dmaSize = p * 4;
+ unsigned int dmaTag = 2;
+ void* src = _array->data;
+ uintptr_t dest = (uintptr_t)(((char*)m_PPUArray) + m_PPUOffset);
+ if (sc_verbose)
+ spu_print(
+ "Tesselator : DMA SPU->PPU : 0x%08x -> 0x%08x : size : %d bytes\n",
+ (unsigned int)src, (unsigned int)dest, dmaSize);
+ cellDmaLargePut(src, dest, dmaSize, dmaTag, 0, 0);
+ cellDmaWaitTagStatusAll(1 << dmaTag);
+ if (sc_verbose)
+ spu_print(
+ "endData - Tesselator : DMA SPU->PPU complete : %d verts, %d bytes "
+ "in total\n",
+ vertices, m_PPUOffset + dmaSize);
+ p = 0;
+ m_PPUOffset += dmaSize;
+#else // SN_TARGET_PS3_SPU
+ m_PPUOffset = p * 4;
#endif
}
-void Tesselator_SPU::beginData()
-{
- p = 0;
-}
+void Tesselator_SPU::beginData() { p = 0; }
diff --git a/Minecraft.Client/Platform/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.cpp b/Minecraft.Client/Platform/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.cpp
index d7d5af1cd..efe51f37a 100644
--- a/Minecraft.Client/Platform/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.cpp
+++ b/Minecraft.Client/Platform/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.cpp
@@ -26,7 +26,7 @@
#ifdef SN_TARGET_PS3_SPU
#include "../Common/spu_assert.h"
-#endif
+#endif
static const float MATH_PI = 3.141592654f;
@@ -35,7 +35,8 @@ static const float MATH_PI = 3.141592654f;
// #include "../../../../Textures/Textures.h"
// #include "../../../../../Minecraft.World/Headers/net.minecraft.world.level.h"
// #include "../../../Minecraft.World/net.minecraft.world.level.tile.h"
-// #include "../../../../../Minecraft.World/Headers/net.minecraft.world.level.material.h"
+// #include
+// "../../../../../Minecraft.World/Headers/net.minecraft.world.level.material.h"
// #include "../../../../../Minecraft.World/Headers/net.minecraft.h"
// #include "../../../../../Minecraft.World/Headers/net.minecraft.world.h"
// #include "../../../Minecraft.World/net.minecraft.world.level.tile.h"
@@ -44,7 +45,7 @@ static const float MATH_PI = 3.141592654f;
#ifdef SN_TARGET_PS3_SPU
#include "Stubs_SPU.h"
-#endif // SN_TARGET_PS3_SPU
+#endif // SN_TARGET_PS3_SPU
// #include "../../../../../Minecraft.World/Util/SharedConstants.h"
#include "Facing_SPU.h"
@@ -54,629 +55,589 @@ static const float MATH_PI = 3.141592654f;
// #define DISABLE_TESS_FUNCS
#ifdef SN_TARGET_PS3_SPU
-class SharedConstants
-{
+class SharedConstants {
public:
- static const bool TEXTURE_LIGHTING = true;
- static const int WORLD_RESOLUTION = 16;
+ static const bool TEXTURE_LIGHTING = true;
+ static const int WORLD_RESOLUTION = 16;
};
#endif
// #define SN_TARGET_PS3_SPU
bool TileRenderer_SPU::fancy = true;
-bool g_ambientOcclusionMax = false; // minecraft->options->ambientOcclusion >= Options::AO_MAX
-const float smallUV = ( 1.0f / 16.0f );
+bool g_ambientOcclusionMax =
+ false; // minecraft->options->ambientOcclusion >= Options::AO_MAX
+const float smallUV = (1.0f / 16.0f);
+void TileRenderer_SPU::_init() {
+ fixedTexture = NULL;
+ xFlipTexture = false;
+ noCulling = false;
+ blsmooth = 1;
+ applyAmbienceOcclusion = false;
+ setColor = true;
+ northFlip = FLIP_NONE;
+ southFlip = FLIP_NONE;
+ eastFlip = FLIP_NONE;
+ westFlip = FLIP_NONE;
+ upFlip = FLIP_NONE;
+ downFlip = FLIP_NONE;
-void TileRenderer_SPU::_init()
-{
- fixedTexture = NULL;
- xFlipTexture = false;
- noCulling = false;
- blsmooth = 1;
- applyAmbienceOcclusion = false;
- setColor = true;
- northFlip = FLIP_NONE;
- southFlip = FLIP_NONE;
- eastFlip = FLIP_NONE;
- westFlip = FLIP_NONE;
- upFlip = FLIP_NONE;
- downFlip = FLIP_NONE;
-
- tileShapeX0 = 0.0;
- tileShapeX1 = 0.0;
- tileShapeY0 = 0.0;
- tileShapeY1 = 0.0;
- tileShapeZ0 = 0.0;
- tileShapeZ1 = 0.0;
- fixedShape = false;
- smoothShapeLighting = false;
-// minecraft = Minecraft::GetInstance();
+ tileShapeX0 = 0.0;
+ tileShapeX1 = 0.0;
+ tileShapeY0 = 0.0;
+ tileShapeY1 = 0.0;
+ tileShapeZ0 = 0.0;
+ tileShapeZ1 = 0.0;
+ fixedShape = false;
+ smoothShapeLighting = false;
+ // minecraft = Minecraft::GetInstance();
}
-TileRenderer_SPU::TileRenderer_SPU( ChunkRebuildData* level )
-{
- this->level = level;
- _init();
+TileRenderer_SPU::TileRenderer_SPU(ChunkRebuildData* level) {
+ this->level = level;
+ _init();
}
-TileRenderer_SPU::TileRenderer_SPU()
-{
- this->level = NULL;
- _init();
+TileRenderer_SPU::TileRenderer_SPU() {
+ this->level = NULL;
+ _init();
}
-Tesselator_SPU* TileRenderer_SPU::getTesselator()
-{
- Tesselator_SPU* t = &level->m_tesselator;
- return t;
+Tesselator_SPU* TileRenderer_SPU::getTesselator() {
+ Tesselator_SPU* t = &level->m_tesselator;
+ return t;
}
-
-
-void TileRenderer_SPU::setFixedTexture( Icon_SPU *fixedTexture )
-{
- this->fixedTexture = fixedTexture;
+void TileRenderer_SPU::setFixedTexture(Icon_SPU* fixedTexture) {
+ this->fixedTexture = fixedTexture;
}
-void TileRenderer_SPU::clearFixedTexture()
-{
- this->fixedTexture = NULL;
+void TileRenderer_SPU::clearFixedTexture() { this->fixedTexture = NULL; }
+
+bool TileRenderer_SPU::hasFixedTexture() { return fixedTexture != NULL; }
+
+void TileRenderer_SPU::setShape(float x0, float y0, float z0, float x1,
+ float y1, float z1) {
+ if (!fixedShape) {
+ tileShapeX0 = x0;
+ tileShapeX1 = x1;
+ tileShapeY0 = y0;
+ tileShapeY1 = y1;
+ tileShapeZ0 = z0;
+ tileShapeZ1 = z1;
+ smoothShapeLighting =
+ (tileShapeX0 > 0 || tileShapeX1 < 1 || tileShapeY0 > 0 ||
+ tileShapeY1 < 1 || tileShapeZ0 > 0 || tileShapeZ1 < 1);
+ }
}
-bool TileRenderer_SPU::hasFixedTexture()
-{
- return fixedTexture != NULL;
+void TileRenderer_SPU::setShape(Tile_SPU* tt) {
+ if (!fixedShape) {
+ tileShapeX0 = tt->getShapeX0();
+ tileShapeX1 = tt->getShapeX1();
+ tileShapeY0 = tt->getShapeY0();
+ tileShapeY1 = tt->getShapeY1();
+ tileShapeZ0 = tt->getShapeZ0();
+ tileShapeZ1 = tt->getShapeZ1();
+ smoothShapeLighting =
+ (tileShapeX0 > 0 || tileShapeX1 < 1 || tileShapeY0 > 0 ||
+ tileShapeY1 < 1 || tileShapeZ0 > 0 || tileShapeZ1 < 1);
+ }
}
-void TileRenderer_SPU::setShape(float x0, float y0, float z0, float x1, float y1, float z1)
-{
- if (!fixedShape)
- {
- tileShapeX0 = x0;
- tileShapeX1 = x1;
- tileShapeY0 = y0;
- tileShapeY1 = y1;
- tileShapeZ0 = z0;
- tileShapeZ1 = z1;
- smoothShapeLighting = (tileShapeX0 > 0 || tileShapeX1 < 1 || tileShapeY0 > 0 || tileShapeY1 < 1 || tileShapeZ0 > 0 || tileShapeZ1 < 1);
- }
+void TileRenderer_SPU::setFixedShape(float x0, float y0, float z0, float x1,
+ float y1, float z1) {
+ tileShapeX0 = x0;
+ tileShapeX1 = x1;
+ tileShapeY0 = y0;
+ tileShapeY1 = y1;
+ tileShapeZ0 = z0;
+ tileShapeZ1 = z1;
+ fixedShape = true;
+
+ smoothShapeLighting =
+ (tileShapeX0 > 0 || tileShapeX1 < 1 || tileShapeY0 > 0 ||
+ tileShapeY1 < 1 || tileShapeZ0 > 0 || tileShapeZ1 < 1);
}
-void TileRenderer_SPU::setShape(Tile_SPU *tt)
+void TileRenderer_SPU::clearFixedShape() { fixedShape = false; }
+
+void TileRenderer_SPU::tesselateInWorldFixedTexture(
+ Tile_SPU* tile, int x, int y, int z,
+ Icon_SPU*
+ fixedTexture) // 4J renamed to differentiate from tesselateInWorld
{
- if (!fixedShape)
- {
- tileShapeX0 = tt->getShapeX0();
- tileShapeX1 = tt->getShapeX1();
- tileShapeY0 = tt->getShapeY0();
- tileShapeY1 = tt->getShapeY1();
- tileShapeZ0 = tt->getShapeZ0();
- tileShapeZ1 = tt->getShapeZ1();
- smoothShapeLighting = (tileShapeX0 > 0 || tileShapeX1 < 1 || tileShapeY0 > 0 || tileShapeY1 < 1 || tileShapeZ0 > 0 || tileShapeZ1 < 1);
- }
+ this->setFixedTexture(fixedTexture);
+ tesselateInWorld(tile, x, y, z);
+ this->clearFixedTexture();
}
-void TileRenderer_SPU::setFixedShape(float x0, float y0, float z0, float x1, float y1, float z1)
+void TileRenderer_SPU::tesselateInWorldNoCulling(
+ Tile_SPU* tile, int x, int y, int z, int forceData,
+ TileEntity* forceEntity) // 4J added forceData, forceEntity param
{
- tileShapeX0 = x0;
- tileShapeX1 = x1;
- tileShapeY0 = y0;
- tileShapeY1 = y1;
- tileShapeZ0 = z0;
- tileShapeZ1 = z1;
- fixedShape = true;
-
- smoothShapeLighting = (tileShapeX0 > 0 || tileShapeX1 < 1 || tileShapeY0 > 0 || tileShapeY1 < 1 || tileShapeZ0 > 0 || tileShapeZ1 < 1);
+ noCulling = true;
+ tesselateInWorld(tile, x, y, z, forceData);
+ noCulling = false;
}
-void TileRenderer_SPU::clearFixedShape()
-{
- fixedShape = false;
+bool TileRenderer_SPU::hasRenderer(Tile_SPU* tt) {
+ int shape = tt->getRenderShape();
+ bool retVal = false;
+ switch (shape) {
+ case Tile_SPU::SHAPE_BLOCK:
+ case Tile_SPU::SHAPE_WATER:
+ case Tile_SPU::SHAPE_CACTUS:
+ case Tile_SPU::SHAPE_STEM:
+ case Tile_SPU::SHAPE_LILYPAD:
+ case Tile_SPU::SHAPE_ROWS:
+ case Tile_SPU::SHAPE_TORCH:
+ case Tile_SPU::SHAPE_FIRE:
+ case Tile_SPU::SHAPE_LADDER:
+ case Tile_SPU::SHAPE_DOOR:
+ case Tile_SPU::SHAPE_RAIL:
+ case Tile_SPU::SHAPE_EGG:
+ case Tile_SPU::SHAPE_VINE:
+ case Tile_SPU::SHAPE_BREWING_STAND:
+ case Tile_SPU::SHAPE_CROSS_TEXTURE:
+ case Tile_SPU::SHAPE_FENCE:
+ retVal = true;
+ break;
+
+ case Tile_SPU::SHAPE_FENCE_GATE:
+ case Tile_SPU::SHAPE_RED_DUST:
+ case Tile_SPU::SHAPE_STAIRS:
+ case Tile_SPU::SHAPE_DIODE:
+ case Tile_SPU::SHAPE_LEVER:
+ case Tile_SPU::SHAPE_BED:
+ case Tile_SPU::SHAPE_PISTON_BASE:
+ case Tile_SPU::SHAPE_PISTON_EXTENSION:
+ case Tile_SPU::SHAPE_IRON_FENCE:
+ case Tile_SPU::SHAPE_CAULDRON:
+ case Tile_SPU::SHAPE_PORTAL_FRAME:
+ retVal = false;
+ break;
+ }
+
+ return retVal;
}
-void TileRenderer_SPU::tesselateInWorldFixedTexture( Tile_SPU* tile, int x, int y, int z, Icon_SPU *fixedTexture ) // 4J renamed to differentiate from tesselateInWorld
+bool TileRenderer_SPU::tesselateInWorld(
+ Tile_SPU* tt, int x, int y, int z, int forceData,
+ TileEntity* forceEntity) // 4J added forceData, forceEntity param
{
- this->setFixedTexture(fixedTexture);
- tesselateInWorld( tile, x, y, z );
- this->clearFixedTexture();
+ Tesselator_SPU* t = getTesselator();
+
+ int shape = tt->getRenderShape();
+ tt->updateShape(level, x, y, z, forceData, forceEntity);
+ setShape(tt);
+ t->setMipmapEnable(level->m_tileData.mipmapEnable[tt->id]); // 4J added
+
+ bool retVal = false;
+ switch (shape) {
+ case Tile_SPU::SHAPE_BLOCK:
+ retVal = tesselateBlockInWorld(tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_TREE:
+ retVal = tesselateTreeInWorld(tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_QUARTZ:
+ retVal = tesselateQuartzInWorld(tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_WATER:
+ retVal = tesselateWaterInWorld(tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_CACTUS:
+ retVal = tesselateCactusInWorld(tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_CROSS_TEXTURE:
+ retVal = tesselateCrossInWorld(tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_STEM:
+ retVal = tesselateStemInWorld(tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_LILYPAD:
+ retVal = tesselateLilypadInWorld((WaterlilyTile_SPU*)tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_ROWS:
+ retVal = tesselateRowInWorld(tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_TORCH:
+ retVal = tesselateTorchInWorld(tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_FIRE:
+ retVal = tesselateFireInWorld((FireTile_SPU*)tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_RED_DUST:
+ retVal = tesselateDustInWorld(tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_LADDER:
+ retVal = tesselateLadderInWorld(tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_DOOR:
+ retVal = tesselateDoorInWorld(tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_RAIL:
+ retVal = tesselateRailInWorld((RailTile_SPU*)tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_STAIRS:
+ retVal = tesselateStairsInWorld((StairTile_SPU*)tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_EGG:
+ retVal = tesselateEggInWorld((EggTile_SPU*)tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_FENCE:
+ retVal = tesselateFenceInWorld((FenceTile_SPU*)tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_WALL:
+ retVal = tesselateWallInWorld((WallTile_SPU*)tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_LEVER:
+ retVal = tesselateLeverInWorld(tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_TRIPWIRE_SOURCE:
+ retVal = tesselateTripwireSourceInWorld(tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_TRIPWIRE:
+ retVal = tesselateTripwireInWorld(tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_BED:
+ retVal = tesselateBedInWorld(tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_DIODE:
+ retVal = tesselateDiodeInWorld((DiodeTile_SPU*)tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_PISTON_BASE:
+ retVal = tesselatePistonBaseInWorld(tt, x, y, z, false, forceData);
+ break;
+ case Tile_SPU::SHAPE_PISTON_EXTENSION:
+ retVal =
+ tesselatePistonExtensionInWorld(tt, x, y, z, true, forceData);
+ break;
+ case Tile_SPU::SHAPE_IRON_FENCE:
+ retVal = tesselateThinFenceInWorld((ThinFenceTile*)tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_VINE:
+ retVal = tesselateVineInWorld(tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_FENCE_GATE:
+ retVal = tesselateFenceGateInWorld((FenceGateTile_SPU*)tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_CAULDRON:
+ retVal = tesselateCauldronInWorld((CauldronTile_SPU*)tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_FLOWER_POT:
+ retVal = tesselateFlowerPotInWorld((FlowerPotTile_SPU*)tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_ANVIL:
+ retVal = tesselateAnvilInWorld((AnvilTile_SPU*)tt, x, y, z);
+ break;
+ case Tile_SPU::SHAPE_BREWING_STAND:
+ retVal = tesselateBrewingStandInWorld((BrewingStandTile_SPU*)tt, x,
+ y, z);
+ break;
+ case Tile_SPU::SHAPE_PORTAL_FRAME:
+ retVal = tesselateAirPortalFrameInWorld((TheEndPortalFrameTile*)tt,
+ x, y, z);
+ break;
+ case Tile_SPU::SHAPE_COCOA:
+ retVal = tesselateCocoaInWorld((CocoaTile_SPU*)tt, x, y, z);
+ break;
+ };
+
+ t->setMipmapEnable(true); // 4J added
+ return retVal;
}
-void TileRenderer_SPU::tesselateInWorldNoCulling( Tile_SPU* tile, int x, int y, int z, int forceData,
- TileEntity* forceEntity ) // 4J added forceData, forceEntity param
-{
- noCulling = true;
- tesselateInWorld( tile, x, y, z, forceData );
- noCulling = false;
-}
-
-bool TileRenderer_SPU::hasRenderer(Tile_SPU* tt)
-{
- int shape = tt->getRenderShape();
- bool retVal = false;
- switch(shape)
- {
- case Tile_SPU::SHAPE_BLOCK:
- case Tile_SPU::SHAPE_WATER:
- case Tile_SPU::SHAPE_CACTUS:
- case Tile_SPU::SHAPE_STEM:
- case Tile_SPU::SHAPE_LILYPAD:
- case Tile_SPU::SHAPE_ROWS:
- case Tile_SPU::SHAPE_TORCH:
- case Tile_SPU::SHAPE_FIRE:
- case Tile_SPU::SHAPE_LADDER:
- case Tile_SPU::SHAPE_DOOR:
- case Tile_SPU::SHAPE_RAIL:
- case Tile_SPU::SHAPE_EGG:
- case Tile_SPU::SHAPE_VINE:
- case Tile_SPU::SHAPE_BREWING_STAND:
- case Tile_SPU::SHAPE_CROSS_TEXTURE:
- case Tile_SPU::SHAPE_FENCE:
- retVal = true;
- break;
-
- case Tile_SPU::SHAPE_FENCE_GATE:
- case Tile_SPU::SHAPE_RED_DUST:
- case Tile_SPU::SHAPE_STAIRS:
- case Tile_SPU::SHAPE_DIODE:
- case Tile_SPU::SHAPE_LEVER:
- case Tile_SPU::SHAPE_BED:
- case Tile_SPU::SHAPE_PISTON_BASE:
- case Tile_SPU::SHAPE_PISTON_EXTENSION:
- case Tile_SPU::SHAPE_IRON_FENCE:
- case Tile_SPU::SHAPE_CAULDRON:
- case Tile_SPU::SHAPE_PORTAL_FRAME:
- retVal = false;
- break;
- }
-
- return retVal;
-}
-
-
-bool TileRenderer_SPU::tesselateInWorld( Tile_SPU* tt, int x, int y, int z, int forceData,
- TileEntity* forceEntity ) // 4J added forceData, forceEntity param
-{
- Tesselator_SPU* t = getTesselator();
-
- int shape = tt->getRenderShape();
- tt->updateShape( level, x, y, z, forceData, forceEntity );
- setShape(tt);
- t->setMipmapEnable( level->m_tileData.mipmapEnable[tt->id] ); // 4J added
-
- bool retVal = false;
- switch(shape)
- {
- case Tile_SPU::SHAPE_BLOCK:
- retVal = tesselateBlockInWorld( tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_TREE:
- retVal = tesselateTreeInWorld(tt, x, y, z);
- break;
- case Tile_SPU::SHAPE_QUARTZ:
- retVal = tesselateQuartzInWorld(tt, x, y, z);
- break;
- case Tile_SPU::SHAPE_WATER:
- retVal = tesselateWaterInWorld( tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_CACTUS:
- retVal = tesselateCactusInWorld( tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_CROSS_TEXTURE:
- retVal = tesselateCrossInWorld( tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_STEM:
- retVal = tesselateStemInWorld( tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_LILYPAD:
- retVal = tesselateLilypadInWorld( (WaterlilyTile_SPU*)tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_ROWS:
- retVal = tesselateRowInWorld( tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_TORCH:
- retVal = tesselateTorchInWorld( tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_FIRE:
- retVal = tesselateFireInWorld( (FireTile_SPU *)tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_RED_DUST:
- retVal = tesselateDustInWorld( tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_LADDER:
- retVal = tesselateLadderInWorld( tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_DOOR:
- retVal = tesselateDoorInWorld( tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_RAIL:
- retVal = tesselateRailInWorld( ( RailTile_SPU* )tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_STAIRS:
- retVal = tesselateStairsInWorld( (StairTile_SPU *)tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_EGG:
- retVal = tesselateEggInWorld((EggTile_SPU*) tt, x, y, z);
- break;
- case Tile_SPU::SHAPE_FENCE:
- retVal = tesselateFenceInWorld( ( FenceTile_SPU* )tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_WALL:
- retVal = tesselateWallInWorld( (WallTile_SPU *) tt, x, y, z);
- break;
- case Tile_SPU::SHAPE_LEVER:
- retVal = tesselateLeverInWorld( tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_TRIPWIRE_SOURCE:
- retVal = tesselateTripwireSourceInWorld(tt, x, y, z);
- break;
- case Tile_SPU::SHAPE_TRIPWIRE:
- retVal = tesselateTripwireInWorld(tt, x, y, z);
- break;
- case Tile_SPU::SHAPE_BED:
- retVal = tesselateBedInWorld( tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_DIODE:
- retVal = tesselateDiodeInWorld( (DiodeTile_SPU *)tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_PISTON_BASE:
- retVal = tesselatePistonBaseInWorld( tt, x, y, z, false, forceData );
- break;
- case Tile_SPU::SHAPE_PISTON_EXTENSION:
- retVal = tesselatePistonExtensionInWorld( tt, x, y, z, true, forceData );
- break;
- case Tile_SPU::SHAPE_IRON_FENCE:
- retVal = tesselateThinFenceInWorld( ( ThinFenceTile* )tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_VINE:
- retVal = tesselateVineInWorld( tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_FENCE_GATE:
- retVal = tesselateFenceGateInWorld( ( FenceGateTile_SPU* )tt, x, y, z );
- break;
- case Tile_SPU::SHAPE_CAULDRON:
- retVal = tesselateCauldronInWorld((CauldronTile_SPU* ) tt, x, y, z);
- break;
- case Tile_SPU::SHAPE_FLOWER_POT:
- retVal = tesselateFlowerPotInWorld((FlowerPotTile_SPU *) tt, x, y, z);
- break;
- case Tile_SPU::SHAPE_ANVIL:
- retVal = tesselateAnvilInWorld((AnvilTile_SPU *) tt, x, y, z);
- break;
- case Tile_SPU::SHAPE_BREWING_STAND:
- retVal = tesselateBrewingStandInWorld((BrewingStandTile_SPU* ) tt, x, y, z);
- break;
- case Tile_SPU::SHAPE_PORTAL_FRAME:
- retVal = tesselateAirPortalFrameInWorld((TheEndPortalFrameTile *)tt, x, y, z);
- break;
- case Tile_SPU::SHAPE_COCOA:
- retVal = tesselateCocoaInWorld((CocoaTile_SPU *) tt, x, y, z);
- break;
-
- };
-
-
- t->setMipmapEnable( true ); // 4J added
- return retVal;
-
-}
-
-bool TileRenderer_SPU::tesselateAirPortalFrameInWorld(TheEndPortalFrameTile *tt, int x, int y, int z)
-{
+bool TileRenderer_SPU::tesselateAirPortalFrameInWorld(TheEndPortalFrameTile* tt,
+ int x, int y, int z) {
#ifdef DISABLE_TESS_FUNCS
int data = level->getData(x, y, z);
int direction = data & 3;
- if (direction == Direction::SOUTH)
- {
+ if (direction == Direction::SOUTH) {
upFlip = FLIP_180;
- }
- else if (direction == Direction::EAST)
- {
+ } else if (direction == Direction::EAST) {
upFlip = FLIP_CW;
- }
- else if (direction == Direction::WEST)
- {
+ } else if (direction == Direction::WEST) {
upFlip = FLIP_CCW;
}
- if (!TheEndPortalFrameTile::hasEye(data))
- {
-// EnterCriticalSection( &Tile_SPU::m_csShape );
+ if (!TheEndPortalFrameTile::hasEye(data)) {
+ // EnterCriticalSection( &Tile_SPU::m_csShape );
setShape(0, 0, 0, 1, 13.0f / 16.0f, 1);
tesselateBlockInWorld(tt, x, y, z);
-// LeaveCriticalSection( &Tile_SPU::m_csShape );
+ // LeaveCriticalSection( &Tile_SPU::m_csShape );
upFlip = FLIP_NONE;
return true;
}
-// EnterCriticalSection( &Tile_SPU::m_csShape );
- noCulling = true;
+ // EnterCriticalSection( &Tile_SPU::m_csShape );
+ noCulling = true;
setShape(0, 0, 0, 1, 13.0f / 16.0f, 1);
tesselateBlockInWorld(tt, x, y, z);
setFixedTexture(tt->getEye());
- setShape(4.0f / 16.0f, 13.0f / 16.0f, 4.0f / 16.0f, 12.0f / 16.0f, 1, 12.0f / 16.0f);
+ setShape(4.0f / 16.0f, 13.0f / 16.0f, 4.0f / 16.0f, 12.0f / 16.0f, 1,
+ 12.0f / 16.0f);
tesselateBlockInWorld(tt, x, y, z);
- noCulling = false;
+ noCulling = false;
clearFixedTexture();
-// LeaveCriticalSection( &Tile_SPU::m_csShape );
+ // LeaveCriticalSection( &Tile_SPU::m_csShape );
upFlip = FLIP_NONE;
-#endif // DISABLE_TESS_FUNCS
+#endif // DISABLE_TESS_FUNCS
return true;
}
-bool TileRenderer_SPU::tesselateBedInWorld( Tile_SPU* tt, int x, int y, int z )
-{
+bool TileRenderer_SPU::tesselateBedInWorld(Tile_SPU* tt, int x, int y, int z) {
#ifdef DISABLE_TESS_FUNCS
- Tesselator_SPU* t = getTesselator();
+ Tesselator_SPU* t = getTesselator();
- int data = level->getData( x, y, z );
- int direction = BedTile::getDirection( data );
- bool isHead = BedTile::isHeadPiece( data );
+ int data = level->getData(x, y, z);
+ int direction = BedTile::getDirection(data);
+ bool isHead = BedTile::isHeadPiece(data);
- float c10 = 0.5f;
- float c11 = 1.0f;
- float c2 = 0.8f;
- float c3 = 0.6f;
+ float c10 = 0.5f;
+ float c11 = 1.0f;
+ float c2 = 0.8f;
+ float c3 = 0.6f;
- float r11 = c11;
- float g11 = c11;
- float b11 = c11;
+ float r11 = c11;
+ float g11 = c11;
+ float b11 = c11;
- float r10 = c10;
- float r2 = c2;
- float r3 = c3;
+ float r10 = c10;
+ float r2 = c2;
+ float r3 = c3;
- float g10 = c10;
- float g2 = c2;
- float g3 = c3;
+ float g10 = c10;
+ float g2 = c2;
+ float g3 = c3;
- float b10 = c10;
- float b2 = c2;
- float b3 = c3;
+ float b10 = c10;
+ float b2 = c2;
+ float b3 = c3;
- // 4J - change brought forward from 1.8.2
- int centerColor;
- float centerBrightness;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- centerColor = tt->getLightColor( level, x, y, z );
- }
- else
- {
- centerBrightness = tt->getBrightness( level, x, y, z );
- }
+ // 4J - change brought forward from 1.8.2
+ int centerColor;
+ float centerBrightness;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ centerColor = tt->getLightColor(level, x, y, z);
+ } else {
+ centerBrightness = tt->getBrightness(level, x, y, z);
+ }
- // render wooden underside
- {
- // 4J - change brought forward from 1.8.2
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( centerColor );
- t->color( r10, g10, b10 );
- }
- else
- {
- t->color( r10 * centerBrightness, g10 * centerBrightness, b10 * centerBrightness );
- }
+ // render wooden underside
+ {
+ // 4J - change brought forward from 1.8.2
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(centerColor);
+ t->color(r10, g10, b10);
+ } else {
+ t->color(r10 * centerBrightness, g10 * centerBrightness,
+ b10 * centerBrightness);
+ }
- Icon_SPU *tex = getTexture( tt, level, x, y, z, Facing::DOWN );
+ Icon_SPU* tex = getTexture(tt, level, x, y, z, Facing::DOWN);
- float u0 = tex->getU0();
- float u1 = tex->getU1();
- float v0 = tex->getV0();
- float v1 = tex->getV1();
+ float u0 = tex->getU0();
+ float u1 = tex->getU1();
+ float v0 = tex->getV0();
+ float v1 = tex->getV1();
- float x0 = x + tileShapeX0;
- float x1 = x + tileShapeX1;
- float y0 = y + tileShapeY0 + 3.0 / 16.0;
- float z0 = z + tileShapeZ0;
- float z1 = z + tileShapeZ1;
+ float x0 = x + tileShapeX0;
+ float x1 = x + tileShapeX1;
+ float y0 = y + tileShapeY0 + 3.0 / 16.0;
+ float z0 = z + tileShapeZ0;
+ float z1 = z + tileShapeZ1;
- t->vertexUV( x0 , y0 , z1 , u0 , v1 );
- t->vertexUV( x0 , y0 , z0 , u0 , v0 );
- t->vertexUV( x1 , y0 , z0 , u1 , v0 );
- t->vertexUV( x1 , y0 , z1 , u1 , v1 );
- }
+ t->vertexUV(x0, y0, z1, u0, v1);
+ t->vertexUV(x0, y0, z0, u0, v0);
+ t->vertexUV(x1, y0, z0, u1, v0);
+ t->vertexUV(x1, y0, z1, u1, v1);
+ }
- // render bed top
- // 4J - change brought forward from 1.8.2
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tt->getLightColor( level, x, y + 1, z ) );
- t->color( r11, g11, b11 );
- }
- else
- {
- float brightness = tt->getBrightness( level, x, y + 1, z );
- t->color( r11 * brightness, g11 * brightness, b11 * brightness );
- }
+ // render bed top
+ // 4J - change brought forward from 1.8.2
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y + 1, z));
+ t->color(r11, g11, b11);
+ } else {
+ float brightness = tt->getBrightness(level, x, y + 1, z);
+ t->color(r11 * brightness, g11 * brightness, b11 * brightness);
+ }
- Icon_SPU *tex = getTexture( tt, level, x, y, z, Facing::UP );
+ Icon_SPU* tex = getTexture(tt, level, x, y, z, Facing::UP);
- float u0 = tex->getU0();
- float u1 = tex->getU1();
- float v0 = tex->getV0();
- float v1 = tex->getV1();
+ float u0 = tex->getU0();
+ float u1 = tex->getU1();
+ float v0 = tex->getV0();
+ float v1 = tex->getV1();
- float topLeftU = u0;
- float topRightU = u1;
- float topLeftV = v0;
- float topRightV = v0;
- float bottomLeftU = u0;
- float bottomRightU = u1;
- float bottomLeftV = v1;
- float bottomRightV = v1;
+ float topLeftU = u0;
+ float topRightU = u1;
+ float topLeftV = v0;
+ float topRightV = v0;
+ float bottomLeftU = u0;
+ float bottomRightU = u1;
+ float bottomLeftV = v1;
+ float bottomRightV = v1;
- if ( direction == Direction::SOUTH )
- {
- // rotate 90 degrees clockwise
- topRightU = u0;
- topLeftV = v1;
- bottomLeftU = u1;
- bottomRightV = v0;
- }
- else if ( direction == Direction::NORTH )
- {
- // rotate 90 degrees counter-clockwise
- topLeftU = u1;
- topRightV = v1;
- bottomRightU = u0;
- bottomLeftV = v0;
- }
- else if ( direction == Direction::EAST )
- {
- // rotate 180 degrees
- topLeftU = u1;
- topRightV = v1;
- bottomRightU = u0;
- bottomLeftV = v0;
- topRightU = u0;
- topLeftV = v1;
- bottomLeftU = u1;
- bottomRightV = v0;
- }
+ if (direction == Direction::SOUTH) {
+ // rotate 90 degrees clockwise
+ topRightU = u0;
+ topLeftV = v1;
+ bottomLeftU = u1;
+ bottomRightV = v0;
+ } else if (direction == Direction::NORTH) {
+ // rotate 90 degrees counter-clockwise
+ topLeftU = u1;
+ topRightV = v1;
+ bottomRightU = u0;
+ bottomLeftV = v0;
+ } else if (direction == Direction::EAST) {
+ // rotate 180 degrees
+ topLeftU = u1;
+ topRightV = v1;
+ bottomRightU = u0;
+ bottomLeftV = v0;
+ topRightU = u0;
+ topLeftV = v1;
+ bottomLeftU = u1;
+ bottomRightV = v0;
+ }
- float x0 = x + tileShapeX0;
- float x1 = x + tileShapeX1;
- float y1 = y + tileShapeY1;
- float z0 = z + tileShapeZ0;
- float z1 = z + tileShapeZ1;
+ float x0 = x + tileShapeX0;
+ float x1 = x + tileShapeX1;
+ float y1 = y + tileShapeY1;
+ float z0 = z + tileShapeZ0;
+ float z1 = z + tileShapeZ1;
- t->vertexUV( x1 , y1 , z1 , bottomLeftU ,bottomLeftV );
- t->vertexUV( x1 , y1 , z0 , topLeftU , topLeftV );
- t->vertexUV( x0 , y1 , z0 , topRightU ,topRightV );
- t->vertexUV( x0 , y1 , z1 , bottomRightU ,bottomRightV );
+ t->vertexUV(x1, y1, z1, bottomLeftU, bottomLeftV);
+ t->vertexUV(x1, y1, z0, topLeftU, topLeftV);
+ t->vertexUV(x0, y1, z0, topRightU, topRightV);
+ t->vertexUV(x0, y1, z1, bottomRightU, bottomRightV);
- // determine which edge to skip (the one between foot and head piece)
- int skipEdge = Direction::DIRECTION_FACING[direction];
- if ( isHead )
- {
- skipEdge = Direction::DIRECTION_FACING[Direction::DIRECTION_OPPOSITE[direction]];
- }
- // and which edge to x-flip
- int flipEdge = Facing::WEST;
- switch ( direction )
- {
- case Direction::NORTH:
- break;
- case Direction::SOUTH:
- flipEdge = Facing::EAST;
- break;
- case Direction::EAST:
- flipEdge = Facing::NORTH;
- break;
- case Direction::WEST:
- flipEdge = Facing::SOUTH;
- break;
- }
+ // determine which edge to skip (the one between foot and head piece)
+ int skipEdge = Direction::DIRECTION_FACING[direction];
+ if (isHead) {
+ skipEdge = Direction::DIRECTION_FACING
+ [Direction::DIRECTION_OPPOSITE[direction]];
+ }
+ // and which edge to x-flip
+ int flipEdge = Facing::WEST;
+ switch (direction) {
+ case Direction::NORTH:
+ break;
+ case Direction::SOUTH:
+ flipEdge = Facing::EAST;
+ break;
+ case Direction::EAST:
+ flipEdge = Facing::NORTH;
+ break;
+ case Direction::WEST:
+ flipEdge = Facing::SOUTH;
+ break;
+ }
- if ( ( skipEdge != Facing::NORTH ) && ( noCulling || tt->shouldRenderFace( level, x, y, z - 1, Facing::NORTH ) ) )
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeZ0 > 0 ? centerColor : tt->getLightColor( level, x, y, z - 1 ) );
- t->color( r2, g2, b2 );
- }
- else
- {
- float br = tt->getBrightness( level, x, y, z - 1 );
- if ( tileShapeZ0 > 0 ) br = centerBrightness;
- t->color( r2 * br, g2 * br, b2 * br );
- }
- xFlipTexture = flipEdge == Facing::NORTH;
- renderNorth( tt, x, y, z, getTexture( tt, level, x, y, z, 2 ) );
- }
+ if ((skipEdge != Facing::NORTH) &&
+ (noCulling ||
+ tt->shouldRenderFace(level, x, y, z - 1, Facing::NORTH))) {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeZ0 > 0 ? centerColor
+ : tt->getLightColor(level, x, y, z - 1));
+ t->color(r2, g2, b2);
+ } else {
+ float br = tt->getBrightness(level, x, y, z - 1);
+ if (tileShapeZ0 > 0) br = centerBrightness;
+ t->color(r2 * br, g2 * br, b2 * br);
+ }
+ xFlipTexture = flipEdge == Facing::NORTH;
+ renderNorth(tt, x, y, z, getTexture(tt, level, x, y, z, 2));
+ }
- if ( ( skipEdge != Facing::SOUTH ) && ( noCulling || tt->shouldRenderFace( level, x, y, z + 1, Facing::SOUTH ) ) )
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeZ1 < 1 ? centerColor : tt->getLightColor( level, x, y, z + 1 ) );
- t->color( r2, g2, b2 );
- }
- else
- {
- float br = tt->getBrightness( level, x, y, z + 1 );
- if ( tileShapeZ1 < 1 ) br = centerBrightness;
- t->color( r2 * br, g2 * br, b2 * br );
- }
+ if ((skipEdge != Facing::SOUTH) &&
+ (noCulling ||
+ tt->shouldRenderFace(level, x, y, z + 1, Facing::SOUTH))) {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeZ1 < 1 ? centerColor
+ : tt->getLightColor(level, x, y, z + 1));
+ t->color(r2, g2, b2);
+ } else {
+ float br = tt->getBrightness(level, x, y, z + 1);
+ if (tileShapeZ1 < 1) br = centerBrightness;
+ t->color(r2 * br, g2 * br, b2 * br);
+ }
- xFlipTexture = flipEdge == Facing::SOUTH;
- renderSouth( tt, x, y, z, getTexture( tt, level, x, y, z, 3 ) );
- }
+ xFlipTexture = flipEdge == Facing::SOUTH;
+ renderSouth(tt, x, y, z, getTexture(tt, level, x, y, z, 3));
+ }
- if ( ( skipEdge != Facing::WEST ) && ( noCulling || tt->shouldRenderFace( level, x - 1, y, z, Facing::WEST ) ) )
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeZ0 > 0 ? centerColor : tt->getLightColor( level, x - 1, y, z ) );
- t->color( r3, g3, b3 );
- }
- else
- {
- float br = tt->getBrightness( level, x - 1, y, z );
- if ( tileShapeX0 > 0 ) br = centerBrightness;
- t->color( r3 * br, g3 * br, b3 * br );
- }
- xFlipTexture = flipEdge == Facing::WEST;
- renderWest( tt, x, y, z, getTexture( tt, level, x, y, z, 4 ) );
- }
+ if ((skipEdge != Facing::WEST) &&
+ (noCulling || tt->shouldRenderFace(level, x - 1, y, z, Facing::WEST))) {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeZ0 > 0 ? centerColor
+ : tt->getLightColor(level, x - 1, y, z));
+ t->color(r3, g3, b3);
+ } else {
+ float br = tt->getBrightness(level, x - 1, y, z);
+ if (tileShapeX0 > 0) br = centerBrightness;
+ t->color(r3 * br, g3 * br, b3 * br);
+ }
+ xFlipTexture = flipEdge == Facing::WEST;
+ renderWest(tt, x, y, z, getTexture(tt, level, x, y, z, 4));
+ }
- if ( ( skipEdge != Facing::EAST ) && ( noCulling || tt->shouldRenderFace( level, x + 1, y, z, Facing::EAST ) ) )
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeZ1 < 1 ? centerColor : tt->getLightColor( level, x + 1, y, z ) );
- t->color( r3, g3, b3 );
- }
- else
- {
- float br = tt->getBrightness( level, x + 1, y, z );
- if ( tileShapeX1 < 1 ) br = centerBrightness;
- t->color( r3 * br, g3 * br, b3 * br );
- }
- xFlipTexture = flipEdge == Facing::EAST;
- renderEast( tt, x, y, z, getTexture( tt, level, x, y, z, 5 ) );
- }
- xFlipTexture = false;
-#endif // DISABLE_TESS_FUNCS
-
- return true;
+ if ((skipEdge != Facing::EAST) &&
+ (noCulling || tt->shouldRenderFace(level, x + 1, y, z, Facing::EAST))) {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeZ1 < 1 ? centerColor
+ : tt->getLightColor(level, x + 1, y, z));
+ t->color(r3, g3, b3);
+ } else {
+ float br = tt->getBrightness(level, x + 1, y, z);
+ if (tileShapeX1 < 1) br = centerBrightness;
+ t->color(r3 * br, g3 * br, b3 * br);
+ }
+ xFlipTexture = flipEdge == Facing::EAST;
+ renderEast(tt, x, y, z, getTexture(tt, level, x, y, z, 5));
+ }
+ xFlipTexture = false;
+#endif // DISABLE_TESS_FUNCS
+ return true;
}
-bool TileRenderer_SPU::tesselateBrewingStandInWorld(BrewingStandTile_SPU *tt, int x, int y, int z)
-{
-
-// EnterCriticalSection( &Tile_SPU::m_csShape );
+bool TileRenderer_SPU::tesselateBrewingStandInWorld(BrewingStandTile_SPU* tt,
+ int x, int y, int z) {
+ // EnterCriticalSection( &Tile_SPU::m_csShape );
// bounding box first
- setShape(7.0f / 16.0f, 0.0f, 7.0f / 16.0f, 9.0f / 16.0f, 14.0f / 16.0f, 9.0f / 16.0f);
+ setShape(7.0f / 16.0f, 0.0f, 7.0f / 16.0f, 9.0f / 16.0f, 14.0f / 16.0f,
+ 9.0f / 16.0f);
tesselateBlockInWorld(tt, x, y, z);
setFixedTexture(tt->getBaseTexture());
- setShape(9.0f / 16.0f, 0.0f, 5.0f / 16.0f, 15.0f / 16.0f, 2 / 16.0f, 11.0f / 16.0f);
+ setShape(9.0f / 16.0f, 0.0f, 5.0f / 16.0f, 15.0f / 16.0f, 2 / 16.0f,
+ 11.0f / 16.0f);
tesselateBlockInWorld(tt, x, y, z);
- setShape(2.0f / 16.0f, 0.0f, 1.0f / 16.0f, 8.0f / 16.0f, 2 / 16.0f, 7.0f / 16.0f);
+ setShape(2.0f / 16.0f, 0.0f, 1.0f / 16.0f, 8.0f / 16.0f, 2 / 16.0f,
+ 7.0f / 16.0f);
tesselateBlockInWorld(tt, x, y, z);
- setShape(2.0f / 16.0f, 0.0f, 9.0f / 16.0f, 8.0f / 16.0f, 2 / 16.0f, 15.0f / 16.0f);
+ setShape(2.0f / 16.0f, 0.0f, 9.0f / 16.0f, 8.0f / 16.0f, 2 / 16.0f,
+ 15.0f / 16.0f);
tesselateBlockInWorld(tt, x, y, z);
clearFixedTexture();
- Tesselator_SPU* t = getTesselator();
+ Tesselator_SPU* t = getTesselator();
float br;
- if (SharedConstants::TEXTURE_LIGHTING)
- {
+ if (SharedConstants::TEXTURE_LIGHTING) {
t->tex2(tt->getLightColor(level, x, y, z));
br = 1;
- }
- else
- {
+ } else {
br = tt->getBrightness(level, x, y, z);
}
int col = tt->getColor(level, x, y, z);
@@ -686,31 +647,29 @@ bool TileRenderer_SPU::tesselateBrewingStandInWorld(BrewingStandTile_SPU *tt, in
t->color(br * r, br * g, br * b);
- Icon_SPU *tex = getTexture(tt, 0, 0);
+ Icon_SPU* tex = getTexture(tt, 0, 0);
- if (hasFixedTexture()) tex = fixedTexture;
- float v0 = tex->getV0();
- float v1 = tex->getV1();
+ if (hasFixedTexture()) tex = fixedTexture;
+ float v0 = tex->getV0();
+ float v1 = tex->getV1();
int data = level->getData(x, y, z);
- for (int arm = 0; arm < 3; arm++)
- {
-
+ for (int arm = 0; arm < 3; arm++) {
float angle = arm * MATH_PI * 2.0f / 3.0f + MATH_PI * 0.5f;
- float u0 = tex->getU(8);
- float u1 = tex->getU1();
-// if (brewEntity != null && brewEntity.getItem(arm) != null) {
- if ((data & (1 << arm)) != 0)
- {
+ float u0 = tex->getU(8);
+ float u1 = tex->getU1();
+ // if (brewEntity != null && brewEntity.getItem(arm) != null)
+ // {
+ if ((data & (1 << arm)) != 0) {
u1 = tex->getU0();
}
- float x0 = x + 8.0f / 16.0f;
- float x1 = x + 8.0f / 16.0f + sin(angle) * 8.0f / 16.0f;
- float z0 = z + 8.0f / 16.0f;
- float z1 = z + 8.0f / 16.0f + cos(angle) * 8.0f / 16.0f;
+ float x0 = x + 8.0f / 16.0f;
+ float x1 = x + 8.0f / 16.0f + sin(angle) * 8.0f / 16.0f;
+ float z0 = z + 8.0f / 16.0f;
+ float z1 = z + 8.0f / 16.0f + cos(angle) * 8.0f / 16.0f;
t->vertexUV(x0, y + 1.0f, z0, u0, v0);
t->vertexUV(x0, y + 0.0f, z0, u0, v1);
@@ -725,27 +684,24 @@ bool TileRenderer_SPU::tesselateBrewingStandInWorld(BrewingStandTile_SPU *tt, in
tt->updateDefaultShape();
-// LeaveCriticalSection( &Tile_SPU::m_csShape );
+ // LeaveCriticalSection( &Tile_SPU::m_csShape );
return true;
}
-bool TileRenderer_SPU::tesselateCauldronInWorld(CauldronTile_SPU *tt, int x, int y, int z)
-{
+bool TileRenderer_SPU::tesselateCauldronInWorld(CauldronTile_SPU* tt, int x,
+ int y, int z) {
#ifdef DISABLE_TESS_FUNCS
// bounding box first
tesselateBlockInWorld(tt, x, y, z);
- Tesselator_SPU* t = getTesselator();
+ Tesselator_SPU* t = getTesselator();
float br;
- if (SharedConstants::TEXTURE_LIGHTING)
- {
+ if (SharedConstants::TEXTURE_LIGHTING) {
t->tex2(tt->getLightColor(level, x, y, z));
br = 1;
- }
- else
- {
+ } else {
br = tt->getBrightness(level, x, y, z);
}
int col = tt->getColor(level, x, y, z);
@@ -756,3058 +712,3045 @@ bool TileRenderer_SPU::tesselateCauldronInWorld(CauldronTile_SPU *tt, int x, int
t->color(br * r, br * g, br * b);
// render inside
- Icon_SPU *insideTex = tt->getTexture(Facing::NORTH);
- const float cWidth = ( 2.0f / 16.0f ) - ( 1.0f / 128.0f ); // 4J - Moved by 1/128th (smallest movement possible with our vertex storage) to remove gap at edge of cauldron
+ Icon_SPU* insideTex = tt->getTexture(Facing::NORTH);
+ const float cWidth =
+ (2.0f / 16.0f) -
+ (1.0f /
+ 128.0f); // 4J - Moved by 1/128th (smallest movement possible with our
+ // vertex storage) to remove gap at edge of cauldron
renderEast(tt, x - 1.0f + cWidth, y, z, insideTex);
renderWest(tt, x + 1.0f - cWidth, y, z, insideTex);
renderSouth(tt, x, y, z - 1.0f + cWidth, insideTex);
renderNorth(tt, x, y, z + 1.0f - cWidth, insideTex);
- Icon_SPU *bottomTex = CauldronTile::getTexture(CauldronTile::TEXTURE_INSIDE);
+ Icon_SPU* bottomTex =
+ CauldronTile::getTexture(CauldronTile::TEXTURE_INSIDE);
renderFaceUp(tt, x, y - 1.0f + 4.0f / 16.0f, z, bottomTex);
renderFaceDown(tt, x, y + 1.0f - 12.0f / 16.0f, z, bottomTex);
int waterLevel = level->getData(x, y, z);
- if (waterLevel > 0)
- {
- Icon_SPU *liquidTex = LiquidTile_SPU::getTexture(LiquidTile_SPU::TEXTURE_WATER_STILL);
+ if (waterLevel > 0) {
+ Icon_SPU* liquidTex =
+ LiquidTile_SPU::getTexture(LiquidTile_SPU::TEXTURE_WATER_STILL);
- if (waterLevel > 3)
- {
+ if (waterLevel > 3) {
waterLevel = 3;
}
- renderFaceUp(tt, x, y - 1.0f + (6.0f + waterLevel * 3.0f) / 16.0f, z, liquidTex);
+ renderFaceUp(tt, x, y - 1.0f + (6.0f + waterLevel * 3.0f) / 16.0f, z,
+ liquidTex);
}
-#endif // DISABLE_TESS_FUNCS
+#endif // DISABLE_TESS_FUNCS
return true;
-
}
-bool TileRenderer_SPU::tesselateFlowerPotInWorld(FlowerPotTile_SPU *tt, int x, int y, int z)
-{
+bool TileRenderer_SPU::tesselateFlowerPotInWorld(FlowerPotTile_SPU* tt, int x,
+ int y, int z) {
#ifdef DISABLE_TESS_FUNCS
- // bounding box first
- tesselateBlockInWorld(tt, x, y, z);
+ // bounding box first
+ tesselateBlockInWorld(tt, x, y, z);
- Tesselator *t = Tesselator::getInstance();
+ Tesselator* t = Tesselator::getInstance();
- float br;
- if (SharedConstants::TEXTURE_LIGHTING)
- {
- t->tex2(tt->getLightColor(level, x, y, z));
- br = 1;
- }
- else
- {
- br = tt->getBrightness(level, x, y, z);
- }
- int col = tt->getColor(level, x, y, z);
- Icon *tex = getTexture(tt, 0);
- float r = ((col >> 16) & 0xff) / 255.0f;
- float g = ((col >> 8) & 0xff) / 255.0f;
- float b = ((col) & 0xff) / 255.0f;
+ float br;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ br = 1;
+ } else {
+ br = tt->getBrightness(level, x, y, z);
+ }
+ int col = tt->getColor(level, x, y, z);
+ Icon* tex = getTexture(tt, 0);
+ float r = ((col >> 16) & 0xff) / 255.0f;
+ float g = ((col >> 8) & 0xff) / 255.0f;
+ float b = ((col) & 0xff) / 255.0f;
- if (GameRenderer::anaglyph3d)
- {
- float cr = (r * 30 + g * 59 + b * 11) / 100;
- float cg = (r * 30 + g * 70) / (100);
- float cb = (r * 30 + b * 70) / (100);
+ if (GameRenderer::anaglyph3d) {
+ float cr = (r * 30 + g * 59 + b * 11) / 100;
+ float cg = (r * 30 + g * 70) / (100);
+ float cb = (r * 30 + b * 70) / (100);
- r = cr;
- g = cg;
- b = cb;
- }
- t->color(br * r, br * g, br * b);
+ r = cr;
+ g = cg;
+ b = cb;
+ }
+ t->color(br * r, br * g, br * b);
- // render inside
+ // render inside
- float halfWidth = (6.0f / 16.0f) / 2 - 0.001f;
- renderEast(tt, x - 0.5f + halfWidth, y, z, tex);
- renderWest(tt, x + 0.5f - halfWidth, y, z, tex);
- renderSouth(tt, x, y, z - 0.5f + halfWidth, tex);
- renderNorth(tt, x, y, z + 0.5f - halfWidth, tex);
+ float halfWidth = (6.0f / 16.0f) / 2 - 0.001f;
+ renderEast(tt, x - 0.5f + halfWidth, y, z, tex);
+ renderWest(tt, x + 0.5f - halfWidth, y, z, tex);
+ renderSouth(tt, x, y, z - 0.5f + halfWidth, tex);
+ renderNorth(tt, x, y, z + 0.5f - halfWidth, tex);
- renderFaceUp(tt, x, y - 0.5f + halfWidth + 3.0f / 16.0f, z, getTexture(Tile::dirt));
+ renderFaceUp(tt, x, y - 0.5f + halfWidth + 3.0f / 16.0f, z,
+ getTexture(Tile::dirt));
- int type = level->getData(x, y, z);
+ int type = level->getData(x, y, z);
- if (type != 0)
- {
- float xOff = 0;
- float yOff = 4;
- float zOff = 0;
- Tile *plant = NULL;
+ if (type != 0) {
+ float xOff = 0;
+ float yOff = 4;
+ float zOff = 0;
+ Tile* plant = NULL;
- switch (type)
- {
- case FlowerPotTile::TYPE_FLOWER_RED:
- plant = Tile::rose;
- break;
- case FlowerPotTile::TYPE_FLOWER_YELLOW:
- plant = Tile::flower;
- break;
- case FlowerPotTile::TYPE_MUSHROOM_BROWN:
- plant = Tile::mushroom1;
- break;
- case FlowerPotTile::TYPE_MUSHROOM_RED:
- plant = Tile::mushroom2;
- break;
- }
+ switch (type) {
+ case FlowerPotTile::TYPE_FLOWER_RED:
+ plant = Tile::rose;
+ break;
+ case FlowerPotTile::TYPE_FLOWER_YELLOW:
+ plant = Tile::flower;
+ break;
+ case FlowerPotTile::TYPE_MUSHROOM_BROWN:
+ plant = Tile::mushroom1;
+ break;
+ case FlowerPotTile::TYPE_MUSHROOM_RED:
+ plant = Tile::mushroom2;
+ break;
+ }
- t->addOffset(xOff / 16.0f, yOff / 16.0f, zOff / 16.0f);
+ t->addOffset(xOff / 16.0f, yOff / 16.0f, zOff / 16.0f);
- if (plant != NULL)
- {
- tesselateInWorld(plant, x, y, z);
- }
- else
- {
- if (type == FlowerPotTile::TYPE_CACTUS)
- {
+ if (plant != NULL) {
+ tesselateInWorld(plant, x, y, z);
+ } else {
+ if (type == FlowerPotTile::TYPE_CACTUS) {
+ // Force drawing of all faces else the cactus misses faces
+ // when a block is adjacent
+ noCulling = true;
- // Force drawing of all faces else the cactus misses faces
- // when a block is adjacent
- noCulling = true;
+ float halfSize = 0.25f / 2;
+ setShape(0.5f - halfSize, 0.0f, 0.5f - halfSize,
+ 0.5f + halfSize, 0.25f, 0.5f + halfSize);
+ tesselateBlockInWorld(Tile::cactus, x, y, z);
+ setShape(0.5f - halfSize, 0.25f, 0.5f - halfSize,
+ 0.5f + halfSize, 0.5f, 0.5f + halfSize);
+ tesselateBlockInWorld(Tile::cactus, x, y, z);
+ setShape(0.5f - halfSize, 0.5f, 0.5f - halfSize,
+ 0.5f + halfSize, 0.75f, 0.5f + halfSize);
+ tesselateBlockInWorld(Tile::cactus, x, y, z);
- float halfSize = 0.25f / 2;
- setShape(0.5f - halfSize, 0.0f, 0.5f - halfSize, 0.5f + halfSize, 0.25f, 0.5f + halfSize);
- tesselateBlockInWorld(Tile::cactus, x, y, z);
- setShape(0.5f - halfSize, 0.25f, 0.5f - halfSize, 0.5f + halfSize, 0.5f, 0.5f + halfSize);
- tesselateBlockInWorld(Tile::cactus, x, y, z);
- setShape(0.5f - halfSize, 0.5f, 0.5f - halfSize, 0.5f + halfSize, 0.75f, 0.5f + halfSize);
- tesselateBlockInWorld(Tile::cactus, x, y, z);
+ noCulling = false;
- noCulling = false;
+ setShape(0, 0, 0, 1, 1, 1);
+ } else if (type == FlowerPotTile::TYPE_SAPLING_DEFAULT) {
+ tesselateCrossTexture(Tile::sapling, Sapling::TYPE_DEFAULT, x,
+ y, z, 0.75f);
+ } else if (type == FlowerPotTile::TYPE_SAPLING_BIRCH) {
+ tesselateCrossTexture(Tile::sapling, Sapling::TYPE_BIRCH, x, y,
+ z, 0.75f);
+ } else if (type == FlowerPotTile::TYPE_SAPLING_EVERGREEN) {
+ tesselateCrossTexture(Tile::sapling, Sapling::TYPE_EVERGREEN, x,
+ y, z, 0.75f);
+ } else if (type == FlowerPotTile::TYPE_SAPLING_JUNGLE) {
+ tesselateCrossTexture(Tile::sapling, Sapling::TYPE_JUNGLE, x, y,
+ z, 0.75f);
+ } else if (type == FlowerPotTile::TYPE_FERN) {
+ col = Tile::tallgrass->getColor(level, x, y, z);
+ r = ((col >> 16) & 0xff) / 255.0f;
+ g = ((col >> 8) & 0xff) / 255.0f;
+ b = ((col) & 0xff) / 255.0f;
+ t->color(br * r, br * g, br * b);
+ tesselateCrossTexture(Tile::tallgrass, TallGrass::FERN, x, y, z,
+ 0.75f);
+ } else if (type == FlowerPotTile::TYPE_DEAD_BUSH) {
+ tesselateCrossTexture(Tile::deadBush, TallGrass::FERN, x, y, z,
+ 0.75f);
+ }
+ }
- setShape(0, 0, 0, 1, 1, 1);
- }
- else if (type == FlowerPotTile::TYPE_SAPLING_DEFAULT)
- {
- tesselateCrossTexture(Tile::sapling, Sapling::TYPE_DEFAULT, x, y, z, 0.75f);
- }
- else if (type == FlowerPotTile::TYPE_SAPLING_BIRCH)
- {
- tesselateCrossTexture(Tile::sapling, Sapling::TYPE_BIRCH, x, y, z, 0.75f);
- }
- else if (type == FlowerPotTile::TYPE_SAPLING_EVERGREEN)
- {
- tesselateCrossTexture(Tile::sapling, Sapling::TYPE_EVERGREEN, x, y, z, 0.75f);
- }
- else if (type == FlowerPotTile::TYPE_SAPLING_JUNGLE)
- {
- tesselateCrossTexture(Tile::sapling, Sapling::TYPE_JUNGLE, x, y, z, 0.75f);
- }
- else if (type == FlowerPotTile::TYPE_FERN)
- {
- col = Tile::tallgrass->getColor(level, x, y, z);
- r = ((col >> 16) & 0xff) / 255.0f;
- g = ((col >> 8) & 0xff) / 255.0f;
- b = ((col) & 0xff) / 255.0f;
- t->color(br * r, br * g, br * b);
- tesselateCrossTexture(Tile::tallgrass, TallGrass::FERN, x, y, z, 0.75f);
- }
- else if (type == FlowerPotTile::TYPE_DEAD_BUSH)
- {
- tesselateCrossTexture(Tile::deadBush, TallGrass::FERN, x, y, z, 0.75f);
- }
- }
+ t->addOffset(-xOff / 16.0f, -yOff / 16.0f, -zOff / 16.0f);
+ }
+#endif // DISABLE_TESS_FUNCS
- t->addOffset(-xOff / 16.0f, -yOff / 16.0f, -zOff / 16.0f);
- }
-#endif //DISABLE_TESS_FUNCS
-
- return true;
+ return true;
}
-bool TileRenderer_SPU::tesselateAnvilInWorld(AnvilTile_SPU *tt, int x, int y, int z)
-{
- return tesselateAnvilInWorld(tt, x, y, z, level->getData(x, y, z));
-
+bool TileRenderer_SPU::tesselateAnvilInWorld(AnvilTile_SPU* tt, int x, int y,
+ int z) {
+ return tesselateAnvilInWorld(tt, x, y, z, level->getData(x, y, z));
}
-bool TileRenderer_SPU::tesselateAnvilInWorld(AnvilTile_SPU *tt, int x, int y, int z, int data)
-{
+bool TileRenderer_SPU::tesselateAnvilInWorld(AnvilTile_SPU* tt, int x, int y,
+ int z, int data) {
#ifdef DISABLE_TESS_FUNCS
- Tesselator *t = Tesselator::getInstance();
+ Tesselator* t = Tesselator::getInstance();
- float br;
- if (SharedConstants::TEXTURE_LIGHTING)
- {
- t->tex2(tt->getLightColor(level, x, y, z));
- br = 1;
- }
- else
- {
- br = tt->getBrightness(level, x, y, z);
- }
- int col = tt->getColor(level, x, y, z);
- float r = ((col >> 16) & 0xff) / 255.0f;
- float g = ((col >> 8) & 0xff) / 255.0f;
- float b = ((col) & 0xff) / 255.0f;
+ float br;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ br = 1;
+ } else {
+ br = tt->getBrightness(level, x, y, z);
+ }
+ int col = tt->getColor(level, x, y, z);
+ float r = ((col >> 16) & 0xff) / 255.0f;
+ float g = ((col >> 8) & 0xff) / 255.0f;
+ float b = ((col) & 0xff) / 255.0f;
- if (GameRenderer::anaglyph3d)
- {
- float cr = (r * 30 + g * 59 + b * 11) / 100;
- float cg = (r * 30 + g * 70) / (100);
- float cb = (r * 30 + b * 70) / (100);
+ if (GameRenderer::anaglyph3d) {
+ float cr = (r * 30 + g * 59 + b * 11) / 100;
+ float cg = (r * 30 + g * 70) / (100);
+ float cb = (r * 30 + b * 70) / (100);
- r = cr;
- g = cg;
- b = cb;
- }
- t->color(br * r, br * g, br * b);
-#endif // DISABLE_TESS_FUNCS
+ r = cr;
+ g = cg;
+ b = cb;
+ }
+ t->color(br * r, br * g, br * b);
+#endif // DISABLE_TESS_FUNCS
-
- return tesselateAnvilInWorld(tt, x, y, z, data, false);
+ return tesselateAnvilInWorld(tt, x, y, z, data, false);
}
-bool TileRenderer_SPU::tesselateAnvilInWorld(AnvilTile_SPU *tt, int x, int y, int z, int data, bool render)
-{
+bool TileRenderer_SPU::tesselateAnvilInWorld(AnvilTile_SPU* tt, int x, int y,
+ int z, int data, bool render) {
#ifdef DISABLE_TESS_FUNCS
- int facing = render ? 0 : data & 3;
- boolean rotate = false;
- float bottom = 0;
+ int facing = render ? 0 : data & 3;
+ boolean rotate = false;
+ float bottom = 0;
- switch (facing)
- {
- case Direction::NORTH:
- eastFlip = FLIP_CW;
- westFlip = FLIP_CCW;
- break;
- case Direction::SOUTH:
- eastFlip = FLIP_CCW;
- westFlip = FLIP_CW;
- upFlip = FLIP_180;
- downFlip = FLIP_180;
- break;
- case Direction::WEST:
- northFlip = FLIP_CW;
- southFlip = FLIP_CCW;
- upFlip = FLIP_CCW;
- downFlip = FLIP_CW;
- rotate = true;
- break;
- case Direction::EAST:
- northFlip = FLIP_CCW;
- southFlip = FLIP_CW;
- upFlip = FLIP_CW;
- downFlip = FLIP_CCW;
- rotate = true;
- break;
- }
+ switch (facing) {
+ case Direction::NORTH:
+ eastFlip = FLIP_CW;
+ westFlip = FLIP_CCW;
+ break;
+ case Direction::SOUTH:
+ eastFlip = FLIP_CCW;
+ westFlip = FLIP_CW;
+ upFlip = FLIP_180;
+ downFlip = FLIP_180;
+ break;
+ case Direction::WEST:
+ northFlip = FLIP_CW;
+ southFlip = FLIP_CCW;
+ upFlip = FLIP_CCW;
+ downFlip = FLIP_CW;
+ rotate = true;
+ break;
+ case Direction::EAST:
+ northFlip = FLIP_CCW;
+ southFlip = FLIP_CW;
+ upFlip = FLIP_CW;
+ downFlip = FLIP_CCW;
+ rotate = true;
+ break;
+ }
- bottom = tesselateAnvilPiece(tt, x, y, z, AnvilTile::PART_BASE, bottom, 12.0f / 16.0f, 4.0f / 16.0f, 12.0f / 16.0f, rotate, render, data);
- bottom = tesselateAnvilPiece(tt, x, y, z, AnvilTile::PART_JOINT, bottom, 8.0f / 16.0f, 1.0f / 16.0f, 10.0f / 16.0f, rotate, render, data);
- bottom = tesselateAnvilPiece(tt, x, y, z, AnvilTile::PART_COLUMN, bottom, 4.0f / 16.0f, 5.0f / 16.0f, 8.0f / 16.0f, rotate, render, data);
- bottom = tesselateAnvilPiece(tt, x, y, z, AnvilTile::PART_TOP, bottom, 10.0f / 16.0f, 6.0f / 16.0f, 16.0f / 16.0f, rotate, render, data);
+ bottom = tesselateAnvilPiece(tt, x, y, z, AnvilTile::PART_BASE, bottom,
+ 12.0f / 16.0f, 4.0f / 16.0f, 12.0f / 16.0f,
+ rotate, render, data);
+ bottom = tesselateAnvilPiece(tt, x, y, z, AnvilTile::PART_JOINT, bottom,
+ 8.0f / 16.0f, 1.0f / 16.0f, 10.0f / 16.0f,
+ rotate, render, data);
+ bottom = tesselateAnvilPiece(tt, x, y, z, AnvilTile::PART_COLUMN, bottom,
+ 4.0f / 16.0f, 5.0f / 16.0f, 8.0f / 16.0f,
+ rotate, render, data);
+ bottom = tesselateAnvilPiece(tt, x, y, z, AnvilTile::PART_TOP, bottom,
+ 10.0f / 16.0f, 6.0f / 16.0f, 16.0f / 16.0f,
+ rotate, render, data);
- setShape(0, 0, 0, 1, 1, 1);
- northFlip = FLIP_NONE;
- southFlip = FLIP_NONE;
- eastFlip = FLIP_NONE;
- westFlip = FLIP_NONE;
- upFlip = FLIP_NONE;
- downFlip = FLIP_NONE;
-#endif // DISABLE_TESS_FUNCS
+ setShape(0, 0, 0, 1, 1, 1);
+ northFlip = FLIP_NONE;
+ southFlip = FLIP_NONE;
+ eastFlip = FLIP_NONE;
+ westFlip = FLIP_NONE;
+ upFlip = FLIP_NONE;
+ downFlip = FLIP_NONE;
+#endif // DISABLE_TESS_FUNCS
- return true;
+ return true;
}
-float TileRenderer_SPU::tesselateAnvilPiece(AnvilTile_SPU *tt, int x, int y, int z, int part, float bottom, float width, float height, float length, bool rotate, bool render, int data)
+float TileRenderer_SPU::tesselateAnvilPiece(AnvilTile_SPU* tt, int x, int y,
+ int z, int part, float bottom,
+ float width, float height,
+ float length, bool rotate,
+ bool render, int data) {
+#ifdef DISABLE_TESS_FUNCS
+ if (rotate) {
+ float swap = width;
+ width = length;
+ length = swap;
+ }
+
+ width /= 2;
+ length /= 2;
+
+ ms_pTileData->anvilPart = part;
+ setShape(0.5f - width, bottom, 0.5f - length, 0.5f + width, bottom + height,
+ 0.5f + length);
+
+ if (render) {
+ Tesselator* t = Tesselator::getInstance();
+ t->begin();
+ t->normal(0, -1, 0);
+ renderFaceDown(tt, 0, 0, 0, getTexture(tt, 0, data));
+ t->end();
+
+ t->begin();
+ t->normal(0, 1, 0);
+ renderFaceUp(tt, 0, 0, 0, getTexture(tt, 1, data));
+ t->end();
+
+ t->begin();
+ t->normal(0, 0, -1);
+ renderNorth(tt, 0, 0, 0, getTexture(tt, 2, data));
+ t->end();
+
+ t->begin();
+ t->normal(0, 0, 1);
+ renderSouth(tt, 0, 0, 0, getTexture(tt, 3, data));
+ t->end();
+
+ t->begin();
+ t->normal(-1, 0, 0);
+ renderWest(tt, 0, 0, 0, getTexture(tt, 4, data));
+ t->end();
+
+ t->begin();
+ t->normal(1, 0, 0);
+ renderEast(tt, 0, 0, 0, getTexture(tt, 5, data));
+ t->end();
+ } else {
+ tesselateBlockInWorld(tt, x, y, z);
+ }
+#endif // DISABLE_TESS_FUNCS
+
+ return bottom + height;
+}
+
+bool TileRenderer_SPU::tesselateTorchInWorld(Tile_SPU* tt, int x, int y,
+ int z) {
+ int dir = level->getData(x, y, z);
+
+ Tesselator_SPU* t = getTesselator();
+
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ t->color(1.0f, 1.0f, 1.0f);
+ } else {
+ float br = tt->getBrightness(level, x, y, z);
+ if (level->m_tileData.lightEmission[tt->id] > 0) br = 1.0f;
+ t->color(br, br, br);
+ }
+
+ float r = 0.40f;
+ float r2 = 0.5f - r;
+ float h = 0.20f;
+ if (dir == 1) {
+ tesselateTorch(tt, (float)x - r2, (float)y + h, (float)z, -r, 0.0f, 0);
+ } else if (dir == 2) {
+ tesselateTorch(tt, (float)x + r2, (float)y + h, (float)z, +r, 0.0f, 0);
+ } else if (dir == 3) {
+ tesselateTorch(tt, (float)x, (float)y + h, z - r2, 0.0f, -r, 0);
+ } else if (dir == 4) {
+ tesselateTorch(tt, (float)x, (float)y + h, (float)z + r2, 0.0f, +r, 0);
+ } else {
+ tesselateTorch(tt, (float)x, (float)y, (float)z, 0.0f, 0.0f, 0);
+ }
+ return true;
+}
+
+bool TileRenderer_SPU::tesselateDiodeInWorld(DiodeTile_SPU* tt, int x, int y,
+ int z) {
+#ifdef DISABLE_TESS_FUNCS
+ Tesselator_SPU* t = getTesselator();
+
+ tesselateDiodeInWorld(
+ tt, x, y, z, level->getData(x, y, z) & DiodeTile_SPU::DIRECTION_MASK);
+ return true;
+#endif // #ifdef DISABLE_TESS_FUNCS
+ return false;
+}
+
+void TileRenderer_SPU::tesselateDiodeInWorld(DiodeTile_SPU* tt, int x, int y,
+ int z, int dir) {
+#ifdef DISABLE_TESS_FUNCS
+ // render half-block edges
+ tesselateBlockInWorld(tt, x, y, z);
+
+ Tesselator_SPU* t = getTesselator();
+
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ t->color(1.0f, 1.0f, 1.0f);
+ } else {
+ float br = tt->getBrightness(level, x, y, z);
+ if (level->m_tileData.lightEmission[tt->id] > 0) br = 1.0f;
+ t->color(br, br, br);
+ }
+
+ int data = level->getData(x, y, z);
+
+ // 4J Stu - This block gets moved in a later version, but we don't need that
+ // yet BEGIN TORCH SECTION
+ {
+ int dir = data & DiodeTile_SPU::DIRECTION_MASK;
+ int delay =
+ (data & DiodeTile_SPU::DELAY_MASK) >> DiodeTile_SPU::DELAY_SHIFT;
+ float h = -3.0f / 16.0f;
+ float transmitterX = 0.0f;
+ float transmitterZ = 0.0f;
+ float receiverX = 0.0f;
+ float receiverZ = 0.0f;
+
+ switch (dir) {
+ case Direction::SOUTH:
+ receiverZ = -5.0f / 16.0f;
+ transmitterZ = DiodeTile_SPU::DELAY_RENDER_OFFSETS[delay];
+ break;
+ case Direction::NORTH:
+ receiverZ = 5.0f / 16.0f;
+ transmitterZ = -DiodeTile_SPU::DELAY_RENDER_OFFSETS[delay];
+ break;
+ case Direction::EAST:
+ receiverX = -5.0f / 16.0f;
+ transmitterX = DiodeTile_SPU::DELAY_RENDER_OFFSETS[delay];
+ break;
+ case Direction::WEST:
+ receiverX = 5.0f / 16.0f;
+ transmitterX = -DiodeTile_SPU::DELAY_RENDER_OFFSETS[delay];
+ break;
+ }
+
+ // render transmitter
+ tesselateTorch(tt, x + transmitterX, y + h, z + transmitterZ, 0.0f,
+ 0.0f, 0);
+ // render receiver
+ tesselateTorch(tt, x + receiverX, y + h, z + receiverZ, 0.0f, 0.0f, 0);
+ }
+ // END TORCH SECTION
+
+ Icon_SPU* tex = getTexture(tt, Facing::UP, data);
+ float u0 = tex->getU0();
+ float u1 = tex->getU1();
+ float v0 = tex->getV0();
+ float v1 = tex->getV1();
+
+ float r = 2.0f / 16.0f;
+
+ float x0 = (float)(x + 1.0f);
+ float x1 = (float)(x + 1.0f);
+ float x2 = (float)(x + 0.0f);
+ float x3 = (float)(x + 0.0f);
+
+ float z0 = (float)(z + 0.0f);
+ float z1 = (float)(z + 1.0f);
+ float z2 = (float)(z + 1.0f);
+ float z3 = (float)(z + 0.0f);
+
+ float y0 = (float)(y + r);
+
+ if (dir == Direction::NORTH) {
+ // rotate 180 degrees
+ x0 = x1 = (float)(x + 0.0f);
+ x2 = x3 = (float)(x + 1.0f);
+ z0 = z3 = (float)(z + 1.0f);
+ z1 = z2 = (float)(z + 0.0f);
+ } else if (dir == Direction::EAST) {
+ // rotate 90 degrees counter-clockwise
+ x0 = x3 = (float)(x + 0.0f);
+ x1 = x2 = (float)(x + 1.0f);
+ z0 = z1 = (float)(z + 0.0f);
+ z2 = z3 = (float)(z + 1.0f);
+ } else if (dir == Direction::WEST) {
+ // rotate 90 degrees clockwise
+ x0 = x3 = (float)(x + 1.0f);
+ x1 = x2 = (float)(x + 0.0f);
+ z0 = z1 = (float)(z + 1.0f);
+ z2 = z3 = (float)(z + 0.0f);
+ }
+
+ t->vertexUV(x3, y0, z3, u0, v0);
+ t->vertexUV(x2, y0, z2, u0, v1);
+ t->vertexUV(x1, y0, z1, u1, v1);
+ t->vertexUV(x0, y0, z0, u1, v0);
+#endif // #ifdef DISABLE_TESS_FUNCS
+}
+
+void TileRenderer_SPU::tesselatePistonBaseForceExtended(
+ Tile_SPU* tile, int x, int y, int z,
+ int forceData) // 4J added forceData param
{
#ifdef DISABLE_TESS_FUNCS
- if (rotate)
- {
- float swap = width;
- width = length;
- length = swap;
- }
-
- width /= 2;
- length /= 2;
-
- ms_pTileData->anvilPart = part;
- setShape(0.5f - width, bottom, 0.5f - length, 0.5f + width, bottom + height, 0.5f + length);
-
- if (render)
- {
- Tesselator *t = Tesselator::getInstance();
- t->begin();
- t->normal(0, -1, 0);
- renderFaceDown(tt, 0, 0, 0, getTexture(tt, 0, data));
- t->end();
-
- t->begin();
- t->normal(0, 1, 0);
- renderFaceUp(tt, 0, 0, 0, getTexture(tt, 1, data));
- t->end();
-
- t->begin();
- t->normal(0, 0, -1);
- renderNorth(tt, 0, 0, 0, getTexture(tt, 2, data));
- t->end();
-
- t->begin();
- t->normal(0, 0, 1);
- renderSouth(tt, 0, 0, 0, getTexture(tt, 3, data));
- t->end();
-
- t->begin();
- t->normal(-1, 0, 0);
- renderWest(tt, 0, 0, 0, getTexture(tt, 4, data));
- t->end();
-
- t->begin();
- t->normal(1, 0, 0);
- renderEast(tt, 0, 0, 0, getTexture(tt, 5, data));
- t->end();
- }
- else
- {
- tesselateBlockInWorld(tt, x, y, z);
- }
-#endif // DISABLE_TESS_FUNCS
-
- return bottom + height;
+ noCulling = true;
+ tesselatePistonBaseInWorld(tile, x, y, z, true, forceData);
+ noCulling = false;
+#endif // DISABLE_TESS_FUNCS
}
-
-bool TileRenderer_SPU::tesselateTorchInWorld( Tile_SPU* tt, int x, int y, int z )
-{
- int dir = level->getData( x, y, z );
-
- Tesselator_SPU* t = getTesselator();
-
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tt->getLightColor( level, x, y, z ) );
- t->color( 1.0f, 1.0f, 1.0f );
- }
- else
- {
- float br = tt->getBrightness( level, x, y, z );
- if ( level->m_tileData.lightEmission[tt->id] > 0 ) br = 1.0f;
- t->color( br, br, br );
- }
-
- float r = 0.40f;
- float r2 = 0.5f - r;
- float h = 0.20f;
- if ( dir == 1 )
- {
- tesselateTorch( tt, (float)x - r2, (float)y + h, (float)z, -r, 0.0f, 0 );
- }
- else if ( dir == 2 )
- {
- tesselateTorch( tt, (float)x + r2, (float)y + h, (float)z, +r, 0.0f, 0 );
- }
- else if ( dir == 3 )
- {
- tesselateTorch( tt, (float)x, (float)y + h, z - r2, 0.0f, -r, 0 );
- }
- else if ( dir == 4 )
- {
- tesselateTorch( tt, (float)x, (float)y + h, (float)z + r2, 0.0f, +r, 0 );
- }
- else
- {
- tesselateTorch( tt, (float)x, (float)y, (float)z, 0.0f, 0.0f, 0 );
- }
- return true;
-
-}
-
-bool TileRenderer_SPU::tesselateDiodeInWorld(DiodeTile_SPU *tt, int x, int y, int z)
+bool TileRenderer_SPU::tesselatePistonBaseInWorld(
+ Tile_SPU* tt, int x, int y, int z, bool forceExtended,
+ int forceData) // 4J added forceData param
{
#ifdef DISABLE_TESS_FUNCS
- Tesselator_SPU* t = getTesselator();
+ int data = (forceData == -1) ? level->getData(x, y, z) : forceData;
+ bool extended = forceExtended || (data & PistonBaseTile::EXTENDED_BIT) != 0;
+ int facing = PistonBaseTile::getFacing(data);
- tesselateDiodeInWorld(tt, x, y, z, level->getData(x, y, z) & DiodeTile_SPU::DIRECTION_MASK);
- return true;
-#endif // #ifdef DISABLE_TESS_FUNCS
- return false;
-}
+ const float thickness = PistonBaseTile::PLATFORM_THICKNESS / 16.0f;
-void TileRenderer_SPU::tesselateDiodeInWorld( DiodeTile_SPU* tt, int x, int y, int z, int dir )
-{
-#ifdef DISABLE_TESS_FUNCS
- // render half-block edges
- tesselateBlockInWorld( tt, x, y, z );
-
- Tesselator_SPU* t = getTesselator();
-
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tt->getLightColor( level, x, y, z ) );
- t->color( 1.0f, 1.0f, 1.0f );
- }
- else
- {
- float br = tt->getBrightness( level, x, y, z );
- if ( level->m_tileData.lightEmission[tt->id] > 0 ) br = 1.0f;
- t->color( br, br, br );
- }
-
- int data = level->getData(x, y, z);
-
- // 4J Stu - This block gets moved in a later version, but we don't need that yet
- // BEGIN TORCH SECTION
- {
- int dir = data & DiodeTile_SPU::DIRECTION_MASK;
- int delay = ( data & DiodeTile_SPU::DELAY_MASK ) >> DiodeTile_SPU::DELAY_SHIFT;
- float h = -3.0f / 16.0f;
- float transmitterX = 0.0f;
- float transmitterZ = 0.0f;
- float receiverX = 0.0f;
- float receiverZ = 0.0f;
-
- switch ( dir )
- {
- case Direction::SOUTH:
- receiverZ = -5.0f / 16.0f;
- transmitterZ = DiodeTile_SPU::DELAY_RENDER_OFFSETS[delay];
- break;
- case Direction::NORTH:
- receiverZ = 5.0f / 16.0f;
- transmitterZ = -DiodeTile_SPU::DELAY_RENDER_OFFSETS[delay];
- break;
- case Direction::EAST:
- receiverX = -5.0f / 16.0f;
- transmitterX = DiodeTile_SPU::DELAY_RENDER_OFFSETS[delay];
- break;
- case Direction::WEST:
- receiverX = 5.0f / 16.0f;
- transmitterX = -DiodeTile_SPU::DELAY_RENDER_OFFSETS[delay];
- break;
- }
-
- // render transmitter
- tesselateTorch( tt, x + transmitterX, y + h, z + transmitterZ, 0.0f, 0.0f, 0 );
- // render receiver
- tesselateTorch( tt, x + receiverX, y + h, z + receiverZ, 0.0f, 0.0f, 0 );
- }
- // END TORCH SECTION
-
- Icon_SPU *tex = getTexture(tt, Facing::UP, data);
- float u0 = tex->getU0();
- float u1 = tex->getU1();
- float v0 = tex->getV0();
- float v1 = tex->getV1();
-
- float r = 2.0f / 16.0f;
-
- float x0 = ( float )( x + 1.0f );
- float x1 = ( float )( x + 1.0f );
- float x2 = ( float )( x + 0.0f );
- float x3 = ( float )( x + 0.0f );
-
- float z0 = ( float )( z + 0.0f );
- float z1 = ( float )( z + 1.0f );
- float z2 = ( float )( z + 1.0f );
- float z3 = ( float )( z + 0.0f );
-
- float y0 = ( float )( y + r );
-
- if ( dir == Direction::NORTH )
- {
- // rotate 180 degrees
- x0 = x1 = ( float )( x + 0.0f );
- x2 = x3 = ( float )( x + 1.0f );
- z0 = z3 = ( float )( z + 1.0f );
- z1 = z2 = ( float )( z + 0.0f );
- }
- else if ( dir == Direction::EAST )
- {
- // rotate 90 degrees counter-clockwise
- x0 = x3 = ( float )( x + 0.0f );
- x1 = x2 = ( float )( x + 1.0f );
- z0 = z1 = ( float )( z + 0.0f );
- z2 = z3 = ( float )( z + 1.0f );
- }
- else if ( dir == Direction::WEST )
- {
- // rotate 90 degrees clockwise
- x0 = x3 = ( float )( x + 1.0f );
- x1 = x2 = ( float )( x + 0.0f );
- z0 = z1 = ( float )( z + 1.0f );
- z2 = z3 = ( float )( z + 0.0f );
- }
-
- t->vertexUV( x3 , y0 , z3 , u0 , v0 );
- t->vertexUV( x2 , y0 , z2 , u0 , v1 );
- t->vertexUV( x1 , y0 , z1 , u1 , v1 );
- t->vertexUV( x0 , y0 , z0 , u1 , v0 );
-#endif // #ifdef DISABLE_TESS_FUNCS
-}
-
-void TileRenderer_SPU::tesselatePistonBaseForceExtended( Tile_SPU* tile, int x, int y, int z, int forceData ) // 4J added forceData param
-{
-#ifdef DISABLE_TESS_FUNCS
- noCulling = true;
- tesselatePistonBaseInWorld( tile, x, y, z, true, forceData );
- noCulling = false;
-#endif // DISABLE_TESS_FUNCS
-
-}
-
-bool TileRenderer_SPU::tesselatePistonBaseInWorld( Tile_SPU* tt, int x, int y, int z, bool forceExtended, int forceData ) // 4J added forceData param
-{
-#ifdef DISABLE_TESS_FUNCS
- int data = ( forceData == -1 ) ? level->getData( x, y, z ) : forceData;
- bool extended = forceExtended || ( data & PistonBaseTile::EXTENDED_BIT ) != 0;
- int facing = PistonBaseTile::getFacing( data );
-
- const float thickness = PistonBaseTile::PLATFORM_THICKNESS / 16.0f;
-
-// EnterCriticalSection( &Tile_SPU::m_csShape );
- if ( extended )
- {
- switch ( facing )
- {
- case Facing::DOWN:
- northFlip = FLIP_180;
- southFlip = FLIP_180;
- eastFlip = FLIP_180;
- westFlip = FLIP_180;
- setShape( 0.0f, thickness, 0.0f, 1.0f, 1.0f, 1.0f );
- break;
- case Facing::UP:
- setShape( 0.0f, 0.0f, 0.0f, 1.0f, 1.0f - thickness, 1.0f );
- break;
- case Facing::NORTH:
- eastFlip = FLIP_CW;
- westFlip = FLIP_CCW;
- setShape( 0.0f, 0.0f, thickness, 1.0f, 1.0f, 1.0f );
- break;
- case Facing::SOUTH:
- eastFlip = FLIP_CCW;
- westFlip = FLIP_CW;
- upFlip = FLIP_180;
- downFlip = FLIP_180;
- setShape( 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f - thickness );
- break;
- case Facing::WEST:
- northFlip = FLIP_CW;
- southFlip = FLIP_CCW;
- upFlip = FLIP_CCW;
- downFlip = FLIP_CW;
- setShape( thickness, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f );
- break;
- case Facing::EAST:
- northFlip = FLIP_CCW;
- southFlip = FLIP_CW;
- upFlip = FLIP_CW;
- downFlip = FLIP_CCW;
- setShape( 0.0f, 0.0f, 0.0f, 1.0f - thickness, 1.0f, 1.0f );
- break;
- }
- // weird way of telling the piston to use the
- // "inside" texture for the forward-facing edge
- ((PistonBaseTile *) tt)->updateShape((float) tileShapeX0, (float) tileShapeY0, (float) tileShapeZ0, (float) tileShapeX1, (float) tileShapeY1, (float) tileShapeZ1);
- tesselateBlockInWorld( tt, x, y, z );
- northFlip = FLIP_NONE;
- southFlip = FLIP_NONE;
- eastFlip = FLIP_NONE;
- westFlip = FLIP_NONE;
- upFlip = FLIP_NONE;
- downFlip = FLIP_NONE;
- ((PistonBaseTile *) tt)->updateShape((float) tileShapeX0, (float) tileShapeY0, (float) tileShapeZ0, (float) tileShapeX1, (float) tileShapeY1, (float) tileShapeZ1);
- }
- else
- {
- switch ( facing )
- {
- case Facing::DOWN:
- northFlip = FLIP_180;
- southFlip = FLIP_180;
- eastFlip = FLIP_180;
- westFlip = FLIP_180;
- break;
- case Facing::UP:
- break;
- case Facing::NORTH:
- eastFlip = FLIP_CW;
- westFlip = FLIP_CCW;
- break;
- case Facing::SOUTH:
- eastFlip = FLIP_CCW;
- westFlip = FLIP_CW;
- upFlip = FLIP_180;
- downFlip = FLIP_180;
- break;
- case Facing::WEST:
- northFlip = FLIP_CW;
- southFlip = FLIP_CCW;
- upFlip = FLIP_CCW;
- downFlip = FLIP_CW;
- break;
- case Facing::EAST:
- northFlip = FLIP_CCW;
- southFlip = FLIP_CW;
- upFlip = FLIP_CW;
- downFlip = FLIP_CCW;
- break;
- }
- tesselateBlockInWorld( tt, x, y, z );
- northFlip = FLIP_NONE;
- southFlip = FLIP_NONE;
- eastFlip = FLIP_NONE;
- westFlip = FLIP_NONE;
- upFlip = FLIP_NONE;
- downFlip = FLIP_NONE;
- }
+ // EnterCriticalSection( &Tile_SPU::m_csShape );
+ if (extended) {
+ switch (facing) {
+ case Facing::DOWN:
+ northFlip = FLIP_180;
+ southFlip = FLIP_180;
+ eastFlip = FLIP_180;
+ westFlip = FLIP_180;
+ setShape(0.0f, thickness, 0.0f, 1.0f, 1.0f, 1.0f);
+ break;
+ case Facing::UP:
+ setShape(0.0f, 0.0f, 0.0f, 1.0f, 1.0f - thickness, 1.0f);
+ break;
+ case Facing::NORTH:
+ eastFlip = FLIP_CW;
+ westFlip = FLIP_CCW;
+ setShape(0.0f, 0.0f, thickness, 1.0f, 1.0f, 1.0f);
+ break;
+ case Facing::SOUTH:
+ eastFlip = FLIP_CCW;
+ westFlip = FLIP_CW;
+ upFlip = FLIP_180;
+ downFlip = FLIP_180;
+ setShape(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f - thickness);
+ break;
+ case Facing::WEST:
+ northFlip = FLIP_CW;
+ southFlip = FLIP_CCW;
+ upFlip = FLIP_CCW;
+ downFlip = FLIP_CW;
+ setShape(thickness, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);
+ break;
+ case Facing::EAST:
+ northFlip = FLIP_CCW;
+ southFlip = FLIP_CW;
+ upFlip = FLIP_CW;
+ downFlip = FLIP_CCW;
+ setShape(0.0f, 0.0f, 0.0f, 1.0f - thickness, 1.0f, 1.0f);
+ break;
+ }
+ // weird way of telling the piston to use the
+ // "inside" texture for the forward-facing edge
+ ((PistonBaseTile*)tt)
+ ->updateShape((float)tileShapeX0, (float)tileShapeY0,
+ (float)tileShapeZ0, (float)tileShapeX1,
+ (float)tileShapeY1, (float)tileShapeZ1);
+ tesselateBlockInWorld(tt, x, y, z);
+ northFlip = FLIP_NONE;
+ southFlip = FLIP_NONE;
+ eastFlip = FLIP_NONE;
+ westFlip = FLIP_NONE;
+ upFlip = FLIP_NONE;
+ downFlip = FLIP_NONE;
+ ((PistonBaseTile*)tt)
+ ->updateShape((float)tileShapeX0, (float)tileShapeY0,
+ (float)tileShapeZ0, (float)tileShapeX1,
+ (float)tileShapeY1, (float)tileShapeZ1);
+ } else {
+ switch (facing) {
+ case Facing::DOWN:
+ northFlip = FLIP_180;
+ southFlip = FLIP_180;
+ eastFlip = FLIP_180;
+ westFlip = FLIP_180;
+ break;
+ case Facing::UP:
+ break;
+ case Facing::NORTH:
+ eastFlip = FLIP_CW;
+ westFlip = FLIP_CCW;
+ break;
+ case Facing::SOUTH:
+ eastFlip = FLIP_CCW;
+ westFlip = FLIP_CW;
+ upFlip = FLIP_180;
+ downFlip = FLIP_180;
+ break;
+ case Facing::WEST:
+ northFlip = FLIP_CW;
+ southFlip = FLIP_CCW;
+ upFlip = FLIP_CCW;
+ downFlip = FLIP_CW;
+ break;
+ case Facing::EAST:
+ northFlip = FLIP_CCW;
+ southFlip = FLIP_CW;
+ upFlip = FLIP_CW;
+ downFlip = FLIP_CCW;
+ break;
+ }
+ tesselateBlockInWorld(tt, x, y, z);
+ northFlip = FLIP_NONE;
+ southFlip = FLIP_NONE;
+ eastFlip = FLIP_NONE;
+ westFlip = FLIP_NONE;
+ upFlip = FLIP_NONE;
+ downFlip = FLIP_NONE;
+ }
// LeaveCriticalSection( &Tile_SPU::m_csShape );
-#endif // DISABLE_TESS_FUNCS
-
- return true;
+#endif // DISABLE_TESS_FUNCS
+ return true;
}
-void TileRenderer_SPU::renderPistonArmUpDown( float x0, float x1, float y0, float y1, float z0, float z1, float br,
- float armLengthPixels )
-{
+void TileRenderer_SPU::renderPistonArmUpDown(float x0, float x1, float y0,
+ float y1, float z0, float z1,
+ float br, float armLengthPixels) {
#ifdef DISABLE_TESS_FUNCS
- Icon_SPU *armTex = PistonBaseTile::getTexture(PistonBaseTile::EDGE_TEX);
- if (hasFixedTexture()) armTex = fixedTexture;
+ Icon_SPU* armTex = PistonBaseTile::getTexture(PistonBaseTile::EDGE_TEX);
+ if (hasFixedTexture()) armTex = fixedTexture;
- Tesselator_SPU* t = getTesselator();
+ Tesselator_SPU* t = getTesselator();
- // upwards arm
- float u00 = armTex->getU0();
- float v00 = armTex->getV0();
- float u11 = armTex->getU(armLengthPixels);
- float v11 = armTex->getV(PistonBaseTile::PLATFORM_THICKNESS);
+ // upwards arm
+ float u00 = armTex->getU0();
+ float v00 = armTex->getV0();
+ float u11 = armTex->getU(armLengthPixels);
+ float v11 = armTex->getV(PistonBaseTile::PLATFORM_THICKNESS);
- t->color( br, br, br );
-
- t->vertexUV( x0, y1, z0, u11, v00 );
- t->vertexUV( x0, y0, z0, u00, v00 );
- t->vertexUV( x1, y0, z1, u00, v11 );
- t->vertexUV( x1, y1, z1, u11, v11 );
-#endif // DISABLE_TESS_FUNCS
+ t->color(br, br, br);
+ t->vertexUV(x0, y1, z0, u11, v00);
+ t->vertexUV(x0, y0, z0, u00, v00);
+ t->vertexUV(x1, y0, z1, u00, v11);
+ t->vertexUV(x1, y1, z1, u11, v11);
+#endif // DISABLE_TESS_FUNCS
}
-void TileRenderer_SPU::renderPistonArmNorthSouth( float x0, float x1, float y0, float y1, float z0, float z1,
- float br, float armLengthPixels )
-{
+void TileRenderer_SPU::renderPistonArmNorthSouth(float x0, float x1, float y0,
+ float y1, float z0, float z1,
+ float br,
+ float armLengthPixels) {
#ifdef DISABLE_TESS_FUNCS
- Icon_SPU *armTex = PistonBaseTile::getTexture(PistonBaseTile::EDGE_TEX);
- if (hasFixedTexture()) armTex = fixedTexture;
+ Icon_SPU* armTex = PistonBaseTile::getTexture(PistonBaseTile::EDGE_TEX);
+ if (hasFixedTexture()) armTex = fixedTexture;
- Tesselator_SPU* t = getTesselator();
+ Tesselator_SPU* t = getTesselator();
- // upwards arm
- float u00 = armTex->getU0();
- float v00 = armTex->getV0();
- float u11 = armTex->getU(armLengthPixels);
- float v11 = armTex->getV(PistonBaseTile::PLATFORM_THICKNESS);
+ // upwards arm
+ float u00 = armTex->getU0();
+ float v00 = armTex->getV0();
+ float u11 = armTex->getU(armLengthPixels);
+ float v11 = armTex->getV(PistonBaseTile::PLATFORM_THICKNESS);
- t->color( br, br, br );
+ t->color(br, br, br);
- t->vertexUV( x0, y0, z1, u11, v00 );
- t->vertexUV( x0, y0, z0, u00, v00 );
- t->vertexUV( x1, y1, z0, u00, v11 );
- t->vertexUV( x1, y1, z1, u11, v11 );
-#endif // DISABLE_TESS_FUNCS
+ t->vertexUV(x0, y0, z1, u11, v00);
+ t->vertexUV(x0, y0, z0, u00, v00);
+ t->vertexUV(x1, y1, z0, u00, v11);
+ t->vertexUV(x1, y1, z1, u11, v11);
+#endif // DISABLE_TESS_FUNCS
}
-void TileRenderer_SPU::renderPistonArmEastWest( float x0, float x1, float y0, float y1, float z0, float z1, float br,
- float armLengthPixels )
-{
+void TileRenderer_SPU::renderPistonArmEastWest(float x0, float x1, float y0,
+ float y1, float z0, float z1,
+ float br,
+ float armLengthPixels) {
#ifdef DISABLE_TESS_FUNCS
- Icon_SPU *armTex = PistonBaseTile::getTexture(PistonBaseTile::EDGE_TEX);
- if (hasFixedTexture()) armTex = fixedTexture;
+ Icon_SPU* armTex = PistonBaseTile::getTexture(PistonBaseTile::EDGE_TEX);
+ if (hasFixedTexture()) armTex = fixedTexture;
- Tesselator_SPU* t = getTesselator();
+ Tesselator_SPU* t = getTesselator();
- // upwards arm
- float u00 = armTex->getU0();
- float v00 = armTex->getV0();
- float u11 = armTex->getU(armLengthPixels);
- float v11 = armTex->getV(PistonBaseTile::PLATFORM_THICKNESS);
+ // upwards arm
+ float u00 = armTex->getU0();
+ float v00 = armTex->getV0();
+ float u11 = armTex->getU(armLengthPixels);
+ float v11 = armTex->getV(PistonBaseTile::PLATFORM_THICKNESS);
- t->color( br, br, br );
+ t->color(br, br, br);
- t->vertexUV( x1, y0, z0, u11, v00 );
- t->vertexUV( x0, y0, z0, u00, v00 );
- t->vertexUV( x0, y1, z1, u00, v11 );
- t->vertexUV( x1, y1, z1, u11, v11 );
-#endif // DISABLE_TESS_FUNCS
+ t->vertexUV(x1, y0, z0, u11, v00);
+ t->vertexUV(x0, y0, z0, u00, v00);
+ t->vertexUV(x0, y1, z1, u00, v11);
+ t->vertexUV(x1, y1, z1, u11, v11);
+#endif // DISABLE_TESS_FUNCS
}
-void TileRenderer_SPU::tesselatePistonArmNoCulling( Tile_SPU* tile, int x, int y, int z, bool fullArm, int forceData ) // 4J added forceData param
+void TileRenderer_SPU::tesselatePistonArmNoCulling(
+ Tile_SPU* tile, int x, int y, int z, bool fullArm,
+ int forceData) // 4J added forceData param
{
#ifdef DISABLE_TESS_FUNCS
- noCulling = true;
- tesselatePistonExtensionInWorld( tile, x, y, z, fullArm );
- noCulling = false;
-#endif // DISABLE_TESS_FUNCS
+ noCulling = true;
+ tesselatePistonExtensionInWorld(tile, x, y, z, fullArm);
+ noCulling = false;
+#endif // DISABLE_TESS_FUNCS
}
-bool TileRenderer_SPU::tesselatePistonExtensionInWorld( Tile_SPU* tt, int x, int y, int z, bool fullArm, int forceData ) // 4J added forceData param
+bool TileRenderer_SPU::tesselatePistonExtensionInWorld(
+ Tile_SPU* tt, int x, int y, int z, bool fullArm,
+ int forceData) // 4J added forceData param
{
#ifdef DISABLE_TESS_FUNCS
- int data = ( forceData == -1 ) ? level->getData( x, y, z ) : forceData;
- int facing = PistonExtensionTile::getFacing( data );
+ int data = (forceData == -1) ? level->getData(x, y, z) : forceData;
+ int facing = PistonExtensionTile::getFacing(data);
- const float thickness = PistonBaseTile::PLATFORM_THICKNESS / 16.0f;
- const float leftEdge = ( 8.0f - ( PistonBaseTile::PLATFORM_THICKNESS / 2.0f ) ) / 16.0f;
- const float rightEdge = ( 8.0f + ( PistonBaseTile::PLATFORM_THICKNESS / 2.0f ) ) / 16.0f;
- const float br = tt->getBrightness( level, x, y, z );
- const float armLength = fullArm ? 1.0f : 0.5f;
- const float armLengthPixels = fullArm ? 16.0f : 8.0f;
+ const float thickness = PistonBaseTile::PLATFORM_THICKNESS / 16.0f;
+ const float leftEdge =
+ (8.0f - (PistonBaseTile::PLATFORM_THICKNESS / 2.0f)) / 16.0f;
+ const float rightEdge =
+ (8.0f + (PistonBaseTile::PLATFORM_THICKNESS / 2.0f)) / 16.0f;
+ const float br = tt->getBrightness(level, x, y, z);
+ const float armLength = fullArm ? 1.0f : 0.5f;
+ const float armLengthPixels = fullArm ? 16.0f : 8.0f;
-// EnterCriticalSection( &Tile_SPU::m_csShape );
- Tesselator_SPU* t = getTesselator();
+ // EnterCriticalSection( &Tile_SPU::m_csShape );
+ Tesselator_SPU* t = getTesselator();
- switch ( facing )
- {
- case Facing::DOWN:
- northFlip = FLIP_180;
- southFlip = FLIP_180;
- eastFlip = FLIP_180;
- westFlip = FLIP_180;
- setShape( 0.0f, 0.0f, 0.0f, 1.0f, thickness, 1.0f );
- tesselateBlockInWorld( tt, x, y, z );
+ switch (facing) {
+ case Facing::DOWN:
+ northFlip = FLIP_180;
+ southFlip = FLIP_180;
+ eastFlip = FLIP_180;
+ westFlip = FLIP_180;
+ setShape(0.0f, 0.0f, 0.0f, 1.0f, thickness, 1.0f);
+ tesselateBlockInWorld(tt, x, y, z);
- t->tex2( getLightColor(tt, level, x, y , z ) ); // 4J added - renderPistonArmDown doesn't set its own tex2 so just inherited from previous tesselateBlockInWorld
- renderPistonArmUpDown( x + leftEdge, x + rightEdge, y + thickness, y + thickness + armLength,
- z + rightEdge, z + rightEdge, br * 0.8f, armLengthPixels );
- renderPistonArmUpDown( x + rightEdge, x + leftEdge, y + thickness, y + thickness + armLength, z + leftEdge,
- z + leftEdge, br * 0.8f, armLengthPixels );
- renderPistonArmUpDown( x + leftEdge, x + leftEdge, y + thickness, y + thickness + armLength, z + leftEdge,
- z + rightEdge, br * 0.6f, armLengthPixels );
- renderPistonArmUpDown( x + rightEdge, x + rightEdge, y + thickness, y + thickness + armLength,
- z + rightEdge, z + leftEdge, br * 0.6f, armLengthPixels );
+ t->tex2(getLightColor(
+ tt, level, x, y,
+ z)); // 4J added - renderPistonArmDown doesn't set its own tex2
+ // so just inherited from previous tesselateBlockInWorld
+ renderPistonArmUpDown(x + leftEdge, x + rightEdge, y + thickness,
+ y + thickness + armLength, z + rightEdge,
+ z + rightEdge, br * 0.8f, armLengthPixels);
+ renderPistonArmUpDown(x + rightEdge, x + leftEdge, y + thickness,
+ y + thickness + armLength, z + leftEdge,
+ z + leftEdge, br * 0.8f, armLengthPixels);
+ renderPistonArmUpDown(x + leftEdge, x + leftEdge, y + thickness,
+ y + thickness + armLength, z + leftEdge,
+ z + rightEdge, br * 0.6f, armLengthPixels);
+ renderPistonArmUpDown(x + rightEdge, x + rightEdge, y + thickness,
+ y + thickness + armLength, z + rightEdge,
+ z + leftEdge, br * 0.6f, armLengthPixels);
- break;
- case Facing::UP:
- setShape( 0.0f, 1.0f - thickness, 0.0f, 1.0f, 1.0f, 1.0f );
- tesselateBlockInWorld( tt, x, y, z );
+ break;
+ case Facing::UP:
+ setShape(0.0f, 1.0f - thickness, 0.0f, 1.0f, 1.0f, 1.0f);
+ tesselateBlockInWorld(tt, x, y, z);
- t->tex2( getLightColor(tt, level, x, y , z ) ); // 4J added - renderPistonArmDown doesn't set its own tex2 so just inherited from previous tesselateBlockInWorld
- renderPistonArmUpDown( x + leftEdge, x + rightEdge, y - thickness + 1.0f - armLength, y - thickness + 1.0f,
- z + rightEdge, z + rightEdge, br * 0.8f, armLengthPixels );
- renderPistonArmUpDown( x + rightEdge, x + leftEdge, y - thickness + 1.0f - armLength, y - thickness + 1.0f,
- z + leftEdge, z + leftEdge, br * 0.8f, armLengthPixels );
- renderPistonArmUpDown( x + leftEdge, x + leftEdge, y - thickness + 1.0f - armLength, y - thickness + 1.0f,
- z + leftEdge, z + rightEdge, br * 0.6f, armLengthPixels );
- renderPistonArmUpDown( x + rightEdge, x + rightEdge, y - thickness + 1.0f - armLength,
- y - thickness + 1.0f, z + rightEdge, z + leftEdge, br * 0.6f, armLengthPixels );
- break;
- case Facing::NORTH:
- eastFlip = FLIP_CW;
- westFlip = FLIP_CCW;
- setShape( 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, thickness );
- tesselateBlockInWorld( tt, x, y, z );
+ t->tex2(getLightColor(
+ tt, level, x, y,
+ z)); // 4J added - renderPistonArmDown doesn't set its own tex2
+ // so just inherited from previous tesselateBlockInWorld
+ renderPistonArmUpDown(x + leftEdge, x + rightEdge,
+ y - thickness + 1.0f - armLength,
+ y - thickness + 1.0f, z + rightEdge,
+ z + rightEdge, br * 0.8f, armLengthPixels);
+ renderPistonArmUpDown(x + rightEdge, x + leftEdge,
+ y - thickness + 1.0f - armLength,
+ y - thickness + 1.0f, z + leftEdge,
+ z + leftEdge, br * 0.8f, armLengthPixels);
+ renderPistonArmUpDown(x + leftEdge, x + leftEdge,
+ y - thickness + 1.0f - armLength,
+ y - thickness + 1.0f, z + leftEdge,
+ z + rightEdge, br * 0.6f, armLengthPixels);
+ renderPistonArmUpDown(x + rightEdge, x + rightEdge,
+ y - thickness + 1.0f - armLength,
+ y - thickness + 1.0f, z + rightEdge,
+ z + leftEdge, br * 0.6f, armLengthPixels);
+ break;
+ case Facing::NORTH:
+ eastFlip = FLIP_CW;
+ westFlip = FLIP_CCW;
+ setShape(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, thickness);
+ tesselateBlockInWorld(tt, x, y, z);
- t->tex2( getLightColor(tt, level, x, y , z ) ); // 4J added - renderPistonArmDown doesn't set its own tex2 so just inherited from previous tesselateBlockInWorld
- renderPistonArmNorthSouth( x + leftEdge, x + leftEdge, y + rightEdge, y + leftEdge, z + thickness,
- z + thickness + armLength, br * 0.6f, armLengthPixels );
- renderPistonArmNorthSouth( x + rightEdge, x + rightEdge, y + leftEdge, y + rightEdge, z + thickness,
- z + thickness + armLength, br * 0.6f, armLengthPixels );
- renderPistonArmNorthSouth( x + leftEdge, x + rightEdge, y + leftEdge, y + leftEdge, z + thickness,
- z + thickness + armLength, br * 0.5f, armLengthPixels );
- renderPistonArmNorthSouth( x + rightEdge, x + leftEdge, y + rightEdge, y + rightEdge, z + thickness,
- z + thickness + armLength, br, armLengthPixels );
- break;
- case Facing::SOUTH:
- eastFlip = FLIP_CCW;
- westFlip = FLIP_CW;
- upFlip = FLIP_180;
- downFlip = FLIP_180;
- setShape( 0.0f, 0.0f, 1.0f - thickness, 1.0f, 1.0f, 1.0f );
- tesselateBlockInWorld( tt, x, y, z );
+ t->tex2(getLightColor(
+ tt, level, x, y,
+ z)); // 4J added - renderPistonArmDown doesn't set its own tex2
+ // so just inherited from previous tesselateBlockInWorld
+ renderPistonArmNorthSouth(x + leftEdge, x + leftEdge, y + rightEdge,
+ y + leftEdge, z + thickness,
+ z + thickness + armLength, br * 0.6f,
+ armLengthPixels);
+ renderPistonArmNorthSouth(x + rightEdge, x + rightEdge,
+ y + leftEdge, y + rightEdge,
+ z + thickness, z + thickness + armLength,
+ br * 0.6f, armLengthPixels);
+ renderPistonArmNorthSouth(x + leftEdge, x + rightEdge, y + leftEdge,
+ y + leftEdge, z + thickness,
+ z + thickness + armLength, br * 0.5f,
+ armLengthPixels);
+ renderPistonArmNorthSouth(
+ x + rightEdge, x + leftEdge, y + rightEdge, y + rightEdge,
+ z + thickness, z + thickness + armLength, br, armLengthPixels);
+ break;
+ case Facing::SOUTH:
+ eastFlip = FLIP_CCW;
+ westFlip = FLIP_CW;
+ upFlip = FLIP_180;
+ downFlip = FLIP_180;
+ setShape(0.0f, 0.0f, 1.0f - thickness, 1.0f, 1.0f, 1.0f);
+ tesselateBlockInWorld(tt, x, y, z);
- t->tex2( getLightColor(tt, level, x, y , z ) ); // 4J added - renderPistonArmDown doesn't set its own tex2 so just inherited from previous tesselateBlockInWorld
- renderPistonArmNorthSouth( x + leftEdge, x + leftEdge, y + rightEdge, y + leftEdge,
- z - thickness + 1.0f - armLength, z - thickness + 1.0f, br * 0.6f,
- armLengthPixels );
- renderPistonArmNorthSouth( x + rightEdge, x + rightEdge, y + leftEdge, y + rightEdge,
- z - thickness + 1.0f - armLength, z - thickness + 1.0f, br * 0.6f,
- armLengthPixels );
- renderPistonArmNorthSouth( x + leftEdge, x + rightEdge, y + leftEdge, y + leftEdge,
- z - thickness + 1.0f - armLength, z - thickness + 1.0f, br * 0.5f,
- armLengthPixels );
- renderPistonArmNorthSouth( x + rightEdge, x + leftEdge, y + rightEdge, y + rightEdge,
- z - thickness + 1.0f - armLength, z - thickness + 1.0f, br, armLengthPixels );
- break;
- case Facing::WEST:
- northFlip = FLIP_CW;
- southFlip = FLIP_CCW;
- upFlip = FLIP_CCW;
- downFlip = FLIP_CW;
- setShape( 0.0f, 0.0f, 0.0f, thickness, 1.0f, 1.0f );
- tesselateBlockInWorld( tt, x, y, z ); // 4J added - renderPistonArmDown doesn't set its own tex2 so just inherited from previous tesselateBlockInWorld
+ t->tex2(getLightColor(
+ tt, level, x, y,
+ z)); // 4J added - renderPistonArmDown doesn't set its own tex2
+ // so just inherited from previous tesselateBlockInWorld
+ renderPistonArmNorthSouth(
+ x + leftEdge, x + leftEdge, y + rightEdge, y + leftEdge,
+ z - thickness + 1.0f - armLength, z - thickness + 1.0f,
+ br * 0.6f, armLengthPixels);
+ renderPistonArmNorthSouth(
+ x + rightEdge, x + rightEdge, y + leftEdge, y + rightEdge,
+ z - thickness + 1.0f - armLength, z - thickness + 1.0f,
+ br * 0.6f, armLengthPixels);
+ renderPistonArmNorthSouth(
+ x + leftEdge, x + rightEdge, y + leftEdge, y + leftEdge,
+ z - thickness + 1.0f - armLength, z - thickness + 1.0f,
+ br * 0.5f, armLengthPixels);
+ renderPistonArmNorthSouth(
+ x + rightEdge, x + leftEdge, y + rightEdge, y + rightEdge,
+ z - thickness + 1.0f - armLength, z - thickness + 1.0f, br,
+ armLengthPixels);
+ break;
+ case Facing::WEST:
+ northFlip = FLIP_CW;
+ southFlip = FLIP_CCW;
+ upFlip = FLIP_CCW;
+ downFlip = FLIP_CW;
+ setShape(0.0f, 0.0f, 0.0f, thickness, 1.0f, 1.0f);
+ tesselateBlockInWorld(
+ tt, x, y,
+ z); // 4J added - renderPistonArmDown doesn't set its own tex2
+ // so just inherited from previous tesselateBlockInWorld
- t->tex2( getLightColor(tt, level, x, y , z ) );
- renderPistonArmEastWest( x + thickness, x + thickness + armLength, y + leftEdge, y + leftEdge,
- z + rightEdge, z + leftEdge, br * 0.5f, armLengthPixels );
- renderPistonArmEastWest( x + thickness, x + thickness + armLength, y + rightEdge, y + rightEdge,
- z + leftEdge, z + rightEdge, br, armLengthPixels );
- renderPistonArmEastWest( x + thickness, x + thickness + armLength, y + leftEdge, y + rightEdge,
- z + leftEdge, z + leftEdge, br * 0.6f, armLengthPixels );
- renderPistonArmEastWest( x + thickness, x + thickness + armLength, y + rightEdge, y + leftEdge,
- z + rightEdge, z + rightEdge, br * 0.6f, armLengthPixels );
- break;
- case Facing::EAST:
- northFlip = FLIP_CCW;
- southFlip = FLIP_CW;
- upFlip = FLIP_CW;
- downFlip = FLIP_CCW;
- setShape( 1.0f - thickness, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f );
- tesselateBlockInWorld( tt, x, y, z );
+ t->tex2(getLightColor(tt, level, x, y, z));
+ renderPistonArmEastWest(x + thickness, x + thickness + armLength,
+ y + leftEdge, y + leftEdge, z + rightEdge,
+ z + leftEdge, br * 0.5f, armLengthPixels);
+ renderPistonArmEastWest(x + thickness, x + thickness + armLength,
+ y + rightEdge, y + rightEdge, z + leftEdge,
+ z + rightEdge, br, armLengthPixels);
+ renderPistonArmEastWest(x + thickness, x + thickness + armLength,
+ y + leftEdge, y + rightEdge, z + leftEdge,
+ z + leftEdge, br * 0.6f, armLengthPixels);
+ renderPistonArmEastWest(x + thickness, x + thickness + armLength,
+ y + rightEdge, y + leftEdge, z + rightEdge,
+ z + rightEdge, br * 0.6f, armLengthPixels);
+ break;
+ case Facing::EAST:
+ northFlip = FLIP_CCW;
+ southFlip = FLIP_CW;
+ upFlip = FLIP_CW;
+ downFlip = FLIP_CCW;
+ setShape(1.0f - thickness, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);
+ tesselateBlockInWorld(tt, x, y, z);
- t->tex2( getLightColor(tt, level, x, y , z ) ); // 4J added - renderPistonArmDown doesn't set its own tex2 so just inherited from previous tesselateBlockInWorld
- renderPistonArmEastWest( x - thickness + 1.0f - armLength, x - thickness + 1.0f, y + leftEdge,
- y + leftEdge, z + rightEdge, z + leftEdge, br * 0.5f, armLengthPixels );
- renderPistonArmEastWest( x - thickness + 1.0f - armLength, x - thickness + 1.0f, y + rightEdge,
- y + rightEdge, z + leftEdge, z + rightEdge, br, armLengthPixels );
- renderPistonArmEastWest( x - thickness + 1.0f - armLength, x - thickness + 1.0f, y + leftEdge,
- y + rightEdge, z + leftEdge, z + leftEdge, br * 0.6f, armLengthPixels );
- renderPistonArmEastWest( x - thickness + 1.0f - armLength, x - thickness + 1.0f, y + rightEdge,
- y + leftEdge, z + rightEdge, z + rightEdge, br * 0.6f, armLengthPixels );
- break;
- }
- northFlip = FLIP_NONE;
- southFlip = FLIP_NONE;
- eastFlip = FLIP_NONE;
- westFlip = FLIP_NONE;
- upFlip = FLIP_NONE;
- downFlip = FLIP_NONE;
- setShape( 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f );
+ t->tex2(getLightColor(
+ tt, level, x, y,
+ z)); // 4J added - renderPistonArmDown doesn't set its own tex2
+ // so just inherited from previous tesselateBlockInWorld
+ renderPistonArmEastWest(x - thickness + 1.0f - armLength,
+ x - thickness + 1.0f, y + leftEdge,
+ y + leftEdge, z + rightEdge, z + leftEdge,
+ br * 0.5f, armLengthPixels);
+ renderPistonArmEastWest(x - thickness + 1.0f - armLength,
+ x - thickness + 1.0f, y + rightEdge,
+ y + rightEdge, z + leftEdge, z + rightEdge,
+ br, armLengthPixels);
+ renderPistonArmEastWest(x - thickness + 1.0f - armLength,
+ x - thickness + 1.0f, y + leftEdge,
+ y + rightEdge, z + leftEdge, z + leftEdge,
+ br * 0.6f, armLengthPixels);
+ renderPistonArmEastWest(x - thickness + 1.0f - armLength,
+ x - thickness + 1.0f, y + rightEdge,
+ y + leftEdge, z + rightEdge, z + rightEdge,
+ br * 0.6f, armLengthPixels);
+ break;
+ }
+ northFlip = FLIP_NONE;
+ southFlip = FLIP_NONE;
+ eastFlip = FLIP_NONE;
+ westFlip = FLIP_NONE;
+ upFlip = FLIP_NONE;
+ downFlip = FLIP_NONE;
+ setShape(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);
// LeaveCriticalSection( &Tile_SPU::m_csShape );
-#endif // DISABLE_TESS_FUNCS
-
- return true;
+#endif // DISABLE_TESS_FUNCS
+ return true;
}
-bool TileRenderer_SPU::tesselateLeverInWorld( Tile_SPU* tt, int x, int y, int z )
-{
+bool TileRenderer_SPU::tesselateLeverInWorld(Tile_SPU* tt, int x, int y,
+ int z) {
#ifdef DISABLE_TESS_FUNCS
- int data = level->getData( x, y, z );
+ int data = level->getData(x, y, z);
- int dir = data & 7;
- bool flipped = ( data & 8 ) > 0;
+ int dir = data & 7;
+ bool flipped = (data & 8) > 0;
- Tesselator_SPU* t = getTesselator();
+ Tesselator_SPU* t = getTesselator();
- bool hadFixed = hasFixedTexture();
- if (!hadFixed) this->setFixedTexture(getTexture(Tile_SPU::stoneBrick));
- float w1 = 4.0f / 16.0f;
- float w2 = 3.0f / 16.0f;
- float h = 3.0f / 16.0f;
-// EnterCriticalSection( &Tile_SPU::m_csShape );
- if ( dir == 5 )
- {
- setShape( 0.5f - w2, 0.0f, 0.5f - w1, 0.5f + w2, h, 0.5f + w1 );
- }
- else if ( dir == 6 )
- {
- setShape( 0.5f - w1, 0.0f, 0.5f - w2, 0.5f + w1, h, 0.5f + w2 );
- }
- else if ( dir == 4 )
- {
- setShape( 0.5f - w2, 0.5f - w1, 1.0f - h, 0.5f + w2, 0.5f + w1, 1.0f );
- }
- else if ( dir == 3 )
- {
- setShape( 0.5f - w2, 0.5f - w1, 0, 0.5f + w2, 0.5f + w1, h );
- }
- else if ( dir == 2 )
- {
- setShape( 1.0f - h, 0.5f - w1, 0.5f - w2, 1.0f, 0.5f + w1, 0.5f + w2 );
- }
- else if ( dir == 1 )
- {
- setShape( 0, 0.5f - w1, 0.5f - w2, h, 0.5f + w1, 0.5f + w2 );
- }
- else if (dir == 0)
- {
- setShape(0.5f - w1, 1 - h, 0.5f - w2, 0.5f + w1, 1, 0.5f + w2);
- }
- else if (dir == 7)
- {
- setShape(0.5f - w2, 1 - h, 0.5f - w1, 0.5f + w2, 1, 0.5f + w1);
- }
- this->tesselateBlockInWorld( tt, x, y, z );
-// LeaveCriticalSection( &Tile_SPU::m_csShape );
- if ( !hadFixed ) this->clearFixedTexture();
+ bool hadFixed = hasFixedTexture();
+ if (!hadFixed) this->setFixedTexture(getTexture(Tile_SPU::stoneBrick));
+ float w1 = 4.0f / 16.0f;
+ float w2 = 3.0f / 16.0f;
+ float h = 3.0f / 16.0f;
+ // EnterCriticalSection( &Tile_SPU::m_csShape );
+ if (dir == 5) {
+ setShape(0.5f - w2, 0.0f, 0.5f - w1, 0.5f + w2, h, 0.5f + w1);
+ } else if (dir == 6) {
+ setShape(0.5f - w1, 0.0f, 0.5f - w2, 0.5f + w1, h, 0.5f + w2);
+ } else if (dir == 4) {
+ setShape(0.5f - w2, 0.5f - w1, 1.0f - h, 0.5f + w2, 0.5f + w1, 1.0f);
+ } else if (dir == 3) {
+ setShape(0.5f - w2, 0.5f - w1, 0, 0.5f + w2, 0.5f + w1, h);
+ } else if (dir == 2) {
+ setShape(1.0f - h, 0.5f - w1, 0.5f - w2, 1.0f, 0.5f + w1, 0.5f + w2);
+ } else if (dir == 1) {
+ setShape(0, 0.5f - w1, 0.5f - w2, h, 0.5f + w1, 0.5f + w2);
+ } else if (dir == 0) {
+ setShape(0.5f - w1, 1 - h, 0.5f - w2, 0.5f + w1, 1, 0.5f + w2);
+ } else if (dir == 7) {
+ setShape(0.5f - w2, 1 - h, 0.5f - w1, 0.5f + w2, 1, 0.5f + w1);
+ }
+ this->tesselateBlockInWorld(tt, x, y, z);
+ // LeaveCriticalSection( &Tile_SPU::m_csShape );
+ if (!hadFixed) this->clearFixedTexture();
- float br;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tt->getLightColor( level, x, y, z ) );
- br = 1;
- }
- else
- {
- br = tt->getBrightness( level, x, y, z );
- }
- if ( Tile_SPU::lightEmission[tt->id] > 0 ) br = 1.0f;
- t->color( br, br, br );
- Icon_SPU *tex = getTexture(tt, 0);
+ float br;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ br = 1;
+ } else {
+ br = tt->getBrightness(level, x, y, z);
+ }
+ if (Tile_SPU::lightEmission[tt->id] > 0) br = 1.0f;
+ t->color(br, br, br);
+ Icon_SPU* tex = getTexture(tt, 0);
- if (hasFixedTexture()) tex = fixedTexture;
- float u0 = tex->getU0();
- float v0 = tex->getV0();
- float u1 = tex->getU1();
- float v1 = tex->getV1();
+ if (hasFixedTexture()) tex = fixedTexture;
+ float u0 = tex->getU0();
+ float v0 = tex->getV0();
+ float u1 = tex->getU1();
+ float v1 = tex->getV1();
- Vec3* corners[8];
- float xv = 1.0f / 16.0f;
- float zv = 1.0f / 16.0f;
- float yv = 10.0f / 16.0f;
- corners[0] = Vec3::newTemp( -xv, -0, -zv );
- corners[1] = Vec3::newTemp( +xv, -0, -zv );
- corners[2] = Vec3::newTemp( +xv, -0, +zv );
- corners[3] = Vec3::newTemp( -xv, -0, +zv );
- corners[4] = Vec3::newTemp( -xv, +yv, -zv );
- corners[5] = Vec3::newTemp( +xv, +yv, -zv );
- corners[6] = Vec3::newTemp( +xv, +yv, +zv );
- corners[7] = Vec3::newTemp( -xv, +yv, +zv );
+ Vec3* corners[8];
+ float xv = 1.0f / 16.0f;
+ float zv = 1.0f / 16.0f;
+ float yv = 10.0f / 16.0f;
+ corners[0] = Vec3::newTemp(-xv, -0, -zv);
+ corners[1] = Vec3::newTemp(+xv, -0, -zv);
+ corners[2] = Vec3::newTemp(+xv, -0, +zv);
+ corners[3] = Vec3::newTemp(-xv, -0, +zv);
+ corners[4] = Vec3::newTemp(-xv, +yv, -zv);
+ corners[5] = Vec3::newTemp(+xv, +yv, -zv);
+ corners[6] = Vec3::newTemp(+xv, +yv, +zv);
+ corners[7] = Vec3::newTemp(-xv, +yv, +zv);
- for ( int i = 0; i < 8; i++ )
- {
- if ( flipped )
- {
- corners[i]->z -= 1 / 16.0f;
- corners[i]->xRot( 40 * PI / 180 );
- }
- else
- {
- corners[i]->z += 1 / 16.0f;
- corners[i]->xRot( -40 * PI / 180 );
- }
- if (dir == 0 || dir == 7)
- {
- corners[i]->zRot(180 * PI / 180);
- }
- if ( dir == 6 || dir == 0 )
- {
- corners[i]->yRot( 90 * PI / 180 );
- }
+ for (int i = 0; i < 8; i++) {
+ if (flipped) {
+ corners[i]->z -= 1 / 16.0f;
+ corners[i]->xRot(40 * PI / 180);
+ } else {
+ corners[i]->z += 1 / 16.0f;
+ corners[i]->xRot(-40 * PI / 180);
+ }
+ if (dir == 0 || dir == 7) {
+ corners[i]->zRot(180 * PI / 180);
+ }
+ if (dir == 6 || dir == 0) {
+ corners[i]->yRot(90 * PI / 180);
+ }
- if ( dir > 0 && dir < 5 )
- {
- corners[i]->y -= 6 / 16.0f;
- corners[i]->xRot( 90 * PI / 180 );
+ if (dir > 0 && dir < 5) {
+ corners[i]->y -= 6 / 16.0f;
+ corners[i]->xRot(90 * PI / 180);
- if ( dir == 4 ) corners[i]->yRot( 0 * PI / 180 );
- if ( dir == 3 ) corners[i]->yRot( 180 * PI / 180 );
- if ( dir == 2 ) corners[i]->yRot( 90 * PI / 180 );
- if ( dir == 1 ) corners[i]->yRot( -90 * PI / 180 );
+ if (dir == 4) corners[i]->yRot(0 * PI / 180);
+ if (dir == 3) corners[i]->yRot(180 * PI / 180);
+ if (dir == 2) corners[i]->yRot(90 * PI / 180);
+ if (dir == 1) corners[i]->yRot(-90 * PI / 180);
- corners[i]->x += x + 0.5;
- corners[i]->y += y + 8 / 16.0f;
- corners[i]->z += z + 0.5;
- }
- else if (dir == 0 || dir == 7)
- {
- corners[i]->x += x + 0.5;
- corners[i]->y += y + 14 / 16.0f;
- corners[i]->z += z + 0.5;
- }
- else
- {
- corners[i]->x += x + 0.5;
- corners[i]->y += y + 2 / 16.0f;
- corners[i]->z += z + 0.5;
- }
- }
-
- Vec3* c0 = NULL, *c1 = NULL, *c2 = NULL, *c3 = NULL;
- for ( int i = 0; i < 6; i++ )
- {
- if ( i == 0 )
- {
- u0 = tex->getU(7);
- v0 = tex->getV(6);
- u1 = tex->getU(9);
- v1 = tex->getV(8);
- }
- else if ( i == 2 )
- {
- u0 = tex->getU(7);
- v0 = tex->getV(6);
- u1 = tex->getU(9);
- v1 = tex->getV1();
- }
- if ( i == 0 )
- {
- c0 = corners[0];
- c1 = corners[1];
- c2 = corners[2];
- c3 = corners[3];
- }
- else if ( i == 1 )
- {
- c0 = corners[7];
- c1 = corners[6];
- c2 = corners[5];
- c3 = corners[4];
- }
- else if ( i == 2 )
- {
- c0 = corners[1];
- c1 = corners[0];
- c2 = corners[4];
- c3 = corners[5];
- }
- else if ( i == 3 )
- {
- c0 = corners[2];
- c1 = corners[1];
- c2 = corners[5];
- c3 = corners[6];
- }
- else if ( i == 4 )
- {
- c0 = corners[3];
- c1 = corners[2];
- c2 = corners[6];
- c3 = corners[7];
- }
- else if ( i == 5 )
- {
- c0 = corners[0];
- c1 = corners[3];
- c2 = corners[7];
- c3 = corners[4];
- }
- t->vertexUV( ( float )( c0->x ), ( float )( c0->y ), ( float )( c0->z ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( c1->x ), ( float )( c1->y ), ( float )( c1->z ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( c2->x ), ( float )( c2->y ), ( float )( c2->z ), ( float )( u1 ), ( float )( v0 ) );
- t->vertexUV( ( float )( c3->x ), ( float )( c3->y ), ( float )( c3->z ), ( float )( u0 ), ( float )( v0 ) );
- }
-#endif // DISABLE_TESS_FUNCS
- return true;
+ corners[i]->x += x + 0.5;
+ corners[i]->y += y + 8 / 16.0f;
+ corners[i]->z += z + 0.5;
+ } else if (dir == 0 || dir == 7) {
+ corners[i]->x += x + 0.5;
+ corners[i]->y += y + 14 / 16.0f;
+ corners[i]->z += z + 0.5;
+ } else {
+ corners[i]->x += x + 0.5;
+ corners[i]->y += y + 2 / 16.0f;
+ corners[i]->z += z + 0.5;
+ }
+ }
+ Vec3 *c0 = NULL, *c1 = NULL, *c2 = NULL, *c3 = NULL;
+ for (int i = 0; i < 6; i++) {
+ if (i == 0) {
+ u0 = tex->getU(7);
+ v0 = tex->getV(6);
+ u1 = tex->getU(9);
+ v1 = tex->getV(8);
+ } else if (i == 2) {
+ u0 = tex->getU(7);
+ v0 = tex->getV(6);
+ u1 = tex->getU(9);
+ v1 = tex->getV1();
+ }
+ if (i == 0) {
+ c0 = corners[0];
+ c1 = corners[1];
+ c2 = corners[2];
+ c3 = corners[3];
+ } else if (i == 1) {
+ c0 = corners[7];
+ c1 = corners[6];
+ c2 = corners[5];
+ c3 = corners[4];
+ } else if (i == 2) {
+ c0 = corners[1];
+ c1 = corners[0];
+ c2 = corners[4];
+ c3 = corners[5];
+ } else if (i == 3) {
+ c0 = corners[2];
+ c1 = corners[1];
+ c2 = corners[5];
+ c3 = corners[6];
+ } else if (i == 4) {
+ c0 = corners[3];
+ c1 = corners[2];
+ c2 = corners[6];
+ c3 = corners[7];
+ } else if (i == 5) {
+ c0 = corners[0];
+ c1 = corners[3];
+ c2 = corners[7];
+ c3 = corners[4];
+ }
+ t->vertexUV((float)(c0->x), (float)(c0->y), (float)(c0->z), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(c1->x), (float)(c1->y), (float)(c1->z), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(c2->x), (float)(c2->y), (float)(c2->z), (float)(u1),
+ (float)(v0));
+ t->vertexUV((float)(c3->x), (float)(c3->y), (float)(c3->z), (float)(u0),
+ (float)(v0));
+ }
+#endif // DISABLE_TESS_FUNCS
+ return true;
}
-bool TileRenderer_SPU::tesselateTripwireSourceInWorld(Tile_SPU *tt, int x, int y, int z)
-{
+bool TileRenderer_SPU::tesselateTripwireSourceInWorld(Tile_SPU* tt, int x,
+ int y, int z) {
#ifdef DISABLE_TESS_FUNCS
- Tesselator *t = Tesselator::getInstance();
- int data = level->getData(x, y, z);
- int dir = data & TripWireSourceTile::MASK_DIR;
- bool attached = (data & TripWireSourceTile::MASK_ATTACHED) == TripWireSourceTile::MASK_ATTACHED;
- bool powered = (data & TripWireSourceTile::MASK_POWERED) == TripWireSourceTile::MASK_POWERED;
- bool suspended = !level->isTopSolidBlocking(x, y - 1, z);
+ Tesselator* t = Tesselator::getInstance();
+ int data = level->getData(x, y, z);
+ int dir = data & TripWireSourceTile::MASK_DIR;
+ bool attached = (data & TripWireSourceTile::MASK_ATTACHED) ==
+ TripWireSourceTile::MASK_ATTACHED;
+ bool powered = (data & TripWireSourceTile::MASK_POWERED) ==
+ TripWireSourceTile::MASK_POWERED;
+ bool suspended = !level->isTopSolidBlocking(x, y - 1, z);
- bool hadFixed = hasFixedTexture();
- if (!hadFixed) this->setFixedTexture(getTexture(Tile::wood));
+ bool hadFixed = hasFixedTexture();
+ if (!hadFixed) this->setFixedTexture(getTexture(Tile::wood));
- float boxHeight = 4 / 16.0f;
- float boxWidth = 2 / 16.0f;
- float boxDepth = 2 / 16.0f;
+ float boxHeight = 4 / 16.0f;
+ float boxWidth = 2 / 16.0f;
+ float boxDepth = 2 / 16.0f;
- float boxy0 = 0.3f - boxHeight;
- float boxy1 = 0.3f + boxHeight;
- if (dir == Direction::NORTH)
- {
- setShape(0.5f - boxWidth, boxy0, 1 - boxDepth, 0.5f + boxWidth, boxy1, 1);
- }
- else if (dir == Direction::SOUTH)
- {
- setShape(0.5f - boxWidth, boxy0, 0, 0.5f + boxWidth, boxy1, boxDepth);
- }
- else if (dir == Direction::WEST)
- {
- setShape(1 - boxDepth, boxy0, 0.5f - boxWidth, 1, boxy1, 0.5f + boxWidth);
- }
- else if (dir == Direction::EAST)
- {
- setShape(0, boxy0, 0.5f - boxWidth, boxDepth, boxy1, 0.5f + boxWidth);
- }
+ float boxy0 = 0.3f - boxHeight;
+ float boxy1 = 0.3f + boxHeight;
+ if (dir == Direction::NORTH) {
+ setShape(0.5f - boxWidth, boxy0, 1 - boxDepth, 0.5f + boxWidth, boxy1,
+ 1);
+ } else if (dir == Direction::SOUTH) {
+ setShape(0.5f - boxWidth, boxy0, 0, 0.5f + boxWidth, boxy1, boxDepth);
+ } else if (dir == Direction::WEST) {
+ setShape(1 - boxDepth, boxy0, 0.5f - boxWidth, 1, boxy1,
+ 0.5f + boxWidth);
+ } else if (dir == Direction::EAST) {
+ setShape(0, boxy0, 0.5f - boxWidth, boxDepth, boxy1, 0.5f + boxWidth);
+ }
- this->tesselateBlockInWorld(tt, x, y, z);
- if (!hadFixed) this->clearFixedTexture();
+ this->tesselateBlockInWorld(tt, x, y, z);
+ if (!hadFixed) this->clearFixedTexture();
- float brightness;
- if (SharedConstants::TEXTURE_LIGHTING)
- {
- t->tex2(tt->getLightColor(level, x, y, z));
- brightness = 1;
- }
- else
- {
- brightness = tt->getBrightness(level, x, y, z);
- }
- if (Tile::lightEmission[tt->id] > 0) brightness = 1.0f;
- t->color(brightness, brightness, brightness);
- Icon *tex = getTexture(tt, 0);
+ float brightness;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ brightness = 1;
+ } else {
+ brightness = tt->getBrightness(level, x, y, z);
+ }
+ if (Tile::lightEmission[tt->id] > 0) brightness = 1.0f;
+ t->color(brightness, brightness, brightness);
+ Icon* tex = getTexture(tt, 0);
- if (hasFixedTexture()) tex = fixedTexture;
- double u0 = tex->getU0();
- double v0 = tex->getV0();
- double u1 = tex->getU1();
- double v1 = tex->getV1();
+ if (hasFixedTexture()) tex = fixedTexture;
+ double u0 = tex->getU0();
+ double v0 = tex->getV0();
+ double u1 = tex->getU1();
+ double v1 = tex->getV1();
- Vec3 *corners[8];
- float stickWidth = 0.75f / 16.0f;
- float stickHeight = 0.75f / 16.0f;
- float stickLength = 5 / 16.0f;
- corners[0] = Vec3::newTemp(-stickWidth, -0, -stickHeight);
- corners[1] = Vec3::newTemp(+stickWidth, -0, -stickHeight);
- corners[2] = Vec3::newTemp(+stickWidth, -0, +stickHeight);
- corners[3] = Vec3::newTemp(-stickWidth, -0, +stickHeight);
- corners[4] = Vec3::newTemp(-stickWidth, +stickLength, -stickHeight);
- corners[5] = Vec3::newTemp(+stickWidth, +stickLength, -stickHeight);
- corners[6] = Vec3::newTemp(+stickWidth, +stickLength, +stickHeight);
- corners[7] = Vec3::newTemp(-stickWidth, +stickLength, +stickHeight);
+ Vec3* corners[8];
+ float stickWidth = 0.75f / 16.0f;
+ float stickHeight = 0.75f / 16.0f;
+ float stickLength = 5 / 16.0f;
+ corners[0] = Vec3::newTemp(-stickWidth, -0, -stickHeight);
+ corners[1] = Vec3::newTemp(+stickWidth, -0, -stickHeight);
+ corners[2] = Vec3::newTemp(+stickWidth, -0, +stickHeight);
+ corners[3] = Vec3::newTemp(-stickWidth, -0, +stickHeight);
+ corners[4] = Vec3::newTemp(-stickWidth, +stickLength, -stickHeight);
+ corners[5] = Vec3::newTemp(+stickWidth, +stickLength, -stickHeight);
+ corners[6] = Vec3::newTemp(+stickWidth, +stickLength, +stickHeight);
+ corners[7] = Vec3::newTemp(-stickWidth, +stickLength, +stickHeight);
- for (int i = 0; i < 8; i++)
- {
- corners[i]->z += 1 / 16.0f;
+ for (int i = 0; i < 8; i++) {
+ corners[i]->z += 1 / 16.0f;
- if (powered)
- {
- corners[i]->xRot(30 * PI / 180);
- corners[i]->y -= 7 / 16.0f;
- }
- else if (attached)
- {
- corners[i]->xRot(5 * PI / 180);
- corners[i]->y -= 7 / 16.0f;
- }
- else
- {
- corners[i]->xRot(-40 * PI / 180);
- corners[i]->y -= 6 / 16.0f;
- }
+ if (powered) {
+ corners[i]->xRot(30 * PI / 180);
+ corners[i]->y -= 7 / 16.0f;
+ } else if (attached) {
+ corners[i]->xRot(5 * PI / 180);
+ corners[i]->y -= 7 / 16.0f;
+ } else {
+ corners[i]->xRot(-40 * PI / 180);
+ corners[i]->y -= 6 / 16.0f;
+ }
- corners[i]->xRot(90 * PI / 180);
+ corners[i]->xRot(90 * PI / 180);
- if (dir == Direction::NORTH) corners[i]->yRot(0 * PI / 180);
- if (dir == Direction::SOUTH) corners[i]->yRot(180 * PI / 180);
- if (dir == Direction::WEST) corners[i]->yRot(90 * PI / 180);
- if (dir == Direction::EAST) corners[i]->yRot(-90 * PI / 180);
+ if (dir == Direction::NORTH) corners[i]->yRot(0 * PI / 180);
+ if (dir == Direction::SOUTH) corners[i]->yRot(180 * PI / 180);
+ if (dir == Direction::WEST) corners[i]->yRot(90 * PI / 180);
+ if (dir == Direction::EAST) corners[i]->yRot(-90 * PI / 180);
- corners[i]->x += x + 0.5;
- corners[i]->y += y + 5 / 16.0f;
- corners[i]->z += z + 0.5;
- }
+ corners[i]->x += x + 0.5;
+ corners[i]->y += y + 5 / 16.0f;
+ corners[i]->z += z + 0.5;
+ }
- Vec3 *c0 = NULL, *c1 = NULL, *c2 = NULL, *c3 = NULL;
- int stickX0 = 7;
- int stickX1 = 9;
- int stickY0 = 9;
- int stickY1 = 16;
+ Vec3 *c0 = NULL, *c1 = NULL, *c2 = NULL, *c3 = NULL;
+ int stickX0 = 7;
+ int stickX1 = 9;
+ int stickY0 = 9;
+ int stickY1 = 16;
- for (int i = 0; i < 6; i++)
- {
- if (i == 0)
- {
- c0 = corners[0];
- c1 = corners[1];
- c2 = corners[2];
- c3 = corners[3];
- u0 = tex->getU(stickX0);
- v0 = tex->getV(stickY0);
- u1 = tex->getU(stickX1);
- v1 = tex->getV(stickY0 + 2);
- }
- else if (i == 1)
- {
- c0 = corners[7];
- c1 = corners[6];
- c2 = corners[5];
- c3 = corners[4];
- }
- else if (i == 2)
- {
- c0 = corners[1];
- c1 = corners[0];
- c2 = corners[4];
- c3 = corners[5];
- u0 = tex->getU(stickX0);
- v0 = tex->getV(stickY0);
- u1 = tex->getU(stickX1);
- v1 = tex->getV(stickY1);
- }
- else if (i == 3)
- {
- c0 = corners[2];
- c1 = corners[1];
- c2 = corners[5];
- c3 = corners[6];
- }
- else if (i == 4)
- {
- c0 = corners[3];
- c1 = corners[2];
- c2 = corners[6];
- c3 = corners[7];
- }
- else if (i == 5)
- {
- c0 = corners[0];
- c1 = corners[3];
- c2 = corners[7];
- c3 = corners[4];
- }
- t->vertexUV(c0->x, c0->y, c0->z, u0, v1);
- t->vertexUV(c1->x, c1->y, c1->z, u1, v1);
- t->vertexUV(c2->x, c2->y, c2->z, u1, v0);
- t->vertexUV(c3->x, c3->y, c3->z, u0, v0);
- }
+ for (int i = 0; i < 6; i++) {
+ if (i == 0) {
+ c0 = corners[0];
+ c1 = corners[1];
+ c2 = corners[2];
+ c3 = corners[3];
+ u0 = tex->getU(stickX0);
+ v0 = tex->getV(stickY0);
+ u1 = tex->getU(stickX1);
+ v1 = tex->getV(stickY0 + 2);
+ } else if (i == 1) {
+ c0 = corners[7];
+ c1 = corners[6];
+ c2 = corners[5];
+ c3 = corners[4];
+ } else if (i == 2) {
+ c0 = corners[1];
+ c1 = corners[0];
+ c2 = corners[4];
+ c3 = corners[5];
+ u0 = tex->getU(stickX0);
+ v0 = tex->getV(stickY0);
+ u1 = tex->getU(stickX1);
+ v1 = tex->getV(stickY1);
+ } else if (i == 3) {
+ c0 = corners[2];
+ c1 = corners[1];
+ c2 = corners[5];
+ c3 = corners[6];
+ } else if (i == 4) {
+ c0 = corners[3];
+ c1 = corners[2];
+ c2 = corners[6];
+ c3 = corners[7];
+ } else if (i == 5) {
+ c0 = corners[0];
+ c1 = corners[3];
+ c2 = corners[7];
+ c3 = corners[4];
+ }
+ t->vertexUV(c0->x, c0->y, c0->z, u0, v1);
+ t->vertexUV(c1->x, c1->y, c1->z, u1, v1);
+ t->vertexUV(c2->x, c2->y, c2->z, u1, v0);
+ t->vertexUV(c3->x, c3->y, c3->z, u0, v0);
+ }
+ float hoopWidth = 1.5f / 16.0f;
+ float hoopHeight = 1.5f / 16.0f;
+ float hoopLength = 0.5f / 16.0f;
+ corners[0] = Vec3::newTemp(-hoopWidth, -0, -hoopHeight);
+ corners[1] = Vec3::newTemp(+hoopWidth, -0, -hoopHeight);
+ corners[2] = Vec3::newTemp(+hoopWidth, -0, +hoopHeight);
+ corners[3] = Vec3::newTemp(-hoopWidth, -0, +hoopHeight);
+ corners[4] = Vec3::newTemp(-hoopWidth, +hoopLength, -hoopHeight);
+ corners[5] = Vec3::newTemp(+hoopWidth, +hoopLength, -hoopHeight);
+ corners[6] = Vec3::newTemp(+hoopWidth, +hoopLength, +hoopHeight);
+ corners[7] = Vec3::newTemp(-hoopWidth, +hoopLength, +hoopHeight);
- float hoopWidth = 1.5f / 16.0f;
- float hoopHeight = 1.5f / 16.0f;
- float hoopLength = 0.5f / 16.0f;
- corners[0] = Vec3::newTemp(-hoopWidth, -0, -hoopHeight);
- corners[1] = Vec3::newTemp(+hoopWidth, -0, -hoopHeight);
- corners[2] = Vec3::newTemp(+hoopWidth, -0, +hoopHeight);
- corners[3] = Vec3::newTemp(-hoopWidth, -0, +hoopHeight);
- corners[4] = Vec3::newTemp(-hoopWidth, +hoopLength, -hoopHeight);
- corners[5] = Vec3::newTemp(+hoopWidth, +hoopLength, -hoopHeight);
- corners[6] = Vec3::newTemp(+hoopWidth, +hoopLength, +hoopHeight);
- corners[7] = Vec3::newTemp(-hoopWidth, +hoopLength, +hoopHeight);
+ for (int i = 0; i < 8; i++) {
+ corners[i]->z += 3.5f / 16.0f;
- for (int i = 0; i < 8; i++)
- {
- corners[i]->z += 3.5f / 16.0f;
+ if (powered) {
+ corners[i]->y -= 1.5 / 16.0f;
+ corners[i]->z -= 2.6 / 16.0f;
+ corners[i]->xRot(0 * PI / 180);
+ } else if (attached) {
+ corners[i]->y += 0.25 / 16.0f;
+ corners[i]->z -= 2.75 / 16.0f;
+ corners[i]->xRot(10 * PI / 180);
+ } else {
+ corners[i]->xRot(50 * PI / 180);
+ }
- if (powered)
- {
- corners[i]->y -= 1.5 / 16.0f;
- corners[i]->z -= 2.6 / 16.0f;
- corners[i]->xRot(0 * PI / 180);
- }
- else if (attached)
- {
- corners[i]->y += 0.25 / 16.0f;
- corners[i]->z -= 2.75 / 16.0f;
- corners[i]->xRot(10 * PI / 180);
- }
- else
- {
- corners[i]->xRot(50 * PI / 180);
- }
+ if (dir == Direction::NORTH) corners[i]->yRot(0 * PI / 180);
+ if (dir == Direction::SOUTH) corners[i]->yRot(180 * PI / 180);
+ if (dir == Direction::WEST) corners[i]->yRot(90 * PI / 180);
+ if (dir == Direction::EAST) corners[i]->yRot(-90 * PI / 180);
- if (dir == Direction::NORTH) corners[i]->yRot(0 * PI / 180);
- if (dir == Direction::SOUTH) corners[i]->yRot(180 * PI / 180);
- if (dir == Direction::WEST) corners[i]->yRot(90 * PI / 180);
- if (dir == Direction::EAST) corners[i]->yRot(-90 * PI / 180);
+ corners[i]->x += x + 0.5;
+ corners[i]->y += y + 5 / 16.0f;
+ corners[i]->z += z + 0.5;
+ }
- corners[i]->x += x + 0.5;
- corners[i]->y += y + 5 / 16.0f;
- corners[i]->z += z + 0.5;
- }
+ int hoopX0 = 5;
+ int hoopX1 = 11;
+ int hoopY0 = 3;
+ int hoopY1 = 9;
- int hoopX0 = 5;
- int hoopX1 = 11;
- int hoopY0 = 3;
- int hoopY1 = 9;
+ for (int i = 0; i < 6; i++) {
+ if (i == 0) {
+ c0 = corners[0];
+ c1 = corners[1];
+ c2 = corners[2];
+ c3 = corners[3];
+ u0 = tex->getU(hoopX0);
+ v0 = tex->getV(hoopY0);
+ u1 = tex->getU(hoopX1);
+ v1 = tex->getV(hoopY1);
+ } else if (i == 1) {
+ c0 = corners[7];
+ c1 = corners[6];
+ c2 = corners[5];
+ c3 = corners[4];
+ } else if (i == 2) {
+ c0 = corners[1];
+ c1 = corners[0];
+ c2 = corners[4];
+ c3 = corners[5];
+ u0 = tex->getU(hoopX0);
+ v0 = tex->getV(hoopY0);
+ u1 = tex->getU(hoopX1);
+ v1 = tex->getV(hoopY0 + 2);
+ } else if (i == 3) {
+ c0 = corners[2];
+ c1 = corners[1];
+ c2 = corners[5];
+ c3 = corners[6];
+ } else if (i == 4) {
+ c0 = corners[3];
+ c1 = corners[2];
+ c2 = corners[6];
+ c3 = corners[7];
+ } else if (i == 5) {
+ c0 = corners[0];
+ c1 = corners[3];
+ c2 = corners[7];
+ c3 = corners[4];
+ }
+ t->vertexUV(c0->x, c0->y, c0->z, u0, v1);
+ t->vertexUV(c1->x, c1->y, c1->z, u1, v1);
+ t->vertexUV(c2->x, c2->y, c2->z, u1, v0);
+ t->vertexUV(c3->x, c3->y, c3->z, u0, v0);
+ }
- for (int i = 0; i < 6; i++)
- {
- if (i == 0)
- {
- c0 = corners[0];
- c1 = corners[1];
- c2 = corners[2];
- c3 = corners[3];
- u0 = tex->getU(hoopX0);
- v0 = tex->getV(hoopY0);
- u1 = tex->getU(hoopX1);
- v1 = tex->getV(hoopY1);
- }
- else if (i == 1)
- {
- c0 = corners[7];
- c1 = corners[6];
- c2 = corners[5];
- c3 = corners[4];
- }
- else if (i == 2)
- {
- c0 = corners[1];
- c1 = corners[0];
- c2 = corners[4];
- c3 = corners[5];
- u0 = tex->getU(hoopX0);
- v0 = tex->getV(hoopY0);
- u1 = tex->getU(hoopX1);
- v1 = tex->getV(hoopY0 + 2);
- }
- else if (i == 3)
- {
- c0 = corners[2];
- c1 = corners[1];
- c2 = corners[5];
- c3 = corners[6];
- }
- else if (i == 4)
- {
- c0 = corners[3];
- c1 = corners[2];
- c2 = corners[6];
- c3 = corners[7];
- }
- else if (i == 5)
- {
- c0 = corners[0];
- c1 = corners[3];
- c2 = corners[7];
- c3 = corners[4];
- }
- t->vertexUV(c0->x, c0->y, c0->z, u0, v1);
- t->vertexUV(c1->x, c1->y, c1->z, u1, v1);
- t->vertexUV(c2->x, c2->y, c2->z, u1, v0);
- t->vertexUV(c3->x, c3->y, c3->z, u0, v0);
- }
+ if (attached) {
+ double hoopBottomY = corners[0]->y;
+ float width = 0.5f / 16.0f;
+ float top = 0.5f - (width / 2);
+ float bottom = top + width;
+ Icon* wireTex = getTexture(Tile::tripWire);
+ double wireX0 = tex->getU0();
+ double wireY0 = tex->getV(attached ? 2 : 0);
+ double wireX1 = tex->getU1();
+ double wireY1 = tex->getV(attached ? 4 : 2);
+ double floating = (suspended ? 3.5f : 1.5f) / 16.0;
- if (attached)
- {
- double hoopBottomY = corners[0]->y;
- float width = 0.5f / 16.0f;
- float top = 0.5f - (width / 2);
- float bottom = top + width;
- Icon *wireTex = getTexture(Tile::tripWire);
- double wireX0 = tex->getU0();
- double wireY0 = tex->getV(attached ? 2 : 0);
- double wireX1 = tex->getU1();
- double wireY1 = tex->getV(attached ? 4 : 2);
- double floating = (suspended ? 3.5f : 1.5f) / 16.0;
+ brightness = tt->getBrightness(level, x, y, z) * 0.75f;
+ t->color(brightness, brightness, brightness);
- brightness = tt->getBrightness(level, x, y, z) * 0.75f;
- t->color(brightness, brightness, brightness);
+ if (dir == Direction::NORTH) {
+ t->vertexUV(x + top, y + floating, z + 0.25, wireX0, wireY0);
+ t->vertexUV(x + bottom, y + floating, z + 0.25, wireX0, wireY1);
+ t->vertexUV(x + bottom, y + floating, z, wireX1, wireY1);
+ t->vertexUV(x + top, y + floating, z, wireX1, wireY0);
- if (dir == Direction::NORTH)
- {
- t->vertexUV(x + top, y + floating, z + 0.25, wireX0, wireY0);
- t->vertexUV(x + bottom, y + floating, z + 0.25, wireX0, wireY1);
- t->vertexUV(x + bottom, y + floating, z, wireX1, wireY1);
- t->vertexUV(x + top, y + floating, z, wireX1, wireY0);
+ t->vertexUV(x + top, hoopBottomY, z + 0.5, wireX0, wireY0);
+ t->vertexUV(x + bottom, hoopBottomY, z + 0.5, wireX0, wireY1);
+ t->vertexUV(x + bottom, y + floating, z + 0.25, wireX1, wireY1);
+ t->vertexUV(x + top, y + floating, z + 0.25, wireX1, wireY0);
+ } else if (dir == Direction::SOUTH) {
+ t->vertexUV(x + top, y + floating, z + 0.75, wireX0, wireY0);
+ t->vertexUV(x + bottom, y + floating, z + 0.75, wireX0, wireY1);
+ t->vertexUV(x + bottom, hoopBottomY, z + 0.5, wireX1, wireY1);
+ t->vertexUV(x + top, hoopBottomY, z + 0.5, wireX1, wireY0);
- t->vertexUV(x + top, hoopBottomY, z + 0.5, wireX0, wireY0);
- t->vertexUV(x + bottom, hoopBottomY, z + 0.5, wireX0, wireY1);
- t->vertexUV(x + bottom, y + floating, z + 0.25, wireX1, wireY1);
- t->vertexUV(x + top, y + floating, z + 0.25, wireX1, wireY0);
- }
- else if (dir == Direction::SOUTH)
- {
- t->vertexUV(x + top, y + floating, z + 0.75, wireX0, wireY0);
- t->vertexUV(x + bottom, y + floating, z + 0.75, wireX0, wireY1);
- t->vertexUV(x + bottom, hoopBottomY, z + 0.5, wireX1, wireY1);
- t->vertexUV(x + top, hoopBottomY, z + 0.5, wireX1, wireY0);
+ t->vertexUV(x + top, y + floating, z + 1, wireX0, wireY0);
+ t->vertexUV(x + bottom, y + floating, z + 1, wireX0, wireY1);
+ t->vertexUV(x + bottom, y + floating, z + 0.75, wireX1, wireY1);
+ t->vertexUV(x + top, y + floating, z + 0.75, wireX1, wireY0);
+ } else if (dir == Direction::WEST) {
+ t->vertexUV(x, y + floating, z + bottom, wireX0, wireY1);
+ t->vertexUV(x + 0.25, y + floating, z + bottom, wireX1, wireY1);
+ t->vertexUV(x + 0.25, y + floating, z + top, wireX1, wireY0);
+ t->vertexUV(x, y + floating, z + top, wireX0, wireY0);
- t->vertexUV(x + top, y + floating, z + 1, wireX0, wireY0);
- t->vertexUV(x + bottom, y + floating, z + 1, wireX0, wireY1);
- t->vertexUV(x + bottom, y + floating, z + 0.75, wireX1, wireY1);
- t->vertexUV(x + top, y + floating, z + 0.75, wireX1, wireY0);
- }
- else if (dir == Direction::WEST)
- {
- t->vertexUV(x, y + floating, z + bottom, wireX0, wireY1);
- t->vertexUV(x + 0.25, y + floating, z + bottom, wireX1, wireY1);
- t->vertexUV(x + 0.25, y + floating, z + top, wireX1, wireY0);
- t->vertexUV(x, y + floating, z + top, wireX0, wireY0);
+ t->vertexUV(x + 0.25, y + floating, z + bottom, wireX0, wireY1);
+ t->vertexUV(x + 0.5, hoopBottomY, z + bottom, wireX1, wireY1);
+ t->vertexUV(x + 0.5, hoopBottomY, z + top, wireX1, wireY0);
+ t->vertexUV(x + 0.25, y + floating, z + top, wireX0, wireY0);
+ } else {
+ t->vertexUV(x + 0.5, hoopBottomY, z + bottom, wireX0, wireY1);
+ t->vertexUV(x + 0.75, y + floating, z + bottom, wireX1, wireY1);
+ t->vertexUV(x + 0.75, y + floating, z + top, wireX1, wireY0);
+ t->vertexUV(x + 0.5, hoopBottomY, z + top, wireX0, wireY0);
- t->vertexUV(x + 0.25, y + floating, z + bottom, wireX0, wireY1);
- t->vertexUV(x + 0.5, hoopBottomY, z + bottom, wireX1, wireY1);
- t->vertexUV(x + 0.5, hoopBottomY, z + top, wireX1, wireY0);
- t->vertexUV(x + 0.25, y + floating, z + top, wireX0, wireY0);
- }
- else
- {
- t->vertexUV(x + 0.5, hoopBottomY, z + bottom, wireX0, wireY1);
- t->vertexUV(x + 0.75, y + floating, z + bottom, wireX1, wireY1);
- t->vertexUV(x + 0.75, y + floating, z + top, wireX1, wireY0);
- t->vertexUV(x + 0.5, hoopBottomY, z + top, wireX0, wireY0);
+ t->vertexUV(x + 0.75, y + floating, z + bottom, wireX0, wireY1);
+ t->vertexUV(x + 1, y + floating, z + bottom, wireX1, wireY1);
+ t->vertexUV(x + 1, y + floating, z + top, wireX1, wireY0);
+ t->vertexUV(x + 0.75, y + floating, z + top, wireX0, wireY0);
+ }
+ }
+#endif // #ifdef DISABLE_TESS_FUNCS
- t->vertexUV(x + 0.75, y + floating, z + bottom, wireX0, wireY1);
- t->vertexUV(x + 1, y + floating, z + bottom, wireX1, wireY1);
- t->vertexUV(x + 1, y + floating, z + top, wireX1, wireY0);
- t->vertexUV(x + 0.75, y + floating, z + top, wireX0, wireY0);
- }
- }
-#endif // #ifdef DISABLE_TESS_FUNCS
-
- return true;
+ return true;
}
-bool TileRenderer_SPU::tesselateTripwireInWorld(Tile_SPU *tt, int x, int y, int z)
-{
+bool TileRenderer_SPU::tesselateTripwireInWorld(Tile_SPU* tt, int x, int y,
+ int z) {
#ifdef DISABLE_TESS_FUNCS
- Tesselator *t = Tesselator::getInstance();
- Icon *tex = getTexture(tt, 0);
- int data = level->getData(x, y, z);
- bool attached = (data & TripWireTile::MASK_ATTACHED) == TripWireTile::MASK_ATTACHED;
- bool suspended = (data & TripWireTile::MASK_SUSPENDED) == TripWireTile::MASK_SUSPENDED;
+ Tesselator* t = Tesselator::getInstance();
+ Icon* tex = getTexture(tt, 0);
+ int data = level->getData(x, y, z);
+ bool attached =
+ (data & TripWireTile::MASK_ATTACHED) == TripWireTile::MASK_ATTACHED;
+ bool suspended =
+ (data & TripWireTile::MASK_SUSPENDED) == TripWireTile::MASK_SUSPENDED;
- if (hasFixedTexture()) tex = fixedTexture;
+ if (hasFixedTexture()) tex = fixedTexture;
- float brightness;
- if (SharedConstants::TEXTURE_LIGHTING)
- {
- t->tex2(tt->getLightColor(level, x, y, z));
- }
- brightness = tt->getBrightness(level, x, y, z) * 0.75f;
- t->color(brightness, brightness, brightness);
+ float brightness;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ }
+ brightness = tt->getBrightness(level, x, y, z) * 0.75f;
+ t->color(brightness, brightness, brightness);
- double wireX0 = tex->getU0();
- double wireY0 = tex->getV(attached ? 2 : 0);
- double wireX1 = tex->getU1();
- double wireY1 = tex->getV(attached ? 4 : 2);
- double floating = (suspended ? 3.5f : 1.5f) / 16.0;
+ double wireX0 = tex->getU0();
+ double wireY0 = tex->getV(attached ? 2 : 0);
+ double wireX1 = tex->getU1();
+ double wireY1 = tex->getV(attached ? 4 : 2);
+ double floating = (suspended ? 3.5f : 1.5f) / 16.0;
- bool w = TripWireTile::shouldConnectTo(level, x, y, z, data, Direction::WEST);
- bool e = TripWireTile::shouldConnectTo(level, x, y, z, data, Direction::EAST);
- bool n = TripWireTile::shouldConnectTo(level, x, y, z, data, Direction::NORTH);
- bool s = TripWireTile::shouldConnectTo(level, x, y, z, data, Direction::SOUTH);
+ bool w =
+ TripWireTile::shouldConnectTo(level, x, y, z, data, Direction::WEST);
+ bool e =
+ TripWireTile::shouldConnectTo(level, x, y, z, data, Direction::EAST);
+ bool n =
+ TripWireTile::shouldConnectTo(level, x, y, z, data, Direction::NORTH);
+ bool s =
+ TripWireTile::shouldConnectTo(level, x, y, z, data, Direction::SOUTH);
- float width = 0.5f / 16.0f;
- float top = 0.5f - (width / 2);
- float bottom = top + width;
+ float width = 0.5f / 16.0f;
+ float top = 0.5f - (width / 2);
+ float bottom = top + width;
- if (!n && !e && !s && !w)
- {
- n = true;
- s = true;
- }
+ if (!n && !e && !s && !w) {
+ n = true;
+ s = true;
+ }
- if (n)
- {
- t->vertexUV(x + top, y + floating, z + 0.25, wireX0, wireY0);
- t->vertexUV(x + bottom, y + floating, z + 0.25, wireX0, wireY1);
- t->vertexUV(x + bottom, y + floating, z, wireX1, wireY1);
- t->vertexUV(x + top, y + floating, z, wireX1, wireY0);
+ if (n) {
+ t->vertexUV(x + top, y + floating, z + 0.25, wireX0, wireY0);
+ t->vertexUV(x + bottom, y + floating, z + 0.25, wireX0, wireY1);
+ t->vertexUV(x + bottom, y + floating, z, wireX1, wireY1);
+ t->vertexUV(x + top, y + floating, z, wireX1, wireY0);
- t->vertexUV(x + top, y + floating, z, wireX1, wireY0);
- t->vertexUV(x + bottom, y + floating, z, wireX1, wireY1);
- t->vertexUV(x + bottom, y + floating, z + 0.25, wireX0, wireY1);
- t->vertexUV(x + top, y + floating, z + 0.25, wireX0, wireY0);
- }
- if (n || (s && !e && !w))
- {
- t->vertexUV(x + top, y + floating, z + 0.5, wireX0, wireY0);
- t->vertexUV(x + bottom, y + floating, z + 0.5, wireX0, wireY1);
- t->vertexUV(x + bottom, y + floating, z + 0.25, wireX1, wireY1);
- t->vertexUV(x + top, y + floating, z + 0.25, wireX1, wireY0);
+ t->vertexUV(x + top, y + floating, z, wireX1, wireY0);
+ t->vertexUV(x + bottom, y + floating, z, wireX1, wireY1);
+ t->vertexUV(x + bottom, y + floating, z + 0.25, wireX0, wireY1);
+ t->vertexUV(x + top, y + floating, z + 0.25, wireX0, wireY0);
+ }
+ if (n || (s && !e && !w)) {
+ t->vertexUV(x + top, y + floating, z + 0.5, wireX0, wireY0);
+ t->vertexUV(x + bottom, y + floating, z + 0.5, wireX0, wireY1);
+ t->vertexUV(x + bottom, y + floating, z + 0.25, wireX1, wireY1);
+ t->vertexUV(x + top, y + floating, z + 0.25, wireX1, wireY0);
- t->vertexUV(x + top, y + floating, z + 0.25, wireX1, wireY0);
- t->vertexUV(x + bottom, y + floating, z + 0.25, wireX1, wireY1);
- t->vertexUV(x + bottom, y + floating, z + 0.5, wireX0, wireY1);
- t->vertexUV(x + top, y + floating, z + 0.5, wireX0, wireY0);
- }
- if (s || (n && !e && !w))
- {
- t->vertexUV(x + top, y + floating, z + 0.75, wireX0, wireY0);
- t->vertexUV(x + bottom, y + floating, z + 0.75, wireX0, wireY1);
- t->vertexUV(x + bottom, y + floating, z + 0.5, wireX1, wireY1);
- t->vertexUV(x + top, y + floating, z + 0.5, wireX1, wireY0);
+ t->vertexUV(x + top, y + floating, z + 0.25, wireX1, wireY0);
+ t->vertexUV(x + bottom, y + floating, z + 0.25, wireX1, wireY1);
+ t->vertexUV(x + bottom, y + floating, z + 0.5, wireX0, wireY1);
+ t->vertexUV(x + top, y + floating, z + 0.5, wireX0, wireY0);
+ }
+ if (s || (n && !e && !w)) {
+ t->vertexUV(x + top, y + floating, z + 0.75, wireX0, wireY0);
+ t->vertexUV(x + bottom, y + floating, z + 0.75, wireX0, wireY1);
+ t->vertexUV(x + bottom, y + floating, z + 0.5, wireX1, wireY1);
+ t->vertexUV(x + top, y + floating, z + 0.5, wireX1, wireY0);
- t->vertexUV(x + top, y + floating, z + 0.5, wireX1, wireY0);
- t->vertexUV(x + bottom, y + floating, z + 0.5, wireX1, wireY1);
- t->vertexUV(x + bottom, y + floating, z + 0.75, wireX0, wireY1);
- t->vertexUV(x + top, y + floating, z + 0.75, wireX0, wireY0);
- }
- if (s)
- {
- t->vertexUV(x + top, y + floating, z + 1, wireX0, wireY0);
- t->vertexUV(x + bottom, y + floating, z + 1, wireX0, wireY1);
- t->vertexUV(x + bottom, y + floating, z + 0.75, wireX1, wireY1);
- t->vertexUV(x + top, y + floating, z + 0.75, wireX1, wireY0);
+ t->vertexUV(x + top, y + floating, z + 0.5, wireX1, wireY0);
+ t->vertexUV(x + bottom, y + floating, z + 0.5, wireX1, wireY1);
+ t->vertexUV(x + bottom, y + floating, z + 0.75, wireX0, wireY1);
+ t->vertexUV(x + top, y + floating, z + 0.75, wireX0, wireY0);
+ }
+ if (s) {
+ t->vertexUV(x + top, y + floating, z + 1, wireX0, wireY0);
+ t->vertexUV(x + bottom, y + floating, z + 1, wireX0, wireY1);
+ t->vertexUV(x + bottom, y + floating, z + 0.75, wireX1, wireY1);
+ t->vertexUV(x + top, y + floating, z + 0.75, wireX1, wireY0);
- t->vertexUV(x + top, y + floating, z + 0.75, wireX1, wireY0);
- t->vertexUV(x + bottom, y + floating, z + 0.75, wireX1, wireY1);
- t->vertexUV(x + bottom, y + floating, z + 1, wireX0, wireY1);
- t->vertexUV(x + top, y + floating, z + 1, wireX0, wireY0);
- }
+ t->vertexUV(x + top, y + floating, z + 0.75, wireX1, wireY0);
+ t->vertexUV(x + bottom, y + floating, z + 0.75, wireX1, wireY1);
+ t->vertexUV(x + bottom, y + floating, z + 1, wireX0, wireY1);
+ t->vertexUV(x + top, y + floating, z + 1, wireX0, wireY0);
+ }
- if (w)
- {
- t->vertexUV(x, y + floating, z + bottom, wireX0, wireY1);
- t->vertexUV(x + 0.25, y + floating, z + bottom, wireX1, wireY1);
- t->vertexUV(x + 0.25, y + floating, z + top, wireX1, wireY0);
- t->vertexUV(x, y + floating, z + top, wireX0, wireY0);
+ if (w) {
+ t->vertexUV(x, y + floating, z + bottom, wireX0, wireY1);
+ t->vertexUV(x + 0.25, y + floating, z + bottom, wireX1, wireY1);
+ t->vertexUV(x + 0.25, y + floating, z + top, wireX1, wireY0);
+ t->vertexUV(x, y + floating, z + top, wireX0, wireY0);
- t->vertexUV(x, y + floating, z + top, wireX0, wireY0);
- t->vertexUV(x + 0.25, y + floating, z + top, wireX1, wireY0);
- t->vertexUV(x + 0.25, y + floating, z + bottom, wireX1, wireY1);
- t->vertexUV(x, y + floating, z + bottom, wireX0, wireY1);
- }
- if (w || (e && !n && !s))
- {
- t->vertexUV(x + 0.25, y + floating, z + bottom, wireX0, wireY1);
- t->vertexUV(x + 0.5, y + floating, z + bottom, wireX1, wireY1);
- t->vertexUV(x + 0.5, y + floating, z + top, wireX1, wireY0);
- t->vertexUV(x + 0.25, y + floating, z + top, wireX0, wireY0);
+ t->vertexUV(x, y + floating, z + top, wireX0, wireY0);
+ t->vertexUV(x + 0.25, y + floating, z + top, wireX1, wireY0);
+ t->vertexUV(x + 0.25, y + floating, z + bottom, wireX1, wireY1);
+ t->vertexUV(x, y + floating, z + bottom, wireX0, wireY1);
+ }
+ if (w || (e && !n && !s)) {
+ t->vertexUV(x + 0.25, y + floating, z + bottom, wireX0, wireY1);
+ t->vertexUV(x + 0.5, y + floating, z + bottom, wireX1, wireY1);
+ t->vertexUV(x + 0.5, y + floating, z + top, wireX1, wireY0);
+ t->vertexUV(x + 0.25, y + floating, z + top, wireX0, wireY0);
- t->vertexUV(x + 0.25, y + floating, z + top, wireX0, wireY0);
- t->vertexUV(x + 0.5, y + floating, z + top, wireX1, wireY0);
- t->vertexUV(x + 0.5, y + floating, z + bottom, wireX1, wireY1);
- t->vertexUV(x + 0.25, y + floating, z + bottom, wireX0, wireY1);
- }
- if (e || (w && !n && !s))
- {
- t->vertexUV(x + 0.5, y + floating, z + bottom, wireX0, wireY1);
- t->vertexUV(x + 0.75, y + floating, z + bottom, wireX1, wireY1);
- t->vertexUV(x + 0.75, y + floating, z + top, wireX1, wireY0);
- t->vertexUV(x + 0.5, y + floating, z + top, wireX0, wireY0);
+ t->vertexUV(x + 0.25, y + floating, z + top, wireX0, wireY0);
+ t->vertexUV(x + 0.5, y + floating, z + top, wireX1, wireY0);
+ t->vertexUV(x + 0.5, y + floating, z + bottom, wireX1, wireY1);
+ t->vertexUV(x + 0.25, y + floating, z + bottom, wireX0, wireY1);
+ }
+ if (e || (w && !n && !s)) {
+ t->vertexUV(x + 0.5, y + floating, z + bottom, wireX0, wireY1);
+ t->vertexUV(x + 0.75, y + floating, z + bottom, wireX1, wireY1);
+ t->vertexUV(x + 0.75, y + floating, z + top, wireX1, wireY0);
+ t->vertexUV(x + 0.5, y + floating, z + top, wireX0, wireY0);
- t->vertexUV(x + 0.5, y + floating, z + top, wireX0, wireY0);
- t->vertexUV(x + 0.75, y + floating, z + top, wireX1, wireY0);
- t->vertexUV(x + 0.75, y + floating, z + bottom, wireX1, wireY1);
- t->vertexUV(x + 0.5, y + floating, z + bottom, wireX0, wireY1);
- }
- if (e)
- {
- t->vertexUV(x + 0.75, y + floating, z + bottom, wireX0, wireY1);
- t->vertexUV(x + 1, y + floating, z + bottom, wireX1, wireY1);
- t->vertexUV(x + 1, y + floating, z + top, wireX1, wireY0);
- t->vertexUV(x + 0.75, y + floating, z + top, wireX0, wireY0);
+ t->vertexUV(x + 0.5, y + floating, z + top, wireX0, wireY0);
+ t->vertexUV(x + 0.75, y + floating, z + top, wireX1, wireY0);
+ t->vertexUV(x + 0.75, y + floating, z + bottom, wireX1, wireY1);
+ t->vertexUV(x + 0.5, y + floating, z + bottom, wireX0, wireY1);
+ }
+ if (e) {
+ t->vertexUV(x + 0.75, y + floating, z + bottom, wireX0, wireY1);
+ t->vertexUV(x + 1, y + floating, z + bottom, wireX1, wireY1);
+ t->vertexUV(x + 1, y + floating, z + top, wireX1, wireY0);
+ t->vertexUV(x + 0.75, y + floating, z + top, wireX0, wireY0);
- t->vertexUV(x + 0.75, y + floating, z + top, wireX0, wireY0);
- t->vertexUV(x + 1, y + floating, z + top, wireX1, wireY0);
- t->vertexUV(x + 1, y + floating, z + bottom, wireX1, wireY1);
- t->vertexUV(x + 0.75, y + floating, z + bottom, wireX0, wireY1);
- }
-#endif // DISABLE_TESS_FUNCS
+ t->vertexUV(x + 0.75, y + floating, z + top, wireX0, wireY0);
+ t->vertexUV(x + 1, y + floating, z + top, wireX1, wireY0);
+ t->vertexUV(x + 1, y + floating, z + bottom, wireX1, wireY1);
+ t->vertexUV(x + 0.75, y + floating, z + bottom, wireX0, wireY1);
+ }
+#endif // DISABLE_TESS_FUNCS
- return true;
+ return true;
}
+bool TileRenderer_SPU::tesselateFireInWorld(FireTile_SPU* tt, int x, int y,
+ int z) {
+ Tesselator_SPU* t = getTesselator();
+ Icon_SPU* firstTex = tt->getTextureLayer(0);
+ Icon_SPU* secondTex = tt->getTextureLayer(1);
+ Icon_SPU* tex = firstTex;
-bool TileRenderer_SPU::tesselateFireInWorld( FireTile_SPU* tt, int x, int y, int z )
-{
- Tesselator_SPU* t = getTesselator();
+ if (hasFixedTexture()) tex = fixedTexture;
- Icon_SPU *firstTex = tt->getTextureLayer(0);
- Icon_SPU *secondTex = tt->getTextureLayer(1);
- Icon_SPU *tex = firstTex;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->color(1.0f, 1.0f, 1.0f);
+ t->tex2(tt->getLightColor(level, x, y, z));
+ } else {
+ float br = tt->getBrightness(level, x, y, z);
+ t->color(br, br, br);
+ }
+ float u0 = tex->getU0();
+ float v0 = tex->getV0();
+ float u1 = tex->getU1();
+ float v1 = tex->getV1();
+ float h = 1.4f;
- if (hasFixedTexture()) tex = fixedTexture;
+ if (level->isSolidBlockingTile(x, y - 1, z) ||
+ FireTile_SPU::canBurn(level, x, y - 1, z)) {
+ float x0 = x + 0.5f + 0.2f;
+ float x1 = x + 0.5f - 0.2f;
+ float z0 = z + 0.5f + 0.2f;
+ float z1 = z + 0.5f - 0.2f;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->color( 1.0f, 1.0f, 1.0f );
- t->tex2( tt->getLightColor( level, x, y, z ) );
- }
- else
- {
- float br = tt->getBrightness( level, x, y, z );
- t->color( br, br, br );
- }
- float u0 = tex->getU0();
- float v0 = tex->getV0();
- float u1 = tex->getU1();
- float v1 = tex->getV1();
- float h = 1.4f;
+ float x0_ = x + 0.5f - 0.3f;
+ float x1_ = x + 0.5f + 0.3f;
+ float z0_ = z + 0.5f - 0.3f;
+ float z1_ = z + 0.5f + 0.3f;
- if ( level->isSolidBlockingTile( x, y - 1, z ) || FireTile_SPU::canBurn( level, x, y - 1, z ) )
- {
- float x0 = x + 0.5f + 0.2f;
- float x1 = x + 0.5f - 0.2f;
- float z0 = z + 0.5f + 0.2f;
- float z1 = z + 0.5f - 0.2f;
+ t->vertexUV((float)(x0_), (float)(y + h), (float)(z + 1), (float)(u1),
+ (float)(v0));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z + 1), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z + 0), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x0_), (float)(y + h), (float)(z + 0), (float)(u0),
+ (float)(v0));
- float x0_ = x + 0.5f - 0.3f;
- float x1_ = x + 0.5f + 0.3f;
- float z0_ = z + 0.5f - 0.3f;
- float z1_ = z + 0.5f + 0.3f;
+ t->vertexUV((float)(x1_), (float)(y + h), (float)(z + 0), (float)(u1),
+ (float)(v0));
+ t->vertexUV((float)(x1), (float)(y + 0), (float)(z + 0), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x1), (float)(y + 0), (float)(z + 1), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x1_), (float)(y + h), (float)(z + 1), (float)(u0),
+ (float)(v0));
- t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z + 1 ), ( float )( u1 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z + 1 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z + 0 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z + 0 ), ( float )( u0 ), ( float )( v0 ) );
+ tex = secondTex;
+ u0 = tex->getU0();
+ v0 = tex->getV0();
+ u1 = tex->getU1();
+ v1 = tex->getV1();
- t->vertexUV( ( float )( x1_ ), ( float )( y + h ), ( float )( z + 0 ), ( float )( u1 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z + 0 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z + 1 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1_ ), ( float )( y + h ), ( float )( z + 1 ), ( float )( u0 ), ( float )( v0 ) );
+ t->vertexUV((float)(x + 1), (float)(y + h), (float)(z1_), (float)(u1),
+ (float)(v0));
+ t->vertexUV((float)(x + 1), (float)(y + 0), (float)(z1), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x + 0), (float)(y + 0), (float)(z1), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x + 0), (float)(y + h), (float)(z1_), (float)(u0),
+ (float)(v0));
- tex = secondTex;
- u0 = tex->getU0();
- v0 = tex->getV0();
- u1 = tex->getU1();
- v1 = tex->getV1();
+ t->vertexUV((float)(x + 0), (float)(y + h), (float)(z0_), (float)(u1),
+ (float)(v0));
+ t->vertexUV((float)(x + 0), (float)(y + 0), (float)(z0), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x + 1), (float)(y + 0), (float)(z0), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x + 1), (float)(y + h), (float)(z0_), (float)(u0),
+ (float)(v0));
- t->vertexUV( ( float )( x + 1 ), ( float )( y + h ), ( float )( z1_ ), ( float )( u1 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 0 ), ( float )( y + h ), ( float )( z1_ ), ( float )( u0 ), ( float )( v0 ) );
+ x0 = x + 0.5f - 0.5f;
+ x1 = x + 0.5f + 0.5f;
+ z0 = z + 0.5f - 0.5f;
+ z1 = z + 0.5f + 0.5f;
- t->vertexUV( ( float )( x + 0 ), ( float )( y + h ), ( float )( z0_ ), ( float )( u1 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 1 ), ( float )( y + h ), ( float )( z0_ ), ( float )( u0 ), ( float )( v0 ) );
+ x0_ = x + 0.5f - 0.4f;
+ x1_ = x + 0.5f + 0.4f;
+ z0_ = z + 0.5f - 0.4f;
+ z1_ = z + 0.5f + 0.4f;
- x0 = x + 0.5f - 0.5f;
- x1 = x + 0.5f + 0.5f;
- z0 = z + 0.5f - 0.5f;
- z1 = z + 0.5f + 0.5f;
+ t->vertexUV((float)(x0_), (float)(y + h), (float)(z + 0), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z + 0), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z + 1), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x0_), (float)(y + h), (float)(z + 1), (float)(u1),
+ (float)(v0));
- x0_ = x + 0.5f - 0.4f;
- x1_ = x + 0.5f + 0.4f;
- z0_ = z + 0.5f - 0.4f;
- z1_ = z + 0.5f + 0.4f;
+ t->vertexUV((float)(x1_), (float)(y + h), (float)(z + 1), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x1), (float)(y + 0), (float)(z + 1), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x1), (float)(y + 0), (float)(z + 0), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x1_), (float)(y + h), (float)(z + 0), (float)(u1),
+ (float)(v0));
- t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z + 0 ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z + 0 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z + 1 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z + 1 ), ( float )( u1 ), ( float )( v0 ) );
+ tex = firstTex;
+ u0 = tex->getU0();
+ v0 = tex->getV0();
+ u1 = tex->getU1();
+ v1 = tex->getV1();
- t->vertexUV( ( float )( x1_ ), ( float )( y + h ), ( float )( z + 1 ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z + 1 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z + 0 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1_ ), ( float )( y + h ), ( float )( z + 0 ), ( float )( u1 ), ( float )( v0 ) );
+ t->vertexUV((float)(x + 0), (float)(y + h), (float)(z1_), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x + 0), (float)(y + 0), (float)(z1), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x + 1), (float)(y + 0), (float)(z1), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x + 1), (float)(y + h), (float)(z1_), (float)(u1),
+ (float)(v0));
- tex = firstTex;
- u0 = tex->getU0();
- v0 = tex->getV0();
- u1 = tex->getU1();
- v1 = tex->getV1();
+ t->vertexUV((float)(x + 1), (float)(y + h), (float)(z0_), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x + 1), (float)(y + 0), (float)(z0), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x + 0), (float)(y + 0), (float)(z0), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x + 0), (float)(y + h), (float)(z0_), (float)(u1),
+ (float)(v0));
+ } else {
+ float r = 0.2f;
+ float yo = 1 / 16.0f;
+ if (((x + y + z) & 1) == 1) {
+ tex = secondTex;
+ u0 = tex->getU0();
+ v0 = tex->getV0();
+ u1 = tex->getU1();
+ v1 = tex->getV1();
+ }
+ if (((x / 2 + y / 2 + z / 2) & 1) == 1) {
+ float tmp = u1;
+ u1 = u0;
+ u0 = tmp;
+ }
+ if (FireTile_SPU::canBurn(level, x - 1, y, z)) {
+ t->vertexUV((float)(x + r), (float)(y + h + yo), (float)(z + 1.0f),
+ (float)(u1), (float)(v0));
+ t->vertexUV((float)(x + 0.0f), (float)(y + 0.0f + yo),
+ (float)(z + 1.0f), (float)(u1), (float)(v1));
+ t->vertexUV((float)(x + 0.0f), (float)(y + 0.0f + yo),
+ (float)(z + 0.0f), (float)(u0), (float)(v1));
+ t->vertexUV((float)(x + r), (float)(y + h + yo), (float)(z + 0.0f),
+ (float)(u0), (float)(v0));
- t->vertexUV( ( float )( x + 0 ), ( float )( y + h ), ( float )( z1_ ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 1 ), ( float )( y + h ), ( float )( z1_ ), ( float )( u1 ), ( float )( v0 ) );
+ t->vertexUV((float)(x + r), (float)(y + h + yo), (float)(z + 0.0f),
+ (float)(u0), (float)(v0));
+ t->vertexUV((float)(x + 0.0f), (float)(y + 0.0f + yo),
+ (float)(z + 0.0f), (float)(u0), (float)(v1));
+ t->vertexUV((float)(x + 0.0f), (float)(y + 0.0f + yo),
+ (float)(z + 1.0f), (float)(u1), (float)(v1));
+ t->vertexUV((float)(x + r), (float)(y + h + yo), (float)(z + 1.0f),
+ (float)(u1), (float)(v0));
+ }
+ if (FireTile_SPU::canBurn(level, x + 1, y, z)) {
+ t->vertexUV((float)(x + 1 - r), (float)(y + h + yo),
+ (float)(z + 0.0f), (float)(u0), (float)(v0));
+ t->vertexUV((float)(x + 1 - 0), (float)(y + 0 + yo),
+ (float)(z + 0.0f), (float)(u0), (float)(v1));
+ t->vertexUV((float)(x + 1 - 0), (float)(y + 0 + yo),
+ (float)(z + 1.0f), (float)(u1), (float)(v1));
+ t->vertexUV((float)(x + 1 - r), (float)(y + h + yo),
+ (float)(z + 1.0f), (float)(u1), (float)(v0));
- t->vertexUV( ( float )( x + 1 ), ( float )( y + h ), ( float )( z0_ ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 0 ), ( float )( y + h ), ( float )( z0_ ), ( float )( u1 ), ( float )( v0 ) );
- }
- else
- {
- float r = 0.2f;
- float yo = 1 / 16.0f;
- if ( ( ( x + y + z ) & 1 ) == 1 )
- {
- tex = secondTex;
- u0 = tex->getU0();
- v0 = tex->getV0();
- u1 = tex->getU1();
- v1 = tex->getV1();
- }
- if ( ( ( x / 2 + y / 2 + z / 2 ) & 1 ) == 1 )
- {
- float tmp = u1;
- u1 = u0;
- u0 = tmp;
- }
- if ( FireTile_SPU::canBurn( level, x - 1, y, z ) )
- {
- t->vertexUV( ( float )( x + r ), ( float )( y + h + yo ), ( float )( z +
- 1.0f ), ( float )( u1 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y + 0.0f + yo ), ( float )( z +
- 1.0f ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y + 0.0f + yo ), ( float )( z +
- 0.0f ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + r ), ( float )( y + h + yo ), ( float )( z +
- 0.0f ), ( float )( u0 ), ( float )( v0 ) );
+ t->vertexUV((float)(x + 1.0f - r), (float)(y + h + yo),
+ (float)(z + 1.0f), (float)(u1), (float)(v0));
+ t->vertexUV((float)(x + 1.0f - 0.0f), (float)(y + 0.0f + yo),
+ (float)(z + 1.0f), (float)(u1), (float)(v1));
+ t->vertexUV((float)(x + 1.0f - 0), (float)(y + 0.0f + yo),
+ (float)(z + 0.0f), (float)(u0), (float)(v1));
+ t->vertexUV((float)(x + 1.0f - r), (float)(y + h + yo),
+ (float)(z + 0.0f), (float)(u0), (float)(v0));
+ }
+ if (FireTile_SPU::canBurn(level, x, y, z - 1)) {
+ t->vertexUV((float)(x + 0.0f), (float)(y + h + yo), (float)(z + r),
+ (float)(u1), (float)(v0));
+ t->vertexUV((float)(x + 0.0f), (float)(y + 0.0f + yo),
+ (float)(z + 0.0f), (float)(u1), (float)(v1));
+ t->vertexUV((float)(x + 1.0f), (float)(y + 0.0f + yo),
+ (float)(z + 0.0f), (float)(u0), (float)(v1));
+ t->vertexUV((float)(x + 1.0f), (float)(y + h + yo), (float)(z + r),
+ (float)(u0), (float)(v0));
- t->vertexUV( ( float )( x + r ), ( float )( y + h + yo ), ( float )( z +
- 0.0f ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y + 0.0f + yo ), ( float )( z +
- 0.0f ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y + 0.0f + yo ), ( float )( z +
- 1.0f ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + r ), ( float )( y + h + yo ), ( float )( z +
- 1.0f ), ( float )( u1 ), ( float )( v0 ) );
- }
- if ( FireTile_SPU::canBurn( level, x + 1, y, z ) )
- {
- t->vertexUV( ( float )( x + 1 - r ), ( float )( y + h + yo ), ( float )( z +
- 0.0f ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 1 - 0 ), ( float )( y + 0 + yo ), ( float )( z +
- 0.0f ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 1 - 0 ), ( float )( y + 0 + yo ), ( float )( z +
- 1.0f ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 1 - r ), ( float )( y + h + yo ), ( float )( z +
- 1.0f ), ( float )( u1 ), ( float )( v0 ) );
+ t->vertexUV((float)(x + 1.0f), (float)(y + h + yo), (float)(z + r),
+ (float)(u0), (float)(v0));
+ t->vertexUV((float)(x + 1.0f), (float)(y + 0.0f + yo),
+ (float)(z + 0.0f), (float)(u0), (float)(v1));
+ t->vertexUV((float)(x + 0.0f), (float)(y + 0.0f + yo),
+ (float)(z + 0.0f), (float)(u1), (float)(v1));
+ t->vertexUV((float)(x + 0.0f), (float)(y + h + yo), (float)(z + r),
+ (float)(u1), (float)(v0));
+ }
+ if (FireTile_SPU::canBurn(level, x, y, z + 1)) {
+ t->vertexUV((float)(x + 1.0f), (float)(y + h + yo),
+ (float)(z + 1.0f - r), (float)(u0), (float)(v0));
+ t->vertexUV((float)(x + 1.0f), (float)(y + 0.0f + yo),
+ (float)(z + 1.0f - 0.0f), (float)(u0), (float)(v1));
+ t->vertexUV((float)(x + 0.0f), (float)(y + 0.0f + yo),
+ (float)(z + 1.0f - 0.0f), (float)(u1), (float)(v1));
+ t->vertexUV((float)(x + 0.0f), (float)(y + h + yo),
+ (float)(z + 1.0f - r), (float)(u1), (float)(v0));
- t->vertexUV( ( float )( x + 1.0f - r ), ( float )( y + h + yo ), ( float )( z +
- 1.0f ), ( float )( u1 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 1.0f - 0.0f ), ( float )( y + 0.0f + yo ), ( float )( z +
- 1.0f ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 1.0f - 0 ), ( float )( y + 0.0f + yo ), ( float )( z +
- 0.0f ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 1.0f - r ), ( float )( y + h + yo ), ( float )( z +
- 0.0f ), ( float )( u0 ), ( float )( v0 ) );
- }
- if ( FireTile_SPU::canBurn( level, x, y, z - 1 ) )
- {
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y + h + yo ), ( float )( z +
- r ), ( float )( u1 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y + 0.0f + yo ), ( float )( z +
- 0.0f ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 1.0f ), ( float )( y + 0.0f + yo ), ( float )( z +
- 0.0f ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 1.0f ), ( float )( y + h + yo ), ( float )( z +
- r ), ( float )( u0 ), ( float )( v0 ) );
+ t->vertexUV((float)(x + 0.0f), (float)(y + h + yo),
+ (float)(z + 1.0f - r), (float)(u1), (float)(v0));
+ t->vertexUV((float)(x + 0.0f), (float)(y + 0.0f + yo),
+ (float)(z + 1.0f - 0.0f), (float)(u1), (float)(v1));
+ t->vertexUV((float)(x + 1.0f), (float)(y + 0.0f + yo),
+ (float)(z + 1.0f - 0.0f), (float)(u0), (float)(v1));
+ t->vertexUV((float)(x + 1.0f), (float)(y + h + yo),
+ (float)(z + 1.0f - r), (float)(u0), (float)(v0));
+ }
+ if (FireTile_SPU::canBurn(level, x, y + 1.0f, z)) {
+ float x0 = x + 0.5f + 0.5f;
+ float x1 = x + 0.5f - 0.5f;
+ float z0 = z + 0.5f + 0.5f;
+ float z1 = z + 0.5f - 0.5f;
- t->vertexUV( ( float )( x + 1.0f ), ( float )( y + h + yo ), ( float )( z +
- r ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 1.0f ), ( float )( y + 0.0f + yo ), ( float )( z +
- 0.0f ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y + 0.0f + yo ), ( float )( z +
- 0.0f ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y + h + yo ), ( float )( z +
- r ), ( float )( u1 ), ( float )( v0 ) );
- }
- if ( FireTile_SPU::canBurn( level, x, y, z + 1 ) )
- {
- t->vertexUV( ( float )( x + 1.0f ), ( float )( y + h + yo ), ( float )( z + 1.0f -
- r ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 1.0f ), ( float )( y + 0.0f + yo ), ( float )( z + 1.0f -
- 0.0f ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y + 0.0f + yo ), ( float )( z + 1.0f -
- 0.0f ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y + h + yo ), ( float )( z + 1.0f -
- r ), ( float )( u1 ), ( float )( v0 ) );
+ float x0_ = x + 0.5f - 0.5f;
+ float x1_ = x + 0.5f + 0.5f;
+ float z0_ = z + 0.5f - 0.5f;
+ float z1_ = z + 0.5f + 0.5f;
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y + h + yo ), ( float )( z + 1.0f -
- r ), ( float )( u1 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y + 0.0f + yo ), ( float )( z + 1.0f -
- 0.0f ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 1.0f ), ( float )( y + 0.0f + yo ), ( float )( z + 1.0f -
- 0.0f ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 1.0f ), ( float )( y + h + yo ), ( float )( z + 1.0f -
- r ), ( float )( u0 ), ( float )( v0 ) );
- }
- if ( FireTile_SPU::canBurn( level, x, y + 1.0f, z ) )
- {
- float x0 = x + 0.5f + 0.5f;
- float x1 = x + 0.5f - 0.5f;
- float z0 = z + 0.5f + 0.5f;
- float z1 = z + 0.5f - 0.5f;
+ tex = firstTex;
+ u0 = tex->getU0();
+ v0 = tex->getV0();
+ u1 = tex->getU1();
+ v1 = tex->getV1();
- float x0_ = x + 0.5f - 0.5f;
- float x1_ = x + 0.5f + 0.5f;
- float z0_ = z + 0.5f - 0.5f;
- float z1_ = z + 0.5f + 0.5f;
+ y += 1;
+ h = -0.2f;
- tex = firstTex;
- u0 = tex->getU0();
- v0 = tex->getV0();
- u1 = tex->getU1();
- v1 = tex->getV1();
+ if (((x + y + z) & 1) == 0) {
+ t->vertexUV((float)(x0_), (float)(y + h), (float)(z + 0),
+ (float)(u1), (float)(v0));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z + 0),
+ (float)(u1), (float)(v1));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z + 1),
+ (float)(u0), (float)(v1));
+ t->vertexUV((float)(x0_), (float)(y + h), (float)(z + 1),
+ (float)(u0), (float)(v0));
- y += 1;
- h = -0.2f;
+ tex = secondTex;
+ u0 = tex->getU0();
+ v0 = tex->getV0();
+ u1 = tex->getU1();
+ v1 = tex->getV1();
- if ( ( ( x + y + z ) & 1 ) == 0 )
- {
- t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z +
- 0 ), ( float )( u1 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z +
- 0 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z +
- 1 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0_ ), ( float )( y + h ), ( float )( z +
- 1 ), ( float )( u0 ), ( float )( v0 ) );
+ t->vertexUV((float)(x1_), (float)(y + h), (float)(z + 1.0f),
+ (float)(u1), (float)(v0));
+ t->vertexUV((float)(x1), (float)(y + 0.0f), (float)(z + 1.0f),
+ (float)(u1), (float)(v1));
+ t->vertexUV((float)(x1), (float)(y + 0.0f), (float)(z + 0),
+ (float)(u0), (float)(v1));
+ t->vertexUV((float)(x1_), (float)(y + h), (float)(z + 0),
+ (float)(u0), (float)(v0));
+ } else {
+ t->vertexUV((float)(x + 0.0f), (float)(y + h), (float)(z1_),
+ (float)(u1), (float)(v0));
+ t->vertexUV((float)(x + 0.0f), (float)(y + 0.0f), (float)(z1),
+ (float)(u1), (float)(v1));
+ t->vertexUV((float)(x + 1.0f), (float)(y + 0.0f), (float)(z1),
+ (float)(u0), (float)(v1));
+ t->vertexUV((float)(x + 1.0f), (float)(y + h), (float)(z1_),
+ (float)(u0), (float)(v0));
- tex = secondTex;
- u0 = tex->getU0();
- v0 = tex->getV0();
- u1 = tex->getU1();
- v1 = tex->getV1();
+ tex = secondTex;
+ u0 = tex->getU0();
+ v0 = tex->getV0();
+ u1 = tex->getU1();
+ v1 = tex->getV1();
- t->vertexUV( ( float )( x1_ ), ( float )( y + h ), ( float )( z +
- 1.0f ), ( float )( u1 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0.0f ), ( float )( z +
- 1.0f ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0.0f ), ( float )( z +
- 0 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1_ ), ( float )( y + h ), ( float )( z +
- 0 ), ( float )( u0 ), ( float )( v0 ) );
- }
- else
- {
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y +
- h ), ( float )( z1_ ), ( float )( u1 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y +
- 0.0f ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 1.0f ), ( float )( y +
- 0.0f ), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 1.0f ), ( float )( y +
- h ), ( float )( z1_ ), ( float )( u0 ), ( float )( v0 ) );
-
- tex = secondTex;
- u0 = tex->getU0();
- v0 = tex->getV0();
- u1 = tex->getU1();
- v1 = tex->getV1();
-
- t->vertexUV( ( float )( x + 1.0f ), ( float )( y +
- h ), ( float )( z0_ ), ( float )( u1 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 1.0f ), ( float )( y +
- 0.0f ), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y +
- 0.0f ), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y +
- h ), ( float )( z0_ ), ( float )( u0 ), ( float )( v0 ) );
- }
- }
- }
- return true;
+ t->vertexUV((float)(x + 1.0f), (float)(y + h), (float)(z0_),
+ (float)(u1), (float)(v0));
+ t->vertexUV((float)(x + 1.0f), (float)(y + 0.0f), (float)(z0),
+ (float)(u1), (float)(v1));
+ t->vertexUV((float)(x + 0.0f), (float)(y + 0.0f), (float)(z0),
+ (float)(u0), (float)(v1));
+ t->vertexUV((float)(x + 0.0f), (float)(y + h), (float)(z0_),
+ (float)(u0), (float)(v0));
+ }
+ }
+ }
+ return true;
}
-bool TileRenderer_SPU::tesselateDustInWorld( Tile_SPU* tt, int x, int y, int z )
-{
+bool TileRenderer_SPU::tesselateDustInWorld(Tile_SPU* tt, int x, int y, int z) {
#ifdef DISABLE_TESS_FUNCS
- Tesselator_SPU* t = getTesselator();
+ Tesselator_SPU* t = getTesselator();
- int data = level->getData( x, y, z );
- Icon_SPU *crossTexture = RedStoneDustTile_SPU::getTextureByName(RedStoneDustTile_SPU::TEXTURE_CROSS);
- Icon_SPU *lineTexture = RedStoneDustTile_SPU::getTextureByName(RedStoneDustTile_SPU::TEXTURE_LINE);
- Icon_SPU *crossTextureOverlay = RedStoneDustTile_SPU::getTextureByName(RedStoneDustTile_SPU::TEXTURE_CROSS_OVERLAY);
- Icon_SPU *lineTextureOverlay = RedStoneDustTile_SPU::getTextureByName(RedStoneDustTile_SPU::TEXTURE_LINE_OVERLAY);
+ int data = level->getData(x, y, z);
+ Icon_SPU* crossTexture = RedStoneDustTile_SPU::getTextureByName(
+ RedStoneDustTile_SPU::TEXTURE_CROSS);
+ Icon_SPU* lineTexture = RedStoneDustTile_SPU::getTextureByName(
+ RedStoneDustTile_SPU::TEXTURE_LINE);
+ Icon_SPU* crossTextureOverlay = RedStoneDustTile_SPU::getTextureByName(
+ RedStoneDustTile_SPU::TEXTURE_CROSS_OVERLAY);
+ Icon_SPU* lineTextureOverlay = RedStoneDustTile_SPU::getTextureByName(
+ RedStoneDustTile_SPU::TEXTURE_LINE_OVERLAY);
- float br;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tt->getLightColor( level, x, y, z ) );
- br = 1;
- }
- else
- {
- br = tt->getBrightness( level, x, y, z );
- }
- float pow = ( data / 15.0f );
- float red = pow * 0.6f + 0.4f;
- if ( data == 0 ) red = 0.3f;
+ float br;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ br = 1;
+ } else {
+ br = tt->getBrightness(level, x, y, z);
+ }
+ float pow = (data / 15.0f);
+ float red = pow * 0.6f + 0.4f;
+ if (data == 0) red = 0.3f;
- float green = pow * pow * 0.7f - 0.5f;
- float blue = pow * pow * 0.6f - 0.7f;
- if ( green < 0 ) green = 0;
- if ( blue < 0 ) blue = 0;
+ float green = pow * pow * 0.7f - 0.5f;
+ float blue = pow * pow * 0.6f - 0.7f;
+ if (green < 0) green = 0;
+ if (blue < 0) blue = 0;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->color( red, green, blue );
- }
- else
- {
- t->color( br * red, br * green, br * blue );
- }
- const float dustOffset = 0.25f / 16.0f;
- const float overlayOffset = 0.25f / 16.0f;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->color(red, green, blue);
+ } else {
+ t->color(br * red, br * green, br * blue);
+ }
+ const float dustOffset = 0.25f / 16.0f;
+ const float overlayOffset = 0.25f / 16.0f;
- bool w = RedStoneDustTile_SPU::shouldConnectTo( level, x - 1, y, z, Direction::WEST )
- || ( !level->isSolidBlockingTile( x - 1, y, z ) && RedStoneDustTile_SPU::shouldConnectTo( level, x - 1, y - 1, z,
- Direction::UNDEFINED ) );
- bool e = RedStoneDustTile_SPU::shouldConnectTo( level, x + 1, y, z, Direction::EAST )
- || ( !level->isSolidBlockingTile( x + 1, y, z ) && RedStoneDustTile_SPU::shouldConnectTo( level, x + 1, y - 1, z,
- Direction::UNDEFINED ) );
- bool n = RedStoneDustTile_SPU::shouldConnectTo( level, x, y, z - 1, Direction::NORTH )
- || ( !level->isSolidBlockingTile( x, y, z - 1 ) && RedStoneDustTile_SPU::shouldConnectTo( level, x, y - 1, z - 1,
- Direction::UNDEFINED ) );
- bool s = RedStoneDustTile_SPU::shouldConnectTo( level, x, y, z + 1, Direction::SOUTH )
- || ( !level->isSolidBlockingTile( x, y, z + 1 ) && RedStoneDustTile_SPU::shouldConnectTo( level, x, y - 1, z + 1,
- Direction::UNDEFINED ) );
- if ( !level->isSolidBlockingTile( x, y + 1, z ) )
- {
- if ( level->isSolidBlockingTile( x - 1, y, z ) && RedStoneDustTile_SPU::shouldConnectTo( level, x - 1, y + 1, z,
- Direction::UNDEFINED ) ) w
- = true;
- if ( level->isSolidBlockingTile( x + 1, y, z ) && RedStoneDustTile_SPU::shouldConnectTo( level, x + 1, y + 1, z,
- Direction::UNDEFINED ) ) e
- = true;
- if ( level->isSolidBlockingTile( x, y, z - 1 ) && RedStoneDustTile_SPU::shouldConnectTo( level, x, y + 1, z - 1,
- Direction::UNDEFINED ) ) n
- = true;
- if ( level->isSolidBlockingTile( x, y, z + 1 ) && RedStoneDustTile_SPU::shouldConnectTo( level, x, y + 1, z + 1,
- Direction::UNDEFINED ) ) s
- = true;
- }
- float x0 = ( float )( x + 0.0f );
- float x1 = ( float )( x + 1.0f );
- float z0 = ( float )( z + 0.0f );
- float z1 = ( float )( z + 1.0f );
+ bool w = RedStoneDustTile_SPU::shouldConnectTo(level, x - 1, y, z,
+ Direction::WEST) ||
+ (!level->isSolidBlockingTile(x - 1, y, z) &&
+ RedStoneDustTile_SPU::shouldConnectTo(level, x - 1, y - 1, z,
+ Direction::UNDEFINED));
+ bool e = RedStoneDustTile_SPU::shouldConnectTo(level, x + 1, y, z,
+ Direction::EAST) ||
+ (!level->isSolidBlockingTile(x + 1, y, z) &&
+ RedStoneDustTile_SPU::shouldConnectTo(level, x + 1, y - 1, z,
+ Direction::UNDEFINED));
+ bool n = RedStoneDustTile_SPU::shouldConnectTo(level, x, y, z - 1,
+ Direction::NORTH) ||
+ (!level->isSolidBlockingTile(x, y, z - 1) &&
+ RedStoneDustTile_SPU::shouldConnectTo(level, x, y - 1, z - 1,
+ Direction::UNDEFINED));
+ bool s = RedStoneDustTile_SPU::shouldConnectTo(level, x, y, z + 1,
+ Direction::SOUTH) ||
+ (!level->isSolidBlockingTile(x, y, z + 1) &&
+ RedStoneDustTile_SPU::shouldConnectTo(level, x, y - 1, z + 1,
+ Direction::UNDEFINED));
+ if (!level->isSolidBlockingTile(x, y + 1, z)) {
+ if (level->isSolidBlockingTile(x - 1, y, z) &&
+ RedStoneDustTile_SPU::shouldConnectTo(level, x - 1, y + 1, z,
+ Direction::UNDEFINED))
+ w = true;
+ if (level->isSolidBlockingTile(x + 1, y, z) &&
+ RedStoneDustTile_SPU::shouldConnectTo(level, x + 1, y + 1, z,
+ Direction::UNDEFINED))
+ e = true;
+ if (level->isSolidBlockingTile(x, y, z - 1) &&
+ RedStoneDustTile_SPU::shouldConnectTo(level, x, y + 1, z - 1,
+ Direction::UNDEFINED))
+ n = true;
+ if (level->isSolidBlockingTile(x, y, z + 1) &&
+ RedStoneDustTile_SPU::shouldConnectTo(level, x, y + 1, z + 1,
+ Direction::UNDEFINED))
+ s = true;
+ }
+ float x0 = (float)(x + 0.0f);
+ float x1 = (float)(x + 1.0f);
+ float z0 = (float)(z + 0.0f);
+ float z1 = (float)(z + 1.0f);
- int pic = 0;
- if ( ( w || e ) && ( !n && !s ) ) pic = 1;
- if ( ( n || s ) && ( !e && !w ) ) pic = 2;
+ int pic = 0;
+ if ((w || e) && (!n && !s)) pic = 1;
+ if ((n || s) && (!e && !w)) pic = 2;
- if ( pic == 0 )
- {
-// if ( e || n || s || w )
- int u0 = 0;
- int v0 = 0;
- int u1 = SharedConstants::WORLD_RESOLUTION;
- int v1 = SharedConstants::WORLD_RESOLUTION;
+ if (pic == 0) {
+ // if ( e || n || s || w )
+ int u0 = 0;
+ int v0 = 0;
+ int u1 = SharedConstants::WORLD_RESOLUTION;
+ int v1 = SharedConstants::WORLD_RESOLUTION;
- int cutDistance = 5;
- if (!w) x0 += cutDistance / (float) SharedConstants::WORLD_RESOLUTION;
- if (!w) u0 += cutDistance;
- if (!e) x1 -= cutDistance / (float) SharedConstants::WORLD_RESOLUTION;
- if (!e) u1 -= cutDistance;
- if (!n) z0 += cutDistance / (float) SharedConstants::WORLD_RESOLUTION;
- if (!n) v0 += cutDistance;
- if (!s) z1 -= cutDistance / (float) SharedConstants::WORLD_RESOLUTION;
- if (!s) v1 -= cutDistance;
- t->vertexUV( ( float )( x1 ), ( float )( y + dustOffset ), ( float )( z1 ), crossTexture->getU(u1), crossTexture->getV(v1) );
- t->vertexUV( ( float )( x1 ), ( float )( y + dustOffset ), ( float )( z0 ), crossTexture->getU(u1), crossTexture->getV(v0) );
- t->vertexUV( ( float )( x0 ), ( float )( y + dustOffset ), ( float )( z0 ), crossTexture->getU(u0), crossTexture->getV(v0) );
- t->vertexUV( ( float )( x0 ), ( float )( y + dustOffset ), ( float )( z1 ), crossTexture->getU(u0), crossTexture->getV(v1) );
+ int cutDistance = 5;
+ if (!w) x0 += cutDistance / (float)SharedConstants::WORLD_RESOLUTION;
+ if (!w) u0 += cutDistance;
+ if (!e) x1 -= cutDistance / (float)SharedConstants::WORLD_RESOLUTION;
+ if (!e) u1 -= cutDistance;
+ if (!n) z0 += cutDistance / (float)SharedConstants::WORLD_RESOLUTION;
+ if (!n) v0 += cutDistance;
+ if (!s) z1 -= cutDistance / (float)SharedConstants::WORLD_RESOLUTION;
+ if (!s) v1 -= cutDistance;
+ t->vertexUV((float)(x1), (float)(y + dustOffset), (float)(z1),
+ crossTexture->getU(u1), crossTexture->getV(v1));
+ t->vertexUV((float)(x1), (float)(y + dustOffset), (float)(z0),
+ crossTexture->getU(u1), crossTexture->getV(v0));
+ t->vertexUV((float)(x0), (float)(y + dustOffset), (float)(z0),
+ crossTexture->getU(u0), crossTexture->getV(v0));
+ t->vertexUV((float)(x0), (float)(y + dustOffset), (float)(z1),
+ crossTexture->getU(u0), crossTexture->getV(v1));
- t->color( br, br, br );
- t->vertexUV( ( float )( x1 ), ( float )( y + dustOffset ), ( float )( z1 ), crossTextureOverlay->getU(u1), crossTextureOverlay->getV(v1) );
- t->vertexUV( ( float )( x1 ), ( float )( y + dustOffset ), ( float )( z0 ), crossTextureOverlay->getU(u1), crossTextureOverlay->getV(v0) );
- t->vertexUV( ( float )( x0 ), ( float )( y + dustOffset ), ( float )( z0 ), crossTextureOverlay->getU(u0), crossTextureOverlay->getV(v0) );
- t->vertexUV( ( float )( x0 ), ( float )( y + dustOffset ), ( float )( z1 ), crossTextureOverlay->getU(u0), crossTextureOverlay->getV(v1) );
- }
- else if ( pic == 1 )
- {
- t->vertexUV( ( float )( x1 ), ( float )( y + dustOffset ), ( float )( z1 ), lineTexture->getU1(), lineTexture->getV1() );
- t->vertexUV( ( float )( x1 ), ( float )( y + dustOffset ), ( float )( z0 ), lineTexture->getU1(), lineTexture->getV0() );
- t->vertexUV( ( float )( x0 ), ( float )( y + dustOffset ), ( float )( z0 ), lineTexture->getU0(), lineTexture->getV0() );
- t->vertexUV( ( float )( x0 ), ( float )( y + dustOffset ), ( float )( z1 ), lineTexture->getU0(), lineTexture->getV1() );
+ t->color(br, br, br);
+ t->vertexUV((float)(x1), (float)(y + dustOffset), (float)(z1),
+ crossTextureOverlay->getU(u1),
+ crossTextureOverlay->getV(v1));
+ t->vertexUV((float)(x1), (float)(y + dustOffset), (float)(z0),
+ crossTextureOverlay->getU(u1),
+ crossTextureOverlay->getV(v0));
+ t->vertexUV((float)(x0), (float)(y + dustOffset), (float)(z0),
+ crossTextureOverlay->getU(u0),
+ crossTextureOverlay->getV(v0));
+ t->vertexUV((float)(x0), (float)(y + dustOffset), (float)(z1),
+ crossTextureOverlay->getU(u0),
+ crossTextureOverlay->getV(v1));
+ } else if (pic == 1) {
+ t->vertexUV((float)(x1), (float)(y + dustOffset), (float)(z1),
+ lineTexture->getU1(), lineTexture->getV1());
+ t->vertexUV((float)(x1), (float)(y + dustOffset), (float)(z0),
+ lineTexture->getU1(), lineTexture->getV0());
+ t->vertexUV((float)(x0), (float)(y + dustOffset), (float)(z0),
+ lineTexture->getU0(), lineTexture->getV0());
+ t->vertexUV((float)(x0), (float)(y + dustOffset), (float)(z1),
+ lineTexture->getU0(), lineTexture->getV1());
- t->color( br, br, br );
- t->vertexUV( ( float )( x1 ), ( float )( y + overlayOffset ), ( float )( z1 ), lineTextureOverlay->getU1(), lineTextureOverlay->getV1() );
- t->vertexUV( ( float )( x1 ), ( float )( y + overlayOffset ), ( float )( z0 ), lineTextureOverlay->getU1(), lineTextureOverlay->getV0() );
- t->vertexUV( ( float )( x0 ), ( float )( y + overlayOffset ), ( float )( z0 ), lineTextureOverlay->getU0(), lineTextureOverlay->getV0() );
- t->vertexUV( ( float )( x0 ), ( float )( y + overlayOffset ), ( float )( z1 ), lineTextureOverlay->getU0(), lineTextureOverlay->getV1() );
- }
- else
- {
- t->vertexUV( ( float )( x1 ), ( float )( y + dustOffset ), ( float )( z1 ), lineTexture->getU1(), lineTexture->getV1() );
- t->vertexUV( ( float )( x1 ), ( float )( y + dustOffset ), ( float )( z0 ), lineTexture->getU0(), lineTexture->getV1() );
- t->vertexUV( ( float )( x0 ), ( float )( y + dustOffset ), ( float )( z0 ), lineTexture->getU0(), lineTexture->getV0() );
- t->vertexUV( ( float )( x0 ), ( float )( y + dustOffset ), ( float )( z1 ), lineTexture->getU1(), lineTexture->getV0() );
+ t->color(br, br, br);
+ t->vertexUV((float)(x1), (float)(y + overlayOffset), (float)(z1),
+ lineTextureOverlay->getU1(), lineTextureOverlay->getV1());
+ t->vertexUV((float)(x1), (float)(y + overlayOffset), (float)(z0),
+ lineTextureOverlay->getU1(), lineTextureOverlay->getV0());
+ t->vertexUV((float)(x0), (float)(y + overlayOffset), (float)(z0),
+ lineTextureOverlay->getU0(), lineTextureOverlay->getV0());
+ t->vertexUV((float)(x0), (float)(y + overlayOffset), (float)(z1),
+ lineTextureOverlay->getU0(), lineTextureOverlay->getV1());
+ } else {
+ t->vertexUV((float)(x1), (float)(y + dustOffset), (float)(z1),
+ lineTexture->getU1(), lineTexture->getV1());
+ t->vertexUV((float)(x1), (float)(y + dustOffset), (float)(z0),
+ lineTexture->getU0(), lineTexture->getV1());
+ t->vertexUV((float)(x0), (float)(y + dustOffset), (float)(z0),
+ lineTexture->getU0(), lineTexture->getV0());
+ t->vertexUV((float)(x0), (float)(y + dustOffset), (float)(z1),
+ lineTexture->getU1(), lineTexture->getV0());
- t->color( br, br, br );
- t->vertexUV( ( float )( x1 ), ( float )( y + overlayOffset ), ( float )( z1 ), lineTextureOverlay->getU1(), lineTextureOverlay->getV1() );
- t->vertexUV( ( float )( x1 ), ( float )( y + overlayOffset ), ( float )( z0 ), lineTextureOverlay->getU0(), lineTextureOverlay->getV1() );
- t->vertexUV( ( float )( x0 ), ( float )( y + overlayOffset ), ( float )( z0 ), lineTextureOverlay->getU0(), lineTextureOverlay->getV0() );
- t->vertexUV( ( float )( x0 ), ( float )( y + overlayOffset ), ( float )( z1 ), lineTextureOverlay->getU1(), lineTextureOverlay->getV0() );
- }
+ t->color(br, br, br);
+ t->vertexUV((float)(x1), (float)(y + overlayOffset), (float)(z1),
+ lineTextureOverlay->getU1(), lineTextureOverlay->getV1());
+ t->vertexUV((float)(x1), (float)(y + overlayOffset), (float)(z0),
+ lineTextureOverlay->getU0(), lineTextureOverlay->getV1());
+ t->vertexUV((float)(x0), (float)(y + overlayOffset), (float)(z0),
+ lineTextureOverlay->getU0(), lineTextureOverlay->getV0());
+ t->vertexUV((float)(x0), (float)(y + overlayOffset), (float)(z1),
+ lineTextureOverlay->getU1(), lineTextureOverlay->getV0());
+ }
- if ( !level->isSolidBlockingTile( x, y + 1, z ) )
- {
- const float yStretch = .35f / 16.0f;
+ if (!level->isSolidBlockingTile(x, y + 1, z)) {
+ const float yStretch = .35f / 16.0f;
- if ( level->isSolidBlockingTile( x - 1, y, z ) && level->getTile( x - 1, y + 1, z ) == Tile_SPU::redStoneDust_Id )
- {
- t->color( br * red, br * green, br * blue );
- t->vertexUV( ( float )( x + dustOffset ), ( float )( y + 1 + yStretch ), ( float )( z + 1 ), lineTexture->getU1(), lineTexture->getV0() );
- t->vertexUV( ( float )( x + dustOffset ), ( float )( y + 0 ), ( float )( z + 1 ), lineTexture->getU0(), lineTexture->getV0() );
- t->vertexUV( ( float )( x + dustOffset ), ( float )( y + 0 ), ( float )( z + 0 ), lineTexture->getU0(), lineTexture->getV1() );
- t->vertexUV( ( float )( x + dustOffset ), ( float )( y + 1 + yStretch ), ( float )( z + 0 ), lineTexture->getU1(), lineTexture->getV1() );
+ if (level->isSolidBlockingTile(x - 1, y, z) &&
+ level->getTile(x - 1, y + 1, z) == Tile_SPU::redStoneDust_Id) {
+ t->color(br * red, br * green, br * blue);
+ t->vertexUV((float)(x + dustOffset), (float)(y + 1 + yStretch),
+ (float)(z + 1), lineTexture->getU1(),
+ lineTexture->getV0());
+ t->vertexUV((float)(x + dustOffset), (float)(y + 0), (float)(z + 1),
+ lineTexture->getU0(), lineTexture->getV0());
+ t->vertexUV((float)(x + dustOffset), (float)(y + 0), (float)(z + 0),
+ lineTexture->getU0(), lineTexture->getV1());
+ t->vertexUV((float)(x + dustOffset), (float)(y + 1 + yStretch),
+ (float)(z + 0), lineTexture->getU1(),
+ lineTexture->getV1());
- t->color( br, br, br );
- t->vertexUV( ( float )( x + overlayOffset ), ( float )( y + 1 + yStretch ), ( float )( z + 1 ), lineTextureOverlay->getU1(), lineTextureOverlay->getV0() );
- t->vertexUV( ( float )( x + overlayOffset ), ( float )( y + 0 ), ( float )( z + 1 ), lineTextureOverlay->getU0(), lineTextureOverlay->getV0() );
- t->vertexUV( ( float )( x + overlayOffset ), ( float )( y + 0 ), ( float )( z + 0 ), lineTextureOverlay->getU0(), lineTextureOverlay->getV1() );
- t->vertexUV( ( float )( x + overlayOffset ), ( float )( y + 1 + yStretch ), ( float )( z + 0 ), lineTextureOverlay->getU1(), lineTextureOverlay->getV1() );
- }
- if ( level->isSolidBlockingTile( x + 1, y, z ) && level->getTile( x + 1, y + 1, z ) == Tile_SPU::redStoneDust_Id )
- {
- t->color( br * red, br * green, br * blue );
- t->vertexUV( ( float )( x + 1 - dustOffset ), ( float )( y + 0 ), ( float )( z + 1 ), lineTexture->getU0(), lineTexture->getV1() );
- t->vertexUV( ( float )( x + 1 - dustOffset ), ( float )( y + 1 + yStretch ), ( float )( z + 1 ), lineTexture->getU1(), lineTexture->getV1() );
- t->vertexUV( ( float )( x + 1 - dustOffset ), ( float )( y + 1 + yStretch ), ( float )( z + 0 ), lineTexture->getU1(), lineTexture->getV0() );
- t->vertexUV( ( float )( x + 1 - dustOffset ), ( float )( y + 0 ), ( float )( z + 0 ), lineTexture->getU0(), lineTexture->getV0() );
+ t->color(br, br, br);
+ t->vertexUV((float)(x + overlayOffset), (float)(y + 1 + yStretch),
+ (float)(z + 1), lineTextureOverlay->getU1(),
+ lineTextureOverlay->getV0());
+ t->vertexUV((float)(x + overlayOffset), (float)(y + 0),
+ (float)(z + 1), lineTextureOverlay->getU0(),
+ lineTextureOverlay->getV0());
+ t->vertexUV((float)(x + overlayOffset), (float)(y + 0),
+ (float)(z + 0), lineTextureOverlay->getU0(),
+ lineTextureOverlay->getV1());
+ t->vertexUV((float)(x + overlayOffset), (float)(y + 1 + yStretch),
+ (float)(z + 0), lineTextureOverlay->getU1(),
+ lineTextureOverlay->getV1());
+ }
+ if (level->isSolidBlockingTile(x + 1, y, z) &&
+ level->getTile(x + 1, y + 1, z) == Tile_SPU::redStoneDust_Id) {
+ t->color(br * red, br * green, br * blue);
+ t->vertexUV((float)(x + 1 - dustOffset), (float)(y + 0),
+ (float)(z + 1), lineTexture->getU0(),
+ lineTexture->getV1());
+ t->vertexUV((float)(x + 1 - dustOffset), (float)(y + 1 + yStretch),
+ (float)(z + 1), lineTexture->getU1(),
+ lineTexture->getV1());
+ t->vertexUV((float)(x + 1 - dustOffset), (float)(y + 1 + yStretch),
+ (float)(z + 0), lineTexture->getU1(),
+ lineTexture->getV0());
+ t->vertexUV((float)(x + 1 - dustOffset), (float)(y + 0),
+ (float)(z + 0), lineTexture->getU0(),
+ lineTexture->getV0());
- t->color( br, br, br );
- t->vertexUV( ( float )( x + 1 - overlayOffset ), ( float )( y + 0 ), ( float )( z + 1 ), lineTextureOverlay->getU0(), lineTextureOverlay->getV1() );
- t->vertexUV( ( float )( x + 1 - overlayOffset ), ( float )( y + 1 + yStretch ), ( float )( z + 1 ), lineTextureOverlay->getU1(), lineTextureOverlay->getV1() );
- t->vertexUV( ( float )( x + 1 - overlayOffset ), ( float )( y + 1 + yStretch ), ( float )( z + 0 ), lineTextureOverlay->getU1(), lineTextureOverlay->getV0() );
- t->vertexUV( ( float )( x + 1 - overlayOffset ), ( float )( y + 0 ), ( float )( z + 0 ), lineTextureOverlay->getU0(), lineTextureOverlay->getV0() );
- }
- if ( level->isSolidBlockingTile( x, y, z - 1 ) && level->getTile( x, y + 1, z - 1 ) == Tile_SPU::redStoneDust_Id )
- {
- t->color( br * red, br * green, br * blue );
- t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z + dustOffset ), lineTexture->getU0(), lineTexture->getV1() );
- t->vertexUV( ( float )( x + 1 ), ( float )( y + 1 + yStretch ), ( float )( z + dustOffset ), lineTexture->getU1(), lineTexture->getV1() );
- t->vertexUV( ( float )( x + 0 ), ( float )( y + 1 + yStretch ), ( float )( z + dustOffset ), lineTexture->getU1(), lineTexture->getV0() );
- t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z + dustOffset ), lineTexture->getU0(), lineTexture->getV0() );
+ t->color(br, br, br);
+ t->vertexUV((float)(x + 1 - overlayOffset), (float)(y + 0),
+ (float)(z + 1), lineTextureOverlay->getU0(),
+ lineTextureOverlay->getV1());
+ t->vertexUV((float)(x + 1 - overlayOffset),
+ (float)(y + 1 + yStretch), (float)(z + 1),
+ lineTextureOverlay->getU1(),
+ lineTextureOverlay->getV1());
+ t->vertexUV((float)(x + 1 - overlayOffset),
+ (float)(y + 1 + yStretch), (float)(z + 0),
+ lineTextureOverlay->getU1(),
+ lineTextureOverlay->getV0());
+ t->vertexUV((float)(x + 1 - overlayOffset), (float)(y + 0),
+ (float)(z + 0), lineTextureOverlay->getU0(),
+ lineTextureOverlay->getV0());
+ }
+ if (level->isSolidBlockingTile(x, y, z - 1) &&
+ level->getTile(x, y + 1, z - 1) == Tile_SPU::redStoneDust_Id) {
+ t->color(br * red, br * green, br * blue);
+ t->vertexUV((float)(x + 1), (float)(y + 0), (float)(z + dustOffset),
+ lineTexture->getU0(), lineTexture->getV1());
+ t->vertexUV((float)(x + 1), (float)(y + 1 + yStretch),
+ (float)(z + dustOffset), lineTexture->getU1(),
+ lineTexture->getV1());
+ t->vertexUV((float)(x + 0), (float)(y + 1 + yStretch),
+ (float)(z + dustOffset), lineTexture->getU1(),
+ lineTexture->getV0());
+ t->vertexUV((float)(x + 0), (float)(y + 0), (float)(z + dustOffset),
+ lineTexture->getU0(), lineTexture->getV0());
- t->color( br, br, br );
- t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z + overlayOffset ), lineTextureOverlay->getU0(), lineTextureOverlay->getV1() );
- t->vertexUV( ( float )( x + 1 ), ( float )( y + 1 + yStretch ), ( float )( z + overlayOffset ), lineTextureOverlay->getU1(), lineTextureOverlay->getV1() );
- t->vertexUV( ( float )( x + 0 ), ( float )( y + 1 + yStretch ), ( float )( z + overlayOffset ), lineTextureOverlay->getU1(), lineTextureOverlay->getV0() );
- t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z + overlayOffset ), lineTextureOverlay->getU0(), lineTextureOverlay->getV0() );
- }
- if ( level->isSolidBlockingTile( x, y, z + 1 ) && level->getTile( x, y + 1, z + 1 ) == Tile_SPU::redStoneDust_Id )
- {
- t->color( br * red, br * green, br * blue );
- t->vertexUV( ( float )( x + 1 ), ( float )( y + 1 + yStretch ), ( float )( z + 1 - dustOffset ), lineTexture->getU1(), lineTexture->getV0() );
- t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z + 1 - dustOffset ), lineTexture->getU0(), lineTexture->getV0() );
- t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z + 1 - dustOffset ), lineTexture->getU0(), lineTexture->getV1() );
- t->vertexUV( ( float )( x + 0 ), ( float )( y + 1 + yStretch ), ( float )( z + 1 - dustOffset ), lineTexture->getU1(), lineTexture->getV1() );
+ t->color(br, br, br);
+ t->vertexUV((float)(x + 1), (float)(y + 0),
+ (float)(z + overlayOffset), lineTextureOverlay->getU0(),
+ lineTextureOverlay->getV1());
+ t->vertexUV((float)(x + 1), (float)(y + 1 + yStretch),
+ (float)(z + overlayOffset), lineTextureOverlay->getU1(),
+ lineTextureOverlay->getV1());
+ t->vertexUV((float)(x + 0), (float)(y + 1 + yStretch),
+ (float)(z + overlayOffset), lineTextureOverlay->getU1(),
+ lineTextureOverlay->getV0());
+ t->vertexUV((float)(x + 0), (float)(y + 0),
+ (float)(z + overlayOffset), lineTextureOverlay->getU0(),
+ lineTextureOverlay->getV0());
+ }
+ if (level->isSolidBlockingTile(x, y, z + 1) &&
+ level->getTile(x, y + 1, z + 1) == Tile_SPU::redStoneDust_Id) {
+ t->color(br * red, br * green, br * blue);
+ t->vertexUV((float)(x + 1), (float)(y + 1 + yStretch),
+ (float)(z + 1 - dustOffset), lineTexture->getU1(),
+ lineTexture->getV0());
+ t->vertexUV((float)(x + 1), (float)(y + 0),
+ (float)(z + 1 - dustOffset), lineTexture->getU0(),
+ lineTexture->getV0());
+ t->vertexUV((float)(x + 0), (float)(y + 0),
+ (float)(z + 1 - dustOffset), lineTexture->getU0(),
+ lineTexture->getV1());
+ t->vertexUV((float)(x + 0), (float)(y + 1 + yStretch),
+ (float)(z + 1 - dustOffset), lineTexture->getU1(),
+ lineTexture->getV1());
- t->color( br, br, br );
- t->vertexUV( ( float )( x + 1 ), ( float )( y + 1 + yStretch ), ( float )( z + 1 - overlayOffset ), lineTextureOverlay->getU1(), lineTextureOverlay->getV0() );
- t->vertexUV( ( float )( x + 1 ), ( float )( y + 0 ), ( float )( z + 1 - overlayOffset ), lineTextureOverlay->getU0(), lineTextureOverlay->getV0() );
- t->vertexUV( ( float )( x + 0 ), ( float )( y + 0 ), ( float )( z + 1 - overlayOffset ), lineTextureOverlay->getU0(), lineTextureOverlay->getV1() );
- t->vertexUV( ( float )( x + 0 ), ( float )( y + 1 + yStretch ), ( float )( z + 1 - overlayOffset ), lineTextureOverlay->getU1(), lineTextureOverlay->getV1() );
- }
- }
-#endif // #ifdef DISABLE_TESS_FUNCS
+ t->color(br, br, br);
+ t->vertexUV((float)(x + 1), (float)(y + 1 + yStretch),
+ (float)(z + 1 - overlayOffset),
+ lineTextureOverlay->getU1(),
+ lineTextureOverlay->getV0());
+ t->vertexUV(
+ (float)(x + 1), (float)(y + 0), (float)(z + 1 - overlayOffset),
+ lineTextureOverlay->getU0(), lineTextureOverlay->getV0());
+ t->vertexUV(
+ (float)(x + 0), (float)(y + 0), (float)(z + 1 - overlayOffset),
+ lineTextureOverlay->getU0(), lineTextureOverlay->getV1());
+ t->vertexUV((float)(x + 0), (float)(y + 1 + yStretch),
+ (float)(z + 1 - overlayOffset),
+ lineTextureOverlay->getU1(),
+ lineTextureOverlay->getV1());
+ }
+ }
+#endif // #ifdef DISABLE_TESS_FUNCS
- return true;
+ return true;
}
-bool TileRenderer_SPU::tesselateRailInWorld( RailTile_SPU* tt, int x, int y, int z )
-{
- Tesselator_SPU* t = getTesselator();
- int data = level->getData( x, y, z );
+bool TileRenderer_SPU::tesselateRailInWorld(RailTile_SPU* tt, int x, int y,
+ int z) {
+ Tesselator_SPU* t = getTesselator();
+ int data = level->getData(x, y, z);
- Icon_SPU *tex = getTexture(tt, 0, data);
- if (hasFixedTexture()) tex = fixedTexture;
+ Icon_SPU* tex = getTexture(tt, 0, data);
+ if (hasFixedTexture()) tex = fixedTexture;
- if ( tt->isUsesDataBit() )
- {
- data &= RailTile_SPU::RAIL_DIRECTION_MASK;
- }
+ if (tt->isUsesDataBit()) {
+ data &= RailTile_SPU::RAIL_DIRECTION_MASK;
+ }
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tt->getLightColor( level, x, y, z ) );
- t->color( 1.0f, 1.0f, 1.0f );
- }
- else
- {
- float br = tt->getBrightness( level, x, y, z );
- t->color( br, br, br );
- }
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ t->color(1.0f, 1.0f, 1.0f);
+ } else {
+ float br = tt->getBrightness(level, x, y, z);
+ t->color(br, br, br);
+ }
- float u0 = tex->getU0();
- float v0 = tex->getV0();
- float u1 = tex->getU1();
- float v1 = tex->getV1();
+ float u0 = tex->getU0();
+ float v0 = tex->getV0();
+ float u1 = tex->getU1();
+ float v1 = tex->getV1();
- float r = 1 / 16.0f;
+ float r = 1 / 16.0f;
- float x0 = ( float )( x + 1 );
- float x1 = ( float )( x + 1 );
- float x2 = ( float )( x + 0 );
- float x3 = ( float )( x + 0 );
+ float x0 = (float)(x + 1);
+ float x1 = (float)(x + 1);
+ float x2 = (float)(x + 0);
+ float x3 = (float)(x + 0);
- float z0 = ( float )( z + 0 );
- float z1 = ( float )( z + 1 );
- float z2 = ( float )( z + 1 );
- float z3 = ( float )( z + 0 );
+ float z0 = (float)(z + 0);
+ float z1 = (float)(z + 1);
+ float z2 = (float)(z + 1);
+ float z3 = (float)(z + 0);
- float y0 = ( float )( y + r );
- float y1 = ( float )( y + r );
- float y2 = ( float )( y + r );
- float y3 = ( float )( y + r );
+ float y0 = (float)(y + r);
+ float y1 = (float)(y + r);
+ float y2 = (float)(y + r);
+ float y3 = (float)(y + r);
- if ( data == 1 || data == 2 || data == 3 || data == 7 )
- {
- x0 = x3 = ( float )( x + 1 );
- x1 = x2 = ( float )( x + 0 );
- z0 = z1 = ( float )( z + 1 );
- z2 = z3 = ( float )( z + 0 );
- }
- else if ( data == 8 )
- {
- x0 = x1 = ( float )( x + 0 );
- x2 = x3 = ( float )( x + 1 );
- z0 = z3 = ( float )( z + 1 );
- z1 = z2 = ( float )( z + 0 );
- }
- else if ( data == 9 )
- {
- x0 = x3 = ( float )( x + 0 );
- x1 = x2 = ( float )( x + 1 );
- z0 = z1 = ( float )( z + 0 );
- z2 = z3 = ( float )( z + 1 );
- }
+ if (data == 1 || data == 2 || data == 3 || data == 7) {
+ x0 = x3 = (float)(x + 1);
+ x1 = x2 = (float)(x + 0);
+ z0 = z1 = (float)(z + 1);
+ z2 = z3 = (float)(z + 0);
+ } else if (data == 8) {
+ x0 = x1 = (float)(x + 0);
+ x2 = x3 = (float)(x + 1);
+ z0 = z3 = (float)(z + 1);
+ z1 = z2 = (float)(z + 0);
+ } else if (data == 9) {
+ x0 = x3 = (float)(x + 0);
+ x1 = x2 = (float)(x + 1);
+ z0 = z1 = (float)(z + 0);
+ z2 = z3 = (float)(z + 1);
+ }
- if ( data == 2 || data == 4 )
- {
- y0 += 1;
- y3 += 1;
- }
- else if ( data == 3 || data == 5 )
- {
- y1 += 1;
- y2 += 1;
- }
+ if (data == 2 || data == 4) {
+ y0 += 1;
+ y3 += 1;
+ } else if (data == 3 || data == 5) {
+ y1 += 1;
+ y2 += 1;
+ }
- t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z0 ), ( float )( u1 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x2 ), ( float )( y2 ), ( float )( z2 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x3 ), ( float )( y3 ), ( float )( z3 ), ( float )( u0 ), ( float )( v0 ) );
+ t->vertexUV((float)(x0), (float)(y0), (float)(z0), (float)(u1),
+ (float)(v0));
+ t->vertexUV((float)(x1), (float)(y1), (float)(z1), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x2), (float)(y2), (float)(z2), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x3), (float)(y3), (float)(z3), (float)(u0),
+ (float)(v0));
- t->vertexUV( ( float )( x3 ), ( float )( y3 ), ( float )( z3 ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x2 ), ( float )( y2 ), ( float )( z2 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z0 ), ( float )( u1 ), ( float )( v0 ) );
-
- return true;
+ t->vertexUV((float)(x3), (float)(y3), (float)(z3), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x2), (float)(y2), (float)(z2), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x1), (float)(y1), (float)(z1), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x0), (float)(y0), (float)(z0), (float)(u1),
+ (float)(v0));
+ return true;
}
-bool TileRenderer_SPU::tesselateLadderInWorld( Tile_SPU* tt, int x, int y, int z )
-{
- Tesselator_SPU* t = getTesselator();
+bool TileRenderer_SPU::tesselateLadderInWorld(Tile_SPU* tt, int x, int y,
+ int z) {
+ Tesselator_SPU* t = getTesselator();
- Icon_SPU *tex = getTexture(tt, 0);
+ Icon_SPU* tex = getTexture(tt, 0);
- if (hasFixedTexture()) tex = fixedTexture;
+ if (hasFixedTexture()) tex = fixedTexture;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tt->getLightColor( level, x, y, z ) );
- float br = 1;
- t->color( br, br, br );
- }
- else
- {
- float br = tt->getBrightness( level, x, y, z );
- t->color( br, br, br );
- }
- float u0 = tex->getU0();
- float v0 = tex->getV0();
- float u1 = tex->getU1();
- float v1 = tex->getV1();
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ float br = 1;
+ t->color(br, br, br);
+ } else {
+ float br = tt->getBrightness(level, x, y, z);
+ t->color(br, br, br);
+ }
+ float u0 = tex->getU0();
+ float v0 = tex->getV0();
+ float u1 = tex->getU1();
+ float v1 = tex->getV1();
- int face = level->getData( x, y, z );
+ int face = level->getData(x, y, z);
- float o = 0 / 16.0f;
- float r = 0.05f;
- if ( face == 5 )
- {
- t->vertexUV( ( float )( x + r ), ( float )( y + 1 + o ), ( float )( z + 1 +
- o ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + r ), ( float )( y + 0 - o ), ( float )( z + 1 +
- o ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + r ), ( float )( y + 0 - o ), ( float )( z + 0 -
- o ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + r ), ( float )( y + 1 + o ), ( float )( z + 0 -
- o ), ( float )( u1 ), ( float )( v0 ) );
- }
- if ( face == 4 )
- {
- t->vertexUV( ( float )( x + 1 - r ), ( float )( y + 0 - o ), ( float )( z + 1 +
- o ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 1 - r ), ( float )( y + 1 + o ), ( float )( z + 1 +
- o ), ( float )( u1 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 1 - r ), ( float )( y + 1 + o ), ( float )( z + 0 -
- o ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 1 - r ), ( float )( y + 0 - o ), ( float )( z + 0 -
- o ), ( float )( u0 ), ( float )( v1 ) );
- }
- if ( face == 3 )
- {
- t->vertexUV( ( float )( x + 1 + o ), ( float )( y + 0 - o ), ( float )( z +
- r ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 1 + o ), ( float )( y + 1 + o ), ( float )( z +
- r ), ( float )( u1 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 0 - o ), ( float )( y + 1 + o ), ( float )( z +
- r ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 0 - o ), ( float )( y + 0 - o ), ( float )( z +
- r ), ( float )( u0 ), ( float )( v1 ) );
- }
- if ( face == 2 )
- {
- t->vertexUV( ( float )( x + 1 + o ), ( float )( y + 1 + o ), ( float )( z + 1 -
- r ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + 1 + o ), ( float )( y + 0 - o ), ( float )( z + 1 -
- r ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 0 - o ), ( float )( y + 0 - o ), ( float )( z + 1 -
- r ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + 0 - o ), ( float )( y + 1 + o ), ( float )( z + 1 -
- r ), ( float )( u1 ), ( float )( v0 ) );
- }
- return true;
+ float o = 0 / 16.0f;
+ float r = 0.05f;
+ if (face == 5) {
+ t->vertexUV((float)(x + r), (float)(y + 1 + o), (float)(z + 1 + o),
+ (float)(u0), (float)(v0));
+ t->vertexUV((float)(x + r), (float)(y + 0 - o), (float)(z + 1 + o),
+ (float)(u0), (float)(v1));
+ t->vertexUV((float)(x + r), (float)(y + 0 - o), (float)(z + 0 - o),
+ (float)(u1), (float)(v1));
+ t->vertexUV((float)(x + r), (float)(y + 1 + o), (float)(z + 0 - o),
+ (float)(u1), (float)(v0));
+ }
+ if (face == 4) {
+ t->vertexUV((float)(x + 1 - r), (float)(y + 0 - o), (float)(z + 1 + o),
+ (float)(u1), (float)(v1));
+ t->vertexUV((float)(x + 1 - r), (float)(y + 1 + o), (float)(z + 1 + o),
+ (float)(u1), (float)(v0));
+ t->vertexUV((float)(x + 1 - r), (float)(y + 1 + o), (float)(z + 0 - o),
+ (float)(u0), (float)(v0));
+ t->vertexUV((float)(x + 1 - r), (float)(y + 0 - o), (float)(z + 0 - o),
+ (float)(u0), (float)(v1));
+ }
+ if (face == 3) {
+ t->vertexUV((float)(x + 1 + o), (float)(y + 0 - o), (float)(z + r),
+ (float)(u1), (float)(v1));
+ t->vertexUV((float)(x + 1 + o), (float)(y + 1 + o), (float)(z + r),
+ (float)(u1), (float)(v0));
+ t->vertexUV((float)(x + 0 - o), (float)(y + 1 + o), (float)(z + r),
+ (float)(u0), (float)(v0));
+ t->vertexUV((float)(x + 0 - o), (float)(y + 0 - o), (float)(z + r),
+ (float)(u0), (float)(v1));
+ }
+ if (face == 2) {
+ t->vertexUV((float)(x + 1 + o), (float)(y + 1 + o), (float)(z + 1 - r),
+ (float)(u0), (float)(v0));
+ t->vertexUV((float)(x + 1 + o), (float)(y + 0 - o), (float)(z + 1 - r),
+ (float)(u0), (float)(v1));
+ t->vertexUV((float)(x + 0 - o), (float)(y + 0 - o), (float)(z + 1 - r),
+ (float)(u1), (float)(v1));
+ t->vertexUV((float)(x + 0 - o), (float)(y + 1 + o), (float)(z + 1 - r),
+ (float)(u1), (float)(v0));
+ }
+ return true;
}
-bool TileRenderer_SPU::tesselateVineInWorld( Tile_SPU* tt, int x, int y, int z )
-{
- Tesselator_SPU* t = getTesselator();
+bool TileRenderer_SPU::tesselateVineInWorld(Tile_SPU* tt, int x, int y, int z) {
+ Tesselator_SPU* t = getTesselator();
- Icon_SPU *tex = getTexture(tt, 0);
+ Icon_SPU* tex = getTexture(tt, 0);
- if (hasFixedTexture()) tex = fixedTexture;
+ if (hasFixedTexture()) tex = fixedTexture;
+ float br = 1;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ } else {
+ br = tt->getBrightness(level, x, y, z);
+ }
+ {
+ int col = tt->getColor(level, x, y, z);
+ float r = ((col >> 16) & 0xff) / 255.0f;
+ float g = ((col >> 8) & 0xff) / 255.0f;
+ float b = ((col) & 0xff) / 255.0f;
- float br = 1;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tt->getLightColor( level, x, y, z ) );
- }
- else
- {
- br = tt->getBrightness( level, x, y, z );
- }
- {
- int col = tt->getColor( level, x, y, z );
- float r = ( ( col >> 16 ) & 0xff ) / 255.0f;
- float g = ( ( col >> 8 ) & 0xff ) / 255.0f;
- float b = ( ( col )& 0xff ) / 255.0f;
+ t->color(br * r, br * g, br * b);
+ }
- t->color( br * r, br * g, br * b );
- }
+ float u0 = tex->getU0();
+ float v0 = tex->getV0();
+ float u1 = tex->getU1();
+ float v1 = tex->getV1();
- float u0 = tex->getU0();
- float v0 = tex->getV0();
- float u1 = tex->getU1();
- float v1 = tex->getV1();
+ float r = 0.05f;
+ int facings = level->getData(x, y, z);
- float r = 0.05f;
- int facings = level->getData( x, y, z );
+ if ((facings & VineTile_SPU::VINE_WEST) != 0) {
+ t->vertexUV(x + r, y + 1, z + 1, u0, v0);
+ t->vertexUV(x + r, y + 0, z + 1, u0, v1);
+ t->vertexUV(x + r, y + 0, z + 0, u1, v1);
+ t->vertexUV(x + r, y + 1, z + 0, u1, v0);
- if ( ( facings & VineTile_SPU::VINE_WEST ) != 0 )
- {
- t->vertexUV( x + r, y + 1, z + 1, u0, v0 );
- t->vertexUV( x + r, y + 0, z + 1, u0, v1 );
- t->vertexUV( x + r, y + 0, z + 0, u1, v1 );
- t->vertexUV( x + r, y + 1, z + 0, u1, v0 );
+ t->vertexUV(x + r, y + 1, z + 0, u1, v0);
+ t->vertexUV(x + r, y + 0, z + 0, u1, v1);
+ t->vertexUV(x + r, y + 0, z + 1, u0, v1);
+ t->vertexUV(x + r, y + 1, z + 1, u0, v0);
+ }
+ if ((facings & VineTile_SPU::VINE_EAST) != 0) {
+ t->vertexUV(x + 1 - r, y + 0, z + 1, u1, v1);
+ t->vertexUV(x + 1 - r, y + 1, z + 1, u1, v0);
+ t->vertexUV(x + 1 - r, y + 1, z + 0, u0, v0);
+ t->vertexUV(x + 1 - r, y + 0, z + 0, u0, v1);
- t->vertexUV( x + r, y + 1, z + 0, u1, v0 );
- t->vertexUV( x + r, y + 0, z + 0, u1, v1 );
- t->vertexUV( x + r, y + 0, z + 1, u0, v1 );
- t->vertexUV( x + r, y + 1, z + 1, u0, v0 );
- }
- if ( ( facings & VineTile_SPU::VINE_EAST ) != 0 )
- {
- t->vertexUV( x + 1 - r, y + 0, z + 1, u1, v1 );
- t->vertexUV( x + 1 - r, y + 1, z + 1, u1, v0 );
- t->vertexUV( x + 1 - r, y + 1, z + 0, u0, v0 );
- t->vertexUV( x + 1 - r, y + 0, z + 0, u0, v1 );
+ t->vertexUV(x + 1 - r, y + 0, z + 0, u0, v1);
+ t->vertexUV(x + 1 - r, y + 1, z + 0, u0, v0);
+ t->vertexUV(x + 1 - r, y + 1, z + 1, u1, v0);
+ t->vertexUV(x + 1 - r, y + 0, z + 1, u1, v1);
+ }
+ if ((facings & VineTile_SPU::VINE_NORTH) != 0) {
+ t->vertexUV(x + 1, y + 0, z + r, u1, v1);
+ t->vertexUV(x + 1, y + 1, z + r, u1, v0);
+ t->vertexUV(x + 0, y + 1, z + r, u0, v0);
+ t->vertexUV(x + 0, y + 0, z + r, u0, v1);
- t->vertexUV( x + 1 - r, y + 0, z + 0, u0, v1 );
- t->vertexUV( x + 1 - r, y + 1, z + 0, u0, v0 );
- t->vertexUV( x + 1 - r, y + 1, z + 1, u1, v0 );
- t->vertexUV( x + 1 - r, y + 0, z + 1, u1, v1 );
- }
- if ( ( facings & VineTile_SPU::VINE_NORTH ) != 0 )
- {
- t->vertexUV( x + 1, y + 0, z + r, u1, v1 );
- t->vertexUV( x + 1, y + 1, z + r, u1, v0 );
- t->vertexUV( x + 0, y + 1, z + r, u0, v0 );
- t->vertexUV( x + 0, y + 0, z + r, u0, v1 );
+ t->vertexUV(x + 0, y + 0, z + r, u0, v1);
+ t->vertexUV(x + 0, y + 1, z + r, u0, v0);
+ t->vertexUV(x + 1, y + 1, z + r, u1, v0);
+ t->vertexUV(x + 1, y + 0, z + r, u1, v1);
+ }
+ if ((facings & VineTile_SPU::VINE_SOUTH) != 0) {
+ t->vertexUV(x + 1, y + 1, z + 1 - r, u0, v0);
+ t->vertexUV(x + 1, y + 0, z + 1 - r, u0, v1);
+ t->vertexUV(x + 0, y + 0, z + 1 - r, u1, v1);
+ t->vertexUV(x + 0, y + 1, z + 1 - r, u1, v0);
- t->vertexUV( x + 0, y + 0, z + r, u0, v1 );
- t->vertexUV( x + 0, y + 1, z + r, u0, v0 );
- t->vertexUV( x + 1, y + 1, z + r, u1, v0 );
- t->vertexUV( x + 1, y + 0, z + r, u1, v1 );
- }
- if ( ( facings & VineTile_SPU::VINE_SOUTH ) != 0 )
- {
- t->vertexUV( x + 1, y + 1, z + 1 - r, u0, v0 );
- t->vertexUV( x + 1, y + 0, z + 1 - r, u0, v1 );
- t->vertexUV( x + 0, y + 0, z + 1 - r, u1, v1 );
- t->vertexUV( x + 0, y + 1, z + 1 - r, u1, v0 );
-
- t->vertexUV( x + 0, y + 1, z + 1 - r, u1, v0 );
- t->vertexUV( x + 0, y + 0, z + 1 - r, u1, v1 );
- t->vertexUV( x + 1, y + 0, z + 1 - r, u0, v1 );
- t->vertexUV( x + 1, y + 1, z + 1 - r, u0, v0 );
- }
- if ( level->isSolidBlockingTile( x, y + 1, z ) )
- {
- t->vertexUV( x + 1, y + 1 - r, z + 0, u0, v0 );
- t->vertexUV( x + 1, y + 1 - r, z + 1, u0, v1 );
- t->vertexUV( x + 0, y + 1 - r, z + 1, u1, v1 );
- t->vertexUV( x + 0, y + 1 - r, z + 0, u1, v0 );
- }
- return true;
+ t->vertexUV(x + 0, y + 1, z + 1 - r, u1, v0);
+ t->vertexUV(x + 0, y + 0, z + 1 - r, u1, v1);
+ t->vertexUV(x + 1, y + 0, z + 1 - r, u0, v1);
+ t->vertexUV(x + 1, y + 1, z + 1 - r, u0, v0);
+ }
+ if (level->isSolidBlockingTile(x, y + 1, z)) {
+ t->vertexUV(x + 1, y + 1 - r, z + 0, u0, v0);
+ t->vertexUV(x + 1, y + 1 - r, z + 1, u0, v1);
+ t->vertexUV(x + 0, y + 1 - r, z + 1, u1, v1);
+ t->vertexUV(x + 0, y + 1 - r, z + 0, u1, v0);
+ }
+ return true;
}
-bool TileRenderer_SPU::tesselateThinFenceInWorld( ThinFenceTile* tt, int x, int y, int z )
-{
+bool TileRenderer_SPU::tesselateThinFenceInWorld(ThinFenceTile* tt, int x,
+ int y, int z) {
#ifdef DISABLE_TESS_FUNCS
- int depth = level->getDepth();
- Tesselator_SPU* t = getTesselator();
+ int depth = level->getDepth();
+ Tesselator_SPU* t = getTesselator();
- float br;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tt->getLightColor( level, x, y, z ) );
- br = 1;
- }
- else
- {
- br = tt->getBrightness( level, x, y, z );
- }
- int col = tt->getColor( level, x, y, z );
- float r = ( ( col >> 16 ) & 0xff ) / 255.0f;
- float g = ( ( col >> 8 ) & 0xff ) / 255.0f;
- float b = ( ( col )& 0xff ) / 255.0f;
+ float br;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ br = 1;
+ } else {
+ br = tt->getBrightness(level, x, y, z);
+ }
+ int col = tt->getColor(level, x, y, z);
+ float r = ((col >> 16) & 0xff) / 255.0f;
+ float g = ((col >> 8) & 0xff) / 255.0f;
+ float b = ((col) & 0xff) / 255.0f;
- if ( GameRenderer::anaglyph3d )
- {
- float cr = ( r * 30 + g * 59 + b * 11 ) / 100;
- float cg = ( r * 30 + g * 70 ) / ( 100 );
- float cb = ( r * 30 + b * 70 ) / ( 100 );
+ if (GameRenderer::anaglyph3d) {
+ float cr = (r * 30 + g * 59 + b * 11) / 100;
+ float cg = (r * 30 + g * 70) / (100);
+ float cb = (r * 30 + b * 70) / (100);
- r = cr;
- g = cg;
- b = cb;
- }
- t->color( br * r, br * g, br * b );
+ r = cr;
+ g = cg;
+ b = cb;
+ }
+ t->color(br * r, br * g, br * b);
- Icon_SPU *tex;
- Icon_SPU *edgeTex;
+ Icon_SPU* tex;
+ Icon_SPU* edgeTex;
- if ( hasFixedTexture() )
- {
- tex = fixedTexture;
- edgeTex = fixedTexture;
- }
- else
- {
- int data = level->getData( x, y, z );
- tex = getTexture( tt, 0, data );
- edgeTex = tt->getEdgeTexture();
- }
+ if (hasFixedTexture()) {
+ tex = fixedTexture;
+ edgeTex = fixedTexture;
+ } else {
+ int data = level->getData(x, y, z);
+ tex = getTexture(tt, 0, data);
+ edgeTex = tt->getEdgeTexture();
+ }
- int xt = tex->getX();
- int yt = tex->getY();
- float u0 = tex->getU0();
- float u1 = tex->getU(8);
- float u2 = tex->getU1();
- float v0 = tex->getV0();
- float v2 = tex->getV1();
+ int xt = tex->getX();
+ int yt = tex->getY();
+ float u0 = tex->getU0();
+ float u1 = tex->getU(8);
+ float u2 = tex->getU1();
+ float v0 = tex->getV0();
+ float v2 = tex->getV1();
- int xet = edgeTex->getX();
- int yet = edgeTex->getY();
+ int xet = edgeTex->getX();
+ int yet = edgeTex->getY();
- float iu0 = edgeTex->getU(7);
- float iu1 = edgeTex->getU(9);
- float iv0 = edgeTex->getV0();
- float iv1 = edgeTex->getV(8);
- float iv2 = edgeTex->getV1();
+ float iu0 = edgeTex->getU(7);
+ float iu1 = edgeTex->getU(9);
+ float iv0 = edgeTex->getV0();
+ float iv1 = edgeTex->getV(8);
+ float iv2 = edgeTex->getV1();
- float x0 = (float)x;
- float x1 = x + 0.5f;
- float x2 = x + 1.0f;
- float z0 = (float)z;
- float z1 = z + 0.5f;
- float z2 = z + 1.0f;
- float ix0 = x + 0.5f - 1.0f / 16.0f;
- float ix1 = x + 0.5f + 1.0f / 16.0f;
- float iz0 = z + 0.5f - 1.0f / 16.0f;
- float iz1 = z + 0.5f + 1.0f / 16.0f;
+ float x0 = (float)x;
+ float x1 = x + 0.5f;
+ float x2 = x + 1.0f;
+ float z0 = (float)z;
+ float z1 = z + 0.5f;
+ float z2 = z + 1.0f;
+ float ix0 = x + 0.5f - 1.0f / 16.0f;
+ float ix1 = x + 0.5f + 1.0f / 16.0f;
+ float iz0 = z + 0.5f - 1.0f / 16.0f;
+ float iz1 = z + 0.5f + 1.0f / 16.0f;
- bool n = tt->attachsTo( level->getTile( x, y, z - 1 ) );
- bool s = tt->attachsTo( level->getTile( x, y, z + 1 ) );
- bool w = tt->attachsTo( level->getTile( x - 1, y, z ) );
- bool e = tt->attachsTo( level->getTile( x + 1, y, z ) );
+ bool n = tt->attachsTo(level->getTile(x, y, z - 1));
+ bool s = tt->attachsTo(level->getTile(x, y, z + 1));
+ bool w = tt->attachsTo(level->getTile(x - 1, y, z));
+ bool e = tt->attachsTo(level->getTile(x + 1, y, z));
- bool up = tt->shouldRenderFace( level, x, y + 1, z, Facing::UP );
- bool down = tt->shouldRenderFace( level, x, y - 1, z, Facing::DOWN );
+ bool up = tt->shouldRenderFace(level, x, y + 1, z, Facing::UP);
+ bool down = tt->shouldRenderFace(level, x, y - 1, z, Facing::DOWN);
- const float noZFightingOffset = 0.01f;
- const float noZFightingOffsetB = 0.005;
+ const float noZFightingOffset = 0.01f;
+ const float noZFightingOffsetB = 0.005;
- if ( ( w && e ) || ( !w && !e && !n && !s ) )
- {
- t->vertexUV( x0, y + 1, z1, u0, v0 );
- t->vertexUV( x0, y + 0, z1, u0, v2 );
- t->vertexUV( x2, y + 0, z1, u2, v2 );
- t->vertexUV( x2, y + 1, z1, u2, v0 );
+ if ((w && e) || (!w && !e && !n && !s)) {
+ t->vertexUV(x0, y + 1, z1, u0, v0);
+ t->vertexUV(x0, y + 0, z1, u0, v2);
+ t->vertexUV(x2, y + 0, z1, u2, v2);
+ t->vertexUV(x2, y + 1, z1, u2, v0);
- t->vertexUV( x2, y + 1, z1, u0, v0 );
- t->vertexUV( x2, y + 0, z1, u0, v2 );
- t->vertexUV( x0, y + 0, z1, u2, v2 );
- t->vertexUV( x0, y + 1, z1, u2, v0 );
+ t->vertexUV(x2, y + 1, z1, u0, v0);
+ t->vertexUV(x2, y + 0, z1, u0, v2);
+ t->vertexUV(x0, y + 0, z1, u2, v2);
+ t->vertexUV(x0, y + 1, z1, u2, v0);
- if ( up )
- {
- // small edge texture
- t->vertexUV( x0, y + 1 + noZFightingOffset, iz1, iu1, iv2 );
- t->vertexUV( x2, y + 1 + noZFightingOffset, iz1, iu1, iv0 );
- t->vertexUV( x2, y + 1 + noZFightingOffset, iz0, iu0, iv0 );
- t->vertexUV( x0, y + 1 + noZFightingOffset, iz0, iu0, iv2 );
+ if (up) {
+ // small edge texture
+ t->vertexUV(x0, y + 1 + noZFightingOffset, iz1, iu1, iv2);
+ t->vertexUV(x2, y + 1 + noZFightingOffset, iz1, iu1, iv0);
+ t->vertexUV(x2, y + 1 + noZFightingOffset, iz0, iu0, iv0);
+ t->vertexUV(x0, y + 1 + noZFightingOffset, iz0, iu0, iv2);
- t->vertexUV( x2, y + 1 + noZFightingOffset, iz1, iu1, iv2 );
- t->vertexUV( x0, y + 1 + noZFightingOffset, iz1, iu1, iv0 );
- t->vertexUV( x0, y + 1 + noZFightingOffset, iz0, iu0, iv0 );
- t->vertexUV( x2, y + 1 + noZFightingOffset, iz0, iu0, iv2 );
- }
- else
- {
- if ( y < ( depth - 1 ) && level->isEmptyTile( x - 1, y + 1, z ) )
- {
- t->vertexUV( x0, y + 1 + noZFightingOffset, iz1, iu1, iv1 );
- t->vertexUV( x1, y + 1 + noZFightingOffset, iz1, iu1, iv2 );
- t->vertexUV( x1, y + 1 + noZFightingOffset, iz0, iu0, iv2 );
- t->vertexUV( x0, y + 1 + noZFightingOffset, iz0, iu0, iv1 );
+ t->vertexUV(x2, y + 1 + noZFightingOffset, iz1, iu1, iv2);
+ t->vertexUV(x0, y + 1 + noZFightingOffset, iz1, iu1, iv0);
+ t->vertexUV(x0, y + 1 + noZFightingOffset, iz0, iu0, iv0);
+ t->vertexUV(x2, y + 1 + noZFightingOffset, iz0, iu0, iv2);
+ } else {
+ if (y < (depth - 1) && level->isEmptyTile(x - 1, y + 1, z)) {
+ t->vertexUV(x0, y + 1 + noZFightingOffset, iz1, iu1, iv1);
+ t->vertexUV(x1, y + 1 + noZFightingOffset, iz1, iu1, iv2);
+ t->vertexUV(x1, y + 1 + noZFightingOffset, iz0, iu0, iv2);
+ t->vertexUV(x0, y + 1 + noZFightingOffset, iz0, iu0, iv1);
- t->vertexUV( x1, y + 1 + noZFightingOffset, iz1, iu1, iv1 );
- t->vertexUV( x0, y + 1 + noZFightingOffset, iz1, iu1, iv2 );
- t->vertexUV( x0, y + 1 + noZFightingOffset, iz0, iu0, iv2 );
- t->vertexUV( x1, y + 1 + noZFightingOffset, iz0, iu0, iv1 );
- }
- if ( y < ( depth - 1 ) && level->isEmptyTile( x + 1, y + 1, z ) )
- {
- t->vertexUV( x1, y + 1 + noZFightingOffset, iz1, iu1, iv0 );
- t->vertexUV( x2, y + 1 + noZFightingOffset, iz1, iu1, iv1 );
- t->vertexUV( x2, y + 1 + noZFightingOffset, iz0, iu0, iv1 );
- t->vertexUV( x1, y + 1 + noZFightingOffset, iz0, iu0, iv0 );
+ t->vertexUV(x1, y + 1 + noZFightingOffset, iz1, iu1, iv1);
+ t->vertexUV(x0, y + 1 + noZFightingOffset, iz1, iu1, iv2);
+ t->vertexUV(x0, y + 1 + noZFightingOffset, iz0, iu0, iv2);
+ t->vertexUV(x1, y + 1 + noZFightingOffset, iz0, iu0, iv1);
+ }
+ if (y < (depth - 1) && level->isEmptyTile(x + 1, y + 1, z)) {
+ t->vertexUV(x1, y + 1 + noZFightingOffset, iz1, iu1, iv0);
+ t->vertexUV(x2, y + 1 + noZFightingOffset, iz1, iu1, iv1);
+ t->vertexUV(x2, y + 1 + noZFightingOffset, iz0, iu0, iv1);
+ t->vertexUV(x1, y + 1 + noZFightingOffset, iz0, iu0, iv0);
- t->vertexUV( x2, y + 1 + noZFightingOffset, iz1, iu1, iv0 );
- t->vertexUV( x1, y + 1 + noZFightingOffset, iz1, iu1, iv1 );
- t->vertexUV( x1, y + 1 + noZFightingOffset, iz0, iu0, iv1 );
- t->vertexUV( x2, y + 1 + noZFightingOffset, iz0, iu0, iv0 );
- }
- }
- if ( down )
- {
- // small edge texture
- t->vertexUV( x0, y - noZFightingOffset, iz1, iu1, iv2 );
- t->vertexUV( x2, y - noZFightingOffset, iz1, iu1, iv0 );
- t->vertexUV( x2, y - noZFightingOffset, iz0, iu0, iv0 );
- t->vertexUV( x0, y - noZFightingOffset, iz0, iu0, iv2 );
+ t->vertexUV(x2, y + 1 + noZFightingOffset, iz1, iu1, iv0);
+ t->vertexUV(x1, y + 1 + noZFightingOffset, iz1, iu1, iv1);
+ t->vertexUV(x1, y + 1 + noZFightingOffset, iz0, iu0, iv1);
+ t->vertexUV(x2, y + 1 + noZFightingOffset, iz0, iu0, iv0);
+ }
+ }
+ if (down) {
+ // small edge texture
+ t->vertexUV(x0, y - noZFightingOffset, iz1, iu1, iv2);
+ t->vertexUV(x2, y - noZFightingOffset, iz1, iu1, iv0);
+ t->vertexUV(x2, y - noZFightingOffset, iz0, iu0, iv0);
+ t->vertexUV(x0, y - noZFightingOffset, iz0, iu0, iv2);
- t->vertexUV( x2, y - noZFightingOffset, iz1, iu1, iv2 );
- t->vertexUV( x0, y - noZFightingOffset, iz1, iu1, iv0 );
- t->vertexUV( x0, y - noZFightingOffset, iz0, iu0, iv0 );
- t->vertexUV( x2, y - noZFightingOffset, iz0, iu0, iv2 );
- }
- else
- {
- if ( y > 1 && level->isEmptyTile( x - 1, y - 1, z ) )
- {
- t->vertexUV( x0, y - noZFightingOffset, iz1, iu1, iv1 );
- t->vertexUV( x1, y - noZFightingOffset, iz1, iu1, iv2 );
- t->vertexUV( x1, y - noZFightingOffset, iz0, iu0, iv2 );
- t->vertexUV( x0, y - noZFightingOffset, iz0, iu0, iv1 );
+ t->vertexUV(x2, y - noZFightingOffset, iz1, iu1, iv2);
+ t->vertexUV(x0, y - noZFightingOffset, iz1, iu1, iv0);
+ t->vertexUV(x0, y - noZFightingOffset, iz0, iu0, iv0);
+ t->vertexUV(x2, y - noZFightingOffset, iz0, iu0, iv2);
+ } else {
+ if (y > 1 && level->isEmptyTile(x - 1, y - 1, z)) {
+ t->vertexUV(x0, y - noZFightingOffset, iz1, iu1, iv1);
+ t->vertexUV(x1, y - noZFightingOffset, iz1, iu1, iv2);
+ t->vertexUV(x1, y - noZFightingOffset, iz0, iu0, iv2);
+ t->vertexUV(x0, y - noZFightingOffset, iz0, iu0, iv1);
- t->vertexUV( x1, y - noZFightingOffset, iz1, iu1, iv1 );
- t->vertexUV( x0, y - noZFightingOffset, iz1, iu1, iv2 );
- t->vertexUV( x0, y - noZFightingOffset, iz0, iu0, iv2 );
- t->vertexUV( x1, y - noZFightingOffset, iz0, iu0, iv1 );
- }
- if ( y > 1 && level->isEmptyTile( x + 1, y - 1, z ) )
- {
- t->vertexUV( x1, y - noZFightingOffset, iz1, iu1, iv0 );
- t->vertexUV( x2, y - noZFightingOffset, iz1, iu1, iv1 );
- t->vertexUV( x2, y - noZFightingOffset, iz0, iu0, iv1 );
- t->vertexUV( x1, y - noZFightingOffset, iz0, iu0, iv0 );
+ t->vertexUV(x1, y - noZFightingOffset, iz1, iu1, iv1);
+ t->vertexUV(x0, y - noZFightingOffset, iz1, iu1, iv2);
+ t->vertexUV(x0, y - noZFightingOffset, iz0, iu0, iv2);
+ t->vertexUV(x1, y - noZFightingOffset, iz0, iu0, iv1);
+ }
+ if (y > 1 && level->isEmptyTile(x + 1, y - 1, z)) {
+ t->vertexUV(x1, y - noZFightingOffset, iz1, iu1, iv0);
+ t->vertexUV(x2, y - noZFightingOffset, iz1, iu1, iv1);
+ t->vertexUV(x2, y - noZFightingOffset, iz0, iu0, iv1);
+ t->vertexUV(x1, y - noZFightingOffset, iz0, iu0, iv0);
- t->vertexUV( x2, y - noZFightingOffset, iz1, iu1, iv0 );
- t->vertexUV( x1, y - noZFightingOffset, iz1, iu1, iv1 );
- t->vertexUV( x1, y - noZFightingOffset, iz0, iu0, iv1 );
- t->vertexUV( x2, y - noZFightingOffset, iz0, iu0, iv0 );
- }
- }
- }
- else if ( w && !e )
- {
- // half-step towards west
- t->vertexUV( x0, y + 1, z1, u0, v0 );
- t->vertexUV( x0, y + 0, z1, u0, v2 );
- t->vertexUV( x1, y + 0, z1, u1, v2 );
- t->vertexUV( x1, y + 1, z1, u1, v0 );
+ t->vertexUV(x2, y - noZFightingOffset, iz1, iu1, iv0);
+ t->vertexUV(x1, y - noZFightingOffset, iz1, iu1, iv1);
+ t->vertexUV(x1, y - noZFightingOffset, iz0, iu0, iv1);
+ t->vertexUV(x2, y - noZFightingOffset, iz0, iu0, iv0);
+ }
+ }
+ } else if (w && !e) {
+ // half-step towards west
+ t->vertexUV(x0, y + 1, z1, u0, v0);
+ t->vertexUV(x0, y + 0, z1, u0, v2);
+ t->vertexUV(x1, y + 0, z1, u1, v2);
+ t->vertexUV(x1, y + 1, z1, u1, v0);
- t->vertexUV( x1, y + 1, z1, u0, v0 );
- t->vertexUV( x1, y + 0, z1, u0, v2 );
- t->vertexUV( x0, y + 0, z1, u1, v2 );
- t->vertexUV( x0, y + 1, z1, u1, v0 );
+ t->vertexUV(x1, y + 1, z1, u0, v0);
+ t->vertexUV(x1, y + 0, z1, u0, v2);
+ t->vertexUV(x0, y + 0, z1, u1, v2);
+ t->vertexUV(x0, y + 1, z1, u1, v0);
- // small edge texture
- if ( !s && !n )
- {
- t->vertexUV( x1, y + 1, iz1, iu0, iv0 );
- t->vertexUV( x1, y + 0, iz1, iu0, iv2 );
- t->vertexUV( x1, y + 0, iz0, iu1, iv2 );
- t->vertexUV( x1, y + 1, iz0, iu1, iv0 );
+ // small edge texture
+ if (!s && !n) {
+ t->vertexUV(x1, y + 1, iz1, iu0, iv0);
+ t->vertexUV(x1, y + 0, iz1, iu0, iv2);
+ t->vertexUV(x1, y + 0, iz0, iu1, iv2);
+ t->vertexUV(x1, y + 1, iz0, iu1, iv0);
- t->vertexUV( x1, y + 1, iz0, iu0, iv0 );
- t->vertexUV( x1, y + 0, iz0, iu0, iv2 );
- t->vertexUV( x1, y + 0, iz1, iu1, iv2 );
- t->vertexUV( x1, y + 1, iz1, iu1, iv0 );
- }
+ t->vertexUV(x1, y + 1, iz0, iu0, iv0);
+ t->vertexUV(x1, y + 0, iz0, iu0, iv2);
+ t->vertexUV(x1, y + 0, iz1, iu1, iv2);
+ t->vertexUV(x1, y + 1, iz1, iu1, iv0);
+ }
- if ( up || ( y < ( depth - 1 ) && level->isEmptyTile( x - 1, y + 1, z ) ) )
- {
- // small edge texture
- t->vertexUV( x0, y + 1 + noZFightingOffset, iz1, iu1, iv1 );
- t->vertexUV( x1, y + 1 + noZFightingOffset, iz1, iu1, iv2 );
- t->vertexUV( x1, y + 1 + noZFightingOffset, iz0, iu0, iv2 );
- t->vertexUV( x0, y + 1 + noZFightingOffset, iz0, iu0, iv1 );
+ if (up || (y < (depth - 1) && level->isEmptyTile(x - 1, y + 1, z))) {
+ // small edge texture
+ t->vertexUV(x0, y + 1 + noZFightingOffset, iz1, iu1, iv1);
+ t->vertexUV(x1, y + 1 + noZFightingOffset, iz1, iu1, iv2);
+ t->vertexUV(x1, y + 1 + noZFightingOffset, iz0, iu0, iv2);
+ t->vertexUV(x0, y + 1 + noZFightingOffset, iz0, iu0, iv1);
- t->vertexUV( x1, y + 1 + noZFightingOffset, iz1, iu1, iv1 );
- t->vertexUV( x0, y + 1 + noZFightingOffset, iz1, iu1, iv2 );
- t->vertexUV( x0, y + 1 + noZFightingOffset, iz0, iu0, iv2 );
- t->vertexUV( x1, y + 1 + noZFightingOffset, iz0, iu0, iv1 );
- }
- if ( down || ( y > 1 && level->isEmptyTile( x - 1, y - 1, z ) ) )
- {
- // small edge texture
- t->vertexUV( x0, y - noZFightingOffset, iz1, iu1, iv1 );
- t->vertexUV( x1, y - noZFightingOffset, iz1, iu1, iv2 );
- t->vertexUV( x1, y - noZFightingOffset, iz0, iu0, iv2 );
- t->vertexUV( x0, y - noZFightingOffset, iz0, iu0, iv1 );
+ t->vertexUV(x1, y + 1 + noZFightingOffset, iz1, iu1, iv1);
+ t->vertexUV(x0, y + 1 + noZFightingOffset, iz1, iu1, iv2);
+ t->vertexUV(x0, y + 1 + noZFightingOffset, iz0, iu0, iv2);
+ t->vertexUV(x1, y + 1 + noZFightingOffset, iz0, iu0, iv1);
+ }
+ if (down || (y > 1 && level->isEmptyTile(x - 1, y - 1, z))) {
+ // small edge texture
+ t->vertexUV(x0, y - noZFightingOffset, iz1, iu1, iv1);
+ t->vertexUV(x1, y - noZFightingOffset, iz1, iu1, iv2);
+ t->vertexUV(x1, y - noZFightingOffset, iz0, iu0, iv2);
+ t->vertexUV(x0, y - noZFightingOffset, iz0, iu0, iv1);
- t->vertexUV( x1, y - noZFightingOffset, iz1, iu1, iv1 );
- t->vertexUV( x0, y - noZFightingOffset, iz1, iu1, iv2 );
- t->vertexUV( x0, y - noZFightingOffset, iz0, iu0, iv2 );
- t->vertexUV( x1, y - noZFightingOffset, iz0, iu0, iv1 );
- }
+ t->vertexUV(x1, y - noZFightingOffset, iz1, iu1, iv1);
+ t->vertexUV(x0, y - noZFightingOffset, iz1, iu1, iv2);
+ t->vertexUV(x0, y - noZFightingOffset, iz0, iu0, iv2);
+ t->vertexUV(x1, y - noZFightingOffset, iz0, iu0, iv1);
+ }
- }
- else if ( !w && e )
- {
- // half-step towards east
- t->vertexUV( x1, y + 1, z1, u1, v0 );
- t->vertexUV( x1, y + 0, z1, u1, v2 );
- t->vertexUV( x2, y + 0, z1, u2, v2 );
- t->vertexUV( x2, y + 1, z1, u2, v0 );
+ } else if (!w && e) {
+ // half-step towards east
+ t->vertexUV(x1, y + 1, z1, u1, v0);
+ t->vertexUV(x1, y + 0, z1, u1, v2);
+ t->vertexUV(x2, y + 0, z1, u2, v2);
+ t->vertexUV(x2, y + 1, z1, u2, v0);
- t->vertexUV( x2, y + 1, z1, u1, v0 );
- t->vertexUV( x2, y + 0, z1, u1, v2 );
- t->vertexUV( x1, y + 0, z1, u2, v2 );
- t->vertexUV( x1, y + 1, z1, u2, v0 );
+ t->vertexUV(x2, y + 1, z1, u1, v0);
+ t->vertexUV(x2, y + 0, z1, u1, v2);
+ t->vertexUV(x1, y + 0, z1, u2, v2);
+ t->vertexUV(x1, y + 1, z1, u2, v0);
- // small edge texture
- if ( !s && !n )
- {
- t->vertexUV( x1, y + 1, iz0, iu0, iv0 );
- t->vertexUV( x1, y + 0, iz0, iu0, iv2 );
- t->vertexUV( x1, y + 0, iz1, iu1, iv2 );
- t->vertexUV( x1, y + 1, iz1, iu1, iv0 );
+ // small edge texture
+ if (!s && !n) {
+ t->vertexUV(x1, y + 1, iz0, iu0, iv0);
+ t->vertexUV(x1, y + 0, iz0, iu0, iv2);
+ t->vertexUV(x1, y + 0, iz1, iu1, iv2);
+ t->vertexUV(x1, y + 1, iz1, iu1, iv0);
- t->vertexUV( x1, y + 1, iz1, iu0, iv0 );
- t->vertexUV( x1, y + 0, iz1, iu0, iv2 );
- t->vertexUV( x1, y + 0, iz0, iu1, iv2 );
- t->vertexUV( x1, y + 1, iz0, iu1, iv0 );
- }
+ t->vertexUV(x1, y + 1, iz1, iu0, iv0);
+ t->vertexUV(x1, y + 0, iz1, iu0, iv2);
+ t->vertexUV(x1, y + 0, iz0, iu1, iv2);
+ t->vertexUV(x1, y + 1, iz0, iu1, iv0);
+ }
- if ( up || ( y < ( depth - 1 ) && level->isEmptyTile( x + 1, y + 1, z ) ) )
- {
- // small edge texture
- t->vertexUV( x1, y + 1 + noZFightingOffset, iz1, iu1, iv0 );
- t->vertexUV( x2, y + 1 + noZFightingOffset, iz1, iu1, iv1 );
- t->vertexUV( x2, y + 1 + noZFightingOffset, iz0, iu0, iv1 );
- t->vertexUV( x1, y + 1 + noZFightingOffset, iz0, iu0, iv0 );
+ if (up || (y < (depth - 1) && level->isEmptyTile(x + 1, y + 1, z))) {
+ // small edge texture
+ t->vertexUV(x1, y + 1 + noZFightingOffset, iz1, iu1, iv0);
+ t->vertexUV(x2, y + 1 + noZFightingOffset, iz1, iu1, iv1);
+ t->vertexUV(x2, y + 1 + noZFightingOffset, iz0, iu0, iv1);
+ t->vertexUV(x1, y + 1 + noZFightingOffset, iz0, iu0, iv0);
- t->vertexUV( x2, y + 1 + noZFightingOffset, iz1, iu1, iv0 );
- t->vertexUV( x1, y + 1 + noZFightingOffset, iz1, iu1, iv1 );
- t->vertexUV( x1, y + 1 + noZFightingOffset, iz0, iu0, iv1 );
- t->vertexUV( x2, y + 1 + noZFightingOffset, iz0, iu0, iv0 );
- }
- if ( down || ( y > 1 && level->isEmptyTile( x + 1, y - 1, z ) ) )
- {
- // small edge texture
- t->vertexUV( x1, y - noZFightingOffset, iz1, iu1, iv0 );
- t->vertexUV( x2, y - noZFightingOffset, iz1, iu1, iv1 );
- t->vertexUV( x2, y - noZFightingOffset, iz0, iu0, iv1 );
- t->vertexUV( x1, y - noZFightingOffset, iz0, iu0, iv0 );
+ t->vertexUV(x2, y + 1 + noZFightingOffset, iz1, iu1, iv0);
+ t->vertexUV(x1, y + 1 + noZFightingOffset, iz1, iu1, iv1);
+ t->vertexUV(x1, y + 1 + noZFightingOffset, iz0, iu0, iv1);
+ t->vertexUV(x2, y + 1 + noZFightingOffset, iz0, iu0, iv0);
+ }
+ if (down || (y > 1 && level->isEmptyTile(x + 1, y - 1, z))) {
+ // small edge texture
+ t->vertexUV(x1, y - noZFightingOffset, iz1, iu1, iv0);
+ t->vertexUV(x2, y - noZFightingOffset, iz1, iu1, iv1);
+ t->vertexUV(x2, y - noZFightingOffset, iz0, iu0, iv1);
+ t->vertexUV(x1, y - noZFightingOffset, iz0, iu0, iv0);
- t->vertexUV( x2, y - noZFightingOffset, iz1, iu1, iv0 );
- t->vertexUV( x1, y - noZFightingOffset, iz1, iu1, iv1 );
- t->vertexUV( x1, y - noZFightingOffset, iz0, iu0, iv1 );
- t->vertexUV( x2, y - noZFightingOffset, iz0, iu0, iv0 );
- }
+ t->vertexUV(x2, y - noZFightingOffset, iz1, iu1, iv0);
+ t->vertexUV(x1, y - noZFightingOffset, iz1, iu1, iv1);
+ t->vertexUV(x1, y - noZFightingOffset, iz0, iu0, iv1);
+ t->vertexUV(x2, y - noZFightingOffset, iz0, iu0, iv0);
+ }
+ }
- }
+ if ((n && s) || (!w && !e && !n && !s)) {
+ // straight north-south
+ t->vertexUV(x1, y + 1, z2, u0, v0);
+ t->vertexUV(x1, y + 0, z2, u0, v2);
+ t->vertexUV(x1, y + 0, z0, u2, v2);
+ t->vertexUV(x1, y + 1, z0, u2, v0);
- if ( ( n && s ) || ( !w && !e && !n && !s ) )
- {
- // straight north-south
- t->vertexUV( x1, y + 1, z2, u0, v0 );
- t->vertexUV( x1, y + 0, z2, u0, v2 );
- t->vertexUV( x1, y + 0, z0, u2, v2 );
- t->vertexUV( x1, y + 1, z0, u2, v0 );
+ t->vertexUV(x1, y + 1, z0, u0, v0);
+ t->vertexUV(x1, y + 0, z0, u0, v2);
+ t->vertexUV(x1, y + 0, z2, u2, v2);
+ t->vertexUV(x1, y + 1, z2, u2, v0);
- t->vertexUV( x1, y + 1, z0, u0, v0 );
- t->vertexUV( x1, y + 0, z0, u0, v2 );
- t->vertexUV( x1, y + 0, z2, u2, v2 );
- t->vertexUV( x1, y + 1, z2, u2, v0 );
+ if (up) {
+ // small edge texture
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z2, iu1, iv2);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z0, iu1, iv0);
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z0, iu0, iv0);
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z2, iu0, iv2);
- if ( up )
- {
- // small edge texture
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z2, iu1, iv2 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z0, iu1, iv0 );
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z0, iu0, iv0 );
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z2, iu0, iv2 );
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z0, iu1, iv2);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z2, iu1, iv0);
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z2, iu0, iv0);
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z0, iu0, iv2);
+ } else {
+ if (y < (depth - 1) && level->isEmptyTile(x, y + 1, z - 1)) {
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z0, iu1, iv0);
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z1, iu1, iv1);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z1, iu0, iv1);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z0, iu0, iv0);
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z0, iu1, iv2 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z2, iu1, iv0 );
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z2, iu0, iv0 );
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z0, iu0, iv2 );
- }
- else
- {
- if ( y < ( depth - 1 ) && level->isEmptyTile( x, y + 1, z - 1 ) )
- {
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z0, iu1, iv0 );
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z1, iu1, iv1 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z1, iu0, iv1 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z0, iu0, iv0 );
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z1, iu1, iv0);
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z0, iu1, iv1);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z0, iu0, iv1);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z1, iu0, iv0);
+ }
+ if (y < (depth - 1) && level->isEmptyTile(x, y + 1, z + 1)) {
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z1, iu0, iv1);
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z2, iu0, iv2);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z2, iu1, iv2);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z1, iu1, iv1);
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z1, iu1, iv0 );
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z0, iu1, iv1 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z0, iu0, iv1 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z1, iu0, iv0 );
- }
- if ( y < ( depth - 1 ) && level->isEmptyTile( x, y + 1, z + 1 ) )
- {
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z1, iu0, iv1 );
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z2, iu0, iv2 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z2, iu1, iv2 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z1, iu1, iv1 );
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z2, iu0, iv1);
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z1, iu0, iv2);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z1, iu1, iv2);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z2, iu1, iv1);
+ }
+ }
+ if (down) {
+ // small edge texture
+ t->vertexUV(ix1, y - noZFightingOffset, z2, iu1, iv2);
+ t->vertexUV(ix1, y - noZFightingOffset, z0, iu1, iv0);
+ t->vertexUV(ix0, y - noZFightingOffset, z0, iu0, iv0);
+ t->vertexUV(ix0, y - noZFightingOffset, z2, iu0, iv2);
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z2, iu0, iv1 );
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z1, iu0, iv2 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z1, iu1, iv2 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z2, iu1, iv1 );
- }
- }
- if ( down )
- {
- // small edge texture
- t->vertexUV( ix1, y - noZFightingOffset, z2, iu1, iv2 );
- t->vertexUV( ix1, y - noZFightingOffset, z0, iu1, iv0 );
- t->vertexUV( ix0, y - noZFightingOffset, z0, iu0, iv0 );
- t->vertexUV( ix0, y - noZFightingOffset, z2, iu0, iv2 );
+ t->vertexUV(ix1, y - noZFightingOffset, z0, iu1, iv2);
+ t->vertexUV(ix1, y - noZFightingOffset, z2, iu1, iv0);
+ t->vertexUV(ix0, y - noZFightingOffset, z2, iu0, iv0);
+ t->vertexUV(ix0, y - noZFightingOffset, z0, iu0, iv2);
+ } else {
+ if (y > 1 && level->isEmptyTile(x, y - 1, z - 1)) {
+ // north half-step
+ t->vertexUV(ix0, y - noZFightingOffset, z0, iu1, iv0);
+ t->vertexUV(ix0, y - noZFightingOffset, z1, iu1, iv1);
+ t->vertexUV(ix1, y - noZFightingOffset, z1, iu0, iv1);
+ t->vertexUV(ix1, y - noZFightingOffset, z0, iu0, iv0);
- t->vertexUV( ix1, y - noZFightingOffset, z0, iu1, iv2 );
- t->vertexUV( ix1, y - noZFightingOffset, z2, iu1, iv0 );
- t->vertexUV( ix0, y - noZFightingOffset, z2, iu0, iv0 );
- t->vertexUV( ix0, y - noZFightingOffset, z0, iu0, iv2 );
- }
- else
- {
- if ( y > 1 && level->isEmptyTile( x, y - 1, z - 1 ) )
- {
- // north half-step
- t->vertexUV( ix0, y - noZFightingOffset, z0, iu1, iv0 );
- t->vertexUV( ix0, y - noZFightingOffset, z1, iu1, iv1 );
- t->vertexUV( ix1, y - noZFightingOffset, z1, iu0, iv1 );
- t->vertexUV( ix1, y - noZFightingOffset, z0, iu0, iv0 );
+ t->vertexUV(ix0, y - noZFightingOffset, z1, iu1, iv0);
+ t->vertexUV(ix0, y - noZFightingOffset, z0, iu1, iv1);
+ t->vertexUV(ix1, y - noZFightingOffset, z0, iu0, iv1);
+ t->vertexUV(ix1, y - noZFightingOffset, z1, iu0, iv0);
+ }
+ if (y > 1 && level->isEmptyTile(x, y - 1, z + 1)) {
+ // south half-step
+ t->vertexUV(ix0, y - noZFightingOffset, z1, iu0, iv1);
+ t->vertexUV(ix0, y - noZFightingOffset, z2, iu0, iv2);
+ t->vertexUV(ix1, y - noZFightingOffset, z2, iu1, iv2);
+ t->vertexUV(ix1, y - noZFightingOffset, z1, iu1, iv1);
- t->vertexUV( ix0, y - noZFightingOffset, z1, iu1, iv0 );
- t->vertexUV( ix0, y - noZFightingOffset, z0, iu1, iv1 );
- t->vertexUV( ix1, y - noZFightingOffset, z0, iu0, iv1 );
- t->vertexUV( ix1, y - noZFightingOffset, z1, iu0, iv0 );
- }
- if ( y > 1 && level->isEmptyTile( x, y - 1, z + 1 ) )
- {
- // south half-step
- t->vertexUV( ix0, y - noZFightingOffset, z1, iu0, iv1 );
- t->vertexUV( ix0, y - noZFightingOffset, z2, iu0, iv2 );
- t->vertexUV( ix1, y - noZFightingOffset, z2, iu1, iv2 );
- t->vertexUV( ix1, y - noZFightingOffset, z1, iu1, iv1 );
+ t->vertexUV(ix0, y - noZFightingOffset, z2, iu0, iv1);
+ t->vertexUV(ix0, y - noZFightingOffset, z1, iu0, iv2);
+ t->vertexUV(ix1, y - noZFightingOffset, z1, iu1, iv2);
+ t->vertexUV(ix1, y - noZFightingOffset, z2, iu1, iv1);
+ }
+ }
- t->vertexUV( ix0, y - noZFightingOffset, z2, iu0, iv1 );
- t->vertexUV( ix0, y - noZFightingOffset, z1, iu0, iv2 );
- t->vertexUV( ix1, y - noZFightingOffset, z1, iu1, iv2 );
- t->vertexUV( ix1, y - noZFightingOffset, z2, iu1, iv1 );
- }
- }
+ } else if (n && !s) {
+ // half-step towards north
+ t->vertexUV(x1, y + 1, z0, u0, v0);
+ t->vertexUV(x1, y + 0, z0, u0, v2);
+ t->vertexUV(x1, y + 0, z1, u1, v2);
+ t->vertexUV(x1, y + 1, z1, u1, v0);
- }
- else if ( n && !s )
- {
- // half-step towards north
- t->vertexUV( x1, y + 1, z0, u0, v0 );
- t->vertexUV( x1, y + 0, z0, u0, v2 );
- t->vertexUV( x1, y + 0, z1, u1, v2 );
- t->vertexUV( x1, y + 1, z1, u1, v0 );
+ t->vertexUV(x1, y + 1, z1, u0, v0);
+ t->vertexUV(x1, y + 0, z1, u0, v2);
+ t->vertexUV(x1, y + 0, z0, u1, v2);
+ t->vertexUV(x1, y + 1, z0, u1, v0);
- t->vertexUV( x1, y + 1, z1, u0, v0 );
- t->vertexUV( x1, y + 0, z1, u0, v2 );
- t->vertexUV( x1, y + 0, z0, u1, v2 );
- t->vertexUV( x1, y + 1, z0, u1, v0 );
+ // small edge texture
+ if (!e && !w) {
+ t->vertexUV(ix0, y + 1, z1, iu0, iv0);
+ t->vertexUV(ix0, y + 0, z1, iu0, iv2);
+ t->vertexUV(ix1, y + 0, z1, iu1, iv2);
+ t->vertexUV(ix1, y + 1, z1, iu1, iv0);
- // small edge texture
- if ( !e && !w )
- {
- t->vertexUV( ix0, y + 1, z1, iu0, iv0 );
- t->vertexUV( ix0, y + 0, z1, iu0, iv2 );
- t->vertexUV( ix1, y + 0, z1, iu1, iv2 );
- t->vertexUV( ix1, y + 1, z1, iu1, iv0 );
+ t->vertexUV(ix1, y + 1, z1, iu0, iv0);
+ t->vertexUV(ix1, y + 0, z1, iu0, iv2);
+ t->vertexUV(ix0, y + 0, z1, iu1, iv2);
+ t->vertexUV(ix0, y + 1, z1, iu1, iv0);
+ }
- t->vertexUV( ix1, y + 1, z1, iu0, iv0 );
- t->vertexUV( ix1, y + 0, z1, iu0, iv2 );
- t->vertexUV( ix0, y + 0, z1, iu1, iv2 );
- t->vertexUV( ix0, y + 1, z1, iu1, iv0 );
- }
+ if (up || (y < (depth - 1) && level->isEmptyTile(x, y + 1, z - 1))) {
+ // small edge texture
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z0, iu1, iv0);
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z1, iu1, iv1);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z1, iu0, iv1);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z0, iu0, iv0);
- if ( up || ( y < ( depth - 1 ) && level->isEmptyTile( x, y + 1, z - 1 ) ) )
- {
- // small edge texture
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z0, iu1, iv0 );
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z1, iu1, iv1 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z1, iu0, iv1 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z0, iu0, iv0 );
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z1, iu1, iv0);
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z0, iu1, iv1);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z0, iu0, iv1);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z1, iu0, iv0);
+ }
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z1, iu1, iv0 );
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z0, iu1, iv1 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z0, iu0, iv1 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z1, iu0, iv0 );
- }
+ if (down || (y > 1 && level->isEmptyTile(x, y - 1, z - 1))) {
+ // small edge texture
+ t->vertexUV(ix0, y - noZFightingOffset, z0, iu1, iv0);
+ t->vertexUV(ix0, y - noZFightingOffset, z1, iu1, iv1);
+ t->vertexUV(ix1, y - noZFightingOffset, z1, iu0, iv1);
+ t->vertexUV(ix1, y - noZFightingOffset, z0, iu0, iv0);
- if ( down || ( y > 1 && level->isEmptyTile( x, y - 1, z - 1 ) ) )
- {
- // small edge texture
- t->vertexUV( ix0, y - noZFightingOffset, z0, iu1, iv0 );
- t->vertexUV( ix0, y - noZFightingOffset, z1, iu1, iv1 );
- t->vertexUV( ix1, y - noZFightingOffset, z1, iu0, iv1 );
- t->vertexUV( ix1, y - noZFightingOffset, z0, iu0, iv0 );
+ t->vertexUV(ix0, y - noZFightingOffset, z1, iu1, iv0);
+ t->vertexUV(ix0, y - noZFightingOffset, z0, iu1, iv1);
+ t->vertexUV(ix1, y - noZFightingOffset, z0, iu0, iv1);
+ t->vertexUV(ix1, y - noZFightingOffset, z1, iu0, iv0);
+ }
- t->vertexUV( ix0, y - noZFightingOffset, z1, iu1, iv0 );
- t->vertexUV( ix0, y - noZFightingOffset, z0, iu1, iv1 );
- t->vertexUV( ix1, y - noZFightingOffset, z0, iu0, iv1 );
- t->vertexUV( ix1, y - noZFightingOffset, z1, iu0, iv0 );
- }
+ } else if (!n && s) {
+ // half-step towards south
+ t->vertexUV(x1, y + 1, z1, u1, v0);
+ t->vertexUV(x1, y + 0, z1, u1, v2);
+ t->vertexUV(x1, y + 0, z2, u2, v2);
+ t->vertexUV(x1, y + 1, z2, u2, v0);
- }
- else if ( !n && s )
- {
- // half-step towards south
- t->vertexUV( x1, y + 1, z1, u1, v0 );
- t->vertexUV( x1, y + 0, z1, u1, v2 );
- t->vertexUV( x1, y + 0, z2, u2, v2 );
- t->vertexUV( x1, y + 1, z2, u2, v0 );
+ t->vertexUV(x1, y + 1, z2, u1, v0);
+ t->vertexUV(x1, y + 0, z2, u1, v2);
+ t->vertexUV(x1, y + 0, z1, u2, v2);
+ t->vertexUV(x1, y + 1, z1, u2, v0);
- t->vertexUV( x1, y + 1, z2, u1, v0 );
- t->vertexUV( x1, y + 0, z2, u1, v2 );
- t->vertexUV( x1, y + 0, z1, u2, v2 );
- t->vertexUV( x1, y + 1, z1, u2, v0 );
+ // small edge texture
+ if (!e && !w) {
+ t->vertexUV(ix1, y + 1, z1, iu0, iv0);
+ t->vertexUV(ix1, y + 0, z1, iu0, iv2);
+ t->vertexUV(ix0, y + 0, z1, iu1, iv2);
+ t->vertexUV(ix0, y + 1, z1, iu1, iv0);
- // small edge texture
- if ( !e && !w )
- {
- t->vertexUV( ix1, y + 1, z1, iu0, iv0 );
- t->vertexUV( ix1, y + 0, z1, iu0, iv2 );
- t->vertexUV( ix0, y + 0, z1, iu1, iv2 );
- t->vertexUV( ix0, y + 1, z1, iu1, iv0 );
+ t->vertexUV(ix0, y + 1, z1, iu0, iv0);
+ t->vertexUV(ix0, y + 0, z1, iu0, iv2);
+ t->vertexUV(ix1, y + 0, z1, iu1, iv2);
+ t->vertexUV(ix1, y + 1, z1, iu1, iv0);
+ }
- t->vertexUV( ix0, y + 1, z1, iu0, iv0 );
- t->vertexUV( ix0, y + 0, z1, iu0, iv2 );
- t->vertexUV( ix1, y + 0, z1, iu1, iv2 );
- t->vertexUV( ix1, y + 1, z1, iu1, iv0 );
- }
+ if (up || (y < (depth - 1) && level->isEmptyTile(x, y + 1, z + 1))) {
+ // small edge texture
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z1, iu0, iv1);
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z2, iu0, iv2);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z2, iu1, iv2);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z1, iu1, iv1);
- if ( up || ( y < ( depth - 1 ) && level->isEmptyTile( x, y + 1, z + 1 ) ) )
- {
- // small edge texture
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z1, iu0, iv1 );
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z2, iu0, iv2 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z2, iu1, iv2 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z1, iu1, iv1 );
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z2, iu0, iv1);
+ t->vertexUV(ix0, y + 1 + noZFightingOffset, z1, iu0, iv2);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z1, iu1, iv2);
+ t->vertexUV(ix1, y + 1 + noZFightingOffset, z2, iu1, iv1);
+ }
+ if (down || (y > 1 && level->isEmptyTile(x, y - 1, z + 1))) {
+ // small edge texture
+ t->vertexUV(ix0, y - noZFightingOffset, z1, iu0, iv1);
+ t->vertexUV(ix0, y - noZFightingOffset, z2, iu0, iv2);
+ t->vertexUV(ix1, y - noZFightingOffset, z2, iu1, iv2);
+ t->vertexUV(ix1, y - noZFightingOffset, z1, iu1, iv1);
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z2, iu0, iv1 );
- t->vertexUV( ix0, y + 1 + noZFightingOffset, z1, iu0, iv2 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z1, iu1, iv2 );
- t->vertexUV( ix1, y + 1 + noZFightingOffset, z2, iu1, iv1 );
- }
- if ( down || ( y > 1 && level->isEmptyTile( x, y - 1, z + 1 ) ) )
- {
- // small edge texture
- t->vertexUV( ix0, y - noZFightingOffset, z1, iu0, iv1 );
- t->vertexUV( ix0, y - noZFightingOffset, z2, iu0, iv2 );
- t->vertexUV( ix1, y - noZFightingOffset, z2, iu1, iv2 );
- t->vertexUV( ix1, y - noZFightingOffset, z1, iu1, iv1 );
+ t->vertexUV(ix0, y - noZFightingOffset, z2, iu0, iv1);
+ t->vertexUV(ix0, y - noZFightingOffset, z1, iu0, iv2);
+ t->vertexUV(ix1, y - noZFightingOffset, z1, iu1, iv2);
+ t->vertexUV(ix1, y - noZFightingOffset, z2, iu1, iv1);
+ }
+ }
+#endif // DISABLE_TESS_FUNCS
- t->vertexUV( ix0, y - noZFightingOffset, z2, iu0, iv1 );
- t->vertexUV( ix0, y - noZFightingOffset, z1, iu0, iv2 );
- t->vertexUV( ix1, y - noZFightingOffset, z1, iu1, iv2 );
- t->vertexUV( ix1, y - noZFightingOffset, z2, iu1, iv1 );
- }
-
- }
-#endif // DISABLE_TESS_FUNCS
-
- return true;
+ return true;
}
-bool TileRenderer_SPU::tesselateCrossInWorld( Tile_SPU* tt, int x, int y, int z )
-{
- Tesselator_SPU* t = getTesselator();
+bool TileRenderer_SPU::tesselateCrossInWorld(Tile_SPU* tt, int x, int y,
+ int z) {
+ Tesselator_SPU* t = getTesselator();
- float br;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tt->getLightColor( level, x, y, z ) );
- br = 1;
- }
- else
- {
- br = tt->getBrightness( level, x, y, z );
- }
+ float br;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ br = 1;
+ } else {
+ br = tt->getBrightness(level, x, y, z);
+ }
- int col = tt->getColor( level, x, y, z );
- float r = ( ( col >> 16 ) & 0xff ) / 255.0f;
- float g = ( ( col >> 8 ) & 0xff ) / 255.0f;
- float b = ( ( col )& 0xff ) / 255.0f;
+ int col = tt->getColor(level, x, y, z);
+ float r = ((col >> 16) & 0xff) / 255.0f;
+ float g = ((col >> 8) & 0xff) / 255.0f;
+ float b = ((col) & 0xff) / 255.0f;
- if ( isAnaglyph3d() )
- {
- float cr = ( r * 30 + g * 59 + b * 11 ) / 100;
- float cg = ( r * 30 + g * 70 ) / ( 100 );
- float cb = ( r * 30 + b * 70 ) / ( 100 );
+ if (isAnaglyph3d()) {
+ float cr = (r * 30 + g * 59 + b * 11) / 100;
+ float cg = (r * 30 + g * 70) / (100);
+ float cb = (r * 30 + b * 70) / (100);
- r = cr;
- g = cg;
- b = cb;
- }
- t->color( br * r, br * g, br * b );
+ r = cr;
+ g = cg;
+ b = cb;
+ }
+ t->color(br * r, br * g, br * b);
- float xt = (float)x;
- float yt = (float)y;
- float zt = (float)z;
+ float xt = (float)x;
+ float yt = (float)y;
+ float zt = (float)z;
- if (tt->id == Tile_SPU::tallgrass_Id)
- {
- int64_t seed = (x * 3129871) ^ (z * 116129781l) ^ (y);
- seed = seed * seed * 42317861 + seed * 11;
-
- xt += ((((seed >> 16) & 0xf) / 15.0f) - 0.5f) * 0.5f;
- yt += ((((seed >> 20) & 0xf) / 15.0f) - 1.0f) * 0.2f;
- zt += ((((seed >> 24) & 0xf) / 15.0f) - 0.5f) * 0.5f;
- }
+ if (tt->id == Tile_SPU::tallgrass_Id) {
+ int64_t seed = (x * 3129871) ^ (z * 116129781l) ^ (y);
+ seed = seed * seed * 42317861 + seed * 11;
- tesselateCrossTexture( tt, level->getData( x, y, z ), xt, yt, zt, 1 );
- return true;
+ xt += ((((seed >> 16) & 0xf) / 15.0f) - 0.5f) * 0.5f;
+ yt += ((((seed >> 20) & 0xf) / 15.0f) - 1.0f) * 0.2f;
+ zt += ((((seed >> 24) & 0xf) / 15.0f) - 0.5f) * 0.5f;
+ }
+
+ tesselateCrossTexture(tt, level->getData(x, y, z), xt, yt, zt, 1);
+ return true;
}
-bool TileRenderer_SPU::tesselateStemInWorld( Tile_SPU* _tt, int x, int y, int z )
-{
- StemTile_SPU* tt = ( StemTile_SPU* )_tt;
- Tesselator_SPU* t = getTesselator();
+bool TileRenderer_SPU::tesselateStemInWorld(Tile_SPU* _tt, int x, int y,
+ int z) {
+ StemTile_SPU* tt = (StemTile_SPU*)_tt;
+ Tesselator_SPU* t = getTesselator();
- float br;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tt->getLightColor( level, x, y, z ) );
- br = 1;
- }
- else
- {
- br = tt->getBrightness( level, x, y, z );
- }
- int col = tt->getColor( level, x, y, z );
- float r = ( ( col >> 16 ) & 0xff ) / 255.0f;
- float g = ( ( col >> 8 ) & 0xff ) / 255.0f;
- float b = ( ( col )& 0xff ) / 255.0f;
+ float br;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ br = 1;
+ } else {
+ br = tt->getBrightness(level, x, y, z);
+ }
+ int col = tt->getColor(level, x, y, z);
+ float r = ((col >> 16) & 0xff) / 255.0f;
+ float g = ((col >> 8) & 0xff) / 255.0f;
+ float b = ((col) & 0xff) / 255.0f;
- if ( isAnaglyph3d())
- {
- float cr = ( r * 30.0f + g * 59.0f + b * 11.0f ) / 100.0f;
- float cg = ( r * 30.0f + g * 70.0f ) / ( 100.0f );
- float cb = ( r * 30.0f + b * 70.0f ) / ( 100.0f );
+ if (isAnaglyph3d()) {
+ float cr = (r * 30.0f + g * 59.0f + b * 11.0f) / 100.0f;
+ float cg = (r * 30.0f + g * 70.0f) / (100.0f);
+ float cb = (r * 30.0f + b * 70.0f) / (100.0f);
- r = cr;
- g = cg;
- b = cb;
- }
- t->color( br * r, br * g, br * b );
+ r = cr;
+ g = cg;
+ b = cb;
+ }
+ t->color(br * r, br * g, br * b);
- tt->updateShape( level, x, y, z );
- int dir = tt->getConnectDir( level, x, y, z );
- if ( dir < 0 )
- {
- tesselateStemTexture( tt, level->getData( x, y, z ), tileShapeY1, x, y - 1 / 16.0f, z );
- }
- else
- {
- tesselateStemTexture( tt, level->getData( x, y, z ), 0.5f, x, y - 1 / 16.0f, z );
- tesselateStemDirTexture( tt, level->getData( x, y, z ), dir, tileShapeY1, x, y - 1 / 16.0f, z );
- }
- return true;
+ tt->updateShape(level, x, y, z);
+ int dir = tt->getConnectDir(level, x, y, z);
+ if (dir < 0) {
+ tesselateStemTexture(tt, level->getData(x, y, z), tileShapeY1, x,
+ y - 1 / 16.0f, z);
+ } else {
+ tesselateStemTexture(tt, level->getData(x, y, z), 0.5f, x,
+ y - 1 / 16.0f, z);
+ tesselateStemDirTexture(tt, level->getData(x, y, z), dir, tileShapeY1,
+ x, y - 1 / 16.0f, z);
+ }
+ return true;
}
-bool TileRenderer_SPU::tesselateRowInWorld( Tile_SPU* tt, int x, int y, int z )
-{
- Tesselator_SPU* t = getTesselator();
+bool TileRenderer_SPU::tesselateRowInWorld(Tile_SPU* tt, int x, int y, int z) {
+ Tesselator_SPU* t = getTesselator();
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tt->getLightColor( level, x, y, z ) );
- t->color( 1.0f, 1.0f, 1.0f );
- }
- else
- {
- float br = tt->getBrightness( level, x, y, z );
- t->color( br, br, br );
- }
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ t->color(1.0f, 1.0f, 1.0f);
+ } else {
+ float br = tt->getBrightness(level, x, y, z);
+ t->color(br, br, br);
+ }
- tesselateRowTexture( tt, level->getData( x, y, z ), x, y - 1.0f / 16.0f, z );
- return true;
+ tesselateRowTexture(tt, level->getData(x, y, z), x, y - 1.0f / 16.0f, z);
+ return true;
}
-void TileRenderer_SPU::tesselateTorch( Tile_SPU* tt, float x, float y, float z, float xxa, float zza, int data )
-{
- Tesselator_SPU* t = getTesselator();
+void TileRenderer_SPU::tesselateTorch(Tile_SPU* tt, float x, float y, float z,
+ float xxa, float zza, int data) {
+ Tesselator_SPU* t = getTesselator();
- Icon_SPU *tex = getTexture(tt, Facing::DOWN, data);
+ Icon_SPU* tex = getTexture(tt, Facing::DOWN, data);
- if (hasFixedTexture()) tex = fixedTexture;
- float u0 = tex->getU0();
- float v0 = tex->getV0();
- float u1 = tex->getU1();
- float v1 = tex->getV1();
+ if (hasFixedTexture()) tex = fixedTexture;
+ float u0 = tex->getU0();
+ float v0 = tex->getV0();
+ float u1 = tex->getU1();
+ float v1 = tex->getV1();
- float ut0 = tex->getU(7);
- float vt0 = tex->getV(6);
- float ut1 = tex->getU(9);
- float vt1 = tex->getV(8);
+ float ut0 = tex->getU(7);
+ float vt0 = tex->getV(6);
+ float ut1 = tex->getU(9);
+ float vt1 = tex->getV(8);
- float ub0 = tex->getU(7);
- float vb0 = tex->getV(13);
- float ub1 = tex->getU(9);
- float vb1 = tex->getV(15);
+ float ub0 = tex->getU(7);
+ float vb0 = tex->getV(13);
+ float ub1 = tex->getU(9);
+ float vb1 = tex->getV(15);
- x += 0.5f;
- z += 0.5f;
+ x += 0.5f;
+ z += 0.5f;
- float x0 = x - 0.5f;
- float x1 = x + 0.5f;
- float z0 = z - 0.5f;
- float z1 = z + 0.5f;
- float r = 1 / 16.0f;
+ float x0 = x - 0.5f;
+ float x1 = x + 0.5f;
+ float z0 = z - 0.5f;
+ float z1 = z + 0.5f;
+ float r = 1 / 16.0f;
- float h = 10.0f / 16.0f;
- t->vertexUV( ( float )( x + xxa * ( 1 - h ) - r ), ( float )( y + h ), ( float )( z + zza * ( 1 - h ) - r ), ut0, vt0 );
- t->vertexUV( ( float )( x + xxa * ( 1 - h ) - r ), ( float )( y + h ), ( float )( z + zza * ( 1 - h ) + r ), ut0, vt1 );
- t->vertexUV( ( float )( x + xxa * ( 1 - h ) + r ), ( float )( y + h ), ( float )( z + zza * ( 1 - h ) + r ), ut1, vt1 );
- t->vertexUV( ( float )( x + xxa * ( 1 - h ) + r ), ( float )( y + h ), ( float )( z + zza * ( 1 - h ) - r ), ut1, vt0 );
+ float h = 10.0f / 16.0f;
+ t->vertexUV((float)(x + xxa * (1 - h) - r), (float)(y + h),
+ (float)(z + zza * (1 - h) - r), ut0, vt0);
+ t->vertexUV((float)(x + xxa * (1 - h) - r), (float)(y + h),
+ (float)(z + zza * (1 - h) + r), ut0, vt1);
+ t->vertexUV((float)(x + xxa * (1 - h) + r), (float)(y + h),
+ (float)(z + zza * (1 - h) + r), ut1, vt1);
+ t->vertexUV((float)(x + xxa * (1 - h) + r), (float)(y + h),
+ (float)(z + zza * (1 - h) - r), ut1, vt0);
- t->vertexUV( (float)(x + r + xxa), (float) y, (float)(z - r + zza), ub1, vb0);
- t->vertexUV( (float)(x + r + xxa), (float) y, (float)(z + r + zza), ub1, vb1);
- t->vertexUV( (float)(x - r + xxa), (float) y, (float)(z + r + zza), ub0, vb1);
- t->vertexUV( (float)(x - r + xxa), (float) y, (float)(z - r + zza), ub0, vb0);
+ t->vertexUV((float)(x + r + xxa), (float)y, (float)(z - r + zza), ub1, vb0);
+ t->vertexUV((float)(x + r + xxa), (float)y, (float)(z + r + zza), ub1, vb1);
+ t->vertexUV((float)(x - r + xxa), (float)y, (float)(z + r + zza), ub0, vb1);
+ t->vertexUV((float)(x - r + xxa), (float)y, (float)(z - r + zza), ub0, vb0);
- t->vertexUV( ( float )( x - r ), ( float )( y + 1 ), ( float )( z0 ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x - r + xxa ), ( float )( y + 0 ), ( float )( z0 +
- zza ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x - r + xxa ), ( float )( y + 0 ), ( float )( z1 +
- zza ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x - r ), ( float )( y + 1 ), ( float )( z1 ), ( float )( u1 ), ( float )( v0 ) );
+ t->vertexUV((float)(x - r), (float)(y + 1), (float)(z0), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x - r + xxa), (float)(y + 0), (float)(z0 + zza),
+ (float)(u0), (float)(v1));
+ t->vertexUV((float)(x - r + xxa), (float)(y + 0), (float)(z1 + zza),
+ (float)(u1), (float)(v1));
+ t->vertexUV((float)(x - r), (float)(y + 1), (float)(z1), (float)(u1),
+ (float)(v0));
- t->vertexUV( ( float )( x + r ), ( float )( y + 1 ), ( float )( z1 ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x + xxa + r ), ( float )( y + 0 ), ( float )( z1 +
- zza ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + xxa + r ), ( float )( y + 0 ), ( float )( z0 +
- zza ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x + r ), ( float )( y + 1 ), ( float )( z0 ), ( float )( u1 ), ( float )( v0 ) );
+ t->vertexUV((float)(x + r), (float)(y + 1), (float)(z1), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x + xxa + r), (float)(y + 0), (float)(z1 + zza),
+ (float)(u0), (float)(v1));
+ t->vertexUV((float)(x + xxa + r), (float)(y + 0), (float)(z0 + zza),
+ (float)(u1), (float)(v1));
+ t->vertexUV((float)(x + r), (float)(y + 1), (float)(z0), (float)(u1),
+ (float)(v0));
- t->vertexUV( ( float )( x0 ), ( float )( y + 1 ), ( float )( z + r ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x0 + xxa ), ( float )( y + 0 ), ( float )( z + r +
- zza ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 + xxa ), ( float )( y + 0 ), ( float )( z + r +
- zza ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 1 ), ( float )( z + r ), ( float )( u1 ), ( float )( v0 ) );
+ t->vertexUV((float)(x0), (float)(y + 1), (float)(z + r), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x0 + xxa), (float)(y + 0), (float)(z + r + zza),
+ (float)(u0), (float)(v1));
+ t->vertexUV((float)(x1 + xxa), (float)(y + 0), (float)(z + r + zza),
+ (float)(u1), (float)(v1));
+ t->vertexUV((float)(x1), (float)(y + 1), (float)(z + r), (float)(u1),
+ (float)(v0));
- t->vertexUV( ( float )( x1 ), ( float )( y + 1 ), ( float )( z - r ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x1 + xxa ), ( float )( y + 0 ), ( float )( z - r +
- zza ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 + xxa ), ( float )( y + 0 ), ( float )( z - r +
- zza ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 1 ), ( float )( z - r ), ( float )( u1 ), ( float )( v0 ) );
+ t->vertexUV((float)(x1), (float)(y + 1), (float)(z - r), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x1 + xxa), (float)(y + 0), (float)(z - r + zza),
+ (float)(u0), (float)(v1));
+ t->vertexUV((float)(x0 + xxa), (float)(y + 0), (float)(z - r + zza),
+ (float)(u1), (float)(v1));
+ t->vertexUV((float)(x0), (float)(y + 1), (float)(z - r), (float)(u1),
+ (float)(v0));
}
-void TileRenderer_SPU::tesselateCrossTexture( Tile_SPU* tt, int data, float x, float y, float z, float scale )
-{
- Tesselator_SPU* t = getTesselator();
+void TileRenderer_SPU::tesselateCrossTexture(Tile_SPU* tt, int data, float x,
+ float y, float z, float scale) {
+ Tesselator_SPU* t = getTesselator();
- Icon_SPU *tex = getTexture(tt, 0, data);
+ Icon_SPU* tex = getTexture(tt, 0, data);
- if (hasFixedTexture()) tex = fixedTexture;
- float u0 = tex->getU0();
- float v0 = tex->getV0();
- float u1 = tex->getU1();
- float v1 = tex->getV1();
+ if (hasFixedTexture()) tex = fixedTexture;
+ float u0 = tex->getU0();
+ float v0 = tex->getV0();
+ float u1 = tex->getU1();
+ float v1 = tex->getV1();
- float width = 0.45 * scale;
- float x0 = x + 0.5 - width;
- float x1 = x + 0.5 + width;
- float z0 = z + 0.5 - width;
- float z1 = z + 0.5 + width;
+ float width = 0.45 * scale;
+ float x0 = x + 0.5 - width;
+ float x1 = x + 0.5 + width;
+ float z0 = z + 0.5 - width;
+ float z1 = z + 0.5 + width;
- t->vertexUV( ( float )( x0 ), ( float )( y + scale ), ( float )( z0 ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + scale ), ( float )( z1 ), ( float )( u1 ), ( float )( v0 ) );
+ t->vertexUV((float)(x0), (float)(y + scale), (float)(z0), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z0), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x1), (float)(y + 0), (float)(z1), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x1), (float)(y + scale), (float)(z1), (float)(u1),
+ (float)(v0));
- t->vertexUV( ( float )( x1 ), ( float )( y + scale ), ( float )( z1 ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + scale ), ( float )( z0 ), ( float )( u1 ), ( float )( v0 ) );
+ t->vertexUV((float)(x1), (float)(y + scale), (float)(z1), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x1), (float)(y + 0), (float)(z1), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z0), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x0), (float)(y + scale), (float)(z0), (float)(u1),
+ (float)(v0));
- t->vertexUV( ( float )( x0 ), ( float )( y + scale ), ( float )( z1 ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + scale ), ( float )( z0 ), ( float )( u1 ), ( float )( v0 ) );
+ t->vertexUV((float)(x0), (float)(y + scale), (float)(z1), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z1), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x1), (float)(y + 0), (float)(z0), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x1), (float)(y + scale), (float)(z0), (float)(u1),
+ (float)(v0));
- t->vertexUV( ( float )( x1 ), ( float )( y + scale ), ( float )( z0 ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + scale ), ( float )( z1 ), ( float )( u1 ), ( float )( v0 ) );
+ t->vertexUV((float)(x1), (float)(y + scale), (float)(z0), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x1), (float)(y + 0), (float)(z0), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z1), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x0), (float)(y + scale), (float)(z1), (float)(u1),
+ (float)(v0));
}
-void TileRenderer_SPU::tesselateStemTexture( Tile_SPU* tt, int data, float h, float x, float y, float z )
-{
-// #ifdef DISABLE_TESS_FUNCS
- Tesselator_SPU* t = getTesselator();
+void TileRenderer_SPU::tesselateStemTexture(Tile_SPU* tt, int data, float h,
+ float x, float y, float z) {
+ // #ifdef DISABLE_TESS_FUNCS
+ Tesselator_SPU* t = getTesselator();
- Icon_SPU *tex = getTexture(tt, 0, data);
+ Icon_SPU* tex = getTexture(tt, 0, data);
- if (hasFixedTexture()) tex = fixedTexture;
- float u0 = tex->getU0();
- float v0 = tex->getV0();
- float u1 = tex->getU1();
- float v1 = tex->getV(h * SharedConstants::WORLD_RESOLUTION);
+ if (hasFixedTexture()) tex = fixedTexture;
+ float u0 = tex->getU0();
+ float v0 = tex->getV0();
+ float u1 = tex->getU1();
+ float v1 = tex->getV(h * SharedConstants::WORLD_RESOLUTION);
- float x0 = x + 0.5f - 0.45f;
- float x1 = x + 0.5f + 0.45f;
- float z0 = z + 0.5f - 0.45f;
- float z1 = z + 0.5f + 0.45f;
+ float x0 = x + 0.5f - 0.45f;
+ float x1 = x + 0.5f + 0.45f;
+ float z0 = z + 0.5f - 0.45f;
+ float z1 = z + 0.5f + 0.45f;
- t->vertexUV( x0, y + h, z0, u0, v0 );
- t->vertexUV( x0, y + 0, z0, u0, v1 );
- t->vertexUV( x1, y + 0, z1, u1, v1 );
- t->vertexUV( x1, y + h, z1, u1, v0 );
+ t->vertexUV(x0, y + h, z0, u0, v0);
+ t->vertexUV(x0, y + 0, z0, u0, v1);
+ t->vertexUV(x1, y + 0, z1, u1, v1);
+ t->vertexUV(x1, y + h, z1, u1, v0);
- t->vertexUV( x1, y + h, z1, u0, v0 );
- t->vertexUV( x1, y + 0, z1, u0, v1 );
- t->vertexUV( x0, y + 0, z0, u1, v1 );
- t->vertexUV( x0, y + h, z0, u1, v0 );
+ t->vertexUV(x1, y + h, z1, u0, v0);
+ t->vertexUV(x1, y + 0, z1, u0, v1);
+ t->vertexUV(x0, y + 0, z0, u1, v1);
+ t->vertexUV(x0, y + h, z0, u1, v0);
- t->vertexUV( x0, y + h, z1, u0, v0 );
- t->vertexUV( x0, y + 0, z1, u0, v1 );
- t->vertexUV( x1, y + 0, z0, u1, v1 );
- t->vertexUV( x1, y + h, z0, u1, v0 );
+ t->vertexUV(x0, y + h, z1, u0, v0);
+ t->vertexUV(x0, y + 0, z1, u0, v1);
+ t->vertexUV(x1, y + 0, z0, u1, v1);
+ t->vertexUV(x1, y + h, z0, u1, v0);
- t->vertexUV( x1, y + h, z0, u0, v0 );
- t->vertexUV( x1, y + 0, z0, u0, v1 );
- t->vertexUV( x0, y + 0, z1, u1, v1 );
- t->vertexUV( x0, y + h, z1, u1, v0 );
-// #endif // DISABLE_TESS_FUNCS
+ t->vertexUV(x1, y + h, z0, u0, v0);
+ t->vertexUV(x1, y + 0, z0, u0, v1);
+ t->vertexUV(x0, y + 0, z1, u1, v1);
+ t->vertexUV(x0, y + h, z1, u1, v0);
+ // #endif // DISABLE_TESS_FUNCS
}
-bool TileRenderer_SPU::tesselateLilypadInWorld(WaterlilyTile_SPU *tt, int x, int y, int z)
-{
- Tesselator_SPU* t = getTesselator();
+bool TileRenderer_SPU::tesselateLilypadInWorld(WaterlilyTile_SPU* tt, int x,
+ int y, int z) {
+ Tesselator_SPU* t = getTesselator();
- Icon_SPU *tex = getTexture(tt, Facing::UP);
+ Icon_SPU* tex = getTexture(tt, Facing::UP);
- if (hasFixedTexture()) tex = fixedTexture;
+ if (hasFixedTexture()) tex = fixedTexture;
float h = 0.25f / 16.0f;
- float u0 = tex->getU0();
- float v0 = tex->getV0();
- float u1 = tex->getU1();
- float v1 = tex->getV1();
+ float u0 = tex->getU0();
+ float v0 = tex->getV0();
+ float u1 = tex->getU1();
+ float v1 = tex->getV1();
int64_t seed = (x * 3129871) ^ (z * 116129781l) ^ (y);
seed = seed * seed * 42317861 + seed * 11;
- int dir = (int) ((seed >> 16) & 0x3);
-
-
+ int dir = (int)((seed >> 16) & 0x3);
t->tex2(tt->getLightColor(level, x, y, z));
@@ -3831,2700 +3774,2735 @@ bool TileRenderer_SPU::tesselateLilypadInWorld(WaterlilyTile_SPU *tt, int x, int
return true;
}
-void TileRenderer_SPU::tesselateStemDirTexture( StemTile_SPU* tt, int data, int dir, float h, float x, float y, float z )
-{
- Tesselator_SPU* t = getTesselator();
+void TileRenderer_SPU::tesselateStemDirTexture(StemTile_SPU* tt, int data,
+ int dir, float h, float x,
+ float y, float z) {
+ Tesselator_SPU* t = getTesselator();
- Icon_SPU *tex = tt->getAngledTexture();
+ Icon_SPU* tex = tt->getAngledTexture();
- if (hasFixedTexture()) tex = fixedTexture;
- float u0 = tex->getU0();
- float v0 = tex->getV0();
- float u1 = tex->getU1();
- float v1 = tex->getV1();
+ if (hasFixedTexture()) tex = fixedTexture;
+ float u0 = tex->getU0();
+ float v0 = tex->getV0();
+ float u1 = tex->getU1();
+ float v1 = tex->getV1();
- float x0 = x + 0.5f - 0.5f;
- float x1 = x + 0.5f + 0.5f;
- float z0 = z + 0.5f - 0.5f;
- float z1 = z + 0.5f + 0.5f;
+ float x0 = x + 0.5f - 0.5f;
+ float x1 = x + 0.5f + 0.5f;
+ float z0 = z + 0.5f - 0.5f;
+ float z1 = z + 0.5f + 0.5f;
- float xm = x + 0.5f;
- float zm = z + 0.5f;
+ float xm = x + 0.5f;
+ float zm = z + 0.5f;
- if ( ( dir + 1 ) / 2 % 2 == 1 )
- {
- float tmp = u1;
- u1 = u0;
- u0 = tmp;
- }
+ if ((dir + 1) / 2 % 2 == 1) {
+ float tmp = u1;
+ u1 = u0;
+ u0 = tmp;
+ }
- if ( dir < 2 )
- {
- t->vertexUV( x0, y + h, zm, u0, v0 );
- t->vertexUV( x0, y + 0, zm, u0, v1 );
- t->vertexUV( x1, y + 0, zm, u1, v1 );
- t->vertexUV( x1, y + h, zm, u1, v0 );
+ if (dir < 2) {
+ t->vertexUV(x0, y + h, zm, u0, v0);
+ t->vertexUV(x0, y + 0, zm, u0, v1);
+ t->vertexUV(x1, y + 0, zm, u1, v1);
+ t->vertexUV(x1, y + h, zm, u1, v0);
- t->vertexUV( x1, y + h, zm, u1, v0 );
- t->vertexUV( x1, y + 0, zm, u1, v1 );
- t->vertexUV( x0, y + 0, zm, u0, v1 );
- t->vertexUV( x0, y + h, zm, u0, v0 );
- }
- else
- {
- t->vertexUV( xm, y + h, z1, u0, v0 );
- t->vertexUV( xm, y + 0, z1, u0, v1 );
- t->vertexUV( xm, y + 0, z0, u1, v1 );
- t->vertexUV( xm, y + h, z0, u1, v0 );
+ t->vertexUV(x1, y + h, zm, u1, v0);
+ t->vertexUV(x1, y + 0, zm, u1, v1);
+ t->vertexUV(x0, y + 0, zm, u0, v1);
+ t->vertexUV(x0, y + h, zm, u0, v0);
+ } else {
+ t->vertexUV(xm, y + h, z1, u0, v0);
+ t->vertexUV(xm, y + 0, z1, u0, v1);
+ t->vertexUV(xm, y + 0, z0, u1, v1);
+ t->vertexUV(xm, y + h, z0, u1, v0);
- t->vertexUV( xm, y + h, z0, u1, v0 );
- t->vertexUV( xm, y + 0, z0, u1, v1 );
- t->vertexUV( xm, y + 0, z1, u0, v1 );
- t->vertexUV( xm, y + h, z1, u0, v0 );
- }
+ t->vertexUV(xm, y + h, z0, u1, v0);
+ t->vertexUV(xm, y + 0, z0, u1, v1);
+ t->vertexUV(xm, y + 0, z1, u0, v1);
+ t->vertexUV(xm, y + h, z1, u0, v0);
+ }
}
+void TileRenderer_SPU::tesselateRowTexture(Tile_SPU* tt, int data, float x,
+ float y, float z) {
+ Tesselator_SPU* t = getTesselator();
-void TileRenderer_SPU::tesselateRowTexture( Tile_SPU* tt, int data, float x, float y, float z )
-{
- Tesselator_SPU* t = getTesselator();
+ Icon_SPU* tex = getTexture(tt, 0, data);
- Icon_SPU *tex = getTexture(tt, 0, data);
+ if (hasFixedTexture()) tex = fixedTexture;
+ float u0 = tex->getU0();
+ float v0 = tex->getV0();
+ float u1 = tex->getU1();
+ float v1 = tex->getV1();
- if (hasFixedTexture()) tex = fixedTexture;
- float u0 = tex->getU0();
- float v0 = tex->getV0();
- float u1 = tex->getU1();
- float v1 = tex->getV1();
+ float x0 = x + 0.5f - 0.25f;
+ float x1 = x + 0.5f + 0.25f;
+ float z0 = z + 0.5f - 0.5f;
+ float z1 = z + 0.5f + 0.5f;
- float x0 = x + 0.5f - 0.25f;
- float x1 = x + 0.5f + 0.25f;
- float z0 = z + 0.5f - 0.5f;
- float z1 = z + 0.5f + 0.5f;
+ t->vertexUV((float)(x0), (float)(y + 1), (float)(z0), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z0), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z1), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x0), (float)(y + 1), (float)(z1), (float)(u1),
+ (float)(v0));
- t->vertexUV( ( float )( x0 ), ( float )( y + 1 ), ( float )( z0 ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 1 ), ( float )( z1 ), ( float )( u1 ), ( float )( v0 ) );
+ t->vertexUV((float)(x0), (float)(y + 1), (float)(z1), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z1), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z0), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x0), (float)(y + 1), (float)(z0), (float)(u1),
+ (float)(v0));
- t->vertexUV( ( float )( x0 ), ( float )( y + 1 ), ( float )( z1 ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 1 ), ( float )( z0 ), ( float )( u1 ), ( float )( v0 ) );
+ t->vertexUV((float)(x1), (float)(y + 1), (float)(z1), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x1), (float)(y + 0), (float)(z1), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x1), (float)(y + 0), (float)(z0), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x1), (float)(y + 1), (float)(z0), (float)(u1),
+ (float)(v0));
- t->vertexUV( ( float )( x1 ), ( float )( y + 1 ), ( float )( z1 ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 1 ), ( float )( z0 ), ( float )( u1 ), ( float )( v0 ) );
+ t->vertexUV((float)(x1), (float)(y + 1), (float)(z0), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x1), (float)(y + 0), (float)(z0), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x1), (float)(y + 0), (float)(z1), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x1), (float)(y + 1), (float)(z1), (float)(u1),
+ (float)(v0));
- t->vertexUV( ( float )( x1 ), ( float )( y + 1 ), ( float )( z0 ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 1 ), ( float )( z1 ), ( float )( u1 ), ( float )( v0 ) );
+ x0 = x + 0.5f - 0.5f;
+ x1 = x + 0.5f + 0.5f;
+ z0 = z + 0.5f - 0.25f;
+ z1 = z + 0.5f + 0.25f;
- x0 = x + 0.5f - 0.5f;
- x1 = x + 0.5f + 0.5f;
- z0 = z + 0.5f - 0.25f;
- z1 = z + 0.5f + 0.25f;
+ t->vertexUV((float)(x0), (float)(y + 1), (float)(z0), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z0), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x1), (float)(y + 0), (float)(z0), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x1), (float)(y + 1), (float)(z0), (float)(u1),
+ (float)(v0));
- t->vertexUV( ( float )( x0 ), ( float )( y + 1 ), ( float )( z0 ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 1 ), ( float )( z0 ), ( float )( u1 ), ( float )( v0 ) );
+ t->vertexUV((float)(x1), (float)(y + 1), (float)(z0), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x1), (float)(y + 0), (float)(z0), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z0), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x0), (float)(y + 1), (float)(z0), (float)(u1),
+ (float)(v0));
- t->vertexUV( ( float )( x1 ), ( float )( y + 1 ), ( float )( z0 ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 1 ), ( float )( z0 ), ( float )( u1 ), ( float )( v0 ) );
-
- t->vertexUV( ( float )( x1 ), ( float )( y + 1 ), ( float )( z1 ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 1 ), ( float )( z1 ), ( float )( u1 ), ( float )( v0 ) );
-
- t->vertexUV( ( float )( x0 ), ( float )( y + 1 ), ( float )( z1 ), ( float )( u0 ), ( float )( v0 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u0 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 1 ), ( float )( z1 ), ( float )( u1 ), ( float )( v0 ) );
+ t->vertexUV((float)(x1), (float)(y + 1), (float)(z1), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x1), (float)(y + 0), (float)(z1), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z1), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x0), (float)(y + 1), (float)(z1), (float)(u1),
+ (float)(v0));
+ t->vertexUV((float)(x0), (float)(y + 1), (float)(z1), (float)(u0),
+ (float)(v0));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z1), (float)(u0),
+ (float)(v1));
+ t->vertexUV((float)(x1), (float)(y + 0), (float)(z1), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x1), (float)(y + 1), (float)(z1), (float)(u1),
+ (float)(v0));
}
-bool TileRenderer_SPU::tesselateWaterInWorld( Tile_SPU* tt, int x, int y, int z )
-{
- // 4J Java comment
- // TODO: This all needs to change. Somehow.
- Tesselator_SPU* t = getTesselator();
+bool TileRenderer_SPU::tesselateWaterInWorld(Tile_SPU* tt, int x, int y,
+ int z) {
+ // 4J Java comment
+ // TODO: This all needs to change. Somehow.
+ Tesselator_SPU* t = getTesselator();
- int col = tt->getColor( level, x, y, z );
- float r = ( col >> 16 & 0xff ) / 255.0f;
- float g = ( col >> 8 & 0xff ) / 255.0f;
- float b = ( col & 0xff ) / 255.0f;
- bool up = tt->shouldRenderFace( level, x, y + 1, z, 1 );
- bool down = tt->shouldRenderFace( level, x, y - 1, z, 0 );
- bool dirs[4];
- dirs[0] = tt->shouldRenderFace( level, x, y, z - 1, 2 );
- dirs[1] = tt->shouldRenderFace( level, x, y, z + 1, 3 );
- dirs[2] = tt->shouldRenderFace( level, x - 1, y, z, 4 );
- dirs[3] = tt->shouldRenderFace( level, x + 1, y, z, 5 );
+ int col = tt->getColor(level, x, y, z);
+ float r = (col >> 16 & 0xff) / 255.0f;
+ float g = (col >> 8 & 0xff) / 255.0f;
+ float b = (col & 0xff) / 255.0f;
+ bool up = tt->shouldRenderFace(level, x, y + 1, z, 1);
+ bool down = tt->shouldRenderFace(level, x, y - 1, z, 0);
+ bool dirs[4];
+ dirs[0] = tt->shouldRenderFace(level, x, y, z - 1, 2);
+ dirs[1] = tt->shouldRenderFace(level, x, y, z + 1, 3);
+ dirs[2] = tt->shouldRenderFace(level, x - 1, y, z, 4);
+ dirs[3] = tt->shouldRenderFace(level, x + 1, y, z, 5);
- if ( !up && !down && !dirs[0] && !dirs[1] && !dirs[2] && !dirs[3] ) return false;
+ if (!up && !down && !dirs[0] && !dirs[1] && !dirs[2] && !dirs[3])
+ return false;
- bool changed = false;
- float c10 = 0.5f;
- float c11 = 1;
- float c2 = 0.8f;
- float c3 = 0.6f;
+ bool changed = false;
+ float c10 = 0.5f;
+ float c11 = 1;
+ float c2 = 0.8f;
+ float c3 = 0.6f;
- float yo0 = 0;
- float yo1 = 1;
+ float yo0 = 0;
+ float yo1 = 1;
- Material_SPU* m = tt->getMaterial();
- int data = level->getData( x, y, z );
+ Material_SPU* m = tt->getMaterial();
+ int data = level->getData(x, y, z);
- float h0 = getWaterHeight( x, y, z, m );
- float h1 = getWaterHeight( x, y, z + 1, m );
- float h2 = getWaterHeight( x + 1, y, z + 1, m );
- float h3 = getWaterHeight( x + 1, y, z, m );
+ float h0 = getWaterHeight(x, y, z, m);
+ float h1 = getWaterHeight(x, y, z + 1, m);
+ float h2 = getWaterHeight(x + 1, y, z + 1, m);
+ float h3 = getWaterHeight(x + 1, y, z, m);
float offs = 0.001f;
- // 4J - added. Farm tiles often found beside water, but they consider themselves non-solid as they only extend up to 15.0f / 16.0f.
- // If the max height of this water is below that level, don't bother rendering sides bordering onto farmland.
- float maxh = h0;
- if ( h1 > maxh ) maxh = h1;
- if ( h2 > maxh ) maxh = h2;
- if ( h3 > maxh ) maxh = h3;
- if ( maxh <= ( 15.0f / 16.0f ) )
- {
- if ( level->getTile( x, y, z - 1 ) == Tile_SPU::farmland_Id )
- {
- dirs[0] = false;
- }
- if ( level->getTile( x, y, z + 1 ) == Tile_SPU::farmland_Id )
- {
- dirs[1] = false;
- }
- if ( level->getTile( x - 1, y, z ) == Tile_SPU::farmland_Id )
- {
- dirs[2] = false;
- }
- if ( level->getTile( x + 1, y, z ) == Tile_SPU::farmland_Id )
- {
- dirs[3] = false;
- }
- }
+ // 4J - added. Farm tiles often found beside water, but they consider
+ // themselves non-solid as they only extend up to 15.0f / 16.0f. If the max
+ // height of this water is below that level, don't bother rendering sides
+ // bordering onto farmland.
+ float maxh = h0;
+ if (h1 > maxh) maxh = h1;
+ if (h2 > maxh) maxh = h2;
+ if (h3 > maxh) maxh = h3;
+ if (maxh <= (15.0f / 16.0f)) {
+ if (level->getTile(x, y, z - 1) == Tile_SPU::farmland_Id) {
+ dirs[0] = false;
+ }
+ if (level->getTile(x, y, z + 1) == Tile_SPU::farmland_Id) {
+ dirs[1] = false;
+ }
+ if (level->getTile(x - 1, y, z) == Tile_SPU::farmland_Id) {
+ dirs[2] = false;
+ }
+ if (level->getTile(x + 1, y, z) == Tile_SPU::farmland_Id) {
+ dirs[3] = false;
+ }
+ }
- if ( noCulling || up )
- {
- changed = true;
- Icon_SPU *tex = getTexture( tt, 1, data );
- float angle = ( float )LiquidTile_SPU::getSlopeAngle( level, x, y, z, m );
- if ( angle > -999 )
- {
- tex = getTexture( tt, 2, data );
- }
+ if (noCulling || up) {
+ changed = true;
+ Icon_SPU* tex = getTexture(tt, 1, data);
+ float angle = (float)LiquidTile_SPU::getSlopeAngle(level, x, y, z, m);
+ if (angle > -999) {
+ tex = getTexture(tt, 2, data);
+ }
h0 -= offs;
h1 -= offs;
h2 -= offs;
h3 -= offs;
- float u00, u01, u10, u11;
- float v00, v01, v10, v11;
- if ( angle < -999 )
- {
- u00 = tex->getU(0);
- v00 = tex->getV(0);
- u01 = u00;
- v01 = tex->getV(SharedConstants::WORLD_RESOLUTION);
- u10 = tex->getU(SharedConstants::WORLD_RESOLUTION);
- v10 = v01;
- u11 = u10;
- v11 = v00;
- }
- else
- {
- float s = sinf(angle) * .25f;
- float c = cosf(angle) * .25f;
- float cc = SharedConstants::WORLD_RESOLUTION * .5f;
- u00 = tex->getU(cc + (-c - s) * SharedConstants::WORLD_RESOLUTION);
- v00 = tex->getV(cc + (-c + s) * SharedConstants::WORLD_RESOLUTION);
- u01 = tex->getU(cc + (-c + s) * SharedConstants::WORLD_RESOLUTION);
- v01 = tex->getV(cc + (+c + s) * SharedConstants::WORLD_RESOLUTION);
- u10 = tex->getU(cc + (+c + s) * SharedConstants::WORLD_RESOLUTION);
- v10 = tex->getV(cc + (+c - s) * SharedConstants::WORLD_RESOLUTION);
- u11 = tex->getU(cc + (+c - s) * SharedConstants::WORLD_RESOLUTION);
- v11 = tex->getV(cc + (-c - s) * SharedConstants::WORLD_RESOLUTION);
- }
+ float u00, u01, u10, u11;
+ float v00, v01, v10, v11;
+ if (angle < -999) {
+ u00 = tex->getU(0);
+ v00 = tex->getV(0);
+ u01 = u00;
+ v01 = tex->getV(SharedConstants::WORLD_RESOLUTION);
+ u10 = tex->getU(SharedConstants::WORLD_RESOLUTION);
+ v10 = v01;
+ u11 = u10;
+ v11 = v00;
+ } else {
+ float s = sinf(angle) * .25f;
+ float c = cosf(angle) * .25f;
+ float cc = SharedConstants::WORLD_RESOLUTION * .5f;
+ u00 = tex->getU(cc + (-c - s) * SharedConstants::WORLD_RESOLUTION);
+ v00 = tex->getV(cc + (-c + s) * SharedConstants::WORLD_RESOLUTION);
+ u01 = tex->getU(cc + (-c + s) * SharedConstants::WORLD_RESOLUTION);
+ v01 = tex->getV(cc + (+c + s) * SharedConstants::WORLD_RESOLUTION);
+ u10 = tex->getU(cc + (+c + s) * SharedConstants::WORLD_RESOLUTION);
+ v10 = tex->getV(cc + (+c - s) * SharedConstants::WORLD_RESOLUTION);
+ u11 = tex->getU(cc + (+c - s) * SharedConstants::WORLD_RESOLUTION);
+ v11 = tex->getV(cc + (-c - s) * SharedConstants::WORLD_RESOLUTION);
+ }
- float br;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tt->getLightColor( level, x, y, z ) );
- br = 1;
- }
- else
- {
- br = tt->getBrightness( level, x, y, z );
- }
- t->color( c11 * br * r, c11 * br * g, c11 * br * b );
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y + h0 ), ( float )( z + 0.0f ), u00, v00 );
- t->vertexUV( ( float )( x + 0.0f ), ( float )( y + h1 ), ( float )( z + 1.0f ), u01, v01 );
- t->vertexUV( ( float )( x + 1.0f ), ( float )( y + h2 ), ( float )( z + 1.0f ), u10, v10 );
- t->vertexUV( ( float )( x + 1.0f ), ( float )( y + h3 ), ( float )( z + 0.0f ), u11, v11 );
- }
+ float br;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ br = 1;
+ } else {
+ br = tt->getBrightness(level, x, y, z);
+ }
+ t->color(c11 * br * r, c11 * br * g, c11 * br * b);
+ t->vertexUV((float)(x + 0.0f), (float)(y + h0), (float)(z + 0.0f), u00,
+ v00);
+ t->vertexUV((float)(x + 0.0f), (float)(y + h1), (float)(z + 1.0f), u01,
+ v01);
+ t->vertexUV((float)(x + 1.0f), (float)(y + h2), (float)(z + 1.0f), u10,
+ v10);
+ t->vertexUV((float)(x + 1.0f), (float)(y + h3), (float)(z + 0.0f), u11,
+ v11);
+ }
- if ( noCulling || down )
- {
- float br;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tt->getLightColor( level, x, y - 1, z ) );
- br = 1;
- }
- else
- {
- br = tt->getBrightness( level, x, y - 1, z );
- }
- t->color( c10 * br, c10 * br, c10 * br );
- renderFaceDown( tt, x, y + offs, z, getTexture( tt, 0 ) );
- changed = true;
- }
+ if (noCulling || down) {
+ float br;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y - 1, z));
+ br = 1;
+ } else {
+ br = tt->getBrightness(level, x, y - 1, z);
+ }
+ t->color(c10 * br, c10 * br, c10 * br);
+ renderFaceDown(tt, x, y + offs, z, getTexture(tt, 0));
+ changed = true;
+ }
- for ( int face = 0; face < 4; face++ )
- {
- int xt = x;
- int yt = y;
- int zt = z;
+ for (int face = 0; face < 4; face++) {
+ int xt = x;
+ int yt = y;
+ int zt = z;
- if ( face == 0 ) zt--;
- if ( face == 1 ) zt++;
- if ( face == 2 ) xt--;
- if ( face == 3 ) xt++;
+ if (face == 0) zt--;
+ if (face == 1) zt++;
+ if (face == 2) xt--;
+ if (face == 3) xt++;
- Icon_SPU *tex = getTexture(tt, face + 2, data);
+ Icon_SPU* tex = getTexture(tt, face + 2, data);
- if ( noCulling || dirs[face] )
- {
- float hh0;
- float hh1;
- float x0, z0, x1, z1;
- if ( face == 0 )
- {
- hh0 = ( float )( h0 );
- hh1 = ( float )( h3 );
- x0 = ( float )( x );
- x1 = ( float )( x + 1 );
- z0 = ( float )( z + offs);
- z1 = ( float )( z + offs);
- }
- else if ( face == 1 )
- {
- hh0 = ( float )( h2 );
- hh1 = ( float )( h1 );
- x0 = ( float )( x + 1 );
- x1 = ( float )( x );
- z0 = ( float )( z + 1 - offs);
- z1 = ( float )( z + 1 - offs);
- }
- else if ( face == 2 )
- {
- hh0 = ( float )( h1 );
- hh1 = ( float )( h0 );
- x0 = ( float )( x + offs);
- x1 = ( float )( x + offs);
- z0 = ( float )( z + 1 );
- z1 = ( float )( z );
- }
- else
- {
- hh0 = ( float )( h3 );
- hh1 = ( float )( h2 );
- x0 = ( float )( x + 1 - offs);
- x1 = ( float )( x + 1 - offs);
- z0 = ( float )( z );
- z1 = ( float )( z + 1 );
- }
+ if (noCulling || dirs[face]) {
+ float hh0;
+ float hh1;
+ float x0, z0, x1, z1;
+ if (face == 0) {
+ hh0 = (float)(h0);
+ hh1 = (float)(h3);
+ x0 = (float)(x);
+ x1 = (float)(x + 1);
+ z0 = (float)(z + offs);
+ z1 = (float)(z + offs);
+ } else if (face == 1) {
+ hh0 = (float)(h2);
+ hh1 = (float)(h1);
+ x0 = (float)(x + 1);
+ x1 = (float)(x);
+ z0 = (float)(z + 1 - offs);
+ z1 = (float)(z + 1 - offs);
+ } else if (face == 2) {
+ hh0 = (float)(h1);
+ hh1 = (float)(h0);
+ x0 = (float)(x + offs);
+ x1 = (float)(x + offs);
+ z0 = (float)(z + 1);
+ z1 = (float)(z);
+ } else {
+ hh0 = (float)(h3);
+ hh1 = (float)(h2);
+ x0 = (float)(x + 1 - offs);
+ x1 = (float)(x + 1 - offs);
+ z0 = (float)(z);
+ z1 = (float)(z + 1);
+ }
+ changed = true;
+ float u0 = tex->getU(0);
+ float u1 = tex->getU(SharedConstants::WORLD_RESOLUTION * .5f);
- changed = true;
- float u0 = tex->getU(0);
- float u1 = tex->getU(SharedConstants::WORLD_RESOLUTION * .5f);
+ // int yTex = tex->getY();
+ float v01 =
+ tex->getV((1 - hh0) * SharedConstants::WORLD_RESOLUTION * .5f);
+ float v02 =
+ tex->getV((1 - hh1) * SharedConstants::WORLD_RESOLUTION * .5f);
+ float v1 = tex->getV(SharedConstants::WORLD_RESOLUTION * .5f);
-// int yTex = tex->getY();
- float v01 = tex->getV((1 - hh0) * SharedConstants::WORLD_RESOLUTION * .5f);
- float v02 = tex->getV((1 - hh1) * SharedConstants::WORLD_RESOLUTION * .5f);
- float v1 = tex->getV(SharedConstants::WORLD_RESOLUTION * .5f);
+ float br;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, xt, yt, zt));
+ br = 1;
+ } else {
+ br = tt->getBrightness(level, xt, yt, zt);
+ }
+ if (face < 2)
+ br *= c2;
+ else
+ br *= c3;
- float br;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tt->getLightColor( level, xt, yt, zt ) );
- br = 1;
- }
- else
- {
- br = tt->getBrightness( level, xt, yt, zt );
- }
- if ( face < 2 ) br *= c2;
- else
- br *= c3;
+ t->color(c11 * br * r, c11 * br * g, c11 * br * b);
+ t->vertexUV((float)(x0), (float)(y + hh0), (float)(z0), (float)(u0),
+ (float)(v01));
+ t->vertexUV((float)(x1), (float)(y + hh1), (float)(z1), (float)(u1),
+ (float)(v02));
+ t->vertexUV((float)(x1), (float)(y + 0), (float)(z1), (float)(u1),
+ (float)(v1));
+ t->vertexUV((float)(x0), (float)(y + 0), (float)(z0), (float)(u0),
+ (float)(v1));
+ }
+ }
- t->color( c11 * br * r, c11 * br * g, c11 * br * b );
- t->vertexUV( ( float )( x0 ), ( float )( y + hh0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v01 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + hh1 ), ( float )( z1 ), ( float )( u1 ), ( float )( v02 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y + 0 ), ( float )( z1 ), ( float )( u1 ), ( float )( v1 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y + 0 ), ( float )( z0 ), ( float )( u0 ), ( float )( v1 ) );
+ tileShapeY0 = yo0;
+ tileShapeY1 = yo1;
- }
-
- }
-
- tileShapeY0 = yo0;
- tileShapeY1 = yo1;
-
- return changed;
+ return changed;
}
-float TileRenderer_SPU::getWaterHeight( int x, int y, int z, Material_SPU* m )
-{
- int count = 0;
- float h = 0;
- for ( int i = 0; i < 4; i++ )
- {
- int xx = x - ( i & 1 );
- int yy = y;
- int zz = z - ( ( i >> 1 ) & 1 );
- if ( level->getMaterial( xx, yy + 1, zz ) == m )
- {
- return 1;
- }
- Material_SPU* tm = level->getMaterial( xx, yy, zz );
- if ( tm == m )
- {
- int d = level->getData( xx, yy, zz );
- if ( d >= 8 || d == 0 )
- {
- h += ( LiquidTile_SPU::getHeight( d ) )* 10;
- count += 10;
- }
- h += LiquidTile_SPU::getHeight( d );
- count++;
- }
- else if ( !tm->isSolid() )
- {
- h += 1;
- count++;
- }
- }
- return 1 - h / count;
+float TileRenderer_SPU::getWaterHeight(int x, int y, int z, Material_SPU* m) {
+ int count = 0;
+ float h = 0;
+ for (int i = 0; i < 4; i++) {
+ int xx = x - (i & 1);
+ int yy = y;
+ int zz = z - ((i >> 1) & 1);
+ if (level->getMaterial(xx, yy + 1, zz) == m) {
+ return 1;
+ }
+ Material_SPU* tm = level->getMaterial(xx, yy, zz);
+ if (tm == m) {
+ int d = level->getData(xx, yy, zz);
+ if (d >= 8 || d == 0) {
+ h += (LiquidTile_SPU::getHeight(d)) * 10;
+ count += 10;
+ }
+ h += LiquidTile_SPU::getHeight(d);
+ count++;
+ } else if (!tm->isSolid()) {
+ h += 1;
+ count++;
+ }
+ }
+ return 1 - h / count;
}
-void TileRenderer_SPU::renderBlock( Tile_SPU* tt, ChunkRebuildData* level, int x, int y, int z )
-{
- renderBlock(tt, level, x, y, z, 0);
+void TileRenderer_SPU::renderBlock(Tile_SPU* tt, ChunkRebuildData* level, int x,
+ int y, int z) {
+ renderBlock(tt, level, x, y, z, 0);
}
-void TileRenderer_SPU::renderBlock(Tile_SPU *tt, ChunkRebuildData *level, int x, int y, int z, int data)
-{
- float c10 = 0.5f;
- float c11 = 1;
- float c2 = 0.8f;
- float c3 = 0.6f;
+void TileRenderer_SPU::renderBlock(Tile_SPU* tt, ChunkRebuildData* level, int x,
+ int y, int z, int data) {
+ float c10 = 0.5f;
+ float c11 = 1;
+ float c2 = 0.8f;
+ float c3 = 0.6f;
- Tesselator_SPU* t = getTesselator();
- t->begin();
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tt->getLightColor( level, x, y, z ) );
- }
- float center = SharedConstants::TEXTURE_LIGHTING ? 1 : tt->getBrightness( level, x, y, z );
- float br = SharedConstants::TEXTURE_LIGHTING ? 1 : tt->getBrightness( level, x, y - 1, z );
+ Tesselator_SPU* t = getTesselator();
+ t->begin();
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ }
+ float center = SharedConstants::TEXTURE_LIGHTING
+ ? 1
+ : tt->getBrightness(level, x, y, z);
+ float br = SharedConstants::TEXTURE_LIGHTING
+ ? 1
+ : tt->getBrightness(level, x, y - 1, z);
- if ( br < center ) br = center;
- t->color( c10 * br, c10 * br, c10 * br );
- renderFaceDown( tt, -0.5f, -0.5f, -0.5f, getTexture( tt, 0, data ) );
+ if (br < center) br = center;
+ t->color(c10 * br, c10 * br, c10 * br);
+ renderFaceDown(tt, -0.5f, -0.5f, -0.5f, getTexture(tt, 0, data));
- br = SharedConstants::TEXTURE_LIGHTING ? 1 : tt->getBrightness( level, x, y + 1, z );
- if ( br < center ) br = center;
- t->color( c11 * br, c11 * br, c11 * br );
- renderFaceUp( tt, -0.5f, -0.5f, -0.5f, getTexture( tt, 1, data ) );
+ br = SharedConstants::TEXTURE_LIGHTING
+ ? 1
+ : tt->getBrightness(level, x, y + 1, z);
+ if (br < center) br = center;
+ t->color(c11 * br, c11 * br, c11 * br);
+ renderFaceUp(tt, -0.5f, -0.5f, -0.5f, getTexture(tt, 1, data));
- br = SharedConstants::TEXTURE_LIGHTING ? 1 : tt->getBrightness( level, x, y, z - 1 );
- if ( br < center ) br = center;
- t->color( c2 * br, c2 * br, c2 * br );
- renderNorth( tt, -0.5f, -0.5f, -0.5f, getTexture( tt, 2, data ) );
+ br = SharedConstants::TEXTURE_LIGHTING
+ ? 1
+ : tt->getBrightness(level, x, y, z - 1);
+ if (br < center) br = center;
+ t->color(c2 * br, c2 * br, c2 * br);
+ renderNorth(tt, -0.5f, -0.5f, -0.5f, getTexture(tt, 2, data));
- br = SharedConstants::TEXTURE_LIGHTING ? 1 : tt->getBrightness( level, x, y, z + 1 );
- if ( br < center ) br = center;
- t->color( c2 * br, c2 * br, c2 * br );
- renderSouth( tt, -0.5f, -0.5f, -0.5f, getTexture( tt, 3, data ) );
+ br = SharedConstants::TEXTURE_LIGHTING
+ ? 1
+ : tt->getBrightness(level, x, y, z + 1);
+ if (br < center) br = center;
+ t->color(c2 * br, c2 * br, c2 * br);
+ renderSouth(tt, -0.5f, -0.5f, -0.5f, getTexture(tt, 3, data));
- br = SharedConstants::TEXTURE_LIGHTING ? 1 : tt->getBrightness( level, x - 1, y, z );
- if ( br < center ) br = center;
- t->color( c3 * br, c3 * br, c3 * br );
- renderWest( tt, -0.5f, -0.5f, -0.5f, getTexture( tt, 4, data ) );
-
- br = SharedConstants::TEXTURE_LIGHTING ? 1 : tt->getBrightness( level, x + 1, y, z );
- if ( br < center ) br = center;
- t->color( c3 * br, c3 * br, c3 * br );
- renderEast( tt, -0.5f, -0.5f, -0.5f, getTexture( tt, 5, data ) );
- t->end();
+ br = SharedConstants::TEXTURE_LIGHTING
+ ? 1
+ : tt->getBrightness(level, x - 1, y, z);
+ if (br < center) br = center;
+ t->color(c3 * br, c3 * br, c3 * br);
+ renderWest(tt, -0.5f, -0.5f, -0.5f, getTexture(tt, 4, data));
+ br = SharedConstants::TEXTURE_LIGHTING
+ ? 1
+ : tt->getBrightness(level, x + 1, y, z);
+ if (br < center) br = center;
+ t->color(c3 * br, c3 * br, c3 * br);
+ renderEast(tt, -0.5f, -0.5f, -0.5f, getTexture(tt, 5, data));
+ t->end();
}
-bool TileRenderer_SPU::tesselateBlockInWorld( Tile_SPU* tt, int x, int y, int z )
-{
- int col = tt->getColor( level, x, y, z );
- float r = ( ( col >> 16 ) & 0xff ) / 255.0f;
- float g = ( ( col >> 8 ) & 0xff ) / 255.0f;
- float b = ( ( col )& 0xff ) / 255.0f;
+bool TileRenderer_SPU::tesselateBlockInWorld(Tile_SPU* tt, int x, int y,
+ int z) {
+ int col = tt->getColor(level, x, y, z);
+ float r = ((col >> 16) & 0xff) / 255.0f;
+ float g = ((col >> 8) & 0xff) / 255.0f;
+ float b = ((col) & 0xff) / 255.0f;
- if ( isAnaglyph3d())
- {
- float cr = ( r * 30 + g * 59 + b * 11 ) / 100;
- float cg = ( r * 30 + g * 70 ) / ( 100 );
- float cb = ( r * 30 + b * 70 ) / ( 100 );
+ if (isAnaglyph3d()) {
+ float cr = (r * 30 + g * 59 + b * 11) / 100;
+ float cg = (r * 30 + g * 70) / (100);
+ float cb = (r * 30 + b * 70) / (100);
- r = cr;
- g = cg;
- b = cb;
- }
+ r = cr;
+ g = cg;
+ b = cb;
+ }
- if ( level->m_tileData.lightEmission[tt->id] == 0 )//4J - TODO/remove (Minecraft::useAmbientOcclusion())
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- return tesselateBlockInWorldWithAmbienceOcclusionTexLighting( tt, x, y, z, r, g, b );
- }
- else
- {
- return tesselateBlockInWorldWithAmbienceOcclusionOldLighting( tt, x, y, z, r, g, b );
- }
- }
- else
- {
- return tesselateBlockInWorld( tt, x, y, z, r, g, b );
- }
+ if (level->m_tileData.lightEmission[tt->id] ==
+ 0) // 4J - TODO/remove (Minecraft::useAmbientOcclusion())
+ {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ return tesselateBlockInWorldWithAmbienceOcclusionTexLighting(
+ tt, x, y, z, r, g, b);
+ } else {
+ return tesselateBlockInWorldWithAmbienceOcclusionOldLighting(
+ tt, x, y, z, r, g, b);
+ }
+ } else {
+ return tesselateBlockInWorld(tt, x, y, z, r, g, b);
+ }
}
-bool TileRenderer_SPU::tesselateTreeInWorld(Tile_SPU *tt, int x, int y, int z)
-{
- int data = level->getData(x, y, z);
- int facing = data & TreeTile_SPU::MASK_FACING;
+bool TileRenderer_SPU::tesselateTreeInWorld(Tile_SPU* tt, int x, int y, int z) {
+ int data = level->getData(x, y, z);
+ int facing = data & TreeTile_SPU::MASK_FACING;
- if (facing == TreeTile_SPU::FACING_X)
- {
- northFlip = FLIP_CW;
- southFlip = FLIP_CW;
- upFlip = FLIP_CW;
- downFlip = FLIP_CW;
- }
- else if (facing == TreeTile_SPU::FACING_Z)
- {
- eastFlip = FLIP_CW;
- westFlip = FLIP_CW;
- }
+ if (facing == TreeTile_SPU::FACING_X) {
+ northFlip = FLIP_CW;
+ southFlip = FLIP_CW;
+ upFlip = FLIP_CW;
+ downFlip = FLIP_CW;
+ } else if (facing == TreeTile_SPU::FACING_Z) {
+ eastFlip = FLIP_CW;
+ westFlip = FLIP_CW;
+ }
- bool result = tesselateBlockInWorld(tt, x, y, z);
+ bool result = tesselateBlockInWorld(tt, x, y, z);
- eastFlip = 0;
- northFlip = 0;
- southFlip = 0;
- westFlip = 0;
- upFlip = 0;
- downFlip = 0;
+ eastFlip = 0;
+ northFlip = 0;
+ southFlip = 0;
+ westFlip = 0;
+ upFlip = 0;
+ downFlip = 0;
- return result;
+ return result;
}
-bool TileRenderer_SPU::tesselateQuartzInWorld(Tile_SPU *tt, int x, int y, int z)
-{
- int data = level->getData(x, y, z);
+bool TileRenderer_SPU::tesselateQuartzInWorld(Tile_SPU* tt, int x, int y,
+ int z) {
+ int data = level->getData(x, y, z);
- if (data == QuartzBlockTile_SPU::TYPE_LINES_X)
- {
- northFlip = FLIP_CW;
- southFlip = FLIP_CW;
- upFlip = FLIP_CW;
- downFlip = FLIP_CW;
- }
- else if (data == QuartzBlockTile_SPU::TYPE_LINES_Z)
- {
- eastFlip = FLIP_CW;
- westFlip = FLIP_CW;
- }
+ if (data == QuartzBlockTile_SPU::TYPE_LINES_X) {
+ northFlip = FLIP_CW;
+ southFlip = FLIP_CW;
+ upFlip = FLIP_CW;
+ downFlip = FLIP_CW;
+ } else if (data == QuartzBlockTile_SPU::TYPE_LINES_Z) {
+ eastFlip = FLIP_CW;
+ westFlip = FLIP_CW;
+ }
- bool result = tesselateBlockInWorld(tt, x, y, z);
+ bool result = tesselateBlockInWorld(tt, x, y, z);
- eastFlip = 0;
- northFlip = 0;
- southFlip = 0;
- westFlip = 0;
- upFlip = 0;
- downFlip = 0;
+ eastFlip = 0;
+ northFlip = 0;
+ southFlip = 0;
+ westFlip = 0;
+ upFlip = 0;
+ downFlip = 0;
- return result;
+ return result;
}
-bool TileRenderer_SPU::tesselateCocoaInWorld(CocoaTile_SPU *tt, int x, int y, int z)
-{
+bool TileRenderer_SPU::tesselateCocoaInWorld(CocoaTile_SPU* tt, int x, int y,
+ int z) {
#ifdef DISABLE_TESS_FUNCS
- Tesselator *t = Tesselator::getInstance();
+ Tesselator* t = Tesselator::getInstance();
- if (SharedConstants::TEXTURE_LIGHTING)
- {
- t->tex2(tt->getLightColor(level, x, y, z));
- t->color(1.0f, 1.0f, 1.0f);
- }
- else
- {
- float br = tt->getBrightness(level, x, y, z);
- if (Tile::lightEmission[tt->id] > 0) br = 1.0f;
- t->color(br, br, br);
- }
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tt->getLightColor(level, x, y, z));
+ t->color(1.0f, 1.0f, 1.0f);
+ } else {
+ float br = tt->getBrightness(level, x, y, z);
+ if (Tile::lightEmission[tt->id] > 0) br = 1.0f;
+ t->color(br, br, br);
+ }
- int data = level->getData(x, y, z);
- int dir = DirectionalTile::getDirection(data);
- int age = CocoaTile::getAge(data);
- Icon *tex = tt->getTextureForAge(age);
+ int data = level->getData(x, y, z);
+ int dir = DirectionalTile::getDirection(data);
+ int age = CocoaTile::getAge(data);
+ Icon* tex = tt->getTextureForAge(age);
- int cocoaWidth = 4 + age * 2;
- int cocoaHeight = 5 + age * 2;
+ int cocoaWidth = 4 + age * 2;
+ int cocoaHeight = 5 + age * 2;
- double us = 15.0 - cocoaWidth;
- double ue = 15.0;
- double vs = 4.0;
- double ve = 4.0 + cocoaHeight;
- double u0 = tex->getU(us, true);
- double u1 = tex->getU(ue, true);
- double v0 = tex->getV(vs, true);
- double v1 = tex->getV(ve, true);
+ double us = 15.0 - cocoaWidth;
+ double ue = 15.0;
+ double vs = 4.0;
+ double ve = 4.0 + cocoaHeight;
+ double u0 = tex->getU(us, true);
+ double u1 = tex->getU(ue, true);
+ double v0 = tex->getV(vs, true);
+ double v1 = tex->getV(ve, true);
+ double offX = 0;
+ double offZ = 0;
- double offX = 0;
- double offZ = 0;
+ switch (dir) {
+ case Direction::NORTH:
+ offX = 8.0 - cocoaWidth / 2;
+ offZ = 1.0;
+ break;
+ case Direction::SOUTH:
+ offX = 8.0 - cocoaWidth / 2;
+ offZ = 15.0 - cocoaWidth;
+ break;
+ case Direction::EAST:
+ offX = 15.0 - cocoaWidth;
+ offZ = 8.0 - cocoaWidth / 2;
+ break;
+ case Direction::WEST:
+ offX = 1.0;
+ offZ = 8.0 - cocoaWidth / 2;
+ break;
+ }
- switch (dir)
- {
- case Direction::NORTH:
- offX = 8.0 - cocoaWidth / 2;
- offZ = 1.0;
- break;
- case Direction::SOUTH:
- offX = 8.0 - cocoaWidth / 2;
- offZ = 15.0 - cocoaWidth;
- break;
- case Direction::EAST:
- offX = 15.0 - cocoaWidth;
- offZ = 8.0 - cocoaWidth / 2;
- break;
- case Direction::WEST:
- offX = 1.0;
- offZ = 8.0 - cocoaWidth / 2;
- break;
- }
+ double x0 = x + offX / 16.0;
+ double x1 = x + (offX + cocoaWidth) / 16.0;
+ double y0 = y + (12.0 - cocoaHeight) / 16.0;
+ double y1 = y + 12.0 / 16.0;
+ double z0 = z + offZ / 16.0;
+ double z1 = z + (offZ + cocoaWidth) / 16.0;
- double x0 = x + offX / 16.0;
- double x1 = x + (offX + cocoaWidth) / 16.0;
- double y0 = y + (12.0 - cocoaHeight) / 16.0;
- double y1 = y + 12.0 / 16.0;
- double z0 = z + offZ / 16.0;
- double z1 = z + (offZ + cocoaWidth) / 16.0;
+ // west
+ {
+ t->vertexUV(x0, y0, z0, u0, v1);
+ t->vertexUV(x0, y0, z1, u1, v1);
+ t->vertexUV(x0, y1, z1, u1, v0);
+ t->vertexUV(x0, y1, z0, u0, v0);
+ }
+ // east
+ {
+ t->vertexUV(x1, y0, z1, u0, v1);
+ t->vertexUV(x1, y0, z0, u1, v1);
+ t->vertexUV(x1, y1, z0, u1, v0);
+ t->vertexUV(x1, y1, z1, u0, v0);
+ }
+ // north
+ {
+ t->vertexUV(x1, y0, z0, u0, v1);
+ t->vertexUV(x0, y0, z0, u1, v1);
+ t->vertexUV(x0, y1, z0, u1, v0);
+ t->vertexUV(x1, y1, z0, u0, v0);
+ }
+ // south
+ {
+ t->vertexUV(x0, y0, z1, u0, v1);
+ t->vertexUV(x1, y0, z1, u1, v1);
+ t->vertexUV(x1, y1, z1, u1, v0);
+ t->vertexUV(x0, y1, z1, u0, v0);
+ }
- // west
- {
- t->vertexUV(x0, y0, z0, u0, v1);
- t->vertexUV(x0, y0, z1, u1, v1);
- t->vertexUV(x0, y1, z1, u1, v0);
- t->vertexUV(x0, y1, z0, u0, v0);
- }
- // east
- {
- t->vertexUV(x1, y0, z1, u0, v1);
- t->vertexUV(x1, y0, z0, u1, v1);
- t->vertexUV(x1, y1, z0, u1, v0);
- t->vertexUV(x1, y1, z1, u0, v0);
- }
- // north
- {
- t->vertexUV(x1, y0, z0, u0, v1);
- t->vertexUV(x0, y0, z0, u1, v1);
- t->vertexUV(x0, y1, z0, u1, v0);
- t->vertexUV(x1, y1, z0, u0, v0);
- }
- // south
- {
- t->vertexUV(x0, y0, z1, u0, v1);
- t->vertexUV(x1, y0, z1, u1, v1);
- t->vertexUV(x1, y1, z1, u1, v0);
- t->vertexUV(x0, y1, z1, u0, v0);
- }
+ int topWidth = cocoaWidth;
+ if (age >= 2) {
+ // special case because the top piece didn't fit
+ topWidth--;
+ }
- int topWidth = cocoaWidth;
- if (age >= 2)
- {
- // special case because the top piece didn't fit
- topWidth--;
- }
+ u0 = tex->getU0(true);
+ u1 = tex->getU(topWidth, true);
+ v0 = tex->getV0(true);
+ v1 = tex->getV(topWidth, true);
- u0 = tex->getU0(true);
- u1 = tex->getU(topWidth, true);
- v0 = tex->getV0(true);
- v1 = tex->getV(topWidth, true);
+ // top
+ {
+ t->vertexUV(x0, y1, z1, u0, v1);
+ t->vertexUV(x1, y1, z1, u1, v1);
+ t->vertexUV(x1, y1, z0, u1, v0);
+ t->vertexUV(x0, y1, z0, u0, v0);
+ }
+ // bottom
+ {
+ t->vertexUV(x0, y0, z0, u0, v0);
+ t->vertexUV(x1, y0, z0, u1, v0);
+ t->vertexUV(x1, y0, z1, u1, v1);
+ t->vertexUV(x0, y0, z1, u0, v1);
+ }
- // top
- {
- t->vertexUV(x0, y1, z1, u0, v1);
- t->vertexUV(x1, y1, z1, u1, v1);
- t->vertexUV(x1, y1, z0, u1, v0);
- t->vertexUV(x0, y1, z0, u0, v0);
- }
- // bottom
- {
- t->vertexUV(x0, y0, z0, u0, v0);
- t->vertexUV(x1, y0, z0, u1, v0);
- t->vertexUV(x1, y0, z1, u1, v1);
- t->vertexUV(x0, y0, z1, u0, v1);
- }
+ // stalk
+ u0 = tex->getU(12, true);
+ u1 = tex->getU1(true);
+ v0 = tex->getV0(true);
+ v1 = tex->getV(4, true);
- // stalk
- u0 = tex->getU(12, true);
- u1 = tex->getU1(true);
- v0 = tex->getV0(true);
- v1 = tex->getV(4, true);
+ offX = 8;
+ offZ = 0;
- offX = 8;
- offZ = 0;
+ switch (dir) {
+ case Direction::NORTH:
+ offX = 8.0;
+ offZ = 0.0;
+ break;
+ case Direction::SOUTH:
+ offX = 8;
+ offZ = 12;
+ {
+ double temp = u0;
+ u0 = u1;
+ u1 = temp;
+ }
+ break;
+ case Direction::EAST:
+ offX = 12.0;
+ offZ = 8.0;
+ {
+ double temp = u0;
+ u0 = u1;
+ u1 = temp;
+ }
+ break;
+ case Direction::WEST:
+ offX = 0.0;
+ offZ = 8.0;
+ break;
+ }
- switch (dir)
- {
- case Direction::NORTH:
- offX = 8.0;
- offZ = 0.0;
- break;
- case Direction::SOUTH:
- offX = 8;
- offZ = 12;
- {
- double temp = u0;
- u0 = u1;
- u1 = temp;
- }
- break;
- case Direction::EAST:
- offX = 12.0;
- offZ = 8.0;
- {
- double temp = u0;
- u0 = u1;
- u1 = temp;
- }
- break;
- case Direction::WEST:
- offX = 0.0;
- offZ = 8.0;
- break;
- }
+ x0 = x + offX / 16.0;
+ x1 = x + (offX + 4.0) / 16.0;
+ y0 = y + 12.0 / 16.0;
+ y1 = y + 16.0 / 16.0;
+ z0 = z + offZ / 16.0;
+ z1 = z + (offZ + 4.0) / 16.0;
+ if (dir == Direction::NORTH || dir == Direction::SOUTH) {
+ // west
+ {
+ t->vertexUV(x0, y0, z0, u1, v1);
+ t->vertexUV(x0, y0, z1, u0, v1);
+ t->vertexUV(x0, y1, z1, u0, v0);
+ t->vertexUV(x0, y1, z0, u1, v0);
+ }
+ // east
+ {
+ t->vertexUV(x0, y0, z1, u0, v1);
+ t->vertexUV(x0, y0, z0, u1, v1);
+ t->vertexUV(x0, y1, z0, u1, v0);
+ t->vertexUV(x0, y1, z1, u0, v0);
+ }
+ } else if (dir == Direction::WEST || dir == Direction::EAST) {
+ // north
+ {
+ t->vertexUV(x1, y0, z0, u0, v1);
+ t->vertexUV(x0, y0, z0, u1, v1);
+ t->vertexUV(x0, y1, z0, u1, v0);
+ t->vertexUV(x1, y1, z0, u0, v0);
+ }
+ // south
+ {
+ t->vertexUV(x0, y0, z0, u1, v1);
+ t->vertexUV(x1, y0, z0, u0, v1);
+ t->vertexUV(x1, y1, z0, u0, v0);
+ t->vertexUV(x0, y1, z0, u1, v0);
+ }
+ }
- x0 = x + offX / 16.0;
- x1 = x + (offX + 4.0) / 16.0;
- y0 = y + 12.0 / 16.0;
- y1 = y + 16.0 / 16.0;
- z0 = z + offZ / 16.0;
- z1 = z + (offZ + 4.0) / 16.0;
- if (dir == Direction::NORTH || dir == Direction::SOUTH)
- {
- // west
- {
- t->vertexUV(x0, y0, z0, u1, v1);
- t->vertexUV(x0, y0, z1, u0, v1);
- t->vertexUV(x0, y1, z1, u0, v0);
- t->vertexUV(x0, y1, z0, u1, v0);
- }
- // east
- {
- t->vertexUV(x0, y0, z1, u0, v1);
- t->vertexUV(x0, y0, z0, u1, v1);
- t->vertexUV(x0, y1, z0, u1, v0);
- t->vertexUV(x0, y1, z1, u0, v0);
- }
- }
- else if (dir == Direction::WEST || dir == Direction::EAST)
- {
- // north
- {
- t->vertexUV(x1, y0, z0, u0, v1);
- t->vertexUV(x0, y0, z0, u1, v1);
- t->vertexUV(x0, y1, z0, u1, v0);
- t->vertexUV(x1, y1, z0, u0, v0);
- }
- // south
- {
- t->vertexUV(x0, y0, z0, u1, v1);
- t->vertexUV(x1, y0, z0, u0, v1);
- t->vertexUV(x1, y1, z0, u0, v0);
- t->vertexUV(x0, y1, z0, u1, v0);
- }
- }
-
-#endif // DISABLE_TESS_FUNCS
- return true;
+#endif // DISABLE_TESS_FUNCS
+ return true;
}
// 4J - brought changes forward from 1.8.2
-bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Tile_SPU* tt, int pX, int pY, int pZ,
- float pBaseRed, float pBaseGreen,
- float pBaseBlue )
-{
- // 4J - added these faceFlags so we can detect whether this block is going to have no visible faces and early out
- // the original code checked noCulling and shouldRenderFace directly where faceFlags is used now
- int faceFlags = 0;
- if ( noCulling )
- {
- faceFlags = 0x3f;
- }
- else
- {
-/*#ifdef _DEBUG
- if(dynamic_cast(tt)!=NULL)
- {
- // stair tile
- faceFlags |= tt->shouldRenderFace( level, pX, pY - 1, pZ, 0 ) ? 0x01 : 0;
- faceFlags |= tt->shouldRenderFace( level, pX, pY + 1, pZ, 1 ) ? 0x02 : 0;
- faceFlags |= tt->shouldRenderFace( level, pX, pY, pZ - 1, 2 ) ? 0x04 : 0;
- faceFlags |= tt->shouldRenderFace( level, pX, pY, pZ + 1, 3 ) ? 0x08 : 0;
- faceFlags |= tt->shouldRenderFace( level, pX - 1, pY, pZ, 4 ) ? 0x10 : 0;
- faceFlags |= tt->shouldRenderFace( level, pX + 1, pY, pZ, 5 ) ? 0x20 : 0;
+bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionTexLighting(
+ Tile_SPU* tt, int pX, int pY, int pZ, float pBaseRed, float pBaseGreen,
+ float pBaseBlue) {
+ // 4J - added these faceFlags so we can detect whether this block is going
+ // to have no visible faces and early out the original code checked
+ // noCulling and shouldRenderFace directly where faceFlags is used now
+ int faceFlags = 0;
+ if (noCulling) {
+ faceFlags = 0x3f;
+ } else {
+ /*#ifdef _DEBUG
+ if(dynamic_cast(tt)!=NULL)
+ {
+ // stair tile
+ faceFlags |= tt->shouldRenderFace( level, pX, pY
+ - 1, pZ, 0 ) ? 0x01 : 0; faceFlags |= tt->shouldRenderFace( level, pX,
+ pY + 1, pZ, 1 ) ? 0x02 : 0; faceFlags |= tt->shouldRenderFace( level,
+ pX, pY, pZ - 1, 2 ) ? 0x04 : 0; faceFlags |= tt->shouldRenderFace(
+ level, pX, pY, pZ + 1, 3 ) ? 0x08 : 0; faceFlags |=
+ tt->shouldRenderFace( level, pX - 1, pY, pZ, 4 ) ? 0x10 : 0; faceFlags
+ |= tt->shouldRenderFace( level, pX + 1, pY, pZ, 5 ) ? 0x20 : 0;
- printf("Stair tile\n");
- }
- else
- {
- faceFlags |= tt->shouldRenderFace( level, pX, pY - 1, pZ, 0 ) ? 0x01 : 0;
- faceFlags |= tt->shouldRenderFace( level, pX, pY + 1, pZ, 1 ) ? 0x02 : 0;
- faceFlags |= tt->shouldRenderFace( level, pX, pY, pZ - 1, 2 ) ? 0x04 : 0;
- faceFlags |= tt->shouldRenderFace( level, pX, pY, pZ + 1, 3 ) ? 0x08 : 0;
- faceFlags |= tt->shouldRenderFace( level, pX - 1, pY, pZ, 4 ) ? 0x10 : 0;
- faceFlags |= tt->shouldRenderFace( level, pX + 1, pY, pZ, 5 ) ? 0x20 : 0;
+ printf("Stair tile\n");
+ }
+ else
+ {
+ faceFlags |= tt->shouldRenderFace( level, pX, pY
+ - 1, pZ, 0 ) ? 0x01 : 0; faceFlags |= tt->shouldRenderFace( level, pX,
+ pY + 1, pZ, 1 ) ? 0x02 : 0; faceFlags |= tt->shouldRenderFace( level,
+ pX, pY, pZ - 1, 2 ) ? 0x04 : 0; faceFlags |= tt->shouldRenderFace(
+ level, pX, pY, pZ + 1, 3 ) ? 0x08 : 0; faceFlags |=
+ tt->shouldRenderFace( level, pX - 1, pY, pZ, 4 ) ? 0x10 : 0; faceFlags
+ |= tt->shouldRenderFace( level, pX + 1, pY, pZ, 5 ) ? 0x20 : 0;
- }
-#else*/
- faceFlags |= tt->shouldRenderFace( level, pX, pY - 1, pZ, 0 ) ? 0x01 : 0;
- faceFlags |= tt->shouldRenderFace( level, pX, pY + 1, pZ, 1 ) ? 0x02 : 0;
- faceFlags |= tt->shouldRenderFace( level, pX, pY, pZ - 1, 2 ) ? 0x04 : 0;
- faceFlags |= tt->shouldRenderFace( level, pX, pY, pZ + 1, 3 ) ? 0x08 : 0;
- faceFlags |= tt->shouldRenderFace( level, pX - 1, pY, pZ, 4 ) ? 0x10 : 0;
- faceFlags |= tt->shouldRenderFace( level, pX + 1, pY, pZ, 5 ) ? 0x20 : 0;
-//#endif
- }
- if ( faceFlags == 0 )
- {
- return false;
- }
+ }
+ #else*/
+ faceFlags |= tt->shouldRenderFace(level, pX, pY - 1, pZ, 0) ? 0x01 : 0;
+ faceFlags |= tt->shouldRenderFace(level, pX, pY + 1, pZ, 1) ? 0x02 : 0;
+ faceFlags |= tt->shouldRenderFace(level, pX, pY, pZ - 1, 2) ? 0x04 : 0;
+ faceFlags |= tt->shouldRenderFace(level, pX, pY, pZ + 1, 3) ? 0x08 : 0;
+ faceFlags |= tt->shouldRenderFace(level, pX - 1, pY, pZ, 4) ? 0x10 : 0;
+ faceFlags |= tt->shouldRenderFace(level, pX + 1, pY, pZ, 5) ? 0x20 : 0;
+ // #endif
+ }
+ if (faceFlags == 0) {
+ return false;
+ }
+ // If we are only rendering the bottom face and we're at the bottom of the
+ // world, we shouldn't be able to see this - don't render anything
+ if ((faceFlags == 1) && (pY == 0)) {
+ return false;
+ }
- // If we are only rendering the bottom face and we're at the bottom of the world, we shouldn't be able to see this - don't render anything
- if( ( faceFlags == 1 ) && ( pY == 0 ) )
- {
- return false;
- }
+ applyAmbienceOcclusion = true;
+ float ll1 = ll000;
+ float ll2 = ll000;
+ float ll3 = ll000;
+ float ll4 = ll000;
+ bool tint0 = true;
+ bool tint1 = true;
+ bool tint2 = true;
+ bool tint3 = true;
+ bool tint4 = true;
+ bool tint5 = true;
- applyAmbienceOcclusion = true;
- float ll1 = ll000;
- float ll2 = ll000;
- float ll3 = ll000;
- float ll4 = ll000;
- bool tint0 = true;
- bool tint1 = true;
- bool tint2 = true;
- bool tint3 = true;
- bool tint4 = true;
- bool tint5 = true;
+ ll000 = tt->getShadeBrightness(level, pX, pY, pZ);
+ // Tile* t2 = Tile::tiles[tt->id];
+ // if(t2->getShadeBrightness(level->m_pRegion, pX, pY, pZ) != ll000)
+ // {
+ // app.DebugPrintf("Failed\n");
+ // ll000 = tt->getShadeBrightness( level, pX, pY, pZ );
+ // ll000 = t2->getShadeBrightness(level->m_pRegion, pX, pY, pZ);
+ // }
+ llx00 = tt->getShadeBrightness(level, pX - 1, pY, pZ);
+ ll0y0 = tt->getShadeBrightness(level, pX, pY - 1, pZ);
+ ll00z = tt->getShadeBrightness(level, pX, pY, pZ - 1);
+ llX00 = tt->getShadeBrightness(level, pX + 1, pY, pZ);
+ ll0Y0 = tt->getShadeBrightness(level, pX, pY + 1, pZ);
+ ll00Z = tt->getShadeBrightness(level, pX, pY, pZ + 1);
+ // 4J - these changes brought forward from 1.2.3
+ int centerColor = tt->getLightColor(level, pX, pY, pZ);
+ int ccx00 = centerColor;
+ int cc0y0 = centerColor;
+ int cc00z = centerColor;
+ int ccX00 = centerColor;
+ int cc0Y0 = centerColor;
+ int cc00Z = centerColor;
- ll000 = tt->getShadeBrightness( level, pX, pY, pZ );
-// Tile* t2 = Tile::tiles[tt->id];
-// if(t2->getShadeBrightness(level->m_pRegion, pX, pY, pZ) != ll000)
-// {
-// app.DebugPrintf("Failed\n");
-// ll000 = tt->getShadeBrightness( level, pX, pY, pZ );
-// ll000 = t2->getShadeBrightness(level->m_pRegion, pX, pY, pZ);
-// }
- llx00 = tt->getShadeBrightness( level, pX - 1, pY, pZ );
- ll0y0 = tt->getShadeBrightness( level, pX, pY - 1, pZ );
- ll00z = tt->getShadeBrightness( level, pX, pY, pZ - 1 );
- llX00 = tt->getShadeBrightness( level, pX + 1, pY, pZ );
- ll0Y0 = tt->getShadeBrightness( level, pX, pY + 1, pZ );
- ll00Z = tt->getShadeBrightness( level, pX, pY, pZ + 1 );
+ if (tileShapeY0 <= 0 || !level->isSolidRenderTile(pX, pY - 1, pZ))
+ cc0y0 = tt->getLightColor(level, pX, pY - 1, pZ);
+ if (tileShapeY1 >= 1 || !level->isSolidRenderTile(pX, pY + 1, pZ))
+ cc0Y0 = tt->getLightColor(level, pX, pY + 1, pZ);
+ if (tileShapeX0 <= 0 || !level->isSolidRenderTile(pX - 1, pY, pZ))
+ ccx00 = tt->getLightColor(level, pX - 1, pY, pZ);
+ if (tileShapeX1 >= 1 || !level->isSolidRenderTile(pX + 1, pY, pZ))
+ ccX00 = tt->getLightColor(level, pX + 1, pY, pZ);
+ if (tileShapeZ0 <= 0 || !level->isSolidRenderTile(pX, pY, pZ - 1))
+ cc00z = tt->getLightColor(level, pX, pY, pZ - 1);
+ if (tileShapeZ1 >= 1 || !level->isSolidRenderTile(pX, pY, pZ + 1))
+ cc00Z = tt->getLightColor(level, pX, pY, pZ + 1);
+ Tesselator_SPU* t = getTesselator();
+ t->tex2(0xf000f);
+ llTransXY0 =
+ level->m_tileData.transculent[level->getTile(pX + 1, pY + 1, pZ)];
+ llTransXy0 =
+ level->m_tileData.transculent[level->getTile(pX + 1, pY - 1, pZ)];
+ llTransX0Z =
+ level->m_tileData.transculent[level->getTile(pX + 1, pY, pZ + 1)];
+ llTransX0z =
+ level->m_tileData.transculent[level->getTile(pX + 1, pY, pZ - 1)];
+ llTransxY0 =
+ level->m_tileData.transculent[level->getTile(pX - 1, pY + 1, pZ)];
+ llTransxy0 =
+ level->m_tileData.transculent[level->getTile(pX - 1, pY - 1, pZ)];
+ llTransx0z =
+ level->m_tileData.transculent[level->getTile(pX - 1, pY, pZ - 1)];
+ llTransx0Z =
+ level->m_tileData.transculent[level->getTile(pX - 1, pY, pZ + 1)];
+ llTrans0YZ =
+ level->m_tileData.transculent[level->getTile(pX, pY + 1, pZ + 1)];
+ llTrans0Yz =
+ level->m_tileData.transculent[level->getTile(pX, pY + 1, pZ - 1)];
+ llTrans0yZ =
+ level->m_tileData.transculent[level->getTile(pX, pY - 1, pZ + 1)];
+ llTrans0yz =
+ level->m_tileData.transculent[level->getTile(pX, pY - 1, pZ - 1)];
- // 4J - these changes brought forward from 1.2.3
- int centerColor = tt->getLightColor( level, pX, pY, pZ );
- int ccx00 = centerColor;
- int cc0y0 = centerColor;
- int cc00z = centerColor;
- int ccX00 = centerColor;
- int cc0Y0 = centerColor;
- int cc00Z = centerColor;
+ if (getTexture(tt) == &Tile_SPU::ms_pTileData->grass_iconTop)
+ tint0 = tint2 = tint3 = tint4 = tint5 = false;
+ if (hasFixedTexture()) tint0 = tint2 = tint3 = tint4 = tint5 = false;
+ if (faceFlags & 0x01) {
+ if (blsmooth > 0) {
+ if (tileShapeY0 <= 0)
+ pY--; // 4J - condition brought forwardEnterCriticalSection
+ // from 1.2.3
- if (tileShapeY0 <= 0 || !level->isSolidRenderTile(pX, pY - 1, pZ)) cc0y0 = tt->getLightColor(level, pX, pY - 1, pZ);
- if (tileShapeY1 >= 1 || !level->isSolidRenderTile(pX, pY + 1, pZ)) cc0Y0 = tt->getLightColor(level, pX, pY + 1, pZ);
- if (tileShapeX0 <= 0 || !level->isSolidRenderTile(pX - 1, pY, pZ)) ccx00 = tt->getLightColor(level, pX - 1, pY, pZ);
- if (tileShapeX1 >= 1 || !level->isSolidRenderTile(pX + 1, pY, pZ)) ccX00 = tt->getLightColor(level, pX + 1, pY, pZ);
- if (tileShapeZ0 <= 0 || !level->isSolidRenderTile(pX, pY, pZ - 1)) cc00z = tt->getLightColor(level, pX, pY, pZ - 1);
- if (tileShapeZ1 >= 1 || !level->isSolidRenderTile(pX, pY, pZ + 1)) cc00Z = tt->getLightColor(level, pX, pY, pZ + 1);
+ ccxy0 = tt->getLightColor(level, pX - 1, pY, pZ);
+ cc0yz = tt->getLightColor(level, pX, pY, pZ - 1);
+ cc0yZ = tt->getLightColor(level, pX, pY, pZ + 1);
+ ccXy0 = tt->getLightColor(level, pX + 1, pY, pZ);
+ llxy0 = tt->getShadeBrightness(level, pX - 1, pY, pZ);
+ ll0yz = tt->getShadeBrightness(level, pX, pY, pZ - 1);
+ ll0yZ = tt->getShadeBrightness(level, pX, pY, pZ + 1);
+ llXy0 = tt->getShadeBrightness(level, pX + 1, pY, pZ);
- Tesselator_SPU* t = getTesselator();
- t->tex2( 0xf000f );
+ if (llTrans0yz || llTransxy0) {
+ llxyz = tt->getShadeBrightness(level, pX - 1, pY, pZ - 1);
+ ccxyz = tt->getLightColor(level, pX - 1, pY, pZ - 1);
+ } else {
+ llxyz = llxy0;
+ ccxyz = ccxy0;
+ }
+ if (llTrans0yZ || llTransxy0) {
+ llxyZ = tt->getShadeBrightness(level, pX - 1, pY, pZ + 1);
+ ccxyZ = tt->getLightColor(level, pX - 1, pY, pZ + 1);
+ } else {
+ llxyZ = llxy0;
+ ccxyZ = ccxy0;
+ }
+ if (llTrans0yz || llTransXy0) {
+ llXyz = tt->getShadeBrightness(level, pX + 1, pY, pZ - 1);
+ ccXyz = tt->getLightColor(level, pX + 1, pY, pZ - 1);
+ } else {
+ llXyz = llXy0;
+ ccXyz = ccXy0;
+ }
+ if (llTrans0yZ || llTransXy0) {
+ llXyZ = tt->getShadeBrightness(level, pX + 1, pY, pZ + 1);
+ ccXyZ = tt->getLightColor(level, pX + 1, pY, pZ + 1);
+ } else {
+ llXyZ = llXy0;
+ ccXyZ = ccXy0;
+ }
- llTransXY0 = level->m_tileData.transculent[level->getTile( pX + 1, pY + 1, pZ )];
- llTransXy0 = level->m_tileData.transculent[level->getTile( pX + 1, pY - 1, pZ )];
- llTransX0Z = level->m_tileData.transculent[level->getTile( pX + 1, pY, pZ + 1 )];
- llTransX0z = level->m_tileData.transculent[level->getTile( pX + 1, pY, pZ - 1 )];
- llTransxY0 = level->m_tileData.transculent[level->getTile( pX - 1, pY + 1, pZ )];
- llTransxy0 = level->m_tileData.transculent[level->getTile( pX - 1, pY - 1, pZ )];
- llTransx0z = level->m_tileData.transculent[level->getTile( pX - 1, pY, pZ - 1 )];
- llTransx0Z = level->m_tileData.transculent[level->getTile( pX - 1, pY, pZ + 1 )];
- llTrans0YZ = level->m_tileData.transculent[level->getTile( pX, pY + 1, pZ + 1 )];
- llTrans0Yz = level->m_tileData.transculent[level->getTile( pX, pY + 1, pZ - 1 )];
- llTrans0yZ = level->m_tileData.transculent[level->getTile( pX, pY - 1, pZ + 1 )];
- llTrans0yz = level->m_tileData.transculent[level->getTile( pX, pY - 1, pZ - 1 )];
+ if (tileShapeY0 <= 0)
+ pY++; // 4J - condition brought forward from 1.2.3
+ ll1 = (llxyZ + llxy0 + ll0yZ + ll0y0) / 4.0f;
+ ll4 = (ll0yZ + ll0y0 + llXyZ + llXy0) / 4.0f;
+ ll3 = (ll0y0 + ll0yz + llXy0 + llXyz) / 4.0f;
+ ll2 = (llxy0 + llxyz + ll0y0 + ll0yz) / 4.0f;
- if ( getTexture(tt)== &Tile_SPU::ms_pTileData->grass_iconTop )
- tint0 = tint2 = tint3 = tint4 = tint5 = false;
- if ( hasFixedTexture() ) tint0 = tint2 = tint3 = tint4 = tint5 = false;
+ tc1 = blend(ccxyZ, ccxy0, cc0yZ, cc0y0);
+ tc4 = blend(cc0yZ, ccXyZ, ccXy0, cc0y0);
+ tc3 = blend(cc0yz, ccXy0, ccXyz, cc0y0);
+ tc2 = blend(ccxy0, ccxyz, cc0yz, cc0y0);
+ } else {
+ ll1 = ll2 = ll3 = ll4 = ll0y0;
+ tc1 = tc2 = tc3 = tc4 = ccxy0;
+ }
+ c1r = c2r = c3r = c4r = (tint0 ? pBaseRed : 1.0f) * 0.5f;
+ c1g = c2g = c3g = c4g = (tint0 ? pBaseGreen : 1.0f) * 0.5f;
+ c1b = c2b = c3b = c4b = (tint0 ? pBaseBlue : 1.0f) * 0.5f;
+ c1r *= ll1;
+ c1g *= ll1;
+ c1b *= ll1;
+ c2r *= ll2;
+ c2g *= ll2;
+ c2b *= ll2;
+ c3r *= ll3;
+ c3g *= ll3;
+ c3b *= ll3;
+ c4r *= ll4;
+ c4g *= ll4;
+ c4b *= ll4;
- if ( faceFlags & 0x01 )
- {
- if ( blsmooth > 0 )
- {
- if ( tileShapeY0 <= 0 ) pY--; // 4J - condition brought forwardEnterCriticalSection from 1.2.3
+ renderFaceDown(tt, (float)pX, (float)pY, (float)pZ,
+ getTexture(tt, level, pX, pY, pZ, 0));
+ }
+ if (faceFlags & 0x02) {
+ if (blsmooth > 0) {
+ if (tileShapeY1 >= 1)
+ pY++; // 4J - condition brought forward from 1.2.3
- ccxy0 = tt->getLightColor( level, pX - 1, pY, pZ );
- cc0yz = tt->getLightColor( level, pX, pY, pZ - 1 );
- cc0yZ = tt->getLightColor( level, pX, pY, pZ + 1 );
- ccXy0 = tt->getLightColor( level, pX + 1, pY, pZ );
+ ccxY0 = tt->getLightColor(level, pX - 1, pY, pZ);
+ ccXY0 = tt->getLightColor(level, pX + 1, pY, pZ);
+ cc0Yz = tt->getLightColor(level, pX, pY, pZ - 1);
+ cc0YZ = tt->getLightColor(level, pX, pY, pZ + 1);
- llxy0 = tt->getShadeBrightness( level, pX - 1, pY, pZ );
- ll0yz = tt->getShadeBrightness( level, pX, pY, pZ - 1 );
- ll0yZ = tt->getShadeBrightness( level, pX, pY, pZ + 1 );
- llXy0 = tt->getShadeBrightness( level, pX + 1, pY, pZ );
+ llxY0 = tt->getShadeBrightness(level, pX - 1, pY, pZ);
+ llXY0 = tt->getShadeBrightness(level, pX + 1, pY, pZ);
+ ll0Yz = tt->getShadeBrightness(level, pX, pY, pZ - 1);
+ ll0YZ = tt->getShadeBrightness(level, pX, pY, pZ + 1);
- if ( llTrans0yz || llTransxy0 )
- {
- llxyz = tt->getShadeBrightness( level, pX - 1, pY, pZ - 1 );
- ccxyz = tt->getLightColor( level, pX - 1, pY, pZ - 1 );
- }
- else
- {
- llxyz = llxy0;
- ccxyz = ccxy0;
- }
- if ( llTrans0yZ || llTransxy0 )
- {
- llxyZ = tt->getShadeBrightness( level, pX - 1, pY, pZ + 1 );
- ccxyZ = tt->getLightColor( level, pX - 1, pY, pZ + 1 );
- }
- else
- {
- llxyZ = llxy0;
- ccxyZ = ccxy0;
- }
- if ( llTrans0yz || llTransXy0 )
- {
- llXyz = tt->getShadeBrightness( level, pX + 1, pY, pZ - 1 );
- ccXyz = tt->getLightColor( level, pX + 1, pY, pZ - 1 );
- }
- else
- {
- llXyz = llXy0;
- ccXyz = ccXy0;
- }
- if ( llTrans0yZ || llTransXy0 )
- {
- llXyZ = tt->getShadeBrightness( level, pX + 1, pY, pZ + 1 );
- ccXyZ = tt->getLightColor( level, pX + 1, pY, pZ + 1 );
- }
- else
- {
- llXyZ = llXy0;
- ccXyZ = ccXy0;
- }
+ if (llTrans0Yz || llTransxY0) {
+ llxYz = tt->getShadeBrightness(level, pX - 1, pY, pZ - 1);
+ ccxYz = tt->getLightColor(level, pX - 1, pY, pZ - 1);
+ } else {
+ llxYz = llxY0;
+ ccxYz = ccxY0;
+ }
+ if (llTrans0Yz || llTransXY0) {
+ llXYz = tt->getShadeBrightness(level, pX + 1, pY, pZ - 1);
+ ccXYz = tt->getLightColor(level, pX + 1, pY, pZ - 1);
+ } else {
+ llXYz = llXY0;
+ ccXYz = ccXY0;
+ }
+ if (llTrans0YZ || llTransxY0) {
+ llxYZ = tt->getShadeBrightness(level, pX - 1, pY, pZ + 1);
+ ccxYZ = tt->getLightColor(level, pX - 1, pY, pZ + 1);
+ } else {
+ llxYZ = llxY0;
+ ccxYZ = ccxY0;
+ }
+ if (llTrans0YZ || llTransXY0) {
+ llXYZ = tt->getShadeBrightness(level, pX + 1, pY, pZ + 1);
+ ccXYZ = tt->getLightColor(level, pX + 1, pY, pZ + 1);
+ } else {
+ llXYZ = llXY0;
+ ccXYZ = ccXY0;
+ }
+ if (tileShapeY1 >= 1)
+ pY--; // 4J - condition brought forward from 1.2.3
- if ( tileShapeY0 <= 0 ) pY++; // 4J - condition brought forward from 1.2.3
- ll1 = ( llxyZ + llxy0 + ll0yZ + ll0y0 ) / 4.0f;
- ll4 = ( ll0yZ + ll0y0 + llXyZ + llXy0 ) / 4.0f;
- ll3 = ( ll0y0 + ll0yz + llXy0 + llXyz ) / 4.0f;
- ll2 = ( llxy0 + llxyz + ll0y0 + ll0yz ) / 4.0f;
+ ll4 = (llxYZ + llxY0 + ll0YZ + ll0Y0) / 4.0f;
+ ll1 = (ll0YZ + ll0Y0 + llXYZ + llXY0) / 4.0f;
+ ll2 = (ll0Y0 + ll0Yz + llXY0 + llXYz) / 4.0f;
+ ll3 = (llxY0 + llxYz + ll0Y0 + ll0Yz) / 4.0f;
- tc1 = blend( ccxyZ, ccxy0, cc0yZ, cc0y0 );
- tc4 = blend( cc0yZ, ccXyZ, ccXy0, cc0y0 );
- tc3 = blend( cc0yz, ccXy0, ccXyz, cc0y0 );
- tc2 = blend( ccxy0, ccxyz, cc0yz, cc0y0 );
- }
- else
- {
- ll1 = ll2 = ll3 = ll4 = ll0y0;
- tc1 = tc2 = tc3 = tc4 = ccxy0;
- }
- c1r = c2r = c3r = c4r = ( tint0 ? pBaseRed : 1.0f ) * 0.5f;
- c1g = c2g = c3g = c4g = ( tint0 ? pBaseGreen : 1.0f ) * 0.5f;
- c1b = c2b = c3b = c4b = ( tint0 ? pBaseBlue : 1.0f ) * 0.5f;
- c1r *= ll1;
- c1g *= ll1;
- c1b *= ll1;
- c2r *= ll2;
- c2g *= ll2;
- c2b *= ll2;
- c3r *= ll3;
- c3g *= ll3;
- c3b *= ll3;
- c4r *= ll4;
- c4g *= ll4;
- c4b *= ll4;
+ tc4 = blend(ccxYZ, ccxY0, cc0YZ, cc0Y0);
+ tc1 = blend(cc0YZ, ccXYZ, ccXY0, cc0Y0);
+ tc2 = blend(cc0Yz, ccXY0, ccXYz, cc0Y0);
+ tc3 = blend(ccxY0, ccxYz, cc0Yz, cc0Y0);
+ } else {
+ ll1 = ll2 = ll3 = ll4 = ll0Y0;
+ tc1 = tc2 = tc3 = tc4 = cc0Y0;
+ }
+ c1r = c2r = c3r = c4r = (tint1 ? pBaseRed : 1.0f);
+ c1g = c2g = c3g = c4g = (tint1 ? pBaseGreen : 1.0f);
+ c1b = c2b = c3b = c4b = (tint1 ? pBaseBlue : 1.0f);
+ c1r *= ll1;
+ c1g *= ll1;
+ c1b *= ll1;
+ c2r *= ll2;
+ c2g *= ll2;
+ c2b *= ll2;
+ c3r *= ll3;
+ c3g *= ll3;
+ c3b *= ll3;
+ c4r *= ll4;
+ c4g *= ll4;
+ c4b *= ll4;
- renderFaceDown( tt, ( float )pX, ( float )pY, ( float )pZ, getTexture( tt, level, pX, pY, pZ, 0 ) );
- }
- if ( faceFlags & 0x02 )
- {
- if ( blsmooth > 0 )
- {
- if ( tileShapeY1 >= 1 ) pY++; // 4J - condition brought forward from 1.2.3
+ renderFaceUp(tt, (float)pX, (float)pY, (float)pZ,
+ getTexture(tt, level, pX, pY, pZ, 1));
+ }
+ if (faceFlags & 0x04) {
+ if (blsmooth > 0) {
+ if (tileShapeZ0 <= 0)
+ pZ--; // 4J - condition brought forward from 1.2.3
+ llx0z = tt->getShadeBrightness(level, pX - 1, pY, pZ);
+ ll0yz = tt->getShadeBrightness(level, pX, pY - 1, pZ);
+ ll0Yz = tt->getShadeBrightness(level, pX, pY + 1, pZ);
+ llX0z = tt->getShadeBrightness(level, pX + 1, pY, pZ);
- ccxY0 = tt->getLightColor( level, pX - 1, pY, pZ );
- ccXY0 = tt->getLightColor( level, pX + 1, pY, pZ );
- cc0Yz = tt->getLightColor( level, pX, pY, pZ - 1 );
- cc0YZ = tt->getLightColor( level, pX, pY, pZ + 1 );
+ ccx0z = tt->getLightColor(level, pX - 1, pY, pZ);
+ cc0yz = tt->getLightColor(level, pX, pY - 1, pZ);
+ cc0Yz = tt->getLightColor(level, pX, pY + 1, pZ);
+ ccX0z = tt->getLightColor(level, pX + 1, pY, pZ);
- llxY0 = tt->getShadeBrightness( level, pX - 1, pY, pZ );
- llXY0 = tt->getShadeBrightness( level, pX + 1, pY, pZ );
- ll0Yz = tt->getShadeBrightness( level, pX, pY, pZ - 1 );
- ll0YZ = tt->getShadeBrightness( level, pX, pY, pZ + 1 );
-
- if ( llTrans0Yz || llTransxY0 )
- {
- llxYz = tt->getShadeBrightness( level, pX - 1, pY, pZ - 1 );
- ccxYz = tt->getLightColor( level, pX - 1, pY, pZ - 1 );
- }
- else
- {
- llxYz = llxY0;
- ccxYz = ccxY0;
- }
- if ( llTrans0Yz || llTransXY0 )
- {
- llXYz = tt->getShadeBrightness( level, pX + 1, pY, pZ - 1 );
- ccXYz = tt->getLightColor( level, pX + 1, pY, pZ - 1 );
- }
- else
- {
- llXYz = llXY0;
- ccXYz = ccXY0;
- }
- if ( llTrans0YZ || llTransxY0 )
- {
- llxYZ = tt->getShadeBrightness( level, pX - 1, pY, pZ + 1 );
- ccxYZ = tt->getLightColor( level, pX - 1, pY, pZ + 1 );
- }
- else
- {
- llxYZ = llxY0;
- ccxYZ = ccxY0;
- }
- if ( llTrans0YZ || llTransXY0 )
- {
- llXYZ = tt->getShadeBrightness( level, pX + 1, pY, pZ + 1 );
- ccXYZ = tt->getLightColor( level, pX + 1, pY, pZ + 1 );
- }
- else
- {
- llXYZ = llXY0;
- ccXYZ = ccXY0;
- }
- if ( tileShapeY1 >= 1 ) pY--; // 4J - condition brought forward from 1.2.3
-
- ll4 = ( llxYZ + llxY0 + ll0YZ + ll0Y0 ) / 4.0f;
- ll1 = ( ll0YZ + ll0Y0 + llXYZ + llXY0 ) / 4.0f;
- ll2 = ( ll0Y0 + ll0Yz + llXY0 + llXYz ) / 4.0f;
- ll3 = ( llxY0 + llxYz + ll0Y0 + ll0Yz ) / 4.0f;
-
- tc4 = blend( ccxYZ, ccxY0, cc0YZ, cc0Y0 );
- tc1 = blend( cc0YZ, ccXYZ, ccXY0, cc0Y0 );
- tc2 = blend( cc0Yz, ccXY0, ccXYz, cc0Y0 );
- tc3 = blend( ccxY0, ccxYz, cc0Yz, cc0Y0 );
- }
- else
- {
- ll1 = ll2 = ll3 = ll4 = ll0Y0;
- tc1 = tc2 = tc3 = tc4 = cc0Y0;
- }
- c1r = c2r = c3r = c4r = ( tint1 ? pBaseRed : 1.0f );
- c1g = c2g = c3g = c4g = ( tint1 ? pBaseGreen : 1.0f );
- c1b = c2b = c3b = c4b = ( tint1 ? pBaseBlue : 1.0f );
- c1r *= ll1;
- c1g *= ll1;
- c1b *= ll1;
- c2r *= ll2;
- c2g *= ll2;
- c2b *= ll2;
- c3r *= ll3;
- c3g *= ll3;
- c3b *= ll3;
- c4r *= ll4;
- c4g *= ll4;
- c4b *= ll4;
-
-
- renderFaceUp( tt, ( float )pX, ( float )pY, ( float )pZ, getTexture( tt, level, pX, pY, pZ, 1 ) );
- }
- if ( faceFlags & 0x04 )
- {
- if ( blsmooth > 0 )
- {
- if ( tileShapeZ0 <= 0 ) pZ--; // 4J - condition brought forward from 1.2.3
- llx0z = tt->getShadeBrightness( level, pX - 1, pY, pZ );
- ll0yz = tt->getShadeBrightness( level, pX, pY - 1, pZ );
- ll0Yz = tt->getShadeBrightness( level, pX, pY + 1, pZ );
- llX0z = tt->getShadeBrightness( level, pX + 1, pY, pZ );
-
- ccx0z = tt->getLightColor( level, pX - 1, pY, pZ );
- cc0yz = tt->getLightColor( level, pX, pY - 1, pZ );
- cc0Yz = tt->getLightColor( level, pX, pY + 1, pZ );
- ccX0z = tt->getLightColor( level, pX + 1, pY, pZ );
-
- if ( llTransx0z || llTrans0yz )
- {
- llxyz = tt->getShadeBrightness( level, pX - 1, pY - 1, pZ );
- ccxyz = tt->getLightColor( level, pX - 1, pY - 1, pZ );
- }
- else
- {
- llxyz = llx0z;
- ccxyz = ccx0z;
- }
- if ( llTransx0z || llTrans0Yz )
- {
- llxYz = tt->getShadeBrightness( level, pX - 1, pY + 1, pZ );
- ccxYz = tt->getLightColor( level, pX - 1, pY + 1, pZ );
- }
- else
- {
- llxYz = llx0z;
- ccxYz = ccx0z;
- }
- if ( llTransX0z || llTrans0yz )
- {
- llXyz = tt->getShadeBrightness( level, pX + 1, pY - 1, pZ );
- ccXyz = tt->getLightColor( level, pX + 1, pY - 1, pZ );
- }
- else
- {
- llXyz = llX0z;
- ccXyz = ccX0z;
- }
- if ( llTransX0z || llTrans0Yz )
- {
- llXYz = tt->getShadeBrightness( level, pX + 1, pY + 1, pZ );
- ccXYz = tt->getLightColor( level, pX + 1, pY + 1, pZ );
- }
- else
- {
- llXYz = llX0z;
- ccXYz = ccX0z;
- }
- if ( tileShapeZ0 <= 0 ) pZ++; // 4J - condition brought forward from 1.2.3
+ if (llTransx0z || llTrans0yz) {
+ llxyz = tt->getShadeBrightness(level, pX - 1, pY - 1, pZ);
+ ccxyz = tt->getLightColor(level, pX - 1, pY - 1, pZ);
+ } else {
+ llxyz = llx0z;
+ ccxyz = ccx0z;
+ }
+ if (llTransx0z || llTrans0Yz) {
+ llxYz = tt->getShadeBrightness(level, pX - 1, pY + 1, pZ);
+ ccxYz = tt->getLightColor(level, pX - 1, pY + 1, pZ);
+ } else {
+ llxYz = llx0z;
+ ccxYz = ccx0z;
+ }
+ if (llTransX0z || llTrans0yz) {
+ llXyz = tt->getShadeBrightness(level, pX + 1, pY - 1, pZ);
+ ccXyz = tt->getLightColor(level, pX + 1, pY - 1, pZ);
+ } else {
+ llXyz = llX0z;
+ ccXyz = ccX0z;
+ }
+ if (llTransX0z || llTrans0Yz) {
+ llXYz = tt->getShadeBrightness(level, pX + 1, pY + 1, pZ);
+ ccXYz = tt->getLightColor(level, pX + 1, pY + 1, pZ);
+ } else {
+ llXYz = llX0z;
+ ccXYz = ccX0z;
+ }
+ if (tileShapeZ0 <= 0)
+ pZ++; // 4J - condition brought forward from 1.2.3
#ifdef _XBOX
- #pragma message(__LOC__"ambientOcclusion NEEDS CHANGED FROM A BOOL ")
+#pragma message(__LOC__ "ambientOcclusion NEEDS CHANGED FROM A BOOL ")
#endif
- if (smoothShapeLighting && g_ambientOcclusionMax)//minecraft->options->ambientOcclusion >= Options::AO_MAX)
- {
- float _ll1 = (llx0z + llxYz + ll00z + ll0Yz) / 4.0f;
- float _ll2 = (ll00z + ll0Yz + llX0z + llXYz) / 4.0f;
- float _ll3 = (ll0yz + ll00z + llXyz + llX0z) / 4.0f;
- float _ll4 = (llxyz + llx0z + ll0yz + ll00z) / 4.0f;
- ll1 = (float) (_ll1 * tileShapeY1 * (1.0 - tileShapeX0) + _ll2 * tileShapeY0 * tileShapeX0 + _ll3 * (1.0 - tileShapeY1) * tileShapeX0 + _ll4 * (1.0 - tileShapeY1)
- * (1.0 - tileShapeX0));
- ll2 = (float) (_ll1 * tileShapeY1 * (1.0 - tileShapeX1) + _ll2 * tileShapeY1 * tileShapeX1 + _ll3 * (1.0 - tileShapeY1) * tileShapeX1 + _ll4 * (1.0 - tileShapeY1)
- * (1.0 - tileShapeX1));
- ll3 = (float) (_ll1 * tileShapeY0 * (1.0 - tileShapeX1) + _ll2 * tileShapeY0 * tileShapeX1 + _ll3 * (1.0 - tileShapeY0) * tileShapeX1 + _ll4 * (1.0 - tileShapeY0)
- * (1.0 - tileShapeX1));
- ll4 = (float) (_ll1 * tileShapeY0 * (1.0 - tileShapeX0) + _ll2 * tileShapeY0 * tileShapeX0 + _ll3 * (1.0 - tileShapeY0) * tileShapeX0 + _ll4 * (1.0 - tileShapeY0)
- * (1.0 - tileShapeX0));
+ if (smoothShapeLighting &&
+ g_ambientOcclusionMax) // minecraft->options->ambientOcclusion
+ // >= Options::AO_MAX)
+ {
+ float _ll1 = (llx0z + llxYz + ll00z + ll0Yz) / 4.0f;
+ float _ll2 = (ll00z + ll0Yz + llX0z + llXYz) / 4.0f;
+ float _ll3 = (ll0yz + ll00z + llXyz + llX0z) / 4.0f;
+ float _ll4 = (llxyz + llx0z + ll0yz + ll00z) / 4.0f;
+ ll1 = (float)(_ll1 * tileShapeY1 * (1.0 - tileShapeX0) +
+ _ll2 * tileShapeY0 * tileShapeX0 +
+ _ll3 * (1.0 - tileShapeY1) * tileShapeX0 +
+ _ll4 * (1.0 - tileShapeY1) * (1.0 - tileShapeX0));
+ ll2 = (float)(_ll1 * tileShapeY1 * (1.0 - tileShapeX1) +
+ _ll2 * tileShapeY1 * tileShapeX1 +
+ _ll3 * (1.0 - tileShapeY1) * tileShapeX1 +
+ _ll4 * (1.0 - tileShapeY1) * (1.0 - tileShapeX1));
+ ll3 = (float)(_ll1 * tileShapeY0 * (1.0 - tileShapeX1) +
+ _ll2 * tileShapeY0 * tileShapeX1 +
+ _ll3 * (1.0 - tileShapeY0) * tileShapeX1 +
+ _ll4 * (1.0 - tileShapeY0) * (1.0 - tileShapeX1));
+ ll4 = (float)(_ll1 * tileShapeY0 * (1.0 - tileShapeX0) +
+ _ll2 * tileShapeY0 * tileShapeX0 +
+ _ll3 * (1.0 - tileShapeY0) * tileShapeX0 +
+ _ll4 * (1.0 - tileShapeY0) * (1.0 - tileShapeX0));
- int _tc1 = blend(ccx0z, ccxYz, cc0Yz, cc00z);
- int _tc2 = blend(cc0Yz, ccX0z, ccXYz, cc00z);
- int _tc3 = blend(cc0yz, ccXyz, ccX0z, cc00z);
- int _tc4 = blend(ccxyz, ccx0z, cc0yz, cc00z);
- tc1 = blend(_tc1, _tc2, _tc3, _tc4, tileShapeY1 * (1.0 - tileShapeX0), tileShapeY1 * tileShapeX0, (1.0 - tileShapeY1) * tileShapeX0, (1.0 - tileShapeY1) * (1.0 - tileShapeX0));
- tc2 = blend(_tc1, _tc2, _tc3, _tc4, tileShapeY1 * (1.0 - tileShapeX1), tileShapeY1 * tileShapeX1, (1.0 - tileShapeY1) * tileShapeX1, (1.0 - tileShapeY1) * (1.0 - tileShapeX1));
- tc3 = blend(_tc1, _tc2, _tc3, _tc4, tileShapeY0 * (1.0 - tileShapeX1), tileShapeY0 * tileShapeX1, (1.0 - tileShapeY0) * tileShapeX1, (1.0 - tileShapeY0) * (1.0 - tileShapeX1));
- tc4 = blend(_tc1, _tc2, _tc3, _tc4, tileShapeY0 * (1.0 - tileShapeX0), tileShapeY0 * tileShapeX0, (1.0 - tileShapeY0) * tileShapeX0, (1.0 - tileShapeY0) * (1.0 - tileShapeX0));
- } else {
- ll1 = ( llx0z + llxYz + ll00z + ll0Yz ) / 4.0f;
- ll2 = ( ll00z + ll0Yz + llX0z + llXYz ) / 4.0f;
- ll3 = ( ll0yz + ll00z + llXyz + llX0z ) / 4.0f;
- ll4 = ( llxyz + llx0z + ll0yz + ll00z ) / 4.0f;
+ int _tc1 = blend(ccx0z, ccxYz, cc0Yz, cc00z);
+ int _tc2 = blend(cc0Yz, ccX0z, ccXYz, cc00z);
+ int _tc3 = blend(cc0yz, ccXyz, ccX0z, cc00z);
+ int _tc4 = blend(ccxyz, ccx0z, cc0yz, cc00z);
+ tc1 = blend(_tc1, _tc2, _tc3, _tc4,
+ tileShapeY1 * (1.0 - tileShapeX0),
+ tileShapeY1 * tileShapeX0,
+ (1.0 - tileShapeY1) * tileShapeX0,
+ (1.0 - tileShapeY1) * (1.0 - tileShapeX0));
+ tc2 = blend(_tc1, _tc2, _tc3, _tc4,
+ tileShapeY1 * (1.0 - tileShapeX1),
+ tileShapeY1 * tileShapeX1,
+ (1.0 - tileShapeY1) * tileShapeX1,
+ (1.0 - tileShapeY1) * (1.0 - tileShapeX1));
+ tc3 = blend(_tc1, _tc2, _tc3, _tc4,
+ tileShapeY0 * (1.0 - tileShapeX1),
+ tileShapeY0 * tileShapeX1,
+ (1.0 - tileShapeY0) * tileShapeX1,
+ (1.0 - tileShapeY0) * (1.0 - tileShapeX1));
+ tc4 = blend(_tc1, _tc2, _tc3, _tc4,
+ tileShapeY0 * (1.0 - tileShapeX0),
+ tileShapeY0 * tileShapeX0,
+ (1.0 - tileShapeY0) * tileShapeX0,
+ (1.0 - tileShapeY0) * (1.0 - tileShapeX0));
+ } else {
+ ll1 = (llx0z + llxYz + ll00z + ll0Yz) / 4.0f;
+ ll2 = (ll00z + ll0Yz + llX0z + llXYz) / 4.0f;
+ ll3 = (ll0yz + ll00z + llXyz + llX0z) / 4.0f;
+ ll4 = (llxyz + llx0z + ll0yz + ll00z) / 4.0f;
- tc1 = blend( ccx0z, ccxYz, cc0Yz, cc00z );
- tc2 = blend( cc0Yz, ccX0z, ccXYz, cc00z );
- tc3 = blend( cc0yz, ccXyz, ccX0z, cc00z );
- tc4 = blend( ccxyz, ccx0z, cc0yz, cc00z );
- }
- }
- else
- {
- ll1 = ll2 = ll3 = ll4 = ll00z;
- tc1 = tc2 = tc3 = tc4 = cc00z;
- }
- c1r = c2r = c3r = c4r = ( tint2 ? pBaseRed : 1.0f ) * 0.8f;
- c1g = c2g = c3g = c4g = ( tint2 ? pBaseGreen : 1.0f ) * 0.8f;
- c1b = c2b = c3b = c4b = ( tint2 ? pBaseBlue : 1.0f ) * 0.8f;
- c1r *= ll1;
- c1g *= ll1;
- c1b *= ll1;
- c2r *= ll2;
- c2g *= ll2;
- c2b *= ll2;
- c3r *= ll3;
- c3g *= ll3;
- c3b *= ll3;
- c4r *= ll4;
- c4g *= ll4;
- c4b *= ll4;
+ tc1 = blend(ccx0z, ccxYz, cc0Yz, cc00z);
+ tc2 = blend(cc0Yz, ccX0z, ccXYz, cc00z);
+ tc3 = blend(cc0yz, ccXyz, ccX0z, cc00z);
+ tc4 = blend(ccxyz, ccx0z, cc0yz, cc00z);
+ }
+ } else {
+ ll1 = ll2 = ll3 = ll4 = ll00z;
+ tc1 = tc2 = tc3 = tc4 = cc00z;
+ }
+ c1r = c2r = c3r = c4r = (tint2 ? pBaseRed : 1.0f) * 0.8f;
+ c1g = c2g = c3g = c4g = (tint2 ? pBaseGreen : 1.0f) * 0.8f;
+ c1b = c2b = c3b = c4b = (tint2 ? pBaseBlue : 1.0f) * 0.8f;
+ c1r *= ll1;
+ c1g *= ll1;
+ c1b *= ll1;
+ c2r *= ll2;
+ c2g *= ll2;
+ c2b *= ll2;
+ c3r *= ll3;
+ c3g *= ll3;
+ c3b *= ll3;
+ c4r *= ll4;
+ c4g *= ll4;
+ c4b *= ll4;
+ Icon_SPU* tex = getTexture(tt, level, pX, pY, pZ, 2);
+ renderNorth(tt, (float)pX, (float)pY, (float)pZ, tex);
- Icon_SPU *tex = getTexture(tt, level, pX, pY, pZ, 2);
- renderNorth( tt, ( float )pX, ( float )pY, ( float )pZ, tex );
+ if (fancy &&
+ (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] &&
+ !hasFixedTexture())) {
+ c1r *= pBaseRed;
+ c2r *= pBaseRed;
+ c3r *= pBaseRed;
+ c4r *= pBaseRed;
+ c1g *= pBaseGreen;
+ c2g *= pBaseGreen;
+ c3g *= pBaseGreen;
+ c4g *= pBaseGreen;
+ c1b *= pBaseBlue;
+ c2b *= pBaseBlue;
+ c3b *= pBaseBlue;
+ c4b *= pBaseBlue;
+ bool prev = t->setMipmapEnable(
+ false); // 4J added - this is rendering the little bit of grass
+ // at the top of the side of dirt, don't mipmap it
+ renderNorth(tt, (float)pX, (float)pY, (float)pZ,
+ GrassTile_SPU::getSideTextureOverlay());
+ t->setMipmapEnable(prev);
+ }
+ }
+ if (faceFlags & 0x08) {
+ if (blsmooth > 0) {
+ if (tileShapeZ1 >= 1)
+ pZ++; // 4J - condition brought forward from 1.2.3
- if ( fancy && (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] && !hasFixedTexture() ))
- {
- c1r *= pBaseRed;
- c2r *= pBaseRed;
- c3r *= pBaseRed;
- c4r *= pBaseRed;
- c1g *= pBaseGreen;
- c2g *= pBaseGreen;
- c3g *= pBaseGreen;
- c4g *= pBaseGreen;
- c1b *= pBaseBlue;
- c2b *= pBaseBlue;
- c3b *= pBaseBlue;
- c4b *= pBaseBlue;
- bool prev = t->setMipmapEnable( false ); // 4J added - this is rendering the little bit of grass at the top of the side of dirt, don't mipmap it
- renderNorth( tt, ( float )pX, ( float )pY, ( float )pZ, GrassTile_SPU::getSideTextureOverlay() );
- t->setMipmapEnable( prev );
- }
- }
- if ( faceFlags & 0x08 )
- {
- if ( blsmooth > 0 )
- {
- if ( tileShapeZ1 >= 1 ) pZ++; // 4J - condition brought forward from 1.2.3
+ llx0Z = tt->getShadeBrightness(level, pX - 1, pY, pZ);
+ llX0Z = tt->getShadeBrightness(level, pX + 1, pY, pZ);
+ ll0yZ = tt->getShadeBrightness(level, pX, pY - 1, pZ);
+ ll0YZ = tt->getShadeBrightness(level, pX, pY + 1, pZ);
- llx0Z = tt->getShadeBrightness( level, pX - 1, pY, pZ );
- llX0Z = tt->getShadeBrightness( level, pX + 1, pY, pZ );
- ll0yZ = tt->getShadeBrightness( level, pX, pY - 1, pZ );
- ll0YZ = tt->getShadeBrightness( level, pX, pY + 1, pZ );
+ ccx0Z = tt->getLightColor(level, pX - 1, pY, pZ);
+ ccX0Z = tt->getLightColor(level, pX + 1, pY, pZ);
+ cc0yZ = tt->getLightColor(level, pX, pY - 1, pZ);
+ cc0YZ = tt->getLightColor(level, pX, pY + 1, pZ);
- ccx0Z = tt->getLightColor( level, pX - 1, pY, pZ );
- ccX0Z = tt->getLightColor( level, pX + 1, pY, pZ );
- cc0yZ = tt->getLightColor( level, pX, pY - 1, pZ );
- cc0YZ = tt->getLightColor( level, pX, pY + 1, pZ );
+ if (llTransx0Z || llTrans0yZ) {
+ llxyZ = tt->getShadeBrightness(level, pX - 1, pY - 1, pZ);
+ ccxyZ = tt->getLightColor(level, pX - 1, pY - 1, pZ);
+ } else {
+ llxyZ = llx0Z;
+ ccxyZ = ccx0Z;
+ }
+ if (llTransx0Z || llTrans0YZ) {
+ llxYZ = tt->getShadeBrightness(level, pX - 1, pY + 1, pZ);
+ ccxYZ = tt->getLightColor(level, pX - 1, pY + 1, pZ);
+ } else {
+ llxYZ = llx0Z;
+ ccxYZ = ccx0Z;
+ }
+ if (llTransX0Z || llTrans0yZ) {
+ llXyZ = tt->getShadeBrightness(level, pX + 1, pY - 1, pZ);
+ ccXyZ = tt->getLightColor(level, pX + 1, pY - 1, pZ);
+ } else {
+ llXyZ = llX0Z;
+ ccXyZ = ccX0Z;
+ }
+ if (llTransX0Z || llTrans0YZ) {
+ llXYZ = tt->getShadeBrightness(level, pX + 1, pY + 1, pZ);
+ ccXYZ = tt->getLightColor(level, pX + 1, pY + 1, pZ);
+ } else {
+ llXYZ = llX0Z;
+ ccXYZ = ccX0Z;
+ }
+ if (tileShapeZ1 >= 1)
+ pZ--; // 4J - condition brought forward from 1.2.3
+ if (smoothShapeLighting &&
+ g_ambientOcclusionMax) // minecraft->options->ambientOcclusion
+ // >= Options::AO_MAX)
+ {
+ float _ll1 = (llx0Z + llxYZ + ll00Z + ll0YZ) / 4.0f;
+ float _ll4 = (ll00Z + ll0YZ + llX0Z + llXYZ) / 4.0f;
+ float _ll3 = (ll0yZ + ll00Z + llXyZ + llX0Z) / 4.0f;
+ float _ll2 = (llxyZ + llx0Z + ll0yZ + ll00Z) / 4.0f;
+ ll1 = (float)(_ll1 * tileShapeY1 * (1.0 - tileShapeX0) +
+ _ll4 * tileShapeY1 * tileShapeX0 +
+ _ll3 * (1.0 - tileShapeY1) * tileShapeX0 +
+ _ll2 * (1.0 - tileShapeY1) * (1.0 - tileShapeX0));
+ ll2 = (float)(_ll1 * tileShapeY0 * (1.0 - tileShapeX0) +
+ _ll4 * tileShapeY0 * tileShapeX0 +
+ _ll3 * (1.0 - tileShapeY0) * tileShapeX0 +
+ _ll2 * (1.0 - tileShapeY0) * (1.0 - tileShapeX0));
+ ll3 = (float)(_ll1 * tileShapeY0 * (1.0 - tileShapeX1) +
+ _ll4 * tileShapeY0 * tileShapeX1 +
+ _ll3 * (1.0 - tileShapeY0) * tileShapeX1 +
+ _ll2 * (1.0 - tileShapeY0) * (1.0 - tileShapeX1));
+ ll4 = (float)(_ll1 * tileShapeY1 * (1.0 - tileShapeX1) +
+ _ll4 * tileShapeY1 * tileShapeX1 +
+ _ll3 * (1.0 - tileShapeY1) * tileShapeX1 +
+ _ll2 * (1.0 - tileShapeY1) * (1.0 - tileShapeX1));
- if ( llTransx0Z || llTrans0yZ )
- {
- llxyZ = tt->getShadeBrightness( level, pX - 1, pY - 1, pZ );
- ccxyZ = tt->getLightColor( level, pX - 1, pY - 1, pZ );
- }
- else
- {
- llxyZ = llx0Z;
- ccxyZ = ccx0Z;
- }
- if ( llTransx0Z || llTrans0YZ )
- {
- llxYZ = tt->getShadeBrightness( level, pX - 1, pY + 1, pZ );
- ccxYZ = tt->getLightColor( level, pX - 1, pY + 1, pZ );
- }
- else
- {
- llxYZ = llx0Z;
- ccxYZ = ccx0Z;
- }
- if ( llTransX0Z || llTrans0yZ )
- {
- llXyZ = tt->getShadeBrightness( level, pX + 1, pY - 1, pZ );
- ccXyZ = tt->getLightColor( level, pX + 1, pY - 1, pZ );
- }
- else
- {
- llXyZ = llX0Z;
- ccXyZ = ccX0Z;
- }
- if ( llTransX0Z || llTrans0YZ )
- {
- llXYZ = tt->getShadeBrightness( level, pX + 1, pY + 1, pZ );
- ccXYZ = tt->getLightColor( level, pX + 1, pY + 1, pZ );
- }
- else
- {
- llXYZ = llX0Z;
- ccXYZ = ccX0Z;
- }
- if ( tileShapeZ1 >= 1 ) pZ--; // 4J - condition brought forward from 1.2.3
- if (smoothShapeLighting && g_ambientOcclusionMax)//minecraft->options->ambientOcclusion >= Options::AO_MAX)
- {
- float _ll1 = (llx0Z + llxYZ + ll00Z + ll0YZ) / 4.0f;
- float _ll4 = (ll00Z + ll0YZ + llX0Z + llXYZ) / 4.0f;
- float _ll3 = (ll0yZ + ll00Z + llXyZ + llX0Z) / 4.0f;
- float _ll2 = (llxyZ + llx0Z + ll0yZ + ll00Z) / 4.0f;
- ll1 = (float) (_ll1 * tileShapeY1 * (1.0 - tileShapeX0) + _ll4 * tileShapeY1 * tileShapeX0 + _ll3 * (1.0 - tileShapeY1) * tileShapeX0 + _ll2 * (1.0 - tileShapeY1)
- * (1.0 - tileShapeX0));
- ll2 = (float) (_ll1 * tileShapeY0 * (1.0 - tileShapeX0) + _ll4 * tileShapeY0 * tileShapeX0 + _ll3 * (1.0 - tileShapeY0) * tileShapeX0 + _ll2 * (1.0 - tileShapeY0)
- * (1.0 - tileShapeX0));
- ll3 = (float) (_ll1 * tileShapeY0 * (1.0 - tileShapeX1) + _ll4 * tileShapeY0 * tileShapeX1 + _ll3 * (1.0 - tileShapeY0) * tileShapeX1 + _ll2 * (1.0 - tileShapeY0)
- * (1.0 - tileShapeX1));
- ll4 = (float) (_ll1 * tileShapeY1 * (1.0 - tileShapeX1) + _ll4 * tileShapeY1 * tileShapeX1 + _ll3 * (1.0 - tileShapeY1) * tileShapeX1 + _ll2 * (1.0 - tileShapeY1)
- * (1.0 - tileShapeX1));
+ int _tc1 = blend(ccx0Z, ccxYZ, cc0YZ, cc00Z);
+ int _tc4 = blend(cc0YZ, ccX0Z, ccXYZ, cc00Z);
+ int _tc3 = blend(cc0yZ, ccXyZ, ccX0Z, cc00Z);
+ int _tc2 = blend(ccxyZ, ccx0Z, cc0yZ, cc00Z);
+ tc1 = blend(_tc1, _tc2, _tc3, _tc4,
+ tileShapeY1 * (1.0 - tileShapeX0),
+ (1.0 - tileShapeY1) * (1.0 - tileShapeX0),
+ (1.0 - tileShapeY1) * tileShapeX0,
+ tileShapeY1 * tileShapeX0);
+ tc2 = blend(_tc1, _tc2, _tc3, _tc4,
+ tileShapeY0 * (1.0 - tileShapeX0),
+ (1.0 - tileShapeY0) * (1.0 - tileShapeX0),
+ (1.0 - tileShapeY0) * tileShapeX0,
+ tileShapeY0 * tileShapeX0);
+ tc3 = blend(_tc1, _tc2, _tc3, _tc4,
+ tileShapeY0 * (1.0 - tileShapeX1),
+ (1.0 - tileShapeY0) * (1.0 - tileShapeX1),
+ (1.0 - tileShapeY0) * tileShapeX1,
+ tileShapeY0 * tileShapeX1);
+ tc4 = blend(_tc1, _tc2, _tc3, _tc4,
+ tileShapeY1 * (1.0 - tileShapeX1),
+ (1.0 - tileShapeY1) * (1.0 - tileShapeX1),
+ (1.0 - tileShapeY1) * tileShapeX1,
+ tileShapeY1 * tileShapeX1);
+ } else {
+ ll1 = (llx0Z + llxYZ + ll00Z + ll0YZ) / 4.0f;
+ ll4 = (ll00Z + ll0YZ + llX0Z + llXYZ) / 4.0f;
+ ll3 = (ll0yZ + ll00Z + llXyZ + llX0Z) / 4.0f;
+ ll2 = (llxyZ + llx0Z + ll0yZ + ll00Z) / 4.0f;
- int _tc1 = blend(ccx0Z, ccxYZ, cc0YZ, cc00Z);
- int _tc4 = blend(cc0YZ, ccX0Z, ccXYZ, cc00Z);
- int _tc3 = blend(cc0yZ, ccXyZ, ccX0Z, cc00Z);
- int _tc2 = blend(ccxyZ, ccx0Z, cc0yZ, cc00Z);
- tc1 = blend(_tc1, _tc2, _tc3, _tc4, tileShapeY1 * (1.0 - tileShapeX0), (1.0 - tileShapeY1) * (1.0 - tileShapeX0), (1.0 - tileShapeY1) * tileShapeX0, tileShapeY1 * tileShapeX0);
- tc2 = blend(_tc1, _tc2, _tc3, _tc4, tileShapeY0 * (1.0 - tileShapeX0), (1.0 - tileShapeY0) * (1.0 - tileShapeX0), (1.0 - tileShapeY0) * tileShapeX0, tileShapeY0 * tileShapeX0);
- tc3 = blend(_tc1, _tc2, _tc3, _tc4, tileShapeY0 * (1.0 - tileShapeX1), (1.0 - tileShapeY0) * (1.0 - tileShapeX1), (1.0 - tileShapeY0) * tileShapeX1, tileShapeY0 * tileShapeX1);
- tc4 = blend(_tc1, _tc2, _tc3, _tc4, tileShapeY1 * (1.0 - tileShapeX1), (1.0 - tileShapeY1) * (1.0 - tileShapeX1), (1.0 - tileShapeY1) * tileShapeX1, tileShapeY1 * tileShapeX1);
- }
- else
- {
- ll1 = ( llx0Z + llxYZ + ll00Z + ll0YZ ) / 4.0f;
- ll4 = ( ll00Z + ll0YZ + llX0Z + llXYZ ) / 4.0f;
- ll3 = ( ll0yZ + ll00Z + llXyZ + llX0Z ) / 4.0f;
- ll2 = ( llxyZ + llx0Z + ll0yZ + ll00Z ) / 4.0f;
+ tc1 = blend(ccx0Z, ccxYZ, cc0YZ, cc00Z);
+ tc4 = blend(cc0YZ, ccX0Z, ccXYZ, cc00Z);
+ tc3 = blend(cc0yZ, ccXyZ, ccX0Z, cc00Z);
+ tc2 = blend(ccxyZ, ccx0Z, cc0yZ, cc00Z);
+ }
+ } else {
+ ll1 = ll2 = ll3 = ll4 = ll00Z;
+ tc1 = tc2 = tc3 = tc4 = cc00Z;
+ }
+ c1r = c2r = c3r = c4r = (tint3 ? pBaseRed : 1.0f) * 0.8f;
+ c1g = c2g = c3g = c4g = (tint3 ? pBaseGreen : 1.0f) * 0.8f;
+ c1b = c2b = c3b = c4b = (tint3 ? pBaseBlue : 1.0f) * 0.8f;
+ c1r *= ll1;
+ c1g *= ll1;
+ c1b *= ll1;
+ c2r *= ll2;
+ c2g *= ll2;
+ c2b *= ll2;
+ c3r *= ll3;
+ c3g *= ll3;
+ c3b *= ll3;
+ c4r *= ll4;
+ c4g *= ll4;
+ c4b *= ll4;
+ Icon_SPU* tex = getTexture(tt, level, pX, pY, pZ, 3);
+ renderSouth(tt, (float)pX, (float)pY, (float)pZ,
+ getTexture(tt, level, pX, pY, pZ, 3));
- tc1 = blend( ccx0Z, ccxYZ, cc0YZ, cc00Z );
- tc4 = blend( cc0YZ, ccX0Z, ccXYZ, cc00Z );
- tc3 = blend( cc0yZ, ccXyZ, ccX0Z, cc00Z );
- tc2 = blend( ccxyZ, ccx0Z, cc0yZ, cc00Z );
- }
- }
- else
- {
- ll1 = ll2 = ll3 = ll4 = ll00Z;
- tc1 = tc2 = tc3 = tc4 = cc00Z;
- }
- c1r = c2r = c3r = c4r = ( tint3 ? pBaseRed : 1.0f ) * 0.8f;
- c1g = c2g = c3g = c4g = ( tint3 ? pBaseGreen : 1.0f ) * 0.8f;
- c1b = c2b = c3b = c4b = ( tint3 ? pBaseBlue : 1.0f ) * 0.8f;
- c1r *= ll1;
- c1g *= ll1;
- c1b *= ll1;
- c2r *= ll2;
- c2g *= ll2;
- c2b *= ll2;
- c3r *= ll3;
- c3g *= ll3;
- c3b *= ll3;
- c4r *= ll4;
- c4g *= ll4;
- c4b *= ll4;
- Icon_SPU *tex = getTexture(tt, level, pX, pY, pZ, 3);
- renderSouth( tt, ( float )pX, ( float )pY, ( float )pZ, getTexture(tt, level, pX, pY, pZ, 3 ) );
+ if (fancy &&
+ (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] &&
+ !hasFixedTexture())) {
+ c1r *= pBaseRed;
+ c2r *= pBaseRed;
+ c3r *= pBaseRed;
+ c4r *= pBaseRed;
+ c1g *= pBaseGreen;
+ c2g *= pBaseGreen;
+ c3g *= pBaseGreen;
+ c4g *= pBaseGreen;
+ c1b *= pBaseBlue;
+ c2b *= pBaseBlue;
+ c3b *= pBaseBlue;
+ c4b *= pBaseBlue;
+ bool prev = t->setMipmapEnable(
+ false); // 4J added - this is rendering the little bit of grass
+ // at the top of the side of dirt, don't mipmap it
+ renderSouth(tt, (float)pX, (float)pY, (float)pZ,
+ GrassTile_SPU::getSideTextureOverlay());
+ t->setMipmapEnable(prev);
+ }
+ }
+ if (faceFlags & 0x10) {
+ if (blsmooth > 0) {
+ if (tileShapeX0 <= 0)
+ pX--; // 4J - condition brought forward from 1.2.3
+ llxy0 = tt->getShadeBrightness(level, pX, pY - 1, pZ);
+ llx0z = tt->getShadeBrightness(level, pX, pY, pZ - 1);
+ llx0Z = tt->getShadeBrightness(level, pX, pY, pZ + 1);
+ llxY0 = tt->getShadeBrightness(level, pX, pY + 1, pZ);
- if ( fancy && (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] && !hasFixedTexture() ))
- {
- c1r *= pBaseRed;
- c2r *= pBaseRed;
- c3r *= pBaseRed;
- c4r *= pBaseRed;
- c1g *= pBaseGreen;
- c2g *= pBaseGreen;
- c3g *= pBaseGreen;
- c4g *= pBaseGreen;
- c1b *= pBaseBlue;
- c2b *= pBaseBlue;
- c3b *= pBaseBlue;
- c4b *= pBaseBlue;
- bool prev = t->setMipmapEnable( false ); // 4J added - this is rendering the little bit of grass at the top of the side of dirt, don't mipmap it
- renderSouth( tt, ( float )pX, ( float )pY, ( float )pZ, GrassTile_SPU::getSideTextureOverlay() );
- t->setMipmapEnable( prev );
- }
- }
- if ( faceFlags & 0x10 )
- {
- if ( blsmooth > 0 )
- {
- if ( tileShapeX0 <= 0 ) pX--; // 4J - condition brought forward from 1.2.3
- llxy0 = tt->getShadeBrightness( level, pX, pY - 1, pZ );
- llx0z = tt->getShadeBrightness( level, pX, pY, pZ - 1 );
- llx0Z = tt->getShadeBrightness( level, pX, pY, pZ + 1 );
- llxY0 = tt->getShadeBrightness( level, pX, pY + 1, pZ );
+ ccxy0 = tt->getLightColor(level, pX, pY - 1, pZ);
+ ccx0z = tt->getLightColor(level, pX, pY, pZ - 1);
+ ccx0Z = tt->getLightColor(level, pX, pY, pZ + 1);
+ ccxY0 = tt->getLightColor(level, pX, pY + 1, pZ);
- ccxy0 = tt->getLightColor( level, pX, pY - 1, pZ );
- ccx0z = tt->getLightColor( level, pX, pY, pZ - 1 );
- ccx0Z = tt->getLightColor( level, pX, pY, pZ + 1 );
- ccxY0 = tt->getLightColor( level, pX, pY + 1, pZ );
+ if (llTransx0z || llTransxy0) {
+ llxyz = tt->getShadeBrightness(level, pX, pY - 1, pZ - 1);
+ ccxyz = tt->getLightColor(level, pX, pY - 1, pZ - 1);
+ } else {
+ llxyz = llx0z;
+ ccxyz = ccx0z;
+ }
+ if (llTransx0Z || llTransxy0) {
+ llxyZ = tt->getShadeBrightness(level, pX, pY - 1, pZ + 1);
+ ccxyZ = tt->getLightColor(level, pX, pY - 1, pZ + 1);
+ } else {
+ llxyZ = llx0Z;
+ ccxyZ = ccx0Z;
+ }
+ if (llTransx0z || llTransxY0) {
+ llxYz = tt->getShadeBrightness(level, pX, pY + 1, pZ - 1);
+ ccxYz = tt->getLightColor(level, pX, pY + 1, pZ - 1);
+ } else {
+ llxYz = llx0z;
+ ccxYz = ccx0z;
+ }
+ if (llTransx0Z || llTransxY0) {
+ llxYZ = tt->getShadeBrightness(level, pX, pY + 1, pZ + 1);
+ ccxYZ = tt->getLightColor(level, pX, pY + 1, pZ + 1);
+ } else {
+ llxYZ = llx0Z;
+ ccxYZ = ccx0Z;
+ }
+ if (tileShapeX0 <= 0)
+ pX++; // 4J - condition brought forward from 1.2.3
+ if (smoothShapeLighting &&
+ g_ambientOcclusionMax) // minecraft->options->ambientOcclusion
+ // >= Options::AO_MAX)
+ {
+ float _ll4 = (llxy0 + llxyZ + llx00 + llx0Z) / 4.0f;
+ float _ll1 = (llx00 + llx0Z + llxY0 + llxYZ) / 4.0f;
+ float _ll2 = (llx0z + llx00 + llxYz + llxY0) / 4.0f;
+ float _ll3 = (llxyz + llxy0 + llx0z + llx00) / 4.0f;
+ ll1 = (float)(_ll1 * tileShapeY1 * tileShapeZ1 +
+ _ll2 * tileShapeY1 * (1.0 - tileShapeZ1) +
+ _ll3 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ1) +
+ _ll4 * (1.0 - tileShapeY1) * tileShapeZ1);
+ ll2 = (float)(_ll1 * tileShapeY1 * tileShapeZ0 +
+ _ll2 * tileShapeY1 * (1.0 - tileShapeZ0) +
+ _ll3 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ0) +
+ _ll4 * (1.0 - tileShapeY1) * tileShapeZ0);
+ ll3 = (float)(_ll1 * tileShapeY0 * tileShapeZ0 +
+ _ll2 * tileShapeY0 * (1.0 - tileShapeZ0) +
+ _ll3 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ0) +
+ _ll4 * (1.0 - tileShapeY0) * tileShapeZ0);
+ ll4 = (float)(_ll1 * tileShapeY0 * tileShapeZ1 +
+ _ll2 * tileShapeY0 * (1.0 - tileShapeZ1) +
+ _ll3 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ1) +
+ _ll4 * (1.0 - tileShapeY0) * tileShapeZ1);
- if ( llTransx0z || llTransxy0 )
- {
- llxyz = tt->getShadeBrightness( level, pX, pY - 1, pZ - 1 );
- ccxyz = tt->getLightColor( level, pX, pY - 1, pZ - 1 );
- }
- else
- {
- llxyz = llx0z;
- ccxyz = ccx0z;
- }
- if ( llTransx0Z || llTransxy0 )
- {
- llxyZ = tt->getShadeBrightness( level, pX, pY - 1, pZ + 1 );
- ccxyZ = tt->getLightColor( level, pX, pY - 1, pZ + 1 );
- }
- else
- {
- llxyZ = llx0Z;
- ccxyZ = ccx0Z;
- }
- if ( llTransx0z || llTransxY0 )
- {
- llxYz = tt->getShadeBrightness( level, pX, pY + 1, pZ - 1 );
- ccxYz = tt->getLightColor( level, pX, pY + 1, pZ - 1 );
- }
- else
- {
- llxYz = llx0z;
- ccxYz = ccx0z;
- }
- if ( llTransx0Z || llTransxY0 )
- {
- llxYZ = tt->getShadeBrightness( level, pX, pY + 1, pZ + 1 );
- ccxYZ = tt->getLightColor( level, pX, pY + 1, pZ + 1 );
- }
- else
- {
- llxYZ = llx0Z;
- ccxYZ = ccx0Z;
- }
- if ( tileShapeX0 <= 0 ) pX++; // 4J - condition brought forward from 1.2.3
- if (smoothShapeLighting && g_ambientOcclusionMax)//minecraft->options->ambientOcclusion >= Options::AO_MAX)
- {
- float _ll4 = (llxy0 + llxyZ + llx00 + llx0Z) / 4.0f;
- float _ll1 = (llx00 + llx0Z + llxY0 + llxYZ) / 4.0f;
- float _ll2 = (llx0z + llx00 + llxYz + llxY0) / 4.0f;
- float _ll3 = (llxyz + llxy0 + llx0z + llx00) / 4.0f;
- ll1 = (float) (_ll1 * tileShapeY1 * tileShapeZ1 + _ll2 * tileShapeY1 * (1.0 - tileShapeZ1) + _ll3 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ1) + _ll4 * (1.0 - tileShapeY1)
- * tileShapeZ1);
- ll2 = (float) (_ll1 * tileShapeY1 * tileShapeZ0 + _ll2 * tileShapeY1 * (1.0 - tileShapeZ0) + _ll3 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ0) + _ll4 * (1.0 - tileShapeY1)
- * tileShapeZ0);
- ll3 = (float) (_ll1 * tileShapeY0 * tileShapeZ0 + _ll2 * tileShapeY0 * (1.0 - tileShapeZ0) + _ll3 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ0) + _ll4 * (1.0 - tileShapeY0)
- * tileShapeZ0);
- ll4 = (float) (_ll1 * tileShapeY0 * tileShapeZ1 + _ll2 * tileShapeY0 * (1.0 - tileShapeZ1) + _ll3 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ1) + _ll4 * (1.0 - tileShapeY0)
- * tileShapeZ1);
+ int _tc4 = blend(ccxy0, ccxyZ, ccx0Z, ccx00);
+ int _tc1 = blend(ccx0Z, ccxY0, ccxYZ, ccx00);
+ int _tc2 = blend(ccx0z, ccxYz, ccxY0, ccx00);
+ int _tc3 = blend(ccxyz, ccxy0, ccx0z, ccx00);
+ tc1 = blend(_tc1, _tc2, _tc3, _tc4, tileShapeY1 * tileShapeZ1,
+ tileShapeY1 * (1.0 - tileShapeZ1),
+ (1.0 - tileShapeY1) * (1.0 - tileShapeZ1),
+ (1.0 - tileShapeY1) * tileShapeZ1);
+ tc2 = blend(_tc1, _tc2, _tc3, _tc4, tileShapeY1 * tileShapeZ0,
+ tileShapeY1 * (1.0 - tileShapeZ0),
+ (1.0 - tileShapeY1) * (1.0 - tileShapeZ0),
+ (1.0 - tileShapeY1) * tileShapeZ0);
+ tc3 = blend(_tc1, _tc2, _tc3, _tc4, tileShapeY0 * tileShapeZ0,
+ tileShapeY0 * (1.0 - tileShapeZ0),
+ (1.0 - tileShapeY0) * (1.0 - tileShapeZ0),
+ (1.0 - tileShapeY0) * tileShapeZ0);
+ tc4 = blend(_tc1, _tc2, _tc3, _tc4, tileShapeY0 * tileShapeZ1,
+ tileShapeY0 * (1.0 - tileShapeZ1),
+ (1.0 - tileShapeY0) * (1.0 - tileShapeZ1),
+ (1.0 - tileShapeY0) * tileShapeZ1);
+ } else {
+ ll4 = (llxy0 + llxyZ + llx00 + llx0Z) / 4.0f;
+ ll1 = (llx00 + llx0Z + llxY0 + llxYZ) / 4.0f;
+ ll2 = (llx0z + llx00 + llxYz + llxY0) / 4.0f;
+ ll3 = (llxyz + llxy0 + llx0z + llx00) / 4.0f;
- int _tc4 = blend(ccxy0, ccxyZ, ccx0Z, ccx00);
- int _tc1 = blend(ccx0Z, ccxY0, ccxYZ, ccx00);
- int _tc2 = blend(ccx0z, ccxYz, ccxY0, ccx00);
- int _tc3 = blend(ccxyz, ccxy0, ccx0z, ccx00);
- tc1 = blend(_tc1, _tc2, _tc3, _tc4, tileShapeY1 * tileShapeZ1, tileShapeY1 * (1.0 - tileShapeZ1), (1.0 - tileShapeY1) * (1.0 - tileShapeZ1), (1.0 - tileShapeY1) * tileShapeZ1);
- tc2 = blend(_tc1, _tc2, _tc3, _tc4, tileShapeY1 * tileShapeZ0, tileShapeY1 * (1.0 - tileShapeZ0), (1.0 - tileShapeY1) * (1.0 - tileShapeZ0), (1.0 - tileShapeY1) * tileShapeZ0);
- tc3 = blend(_tc1, _tc2, _tc3, _tc4, tileShapeY0 * tileShapeZ0, tileShapeY0 * (1.0 - tileShapeZ0), (1.0 - tileShapeY0) * (1.0 - tileShapeZ0), (1.0 - tileShapeY0) * tileShapeZ0);
- tc4 = blend(_tc1, _tc2, _tc3, _tc4, tileShapeY0 * tileShapeZ1, tileShapeY0 * (1.0 - tileShapeZ1), (1.0 - tileShapeY0) * (1.0 - tileShapeZ1), (1.0 - tileShapeY0) * tileShapeZ1);
- }
- else
- {
- ll4 = ( llxy0 + llxyZ + llx00 + llx0Z ) / 4.0f;
- ll1 = ( llx00 + llx0Z + llxY0 + llxYZ ) / 4.0f;
- ll2 = ( llx0z + llx00 + llxYz + llxY0 ) / 4.0f;
- ll3 = ( llxyz + llxy0 + llx0z + llx00 ) / 4.0f;
+ tc4 = blend(ccxy0, ccxyZ, ccx0Z, ccx00);
+ tc1 = blend(ccx0Z, ccxY0, ccxYZ, ccx00);
+ tc2 = blend(ccx0z, ccxYz, ccxY0, ccx00);
+ tc3 = blend(ccxyz, ccxy0, ccx0z, ccx00);
+ }
+ } else {
+ ll1 = ll2 = ll3 = ll4 = llx00;
+ tc1 = tc2 = tc3 = tc4 = ccx00;
+ }
+ c1r = c2r = c3r = c4r = (tint4 ? pBaseRed : 1.0f) * 0.6f;
+ c1g = c2g = c3g = c4g = (tint4 ? pBaseGreen : 1.0f) * 0.6f;
+ c1b = c2b = c3b = c4b = (tint4 ? pBaseBlue : 1.0f) * 0.6f;
+ c1r *= ll1;
+ c1g *= ll1;
+ c1b *= ll1;
+ c2r *= ll2;
+ c2g *= ll2;
+ c2b *= ll2;
+ c3r *= ll3;
+ c3g *= ll3;
+ c3b *= ll3;
+ c4r *= ll4;
+ c4g *= ll4;
+ c4b *= ll4;
+ Icon_SPU* tex = getTexture(tt, level, pX, pY, pZ, 4);
+ renderWest(tt, (float)pX, (float)pY, (float)pZ, tex);
- tc4 = blend( ccxy0, ccxyZ, ccx0Z, ccx00 );
- tc1 = blend( ccx0Z, ccxY0, ccxYZ, ccx00 );
- tc2 = blend( ccx0z, ccxYz, ccxY0, ccx00 );
- tc3 = blend( ccxyz, ccxy0, ccx0z, ccx00 );
- }
- }
- else
- {
- ll1 = ll2 = ll3 = ll4 = llx00;
- tc1 = tc2 = tc3 = tc4 = ccx00;
- }
- c1r = c2r = c3r = c4r = ( tint4 ? pBaseRed : 1.0f ) * 0.6f;
- c1g = c2g = c3g = c4g = ( tint4 ? pBaseGreen : 1.0f ) * 0.6f;
- c1b = c2b = c3b = c4b = ( tint4 ? pBaseBlue : 1.0f ) * 0.6f;
- c1r *= ll1;
- c1g *= ll1;
- c1b *= ll1;
- c2r *= ll2;
- c2g *= ll2;
- c2b *= ll2;
- c3r *= ll3;
- c3g *= ll3;
- c3b *= ll3;
- c4r *= ll4;
- c4g *= ll4;
- c4b *= ll4;
- Icon_SPU *tex = getTexture(tt, level, pX, pY, pZ, 4);
- renderWest( tt, ( float )pX, ( float )pY, ( float )pZ, tex );
+ if (fancy &&
+ (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] &&
+ !hasFixedTexture())) {
+ c1r *= pBaseRed;
+ c2r *= pBaseRed;
+ c3r *= pBaseRed;
+ c4r *= pBaseRed;
+ c1g *= pBaseGreen;
+ c2g *= pBaseGreen;
+ c3g *= pBaseGreen;
+ c4g *= pBaseGreen;
+ c1b *= pBaseBlue;
+ c2b *= pBaseBlue;
+ c3b *= pBaseBlue;
+ c4b *= pBaseBlue;
+ bool prev = t->setMipmapEnable(
+ false); // 4J added - this is rendering the little bit of grass
+ // at the top of the side of dirt, don't mipmap it
+ renderWest(tt, (float)pX, (float)pY, (float)pZ,
+ GrassTile_SPU::getSideTextureOverlay());
+ t->setMipmapEnable(prev);
+ }
+ }
+ if (faceFlags & 0x20) {
+ if (blsmooth > 0) {
+ if (tileShapeX1 >= 1)
+ pX++; // 4J - condition brought forward from 1.2.3
+ llXy0 = tt->getShadeBrightness(level, pX, pY - 1, pZ);
+ llX0z = tt->getShadeBrightness(level, pX, pY, pZ - 1);
+ llX0Z = tt->getShadeBrightness(level, pX, pY, pZ + 1);
+ llXY0 = tt->getShadeBrightness(level, pX, pY + 1, pZ);
- if ( fancy && (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] && !hasFixedTexture() ))
- {
- c1r *= pBaseRed;
- c2r *= pBaseRed;
- c3r *= pBaseRed;
- c4r *= pBaseRed;
- c1g *= pBaseGreen;
- c2g *= pBaseGreen;
- c3g *= pBaseGreen;
- c4g *= pBaseGreen;
- c1b *= pBaseBlue;
- c2b *= pBaseBlue;
- c3b *= pBaseBlue;
- c4b *= pBaseBlue;
- bool prev = t->setMipmapEnable( false ); // 4J added - this is rendering the little bit of grass at the top of the side of dirt, don't mipmap it
- renderWest( tt, ( float )pX, ( float )pY, ( float )pZ, GrassTile_SPU::getSideTextureOverlay() );
- t->setMipmapEnable( prev );
- }
- }
- if ( faceFlags & 0x20 )
- {
- if ( blsmooth > 0 )
- {
- if ( tileShapeX1 >= 1 ) pX++; // 4J - condition brought forward from 1.2.3
- llXy0 = tt->getShadeBrightness( level, pX, pY - 1, pZ );
- llX0z = tt->getShadeBrightness( level, pX, pY, pZ - 1 );
- llX0Z = tt->getShadeBrightness( level, pX, pY, pZ + 1 );
- llXY0 = tt->getShadeBrightness( level, pX, pY + 1, pZ );
+ ccXy0 = tt->getLightColor(level, pX, pY - 1, pZ);
+ ccX0z = tt->getLightColor(level, pX, pY, pZ - 1);
+ ccX0Z = tt->getLightColor(level, pX, pY, pZ + 1);
+ ccXY0 = tt->getLightColor(level, pX, pY + 1, pZ);
- ccXy0 = tt->getLightColor( level, pX, pY - 1, pZ );
- ccX0z = tt->getLightColor( level, pX, pY, pZ - 1 );
- ccX0Z = tt->getLightColor( level, pX, pY, pZ + 1 );
- ccXY0 = tt->getLightColor( level, pX, pY + 1, pZ );
+ if (llTransXy0 || llTransX0z) {
+ llXyz = tt->getShadeBrightness(level, pX, pY - 1, pZ - 1);
+ ccXyz = tt->getLightColor(level, pX, pY - 1, pZ - 1);
+ } else {
+ llXyz = llX0z;
+ ccXyz = ccX0z;
+ }
+ if (llTransXy0 || llTransX0Z) {
+ llXyZ = tt->getShadeBrightness(level, pX, pY - 1, pZ + 1);
+ ccXyZ = tt->getLightColor(level, pX, pY - 1, pZ + 1);
+ } else {
+ llXyZ = llX0Z;
+ ccXyZ = ccX0Z;
+ }
+ if (llTransXY0 || llTransX0z) {
+ llXYz = tt->getShadeBrightness(level, pX, pY + 1, pZ - 1);
+ ccXYz = tt->getLightColor(level, pX, pY + 1, pZ - 1);
+ } else {
+ llXYz = llX0z;
+ ccXYz = ccX0z;
+ }
+ if (llTransXY0 || llTransX0Z) {
+ llXYZ = tt->getShadeBrightness(level, pX, pY + 1, pZ + 1);
+ ccXYZ = tt->getLightColor(level, pX, pY + 1, pZ + 1);
+ } else {
+ llXYZ = llX0Z;
+ ccXYZ = ccX0Z;
+ }
+ if (tileShapeX1 >= 1)
+ pX--; // 4J - condition brought forward from 1.2.3
+ if (smoothShapeLighting &&
+ g_ambientOcclusionMax) // minecraft->options->ambientOcclusion
+ // >= Options::AO_MAX)
+ {
+ float _ll1 = (llXy0 + llXyZ + llX00 + llX0Z) / 4.0f;
+ float _ll2 = (llXyz + llXy0 + llX0z + llX00) / 4.0f;
+ float _ll3 = (llX0z + llX00 + llXYz + llXY0) / 4.0f;
+ float _ll4 = (llX00 + llX0Z + llXY0 + llXYZ) / 4.0f;
+ ll1 = (float)(_ll1 * (1.0 - tileShapeY0) * tileShapeZ1 +
+ _ll2 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ1) +
+ _ll3 * tileShapeY0 * (1.0 - tileShapeZ1) +
+ _ll4 * tileShapeY0 * tileShapeZ1);
+ ll2 = (float)(_ll1 * (1.0 - tileShapeY0) * tileShapeZ0 +
+ _ll2 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ0) +
+ _ll3 * tileShapeY0 * (1.0 - tileShapeZ0) +
+ _ll4 * tileShapeY0 * tileShapeZ0);
+ ll3 = (float)(_ll1 * (1.0 - tileShapeY1) * tileShapeZ0 +
+ _ll2 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ0) +
+ _ll3 * tileShapeY1 * (1.0 - tileShapeZ0) +
+ _ll4 * tileShapeY1 * tileShapeZ0);
+ ll4 = (float)(_ll1 * (1.0 - tileShapeY1) * tileShapeZ1 +
+ _ll2 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ1) +
+ _ll3 * tileShapeY1 * (1.0 - tileShapeZ1) +
+ _ll4 * tileShapeY1 * tileShapeZ1);
- if ( llTransXy0 || llTransX0z )
- {
- llXyz = tt->getShadeBrightness( level, pX, pY - 1, pZ - 1 );
- ccXyz = tt->getLightColor( level, pX, pY - 1, pZ - 1 );
- }
- else
- {
- llXyz = llX0z;
- ccXyz = ccX0z;
- }
- if ( llTransXy0 || llTransX0Z )
- {
- llXyZ = tt->getShadeBrightness( level, pX, pY - 1, pZ + 1 );
- ccXyZ = tt->getLightColor( level, pX, pY - 1, pZ + 1 );
- }
- else
- {
- llXyZ = llX0Z;
- ccXyZ = ccX0Z;
- }
- if ( llTransXY0 || llTransX0z )
- {
- llXYz = tt->getShadeBrightness( level, pX, pY + 1, pZ - 1 );
- ccXYz = tt->getLightColor( level, pX, pY + 1, pZ - 1 );
- }
- else
- {
- llXYz = llX0z;
- ccXYz = ccX0z;
- }
- if ( llTransXY0 || llTransX0Z )
- {
- llXYZ = tt->getShadeBrightness( level, pX, pY + 1, pZ + 1 );
- ccXYZ = tt->getLightColor( level, pX, pY + 1, pZ + 1 );
- }
- else
- {
- llXYZ = llX0Z;
- ccXYZ = ccX0Z;
- }
- if ( tileShapeX1 >= 1 ) pX--; // 4J - condition brought forward from 1.2.3
- if (smoothShapeLighting && g_ambientOcclusionMax)//minecraft->options->ambientOcclusion >= Options::AO_MAX)
- {
- float _ll1 = (llXy0 + llXyZ + llX00 + llX0Z) / 4.0f;
- float _ll2 = (llXyz + llXy0 + llX0z + llX00) / 4.0f;
- float _ll3 = (llX0z + llX00 + llXYz + llXY0) / 4.0f;
- float _ll4 = (llX00 + llX0Z + llXY0 + llXYZ) / 4.0f;
- ll1 = (float) (_ll1 * (1.0 - tileShapeY0) * tileShapeZ1 + _ll2 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ1) + _ll3 * tileShapeY0 * (1.0 - tileShapeZ1) + _ll4 * tileShapeY0
- * tileShapeZ1);
- ll2 = (float) (_ll1 * (1.0 - tileShapeY0) * tileShapeZ0 + _ll2 * (1.0 - tileShapeY0) * (1.0 - tileShapeZ0) + _ll3 * tileShapeY0 * (1.0 - tileShapeZ0) + _ll4 * tileShapeY0
- * tileShapeZ0);
- ll3 = (float) (_ll1 * (1.0 - tileShapeY1) * tileShapeZ0 + _ll2 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ0) + _ll3 * tileShapeY1 * (1.0 - tileShapeZ0) + _ll4 * tileShapeY1
- * tileShapeZ0);
- ll4 = (float) (_ll1 * (1.0 - tileShapeY1) * tileShapeZ1 + _ll2 * (1.0 - tileShapeY1) * (1.0 - tileShapeZ1) + _ll3 * tileShapeY1 * (1.0 - tileShapeZ1) + _ll4 * tileShapeY1
- * tileShapeZ1);
+ int _tc1 = blend(ccXy0, ccXyZ, ccX0Z, ccX00);
+ int _tc4 = blend(ccX0Z, ccXY0, ccXYZ, ccX00);
+ int _tc3 = blend(ccX0z, ccXYz, ccXY0, ccX00);
+ int _tc2 = blend(ccXyz, ccXy0, ccX0z, ccX00);
+ tc1 = blend(_tc1, _tc2, _tc3, _tc4,
+ (1.0 - tileShapeY0) * tileShapeZ1,
+ (1.0 - tileShapeY0) * (1.0 - tileShapeZ1),
+ tileShapeY0 * (1.0 - tileShapeZ1),
+ tileShapeY0 * tileShapeZ1);
+ tc2 = blend(_tc1, _tc2, _tc3, _tc4,
+ (1.0 - tileShapeY0) * tileShapeZ0,
+ (1.0 - tileShapeY0) * (1.0 - tileShapeZ0),
+ tileShapeY0 * (1.0 - tileShapeZ0),
+ tileShapeY0 * tileShapeZ0);
+ tc3 = blend(_tc1, _tc2, _tc3, _tc4,
+ (1.0 - tileShapeY1) * tileShapeZ0,
+ (1.0 - tileShapeY1) * (1.0 - tileShapeZ0),
+ tileShapeY1 * (1.0 - tileShapeZ0),
+ tileShapeY1 * tileShapeZ0);
+ tc4 = blend(_tc1, _tc2, _tc3, _tc4,
+ (1.0 - tileShapeY1) * tileShapeZ1,
+ (1.0 - tileShapeY1) * (1.0 - tileShapeZ1),
+ tileShapeY1 * (1.0 - tileShapeZ1),
+ tileShapeY1 * tileShapeZ1);
+ } else {
+ ll1 = (llXy0 + llXyZ + llX00 + llX0Z) / 4.0f;
+ ll2 = (llXyz + llXy0 + llX0z + llX00) / 4.0f;
+ ll3 = (llX0z + llX00 + llXYz + llXY0) / 4.0f;
+ ll4 = (llX00 + llX0Z + llXY0 + llXYZ) / 4.0f;
- int _tc1 = blend(ccXy0, ccXyZ, ccX0Z, ccX00);
- int _tc4 = blend(ccX0Z, ccXY0, ccXYZ, ccX00);
- int _tc3 = blend(ccX0z, ccXYz, ccXY0, ccX00);
- int _tc2 = blend(ccXyz, ccXy0, ccX0z, ccX00);
- tc1 = blend(_tc1, _tc2, _tc3, _tc4, (1.0 - tileShapeY0) * tileShapeZ1, (1.0 - tileShapeY0) * (1.0 - tileShapeZ1), tileShapeY0 * (1.0 - tileShapeZ1), tileShapeY0 * tileShapeZ1);
- tc2 = blend(_tc1, _tc2, _tc3, _tc4, (1.0 - tileShapeY0) * tileShapeZ0, (1.0 - tileShapeY0) * (1.0 - tileShapeZ0), tileShapeY0 * (1.0 - tileShapeZ0), tileShapeY0 * tileShapeZ0);
- tc3 = blend(_tc1, _tc2, _tc3, _tc4, (1.0 - tileShapeY1) * tileShapeZ0, (1.0 - tileShapeY1) * (1.0 - tileShapeZ0), tileShapeY1 * (1.0 - tileShapeZ0), tileShapeY1 * tileShapeZ0);
- tc4 = blend(_tc1, _tc2, _tc3, _tc4, (1.0 - tileShapeY1) * tileShapeZ1, (1.0 - tileShapeY1) * (1.0 - tileShapeZ1), tileShapeY1 * (1.0 - tileShapeZ1), tileShapeY1 * tileShapeZ1);
- }
- else
- {
- ll1 = (llXy0 + llXyZ + llX00 + llX0Z) / 4.0f;
- ll2 = (llXyz + llXy0 + llX0z + llX00) / 4.0f;
- ll3 = (llX0z + llX00 + llXYz + llXY0) / 4.0f;
- ll4 = (llX00 + llX0Z + llXY0 + llXYZ) / 4.0f;
+ tc1 = blend(ccXy0, ccXyZ, ccX0Z, ccX00);
+ tc4 = blend(ccX0Z, ccXY0, ccXYZ, ccX00);
+ tc3 = blend(ccX0z, ccXYz, ccXY0, ccX00);
+ tc2 = blend(ccXyz, ccXy0, ccX0z, ccX00);
+ }
+ } else {
+ ll1 = ll2 = ll3 = ll4 = llX00;
+ tc1 = tc2 = tc3 = tc4 = ccX00;
+ }
+ c1r = c2r = c3r = c4r = (tint5 ? pBaseRed : 1.0f) * 0.6f;
+ c1g = c2g = c3g = c4g = (tint5 ? pBaseGreen : 1.0f) * 0.6f;
+ c1b = c2b = c3b = c4b = (tint5 ? pBaseBlue : 1.0f) * 0.6f;
+ c1r *= ll1;
+ c1g *= ll1;
+ c1b *= ll1;
+ c2r *= ll2;
+ c2g *= ll2;
+ c2b *= ll2;
+ c3r *= ll3;
+ c3g *= ll3;
+ c3b *= ll3;
+ c4r *= ll4;
+ c4g *= ll4;
+ c4b *= ll4;
- tc1 = blend(ccXy0, ccXyZ, ccX0Z, ccX00);
- tc4 = blend(ccX0Z, ccXY0, ccXYZ, ccX00);
- tc3 = blend(ccX0z, ccXYz, ccXY0, ccX00);
- tc2 = blend(ccXyz, ccXy0, ccX0z, ccX00);
- }
- }
- else
- {
- ll1 = ll2 = ll3 = ll4 = llX00;
- tc1 = tc2 = tc3 = tc4 = ccX00;
- }
- c1r = c2r = c3r = c4r = ( tint5 ? pBaseRed : 1.0f ) * 0.6f;
- c1g = c2g = c3g = c4g = ( tint5 ? pBaseGreen : 1.0f ) * 0.6f;
- c1b = c2b = c3b = c4b = ( tint5 ? pBaseBlue : 1.0f ) * 0.6f;
- c1r *= ll1;
- c1g *= ll1;
- c1b *= ll1;
- c2r *= ll2;
- c2g *= ll2;
- c2b *= ll2;
- c3r *= ll3;
- c3g *= ll3;
- c3b *= ll3;
- c4r *= ll4;
- c4g *= ll4;
- c4b *= ll4;
+ Icon_SPU* tex = getTexture(tt, level, pX, pY, pZ, 5);
+ renderEast(tt, (float)pX, (float)pY, (float)pZ, tex);
+ if (fancy &&
+ (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] &&
+ !hasFixedTexture())) {
+ c1r *= pBaseRed;
+ c2r *= pBaseRed;
+ c3r *= pBaseRed;
+ c4r *= pBaseRed;
+ c1g *= pBaseGreen;
+ c2g *= pBaseGreen;
+ c3g *= pBaseGreen;
+ c4g *= pBaseGreen;
+ c1b *= pBaseBlue;
+ c2b *= pBaseBlue;
+ c3b *= pBaseBlue;
+ c4b *= pBaseBlue;
- Icon_SPU *tex = getTexture(tt, level, pX, pY, pZ, 5);
- renderEast( tt, ( float )pX, ( float )pY, ( float )pZ, tex );
- if ( fancy && (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] && !hasFixedTexture() ))
- {
- c1r *= pBaseRed;
- c2r *= pBaseRed;
- c3r *= pBaseRed;
- c4r *= pBaseRed;
- c1g *= pBaseGreen;
- c2g *= pBaseGreen;
- c3g *= pBaseGreen;
- c4g *= pBaseGreen;
- c1b *= pBaseBlue;
- c2b *= pBaseBlue;
- c3b *= pBaseBlue;
- c4b *= pBaseBlue;
-
- bool prev = t->setMipmapEnable( false ); // 4J added - this is rendering the little bit of grass at the top of the side of dirt, don't mipmap it
- renderEast( tt, ( float )pX, ( float )pY, ( float )pZ, GrassTile_SPU::getSideTextureOverlay() );
- t->setMipmapEnable( prev );
- }
- }
- applyAmbienceOcclusion = false;
-
- return true;
+ bool prev = t->setMipmapEnable(
+ false); // 4J added - this is rendering the little bit of grass
+ // at the top of the side of dirt, don't mipmap it
+ renderEast(tt, (float)pX, (float)pY, (float)pZ,
+ GrassTile_SPU::getSideTextureOverlay());
+ t->setMipmapEnable(prev);
+ }
+ }
+ applyAmbienceOcclusion = false;
+ return true;
}
-bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionOldLighting( Tile_SPU* tt, int pX, int pY, int pZ,
- float pBaseRed, float pBaseGreen,
- float pBaseBlue )
-{
-//
-// // 4J - added these faceFlags so we can detect whether this block is going to have no visible faces and early out
-// // the original code checked noCulling and shouldRenderFace directly where faceFlags is used now
-// int faceFlags = 0;
-// if ( noCulling )
-// {
-// faceFlags = 0x3f;
-// }
-// else
-// {
-// faceFlags |= tt->shouldRenderFace( level, pX, pY - 1, pZ, 0 ) ? 0x01 : 0;
-// faceFlags |= tt->shouldRenderFace( level, pX, pY + 1, pZ, 1 ) ? 0x02 : 0;
-// faceFlags |= tt->shouldRenderFace( level, pX, pY, pZ - 1, 2 ) ? 0x04 : 0;
-// faceFlags |= tt->shouldRenderFace( level, pX, pY, pZ + 1, 3 ) ? 0x08 : 0;
-// faceFlags |= tt->shouldRenderFace( level, pX - 1, pY, pZ, 4 ) ? 0x10 : 0;
-// faceFlags |= tt->shouldRenderFace( level, pX + 1, pY, pZ, 5 ) ? 0x20 : 0;
-// }
-// if ( faceFlags == 0 )
-// {
-// return false;
-// }
-//
-// applyAmbienceOcclusion = true;
-// float ll1 = ll000;
-// float ll2 = ll000;
-// float ll3 = ll000;
-// float ll4 = ll000;
-// bool tint0 = true;
-// bool tint1 = true;
-// bool tint2 = true;
-// bool tint3 = true;
-// bool tint4 = true;
-// bool tint5 = true;
-//
-//
-// ll000 = tt->getBrightness( level, pX, pY, pZ );
-// llx00 = tt->getBrightness( level, pX - 1, pY, pZ );
-// ll0y0 = tt->getBrightness( level, pX, pY - 1, pZ );
-// ll00z = tt->getBrightness( level, pX, pY, pZ - 1 );
-// llX00 = tt->getBrightness( level, pX + 1, pY, pZ );
-// ll0Y0 = tt->getBrightness( level, pX, pY + 1, pZ );
-// ll00Z = tt->getBrightness( level, pX, pY, pZ + 1 );
-//
-// llTransXY0 = level->m_tileData.transculent[level->getTile( pX + 1, pY + 1, pZ )];
-// llTransXy0 = level->m_tileData.transculent[level->getTile( pX + 1, pY - 1, pZ )];
-// llTransX0Z = level->m_tileData.transculent[level->getTile( pX + 1, pY, pZ + 1 )];
-// llTransX0z = level->m_tileData.transculent[level->getTile( pX + 1, pY, pZ - 1 )];
-// llTransxY0 = level->m_tileData.transculent[level->getTile( pX - 1, pY + 1, pZ )];
-// llTransxy0 = level->m_tileData.transculent[level->getTile( pX - 1, pY - 1, pZ )];
-// llTransx0z = level->m_tileData.transculent[level->getTile( pX - 1, pY, pZ - 1 )];
-// llTransx0Z = level->m_tileData.transculent[level->getTile( pX - 1, pY, pZ + 1 )];
-// llTrans0YZ = level->m_tileData.transculent[level->getTile( pX, pY + 1, pZ + 1 )];
-// llTrans0Yz = level->m_tileData.transculent[level->getTile( pX, pY + 1, pZ - 1 )];
-// llTrans0yZ = level->m_tileData.transculent[level->getTile( pX, pY - 1, pZ + 1 )];
-// llTrans0yz = level->m_tileData.transculent[level->getTile( pX, pY - 1, pZ - 1 )];
-//
-// spu_print("Have to add texture name check here\n");
-// if ( getTexture(tt)->getName().compare(L"grass_top") == 0 ) tint0 = tint2 = tint3 = tint4 = tint5 = false;
-// if ( hasFixedTexture() ) tint0 = tint2 = tint3 = tint4 = tint5 = false;
-//
-// if ( faceFlags & 0x01 )
-// {
-// if ( blsmooth > 0 )
-// {
-// pY--;
-//
-// llxy0 = tt->getBrightness( level, pX - 1, pY, pZ );
-// ll0yz = tt->getBrightness( level, pX, pY, pZ - 1 );
-// ll0yZ = tt->getBrightness( level, pX, pY, pZ + 1 );
-// llXy0 = tt->getBrightness( level, pX + 1, pY, pZ );
-//
-// if ( llTrans0yz || llTransxy0 )
-// {
-// llxyz = tt->getBrightness( level, pX - 1, pY, pZ - 1 );
-// }
-// else
-// {
-// llxyz = llxy0;
-// }
-// if ( llTrans0yZ || llTransxy0 )
-// {
-// llxyZ = tt->getBrightness( level, pX - 1, pY, pZ + 1 );
-// }
-// else
-// {
-// llxyZ = llxy0;
-// }
-// if ( llTrans0yz || llTransXy0 )
-// {
-// llXyz = tt->getBrightness( level, pX + 1, pY, pZ - 1 );
-// }
-// else
-// {
-// llXyz = llXy0;
-// }
-// if ( llTrans0yZ || llTransXy0 )
-// {
-// llXyZ = tt->getBrightness( level, pX + 1, pY, pZ + 1 );
-// }
-// else
-// {
-// llXyZ = llXy0;
-// }
-//
-// pY++;
-// ll1 = ( llxyZ + llxy0 + ll0yZ + ll0y0 ) / 4.0f;
-// ll4 = ( ll0yZ + ll0y0 + llXyZ + llXy0 ) / 4.0f;
-// ll3 = ( ll0y0 + ll0yz + llXy0 + llXyz ) / 4.0f;
-// ll2 = ( llxy0 + llxyz + ll0y0 + ll0yz ) / 4.0f;
-// }
-// else
-// {
-// ll1 = ll2 = ll3 = ll4 = ll0y0;
-// }
-// c1r = c2r = c3r = c4r = ( tint0 ? pBaseRed : 1.0f ) * 0.5f;
-// c1g = c2g = c3g = c4g = ( tint0 ? pBaseGreen : 1.0f ) * 0.5f;
-// c1b = c2b = c3b = c4b = ( tint0 ? pBaseBlue : 1.0f ) * 0.5f;
-// c1r *= ll1;
-// c1g *= ll1;
-// c1b *= ll1;
-// c2r *= ll2;
-// c2g *= ll2;
-// c2b *= ll2;
-// c3r *= ll3;
-// c3g *= ll3;
-// c3b *= ll3;
-// c4r *= ll4;
-// c4g *= ll4;
-// c4b *= ll4;
-//
-// renderFaceDown( tt, ( float )pX, ( float )pY, ( float )pZ, getTexture( tt, level, pX, pY, pZ, 0 ) );
-// }
-// if ( faceFlags & 0x02 )
-// {
-// if ( blsmooth > 0 )
-// {
-// pY++;
-//
-// llxY0 = tt->getBrightness( level, pX - 1, pY, pZ );
-// llXY0 = tt->getBrightness( level, pX + 1, pY, pZ );
-// ll0Yz = tt->getBrightness( level, pX, pY, pZ - 1 );
-// ll0YZ = tt->getBrightness( level, pX, pY, pZ + 1 );
-//
-// if ( llTrans0Yz || llTransxY0 )
-// {
-// llxYz = tt->getBrightness( level, pX - 1, pY, pZ - 1 );
-// }
-// else
-// {
-// llxYz = llxY0;
-// }
-// if ( llTrans0Yz || llTransXY0 )
-// {
-// llXYz = tt->getBrightness( level, pX + 1, pY, pZ - 1 );
-// }
-// else
-// {
-// llXYz = llXY0;
-// }
-// if ( llTrans0YZ || llTransxY0 )
-// {
-// llxYZ = tt->getBrightness( level, pX - 1, pY, pZ + 1 );
-// }
-// else
-// {
-// llxYZ = llxY0;
-// }
-// if ( llTrans0YZ || llTransXY0 )
-// {
-// llXYZ = tt->getBrightness( level, pX + 1, pY, pZ + 1 );
-// }
-// else
-// {
-// llXYZ = llXY0;
-// }
-// pY--;
-//
-// ll4 = ( llxYZ + llxY0 + ll0YZ + ll0Y0 ) / 4.0f;
-// ll1 = ( ll0YZ + ll0Y0 + llXYZ + llXY0 ) / 4.0f;
-// ll2 = ( ll0Y0 + ll0Yz + llXY0 + llXYz ) / 4.0f;
-// ll3 = ( llxY0 + llxYz + ll0Y0 + ll0Yz ) / 4.0f;
-// }
-// else
-// {
-// ll1 = ll2 = ll3 = ll4 = ll0Y0;
-// }
-// c1r = c2r = c3r = c4r = ( tint1 ? pBaseRed : 1.0f );
-// c1g = c2g = c3g = c4g = ( tint1 ? pBaseGreen : 1.0f );
-// c1b = c2b = c3b = c4b = ( tint1 ? pBaseBlue : 1.0f );
-// c1r *= ll1;
-// c1g *= ll1;
-// c1b *= ll1;
-// c2r *= ll2;
-// c2g *= ll2;
-// c2b *= ll2;
-// c3r *= ll3;
-// c3g *= ll3;
-// c3b *= ll3;
-// c4r *= ll4;
-// c4g *= ll4;
-// c4b *= ll4;
-// renderFaceUp( tt, ( float )pX, ( float )pY, ( float )pZ, getTexture( tt, level, pX, pY, pZ, 1 ) );
-// }
-// if ( faceFlags & 0x04 )
-// {
-// if ( blsmooth > 0 )
-// {
-// pZ--;
-// llx0z = tt->getBrightness( level, pX - 1, pY, pZ );
-// ll0yz = tt->getBrightness( level, pX, pY - 1, pZ );
-// ll0Yz = tt->getBrightness( level, pX, pY + 1, pZ );
-// llX0z = tt->getBrightness( level, pX + 1, pY, pZ );
-//
-// if ( llTransx0z || llTrans0yz )
-// {
-// llxyz = tt->getBrightness( level, pX - 1, pY - 1, pZ );
-// }
-// else
-// {
-// llxyz = llx0z;
-// }
-// if ( llTransx0z || llTrans0Yz )
-// {
-// llxYz = tt->getBrightness( level, pX - 1, pY + 1, pZ );
-// }
-// else
-// {
-// llxYz = llx0z;
-// }
-// if ( llTransX0z || llTrans0yz )
-// {
-// llXyz = tt->getBrightness( level, pX + 1, pY - 1, pZ );
-// }
-// else
-// {
-// llXyz = llX0z;
-// }
-// if ( llTransX0z || llTrans0Yz )
-// {
-// llXYz = tt->getBrightness( level, pX + 1, pY + 1, pZ );
-// }
-// else
-// {
-// llXYz = llX0z;
-// }
-// pZ++;
-// ll1 = ( llx0z + llxYz + ll00z + ll0Yz ) / 4.0f;
-// ll2 = ( ll00z + ll0Yz + llX0z + llXYz ) / 4.0f;
-// ll3 = ( ll0yz + ll00z + llXyz + llX0z ) / 4.0f;
-// ll4 = ( llxyz + llx0z + ll0yz + ll00z ) / 4.0f;
-// }
-// else
-// {
-// ll1 = ll2 = ll3 = ll4 = ll00z;
-// }
-// c1r = c2r = c3r = c4r = ( tint2 ? pBaseRed : 1.0f ) * 0.8f;
-// c1g = c2g = c3g = c4g = ( tint2 ? pBaseGreen : 1.0f ) * 0.8f;
-// c1b = c2b = c3b = c4b = ( tint2 ? pBaseBlue : 1.0f ) * 0.8f;
-// c1r *= ll1;
-// c1g *= ll1;
-// c1b *= ll1;
-// c2r *= ll2;
-// c2g *= ll2;
-// c2b *= ll2;
-// c3r *= ll3;
-// c3g *= ll3;
-// c3b *= ll3;
-// c4r *= ll4;
-// c4g *= ll4;
-// c4b *= ll4;
-//
-// Icon_SPU *tex = getTexture(tt, level, pX, pY, pZ, 2);
-// renderNorth( tt, ( float )pX, ( float )pY, ( float )pZ, tex );
-//
-// if ( fancy && (tex->getName().compare(L"grass_side") == 0) && !hasFixedTexture())
-// {
-// c1r *= pBaseRed;
-// c2r *= pBaseRed;
-// c3r *= pBaseRed;
-// c4r *= pBaseRed;
-// c1g *= pBaseGreen;
-// c2g *= pBaseGreen;
-// c3g *= pBaseGreen;
-// c4g *= pBaseGreen;
-// c1b *= pBaseBlue;
-// c2b *= pBaseBlue;
-// c3b *= pBaseBlue;
-// c4b *= pBaseBlue;
-// renderNorth( tt, ( float )pX, ( float )pY, ( float )pZ, getGrassSideTextureOverlay() );
-// }
-// }
-// if ( faceFlags & 0x08 )
-// {
-// if ( blsmooth > 0 )
-// {
-// pZ++;
-//
-// llx0Z = tt->getBrightness( level, pX - 1, pY, pZ );
-// llX0Z = tt->getBrightness( level, pX + 1, pY, pZ );
-// ll0yZ = tt->getBrightness( level, pX, pY - 1, pZ );
-// ll0YZ = tt->getBrightness( level, pX, pY + 1, pZ );
-//
-// if ( llTransx0Z || llTrans0yZ )
-// {
-// llxyZ = tt->getBrightness( level, pX - 1, pY - 1, pZ );
-// }
-// else
-// {
-// llxyZ = llx0Z;
-// }
-// if ( llTransx0Z || llTrans0YZ )
-// {
-// llxYZ = tt->getBrightness( level, pX - 1, pY + 1, pZ );
-// }
-// else
-// {
-// llxYZ = llx0Z;
-// }
-// if ( llTransX0Z || llTrans0yZ )
-// {
-// llXyZ = tt->getBrightness( level, pX + 1, pY - 1, pZ );
-// }
-// else
-// {
-// llXyZ = llX0Z;
-// }
-// if ( llTransX0Z || llTrans0YZ )
-// {
-// llXYZ = tt->getBrightness( level, pX + 1, pY + 1, pZ );
-// }
-// else
-// {
-// llXYZ = llX0Z;
-// }
-// pZ--;
-// ll1 = ( llx0Z + llxYZ + ll00Z + ll0YZ ) / 4.0f;
-// ll4 = ( ll00Z + ll0YZ + llX0Z + llXYZ ) / 4.0f;
-// ll3 = ( ll0yZ + ll00Z + llXyZ + llX0Z ) / 4.0f;
-// ll2 = ( llxyZ + llx0Z + ll0yZ + ll00Z ) / 4.0f;
-// }
-// else
-// {
-// ll1 = ll2 = ll3 = ll4 = ll00Z;
-// }
-// c1r = c2r = c3r = c4r = ( tint3 ? pBaseRed : 1.0f ) * 0.8f;
-// c1g = c2g = c3g = c4g = ( tint3 ? pBaseGreen : 1.0f ) * 0.8f;
-// c1b = c2b = c3b = c4b = ( tint3 ? pBaseBlue : 1.0f ) * 0.8f;
-// c1r *= ll1;
-// c1g *= ll1;
-// c1b *= ll1;
-// c2r *= ll2;
-// c2g *= ll2;
-// c2b *= ll2;
-// c3r *= ll3;
-// c3g *= ll3;
-// c3b *= ll3;
-// c4r *= ll4;
-// c4g *= ll4;
-// c4b *= ll4;
-// Icon_SPU *tex = getTexture(tt, level, pX, pY, pZ, 3);
-// renderSouth( tt, ( float )pX, ( float )pY, ( float )pZ, getTexture(tt, level, pX, pY, pZ, 3 ) );
-// if ( fancy && (tex->getName().compare(L"grass_side") == 0) && !hasFixedTexture() )
-// {
-// c1r *= pBaseRed;
-// c2r *= pBaseRed;
-// c3r *= pBaseRed;
-// c4r *= pBaseRed;
-// c1g *= pBaseGreen;
-// c2g *= pBaseGreen;
-// c3g *= pBaseGreen;
-// c4g *= pBaseGreen;
-// c1b *= pBaseBlue;
-// c2b *= pBaseBlue;
-// c3b *= pBaseBlue;
-// c4b *= pBaseBlue;
-// renderSouth( tt, ( float )pX, ( float )pY, ( float )pZ, getGrassSideTextureOverlay() );
-// }
-// }
-// if ( faceFlags & 0x10 )
-// {
-// if ( blsmooth > 0 )
-// {
-// pX--;
-// llxy0 = tt->getBrightness( level, pX, pY - 1, pZ );
-// llx0z = tt->getBrightness( level, pX, pY, pZ - 1 );
-// llx0Z = tt->getBrightness( level, pX, pY, pZ + 1 );
-// llxY0 = tt->getBrightness( level, pX, pY + 1, pZ );
-//
-// if ( llTransx0z || llTransxy0 )
-// {
-// llxyz = tt->getBrightness( level, pX, pY - 1, pZ - 1 );
-// }
-// else
-// {
-// llxyz = llx0z;
-// }
-// if ( llTransx0Z || llTransxy0 )
-// {
-// llxyZ = tt->getBrightness( level, pX, pY - 1, pZ + 1 );
-// }
-// else
-// {
-// llxyZ = llx0Z;
-// }
-// if ( llTransx0z || llTransxY0 )
-// {
-// llxYz = tt->getBrightness( level, pX, pY + 1, pZ - 1 );
-// }
-// else
-// {
-// llxYz = llx0z;
-// }
-// if ( llTransx0Z || llTransxY0 )
-// {
-// llxYZ = tt->getBrightness( level, pX, pY + 1, pZ + 1 );
-// }
-// else
-// {
-// llxYZ = llx0Z;
-// }
-// pX++;
-// ll4 = ( llxy0 + llxyZ + llx00 + llx0Z ) / 4.0f;
-// ll1 = ( llx00 + llx0Z + llxY0 + llxYZ ) / 4.0f;
-// ll2 = ( llx0z + llx00 + llxYz + llxY0 ) / 4.0f;
-// ll3 = ( llxyz + llxy0 + llx0z + llx00 ) / 4.0f;
-// }
-// else
-// {
-// ll1 = ll2 = ll3 = ll4 = llx00;
-// }
-// c1r = c2r = c3r = c4r = ( tint4 ? pBaseRed : 1.0f ) * 0.6f;
-// c1g = c2g = c3g = c4g = ( tint4 ? pBaseGreen : 1.0f ) * 0.6f;
-// c1b = c2b = c3b = c4b = ( tint4 ? pBaseBlue : 1.0f ) * 0.6f;
-// c1r *= ll1;
-// c1g *= ll1;
-// c1b *= ll1;
-// c2r *= ll2;
-// c2g *= ll2;
-// c2b *= ll2;
-// c3r *= ll3;
-// c3g *= ll3;
-// c3b *= ll3;
-// c4r *= ll4;
-// c4g *= ll4;
-// c4b *= ll4;
-// Icon_SPU *tex = getTexture(tt, level, pX, pY, pZ, 4);
-// renderWest( tt, ( float )pX, ( float )pY, ( float )pZ, tex );
-// if ( fancy &&(tex->getName().compare(L"grass_side") == 0) && !hasFixedTexture() )
-// {
-// c1r *= pBaseRed;
-// c2r *= pBaseRed;
-// c3r *= pBaseRed;
-// c4r *= pBaseRed;
-// c1g *= pBaseGreen;
-// c2g *= pBaseGreen;
-// c3g *= pBaseGreen;
-// c4g *= pBaseGreen;
-// c1b *= pBaseBlue;
-// c2b *= pBaseBlue;
-// c3b *= pBaseBlue;
-// c4b *= pBaseBlue;
-// renderWest( tt, ( float )pX, ( float )pY, ( float )pZ, getGrassSideTextureOverlay() );
-// }
-// }
-// if ( faceFlags & 0x20 )
-// {
-// if ( blsmooth > 0 )
-// {
-// pX++;
-// llXy0 = tt->getBrightness( level, pX, pY - 1, pZ );
-// llX0z = tt->getBrightness( level, pX, pY, pZ - 1 );
-// llX0Z = tt->getBrightness( level, pX, pY, pZ + 1 );
-// llXY0 = tt->getBrightness( level, pX, pY + 1, pZ );
-//
-// if ( llTransXy0 || llTransX0z )
-// {
-// llXyz = tt->getBrightness( level, pX, pY - 1, pZ - 1 );
-// }
-// else
-// {
-// llXyz = llX0z;
-// }
-// if ( llTransXy0 || llTransX0Z )
-// {
-// llXyZ = tt->getBrightness( level, pX, pY - 1, pZ + 1 );
-// }
-// else
-// {
-// llXyZ = llX0Z;
-// }
-// if ( llTransXY0 || llTransX0z )
-// {
-// llXYz = tt->getBrightness( level, pX, pY + 1, pZ - 1 );
-// }
-// else
-// {
-// llXYz = llX0z;
-// }
-// if ( llTransXY0 || llTransX0Z )
-// {
-// llXYZ = tt->getBrightness( level, pX, pY + 1, pZ + 1 );
-// }
-// else
-// {
-// llXYZ = llX0Z;
-// }
-// pX--;
-// ll1 = ( llXy0 + llXyZ + llX00 + llX0Z ) / 4.0f;
-// ll4 = ( llX00 + llX0Z + llXY0 + llXYZ ) / 4.0f;
-// ll3 = ( llX0z + llX00 + llXYz + llXY0 ) / 4.0f;
-// ll2 = ( llXyz + llXy0 + llX0z + llX00 ) / 4.0f;
-// }
-// else
-// {
-// ll1 = ll2 = ll3 = ll4 = llX00;
-// }
-// c1r = c2r = c3r = c4r = ( tint5 ? pBaseRed : 1.0f ) * 0.6f;
-// c1g = c2g = c3g = c4g = ( tint5 ? pBaseGreen : 1.0f ) * 0.6f;
-// c1b = c2b = c3b = c4b = ( tint5 ? pBaseBlue : 1.0f ) * 0.6f;
-// c1r *= ll1;
-// c1g *= ll1;
-// c1b *= ll1;
-// c2r *= ll2;
-// c2g *= ll2;
-// c2b *= ll2;
-// c3r *= ll3;
-// c3g *= ll3;
-// c3b *= ll3;
-// c4r *= ll4;
-// c4g *= ll4;
-// c4b *= ll4;
-//
-// Icon_SPU *tex = getTexture(tt, level, pX, pY, pZ, 5);
-// renderEast( tt, ( float )pX, ( float )pY, ( float )pZ, tex );
-// if ( fancy && (tex->getName().compare(L"grass_side") == 0) && !hasFixedTexture() )
-// {
-// c1r *= pBaseRed;
-// c2r *= pBaseRed;
-// c3r *= pBaseRed;
-// c4r *= pBaseRed;
-// c1g *= pBaseGreen;
-// c2g *= pBaseGreen;
-// c3g *= pBaseGreen;
-// c4g *= pBaseGreen;
-// c1b *= pBaseBlue;
-// c2b *= pBaseBlue;
-// c3b *= pBaseBlue;
-// c4b *= pBaseBlue;
-// renderEast( tt, ( float )pX, ( float )pY, ( float )pZ, getGrassSideTextureOverlay() );
-// }
-// }
-// applyAmbienceOcclusion = false;
-//
- return true;
-
+bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionOldLighting(
+ Tile_SPU* tt, int pX, int pY, int pZ, float pBaseRed, float pBaseGreen,
+ float pBaseBlue) {
+ //
+ // // 4J - added these faceFlags so we can detect whether this block is
+ // going to have no visible faces and early out
+ // // the original code checked noCulling and shouldRenderFace directly
+ // where faceFlags is used now int faceFlags = 0; if (
+ // noCulling )
+ // {
+ // faceFlags = 0x3f;
+ // }
+ // else
+ // {
+ // faceFlags |= tt->shouldRenderFace( level, pX, pY - 1, pZ, 0 ) ?
+ // 0x01 : 0; faceFlags |= tt->shouldRenderFace( level, pX, pY
+ // + 1, pZ, 1 ) ? 0x02 : 0; faceFlags |=
+ // tt->shouldRenderFace( level, pX, pY, pZ - 1, 2 ) ? 0x04 : 0;
+ // faceFlags |= tt->shouldRenderFace( level, pX, pY, pZ + 1, 3 ) ? 0x08 : 0;
+ // faceFlags |= tt->shouldRenderFace( level, pX - 1, pY, pZ, 4 ) ? 0x10 : 0;
+ // faceFlags |= tt->shouldRenderFace( level, pX + 1, pY, pZ, 5 ) ? 0x20 : 0;
+ // }
+ // if ( faceFlags == 0 )
+ // {
+ // return false;
+ // }
+ //
+ // applyAmbienceOcclusion = true;
+ // float ll1 = ll000;
+ // float ll2 = ll000;
+ // float ll3 = ll000;
+ // float ll4 = ll000;
+ // bool tint0 = true;
+ // bool tint1 = true;
+ // bool tint2 = true;
+ // bool tint3 = true;
+ // bool tint4 = true;
+ // bool tint5 = true;
+ //
+ //
+ // ll000 = tt->getBrightness( level, pX, pY, pZ );
+ // llx00 = tt->getBrightness( level, pX - 1, pY, pZ );
+ // ll0y0 = tt->getBrightness( level, pX, pY - 1, pZ );
+ // ll00z = tt->getBrightness( level, pX, pY, pZ - 1 );
+ // llX00 = tt->getBrightness( level, pX + 1, pY, pZ );
+ // ll0Y0 = tt->getBrightness( level, pX, pY + 1, pZ );
+ // ll00Z = tt->getBrightness( level, pX, pY, pZ + 1 );
+ //
+ // llTransXY0 = level->m_tileData.transculent[level->getTile( pX + 1, pY +
+ // 1, pZ )]; llTransXy0 =
+ // level->m_tileData.transculent[level->getTile( pX + 1, pY - 1, pZ )];
+ // llTransX0Z = level->m_tileData.transculent[level->getTile( pX + 1, pY, pZ
+ // + 1 )]; llTransX0z = level->m_tileData.transculent[level->getTile( pX +
+ // 1, pY, pZ - 1 )]; llTransxY0 =
+ // level->m_tileData.transculent[level->getTile( pX
+ // - 1, pY + 1, pZ )]; llTransxy0 =
+ // level->m_tileData.transculent[level->getTile( pX - 1, pY - 1, pZ )];
+ // llTransx0z = level->m_tileData.transculent[level->getTile( pX - 1, pY,
+ // pZ - 1 )]; llTransx0Z =
+ // level->m_tileData.transculent[level->getTile( pX
+ // - 1, pY, pZ + 1 )]; llTrans0YZ =
+ // level->m_tileData.transculent[level->getTile( pX, pY + 1, pZ + 1 )];
+ // llTrans0Yz = level->m_tileData.transculent[level->getTile( pX, pY + 1,
+ // pZ - 1 )]; llTrans0yZ =
+ // level->m_tileData.transculent[level->getTile( pX, pY - 1, pZ + 1 )];
+ // llTrans0yz = level->m_tileData.transculent[level->getTile( pX, pY - 1, pZ
+ // - 1 )];
+ //
+ // spu_print("Have to add texture name check here\n");
+ // if ( getTexture(tt)->getName().compare(L"grass_top") == 0 ) tint0 =
+ // tint2 = tint3 = tint4 = tint5 = false; if ( hasFixedTexture() ) tint0 =
+ // tint2 = tint3 = tint4 = tint5 = false;
+ //
+ // if ( faceFlags & 0x01 )
+ // {
+ // if ( blsmooth > 0 )
+ // {
+ // pY--;
+ //
+ // llxy0 = tt->getBrightness( level, pX - 1, pY, pZ );
+ // ll0yz = tt->getBrightness( level, pX, pY, pZ - 1 );
+ // ll0yZ = tt->getBrightness( level, pX, pY, pZ + 1 );
+ // llXy0 = tt->getBrightness( level, pX + 1, pY, pZ );
+ //
+ // if ( llTrans0yz || llTransxy0 )
+ // {
+ // llxyz = tt->getBrightness( level, pX - 1, pY, pZ
+ // - 1 );
+ // }
+ // else
+ // {
+ // llxyz = llxy0;
+ // }
+ // if ( llTrans0yZ || llTransxy0 )
+ // {
+ // llxyZ = tt->getBrightness( level, pX - 1, pY, pZ
+ // + 1 );
+ // }
+ // else
+ // {
+ // llxyZ = llxy0;
+ // }
+ // if ( llTrans0yz || llTransXy0 )
+ // {
+ // llXyz = tt->getBrightness( level, pX + 1, pY, pZ
+ // - 1 );
+ // }
+ // else
+ // {
+ // llXyz = llXy0;
+ // }
+ // if ( llTrans0yZ || llTransXy0 )
+ // {
+ // llXyZ = tt->getBrightness( level, pX + 1, pY, pZ
+ // + 1 );
+ // }
+ // else
+ // {
+ // llXyZ = llXy0;
+ // }
+ //
+ // pY++;
+ // ll1 = ( llxyZ + llxy0 + ll0yZ + ll0y0 ) / 4.0f;
+ // ll4 = ( ll0yZ + ll0y0 + llXyZ + llXy0 ) / 4.0f;
+ // ll3 = ( ll0y0 + ll0yz + llXy0 + llXyz ) / 4.0f;
+ // ll2 = ( llxy0 + llxyz + ll0y0 + ll0yz ) / 4.0f;
+ // }
+ // else
+ // {
+ // ll1 = ll2 = ll3 = ll4 = ll0y0;
+ // }
+ // c1r = c2r = c3r = c4r = ( tint0 ? pBaseRed : 1.0f ) * 0.5f;
+ // c1g = c2g = c3g = c4g = ( tint0 ? pBaseGreen : 1.0f ) * 0.5f;
+ // c1b = c2b = c3b = c4b = ( tint0 ? pBaseBlue : 1.0f ) * 0.5f;
+ // c1r *= ll1;
+ // c1g *= ll1;
+ // c1b *= ll1;
+ // c2r *= ll2;
+ // c2g *= ll2;
+ // c2b *= ll2;
+ // c3r *= ll3;
+ // c3g *= ll3;
+ // c3b *= ll3;
+ // c4r *= ll4;
+ // c4g *= ll4;
+ // c4b *= ll4;
+ //
+ // renderFaceDown( tt, ( float )pX, ( float )pY, ( float )pZ,
+ // getTexture( tt, level, pX, pY, pZ, 0 ) );
+ // }
+ // if ( faceFlags & 0x02 )
+ // {
+ // if ( blsmooth > 0 )
+ // {
+ // pY++;
+ //
+ // llxY0 = tt->getBrightness( level, pX - 1, pY, pZ );
+ // llXY0 = tt->getBrightness( level, pX + 1, pY, pZ );
+ // ll0Yz = tt->getBrightness( level, pX, pY, pZ - 1 );
+ // ll0YZ = tt->getBrightness( level, pX, pY, pZ + 1 );
+ //
+ // if ( llTrans0Yz || llTransxY0 )
+ // {
+ // llxYz = tt->getBrightness( level, pX - 1, pY, pZ
+ // - 1 );
+ // }
+ // else
+ // {
+ // llxYz = llxY0;
+ // }
+ // if ( llTrans0Yz || llTransXY0 )
+ // {
+ // llXYz = tt->getBrightness( level, pX + 1, pY, pZ
+ // - 1 );
+ // }
+ // else
+ // {
+ // llXYz = llXY0;
+ // }
+ // if ( llTrans0YZ || llTransxY0 )
+ // {
+ // llxYZ = tt->getBrightness( level, pX - 1, pY, pZ
+ // + 1 );
+ // }
+ // else
+ // {
+ // llxYZ = llxY0;
+ // }
+ // if ( llTrans0YZ || llTransXY0 )
+ // {
+ // llXYZ = tt->getBrightness( level, pX + 1, pY, pZ
+ // + 1 );
+ // }
+ // else
+ // {
+ // llXYZ = llXY0;
+ // }
+ // pY--;
+ //
+ // ll4 = ( llxYZ + llxY0 + ll0YZ + ll0Y0 ) / 4.0f;
+ // ll1 = ( ll0YZ + ll0Y0 + llXYZ + llXY0 ) / 4.0f;
+ // ll2 = ( ll0Y0 + ll0Yz + llXY0 + llXYz ) / 4.0f;
+ // ll3 = ( llxY0 + llxYz + ll0Y0 + ll0Yz ) / 4.0f;
+ // }
+ // else
+ // {
+ // ll1 = ll2 = ll3 = ll4 = ll0Y0;
+ // }
+ // c1r = c2r = c3r = c4r = ( tint1 ? pBaseRed : 1.0f );
+ // c1g = c2g = c3g = c4g = ( tint1 ? pBaseGreen : 1.0f );
+ // c1b = c2b = c3b = c4b = ( tint1 ? pBaseBlue : 1.0f );
+ // c1r *= ll1;
+ // c1g *= ll1;
+ // c1b *= ll1;
+ // c2r *= ll2;
+ // c2g *= ll2;
+ // c2b *= ll2;
+ // c3r *= ll3;
+ // c3g *= ll3;
+ // c3b *= ll3;
+ // c4r *= ll4;
+ // c4g *= ll4;
+ // c4b *= ll4;
+ // renderFaceUp( tt, ( float )pX, ( float )pY, ( float )pZ,
+ // getTexture( tt, level, pX, pY, pZ, 1 ) );
+ // }
+ // if ( faceFlags & 0x04 )
+ // {
+ // if ( blsmooth > 0 )
+ // {
+ // pZ--;
+ // llx0z = tt->getBrightness( level, pX - 1, pY, pZ );
+ // ll0yz = tt->getBrightness( level, pX, pY - 1, pZ );
+ // ll0Yz = tt->getBrightness( level, pX, pY + 1, pZ );
+ // llX0z = tt->getBrightness( level, pX + 1, pY, pZ );
+ //
+ // if ( llTransx0z || llTrans0yz )
+ // {
+ // llxyz = tt->getBrightness( level, pX - 1, pY -
+ // 1, pZ );
+ // }
+ // else
+ // {
+ // llxyz = llx0z;
+ // }
+ // if ( llTransx0z || llTrans0Yz )
+ // {
+ // llxYz = tt->getBrightness( level, pX - 1, pY +
+ // 1, pZ );
+ // }
+ // else
+ // {
+ // llxYz = llx0z;
+ // }
+ // if ( llTransX0z || llTrans0yz )
+ // {
+ // llXyz = tt->getBrightness( level, pX + 1, pY -
+ // 1, pZ );
+ // }
+ // else
+ // {
+ // llXyz = llX0z;
+ // }
+ // if ( llTransX0z || llTrans0Yz )
+ // {
+ // llXYz = tt->getBrightness( level, pX + 1, pY +
+ // 1, pZ );
+ // }
+ // else
+ // {
+ // llXYz = llX0z;
+ // }
+ // pZ++;
+ // ll1 = ( llx0z + llxYz + ll00z + ll0Yz ) / 4.0f;
+ // ll2 = ( ll00z + ll0Yz + llX0z + llXYz ) / 4.0f;
+ // ll3 = ( ll0yz + ll00z + llXyz + llX0z ) / 4.0f;
+ // ll4 = ( llxyz + llx0z + ll0yz + ll00z ) / 4.0f;
+ // }
+ // else
+ // {
+ // ll1 = ll2 = ll3 = ll4 = ll00z;
+ // }
+ // c1r = c2r = c3r = c4r = ( tint2 ? pBaseRed : 1.0f ) * 0.8f;
+ // c1g = c2g = c3g = c4g = ( tint2 ? pBaseGreen : 1.0f ) * 0.8f;
+ // c1b = c2b = c3b = c4b = ( tint2 ? pBaseBlue : 1.0f ) * 0.8f;
+ // c1r *= ll1;
+ // c1g *= ll1;
+ // c1b *= ll1;
+ // c2r *= ll2;
+ // c2g *= ll2;
+ // c2b *= ll2;
+ // c3r *= ll3;
+ // c3g *= ll3;
+ // c3b *= ll3;
+ // c4r *= ll4;
+ // c4g *= ll4;
+ // c4b *= ll4;
+ //
+ // Icon_SPU *tex = getTexture(tt, level, pX, pY, pZ, 2);
+ // renderNorth( tt, ( float )pX, ( float )pY, ( float )pZ, tex );
+ //
+ // if ( fancy && (tex->getName().compare(L"grass_side") == 0) &&
+ // !hasFixedTexture())
+ // {
+ // c1r *= pBaseRed;
+ // c2r *= pBaseRed;
+ // c3r *= pBaseRed;
+ // c4r *= pBaseRed;
+ // c1g *= pBaseGreen;
+ // c2g *= pBaseGreen;
+ // c3g *= pBaseGreen;
+ // c4g *= pBaseGreen;
+ // c1b *= pBaseBlue;
+ // c2b *= pBaseBlue;
+ // c3b *= pBaseBlue;
+ // c4b *= pBaseBlue;
+ // renderNorth( tt, ( float )pX, ( float )pY, ( float )pZ,
+ // getGrassSideTextureOverlay() );
+ // }
+ // }
+ // if ( faceFlags & 0x08 )
+ // {
+ // if ( blsmooth > 0 )
+ // {
+ // pZ++;
+ //
+ // llx0Z = tt->getBrightness( level, pX - 1, pY, pZ );
+ // llX0Z = tt->getBrightness( level, pX + 1, pY, pZ );
+ // ll0yZ = tt->getBrightness( level, pX, pY - 1, pZ );
+ // ll0YZ = tt->getBrightness( level, pX, pY + 1, pZ );
+ //
+ // if ( llTransx0Z || llTrans0yZ )
+ // {
+ // llxyZ = tt->getBrightness( level, pX - 1, pY -
+ // 1, pZ );
+ // }
+ // else
+ // {
+ // llxyZ = llx0Z;
+ // }
+ // if ( llTransx0Z || llTrans0YZ )
+ // {
+ // llxYZ = tt->getBrightness( level, pX - 1, pY +
+ // 1, pZ );
+ // }
+ // else
+ // {
+ // llxYZ = llx0Z;
+ // }
+ // if ( llTransX0Z || llTrans0yZ )
+ // {
+ // llXyZ = tt->getBrightness( level, pX + 1, pY -
+ // 1, pZ );
+ // }
+ // else
+ // {
+ // llXyZ = llX0Z;
+ // }
+ // if ( llTransX0Z || llTrans0YZ )
+ // {
+ // llXYZ = tt->getBrightness( level, pX + 1, pY +
+ // 1, pZ );
+ // }
+ // else
+ // {
+ // llXYZ = llX0Z;
+ // }
+ // pZ--;
+ // ll1 = ( llx0Z + llxYZ + ll00Z + ll0YZ ) / 4.0f;
+ // ll4 = ( ll00Z + ll0YZ + llX0Z + llXYZ ) / 4.0f;
+ // ll3 = ( ll0yZ + ll00Z + llXyZ + llX0Z ) / 4.0f;
+ // ll2 = ( llxyZ + llx0Z + ll0yZ + ll00Z ) / 4.0f;
+ // }
+ // else
+ // {
+ // ll1 = ll2 = ll3 = ll4 = ll00Z;
+ // }
+ // c1r = c2r = c3r = c4r = ( tint3 ? pBaseRed : 1.0f ) * 0.8f;
+ // c1g = c2g = c3g = c4g = ( tint3 ? pBaseGreen : 1.0f ) * 0.8f;
+ // c1b = c2b = c3b = c4b = ( tint3 ? pBaseBlue : 1.0f ) * 0.8f;
+ // c1r *= ll1;
+ // c1g *= ll1;
+ // c1b *= ll1;
+ // c2r *= ll2;
+ // c2g *= ll2;
+ // c2b *= ll2;
+ // c3r *= ll3;
+ // c3g *= ll3;
+ // c3b *= ll3;
+ // c4r *= ll4;
+ // c4g *= ll4;
+ // c4b *= ll4;
+ // Icon_SPU *tex = getTexture(tt, level, pX, pY, pZ, 3);
+ // renderSouth( tt, ( float )pX, ( float )pY, ( float )pZ,
+ // getTexture(tt, level, pX, pY, pZ, 3 ) ); if ( fancy &&
+ // (tex->getName().compare(L"grass_side") == 0) && !hasFixedTexture() )
+ // {
+ // c1r *= pBaseRed;
+ // c2r *= pBaseRed;
+ // c3r *= pBaseRed;
+ // c4r *= pBaseRed;
+ // c1g *= pBaseGreen;
+ // c2g *= pBaseGreen;
+ // c3g *= pBaseGreen;
+ // c4g *= pBaseGreen;
+ // c1b *= pBaseBlue;
+ // c2b *= pBaseBlue;
+ // c3b *= pBaseBlue;
+ // c4b *= pBaseBlue;
+ // renderSouth( tt, ( float )pX, ( float )pY, ( float )pZ,
+ // getGrassSideTextureOverlay() );
+ // }
+ // }
+ // if ( faceFlags & 0x10 )
+ // {
+ // if ( blsmooth > 0 )
+ // {
+ // pX--;
+ // llxy0 = tt->getBrightness( level, pX, pY - 1, pZ );
+ // llx0z = tt->getBrightness( level, pX, pY, pZ - 1 );
+ // llx0Z = tt->getBrightness( level, pX, pY, pZ + 1 );
+ // llxY0 = tt->getBrightness( level, pX, pY + 1, pZ );
+ //
+ // if ( llTransx0z || llTransxy0 )
+ // {
+ // llxyz = tt->getBrightness( level, pX, pY - 1, pZ
+ // - 1 );
+ // }
+ // else
+ // {
+ // llxyz = llx0z;
+ // }
+ // if ( llTransx0Z || llTransxy0 )
+ // {
+ // llxyZ = tt->getBrightness( level, pX, pY - 1, pZ
+ // + 1 );
+ // }
+ // else
+ // {
+ // llxyZ = llx0Z;
+ // }
+ // if ( llTransx0z || llTransxY0 )
+ // {
+ // llxYz = tt->getBrightness( level, pX, pY + 1, pZ
+ // - 1 );
+ // }
+ // else
+ // {
+ // llxYz = llx0z;
+ // }
+ // if ( llTransx0Z || llTransxY0 )
+ // {
+ // llxYZ = tt->getBrightness( level, pX, pY + 1, pZ
+ // + 1 );
+ // }
+ // else
+ // {
+ // llxYZ = llx0Z;
+ // }
+ // pX++;
+ // ll4 = ( llxy0 + llxyZ + llx00 + llx0Z ) / 4.0f;
+ // ll1 = ( llx00 + llx0Z + llxY0 + llxYZ ) / 4.0f;
+ // ll2 = ( llx0z + llx00 + llxYz + llxY0 ) / 4.0f;
+ // ll3 = ( llxyz + llxy0 + llx0z + llx00 ) / 4.0f;
+ // }
+ // else
+ // {
+ // ll1 = ll2 = ll3 = ll4 = llx00;
+ // }
+ // c1r = c2r = c3r = c4r = ( tint4 ? pBaseRed : 1.0f ) * 0.6f;
+ // c1g = c2g = c3g = c4g = ( tint4 ? pBaseGreen : 1.0f ) * 0.6f;
+ // c1b = c2b = c3b = c4b = ( tint4 ? pBaseBlue : 1.0f ) * 0.6f;
+ // c1r *= ll1;
+ // c1g *= ll1;
+ // c1b *= ll1;
+ // c2r *= ll2;
+ // c2g *= ll2;
+ // c2b *= ll2;
+ // c3r *= ll3;
+ // c3g *= ll3;
+ // c3b *= ll3;
+ // c4r *= ll4;
+ // c4g *= ll4;
+ // c4b *= ll4;
+ // Icon_SPU *tex = getTexture(tt, level, pX, pY, pZ, 4);
+ // renderWest( tt, ( float )pX, ( float )pY, ( float )pZ, tex );
+ // if ( fancy &&(tex->getName().compare(L"grass_side") == 0) &&
+ // !hasFixedTexture() )
+ // {
+ // c1r *= pBaseRed;
+ // c2r *= pBaseRed;
+ // c3r *= pBaseRed;
+ // c4r *= pBaseRed;
+ // c1g *= pBaseGreen;
+ // c2g *= pBaseGreen;
+ // c3g *= pBaseGreen;
+ // c4g *= pBaseGreen;
+ // c1b *= pBaseBlue;
+ // c2b *= pBaseBlue;
+ // c3b *= pBaseBlue;
+ // c4b *= pBaseBlue;
+ // renderWest( tt, ( float )pX, ( float )pY, ( float )pZ,
+ // getGrassSideTextureOverlay() );
+ // }
+ // }
+ // if ( faceFlags & 0x20 )
+ // {
+ // if ( blsmooth > 0 )
+ // {
+ // pX++;
+ // llXy0 = tt->getBrightness( level, pX, pY - 1, pZ );
+ // llX0z = tt->getBrightness( level, pX, pY, pZ - 1 );
+ // llX0Z = tt->getBrightness( level, pX, pY, pZ + 1 );
+ // llXY0 = tt->getBrightness( level, pX, pY + 1, pZ );
+ //
+ // if ( llTransXy0 || llTransX0z )
+ // {
+ // llXyz = tt->getBrightness( level, pX, pY - 1, pZ
+ // - 1 );
+ // }
+ // else
+ // {
+ // llXyz = llX0z;
+ // }
+ // if ( llTransXy0 || llTransX0Z )
+ // {
+ // llXyZ = tt->getBrightness( level, pX, pY - 1, pZ
+ // + 1 );
+ // }
+ // else
+ // {
+ // llXyZ = llX0Z;
+ // }
+ // if ( llTransXY0 || llTransX0z )
+ // {
+ // llXYz = tt->getBrightness( level, pX, pY + 1, pZ
+ // - 1 );
+ // }
+ // else
+ // {
+ // llXYz = llX0z;
+ // }
+ // if ( llTransXY0 || llTransX0Z )
+ // {
+ // llXYZ = tt->getBrightness( level, pX, pY + 1, pZ
+ // + 1 );
+ // }
+ // else
+ // {
+ // llXYZ = llX0Z;
+ // }
+ // pX--;
+ // ll1 = ( llXy0 + llXyZ + llX00 + llX0Z ) / 4.0f;
+ // ll4 = ( llX00 + llX0Z + llXY0 + llXYZ ) / 4.0f;
+ // ll3 = ( llX0z + llX00 + llXYz + llXY0 ) / 4.0f;
+ // ll2 = ( llXyz + llXy0 + llX0z + llX00 ) / 4.0f;
+ // }
+ // else
+ // {
+ // ll1 = ll2 = ll3 = ll4 = llX00;
+ // }
+ // c1r = c2r = c3r = c4r = ( tint5 ? pBaseRed : 1.0f ) * 0.6f;
+ // c1g = c2g = c3g = c4g = ( tint5 ? pBaseGreen : 1.0f ) * 0.6f;
+ // c1b = c2b = c3b = c4b = ( tint5 ? pBaseBlue : 1.0f ) * 0.6f;
+ // c1r *= ll1;
+ // c1g *= ll1;
+ // c1b *= ll1;
+ // c2r *= ll2;
+ // c2g *= ll2;
+ // c2b *= ll2;
+ // c3r *= ll3;
+ // c3g *= ll3;
+ // c3b *= ll3;
+ // c4r *= ll4;
+ // c4g *= ll4;
+ // c4b *= ll4;
+ //
+ // Icon_SPU *tex = getTexture(tt, level, pX, pY, pZ, 5);
+ // renderEast( tt, ( float )pX, ( float )pY, ( float )pZ, tex );
+ // if ( fancy && (tex->getName().compare(L"grass_side") == 0) &&
+ // !hasFixedTexture() )
+ // {
+ // c1r *= pBaseRed;
+ // c2r *= pBaseRed;
+ // c3r *= pBaseRed;
+ // c4r *= pBaseRed;
+ // c1g *= pBaseGreen;
+ // c2g *= pBaseGreen;
+ // c3g *= pBaseGreen;
+ // c4g *= pBaseGreen;
+ // c1b *= pBaseBlue;
+ // c2b *= pBaseBlue;
+ // c3b *= pBaseBlue;
+ // c4b *= pBaseBlue;
+ // renderEast( tt, ( float )pX, ( float )pY, ( float )pZ,
+ // getGrassSideTextureOverlay() );
+ // }
+ // }
+ // applyAmbienceOcclusion = false;
+ //
+ return true;
}
// 4J - brought forward from 1.8.2
-int TileRenderer_SPU::blend( int a, int b, int c, int def )
-{
- if ( a == 0 ) a = def;
- if ( b == 0 ) b = def;
- if ( c == 0 ) c = def;
- return ( ( a + b + c + def ) >> 2 ) & 0xff00ff;
+int TileRenderer_SPU::blend(int a, int b, int c, int def) {
+ if (a == 0) a = def;
+ if (b == 0) b = def;
+ if (c == 0) c = def;
+ return ((a + b + c + def) >> 2) & 0xff00ff;
}
-int TileRenderer_SPU::blend(int a, int b, int c, int d, float fa, float fb, float fc, float fd)
-{
-
- int top = (int) ((float) ((a >> 16) & 0xff) * fa + (float) ((b >> 16) & 0xff) * fb + (float) ((c >> 16) & 0xff) * fc + (float) ((d >> 16) & 0xff) * fd) & 0xff;
- int bottom = (int) ((float) (a & 0xff) * fa + (float) (b & 0xff) * fb + (float) (c & 0xff) * fc + (float) (d & 0xff) * fd) & 0xff;
- return (top << 16) | bottom;
+int TileRenderer_SPU::blend(int a, int b, int c, int d, float fa, float fb,
+ float fc, float fd) {
+ int top =
+ (int)((float)((a >> 16) & 0xff) * fa + (float)((b >> 16) & 0xff) * fb +
+ (float)((c >> 16) & 0xff) * fc + (float)((d >> 16) & 0xff) * fd) &
+ 0xff;
+ int bottom = (int)((float)(a & 0xff) * fa + (float)(b & 0xff) * fb +
+ (float)(c & 0xff) * fc + (float)(d & 0xff) * fd) &
+ 0xff;
+ return (top << 16) | bottom;
}
-bool TileRenderer_SPU::tesselateBlockInWorld( Tile_SPU* tt, int x, int y, int z, float r, float g, float b )
-{
- applyAmbienceOcclusion = false;
+bool TileRenderer_SPU::tesselateBlockInWorld(Tile_SPU* tt, int x, int y, int z,
+ float r, float g, float b) {
+ applyAmbienceOcclusion = false;
- Tesselator_SPU* t = getTesselator();
+ Tesselator_SPU* t = getTesselator();
- bool changed = false;
- float c10 = 0.5f;
- float c11 = 1;
- float c2 = 0.8f;
- float c3 = 0.6f;
+ bool changed = false;
+ float c10 = 0.5f;
+ float c11 = 1;
+ float c2 = 0.8f;
+ float c3 = 0.6f;
- float r11 = c11 * r;
- float g11 = c11 * g;
- float b11 = c11 * b;
+ float r11 = c11 * r;
+ float g11 = c11 * g;
+ float b11 = c11 * b;
- float r10 = c10;
- float r2 = c2;
- float r3 = c3;
+ float r10 = c10;
+ float r2 = c2;
+ float r3 = c3;
- float g10 = c10;
- float g2 = c2;
- float g3 = c3;
+ float g10 = c10;
+ float g2 = c2;
+ float g3 = c3;
- float b10 = c10;
- float b2 = c2;
- float b3 = c3;
+ float b10 = c10;
+ float b2 = c2;
+ float b3 = c3;
- if ( tt->id != Tile_SPU::grass_Id )
- {
- r10 *= r;
- r2 *= r;
- r3 *= r;
+ if (tt->id != Tile_SPU::grass_Id) {
+ r10 *= r;
+ r2 *= r;
+ r3 *= r;
- g10 *= g;
- g2 *= g;
- g3 *= g;
+ g10 *= g;
+ g2 *= g;
+ g3 *= g;
- b10 *= b;
- b2 *= b;
- b3 *= b;
- }
+ b10 *= b;
+ b2 *= b;
+ b3 *= b;
+ }
- int centerColor = 0;
- float centerBrightness = 0.0f;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- centerColor = tt->getLightColor( level, x, y, z );
- }
- else
- {
- centerBrightness = tt->getBrightness( level, x, y, z );
- }
+ int centerColor = 0;
+ float centerBrightness = 0.0f;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ centerColor = tt->getLightColor(level, x, y, z);
+ } else {
+ centerBrightness = tt->getBrightness(level, x, y, z);
+ }
- if ( noCulling || tt->shouldRenderFace( level, x, y - 1, z, Facing::DOWN ) )
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeY0 > 0 ? centerColor : tt->getLightColor( level, x, y - 1, z ) );
- t->color( r10, g10, b10 );
- }
- else
- {
- float br = tt->getBrightness( level, x, y - 1, z );
- t->color( r10 * br, g10 * br, b10 * br );
- }
- renderFaceDown( tt, x, y, z, getTexture(tt, level, x, y, z, 0 ) );
- changed = true;
- }
+ if (noCulling || tt->shouldRenderFace(level, x, y - 1, z, Facing::DOWN)) {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeY0 > 0 ? centerColor
+ : tt->getLightColor(level, x, y - 1, z));
+ t->color(r10, g10, b10);
+ } else {
+ float br = tt->getBrightness(level, x, y - 1, z);
+ t->color(r10 * br, g10 * br, b10 * br);
+ }
+ renderFaceDown(tt, x, y, z, getTexture(tt, level, x, y, z, 0));
+ changed = true;
+ }
- if ( noCulling || tt->shouldRenderFace( level, x, y + 1, z, Facing::UP ) )
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeY1 < 1 ? centerColor : tt->getLightColor( level, x, y + 1, z ) );
- t->color( r11, g11, b11 );
- }
- else
- {
- float br = tt->getBrightness( level, x, y + 1, z );
- // spu_print("need to add material settings\n");
-// if ( tileShapeY1 != 1 && !tt->material->isLiquid() ) br = centerBrightness;
- t->color( r11 * br, g11 * br, b11 * br );
- }
- renderFaceUp( tt, x, y, z, getTexture(tt, level, x, y, z, 1 ) );
- changed = true;
- }
+ if (noCulling || tt->shouldRenderFace(level, x, y + 1, z, Facing::UP)) {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeY1 < 1 ? centerColor
+ : tt->getLightColor(level, x, y + 1, z));
+ t->color(r11, g11, b11);
+ } else {
+ float br = tt->getBrightness(level, x, y + 1, z);
+ // spu_print("need to add material settings\n");
+ // if ( tileShapeY1 != 1 &&
+ //! tt->material->isLiquid() ) br = centerBrightness;
+ t->color(r11 * br, g11 * br, b11 * br);
+ }
+ renderFaceUp(tt, x, y, z, getTexture(tt, level, x, y, z, 1));
+ changed = true;
+ }
- if ( noCulling || tt->shouldRenderFace( level, x, y, z - 1, Facing::NORTH ) )
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeZ0 > 0 ? centerColor : tt->getLightColor( level, x, y, z - 1 ) );
- t->color( r2, g2, b2 );
- }
- else
- {
- float br = tt->getBrightness( level, x, y, z - 1 );
- if ( tileShapeZ0 > 0 ) br = centerBrightness;
- t->color( r2 * br, g2 * br, b2 * br );
- }
+ if (noCulling || tt->shouldRenderFace(level, x, y, z - 1, Facing::NORTH)) {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeZ0 > 0 ? centerColor
+ : tt->getLightColor(level, x, y, z - 1));
+ t->color(r2, g2, b2);
+ } else {
+ float br = tt->getBrightness(level, x, y, z - 1);
+ if (tileShapeZ0 > 0) br = centerBrightness;
+ t->color(r2 * br, g2 * br, b2 * br);
+ }
- Icon_SPU *tex = getTexture(tt, level, x, y, z, 2);
- renderNorth( tt, x, y, z, tex );
+ Icon_SPU* tex = getTexture(tt, level, x, y, z, 2);
+ renderNorth(tt, x, y, z, tex);
- if ( fancy && (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] && !hasFixedTexture() ))
- {
- t->color( r2 * r, g2 * g, b2 * b );
- renderNorth( tt, x, y, z, GrassTile_SPU::getSideTextureOverlay() );
- }
- changed = true;
- }
+ if (fancy &&
+ (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] &&
+ !hasFixedTexture())) {
+ t->color(r2 * r, g2 * g, b2 * b);
+ renderNorth(tt, x, y, z, GrassTile_SPU::getSideTextureOverlay());
+ }
+ changed = true;
+ }
- if ( noCulling || tt->shouldRenderFace( level, x, y, z + 1, Facing::SOUTH ) )
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeZ1 < 1 ? centerColor : tt->getLightColor( level, x, y, z + 1 ) );
- t->color( r2, g2, b2 );
- }
- else
- {
- float br = tt->getBrightness( level, x, y, z + 1 );
- if ( tileShapeZ1 < 1 ) br = centerBrightness;
- t->color( r2 * br, g2 * br, b2 * br );
- }
- Icon_SPU *tex = getTexture(tt, level, x, y, z, 3);
- renderSouth( tt, x, y, z, tex );
+ if (noCulling || tt->shouldRenderFace(level, x, y, z + 1, Facing::SOUTH)) {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeZ1 < 1 ? centerColor
+ : tt->getLightColor(level, x, y, z + 1));
+ t->color(r2, g2, b2);
+ } else {
+ float br = tt->getBrightness(level, x, y, z + 1);
+ if (tileShapeZ1 < 1) br = centerBrightness;
+ t->color(r2 * br, g2 * br, b2 * br);
+ }
+ Icon_SPU* tex = getTexture(tt, level, x, y, z, 3);
+ renderSouth(tt, x, y, z, tex);
- if ( fancy && (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] && !hasFixedTexture() ))
- {
- t->color( r2 * r, g2 * g, b2 * b );
- renderSouth( tt, x, y, z, GrassTile_SPU::getSideTextureOverlay() );
- }
- changed = true;
- }
+ if (fancy &&
+ (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] &&
+ !hasFixedTexture())) {
+ t->color(r2 * r, g2 * g, b2 * b);
+ renderSouth(tt, x, y, z, GrassTile_SPU::getSideTextureOverlay());
+ }
+ changed = true;
+ }
- if ( noCulling || tt->shouldRenderFace( level, x - 1, y, z, Facing::WEST ) )
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeX0 > 0 ? centerColor : tt->getLightColor( level, x - 1, y, z ) );
- t->color( r3, g3, b3 );
- }
- else
- {
- float br = tt->getBrightness( level, x - 1, y, z );
- if ( tileShapeX0 > 0 ) br = centerBrightness;
- t->color( r3 * br, g3 * br, b3 * br );
- }
- Icon_SPU *tex = getTexture(tt, level, x, y, z, 4);
- renderWest( tt, x, y, z, tex );
+ if (noCulling || tt->shouldRenderFace(level, x - 1, y, z, Facing::WEST)) {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeX0 > 0 ? centerColor
+ : tt->getLightColor(level, x - 1, y, z));
+ t->color(r3, g3, b3);
+ } else {
+ float br = tt->getBrightness(level, x - 1, y, z);
+ if (tileShapeX0 > 0) br = centerBrightness;
+ t->color(r3 * br, g3 * br, b3 * br);
+ }
+ Icon_SPU* tex = getTexture(tt, level, x, y, z, 4);
+ renderWest(tt, x, y, z, tex);
- if ( fancy && (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] && !hasFixedTexture() ))
- {
- t->color( r3 * r, g3 * g, b3 * b );
- renderWest( tt, x, y, z, GrassTile_SPU::getSideTextureOverlay() );
- }
- changed = true;
- }
+ if (fancy &&
+ (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] &&
+ !hasFixedTexture())) {
+ t->color(r3 * r, g3 * g, b3 * b);
+ renderWest(tt, x, y, z, GrassTile_SPU::getSideTextureOverlay());
+ }
+ changed = true;
+ }
- if ( noCulling || tt->shouldRenderFace( level, x + 1, y, z, Facing::EAST ) )
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeX1 < 1 ? centerColor : tt->getLightColor( level, x + 1, y, z ) );
- t->color( r3, g3, b3 );
- }
- else
- {
- float br = tt->getBrightness( level, x + 1, y, z );
- if ( tileShapeX1 < 1 ) br = centerBrightness;
- t->color( r3 * br, g3 * br, b3 * br );
- }
- Icon_SPU *tex = getTexture(tt, level, x, y, z, 5);
- renderEast( tt, x, y, z, tex );
+ if (noCulling || tt->shouldRenderFace(level, x + 1, y, z, Facing::EAST)) {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeX1 < 1 ? centerColor
+ : tt->getLightColor(level, x + 1, y, z));
+ t->color(r3, g3, b3);
+ } else {
+ float br = tt->getBrightness(level, x + 1, y, z);
+ if (tileShapeX1 < 1) br = centerBrightness;
+ t->color(r3 * br, g3 * br, b3 * br);
+ }
+ Icon_SPU* tex = getTexture(tt, level, x, y, z, 5);
+ renderEast(tt, x, y, z, tex);
- if ( fancy && (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] && !hasFixedTexture() ))
- {
- t->color( r3 * r, g3 * g, b3 * b );
- renderEast( tt, x, y, z, GrassTile_SPU::getSideTextureOverlay() );
- }
- changed = true;
- }
-
- return changed;
+ if (fancy &&
+ (tex == &Tile_SPU::ms_pTileData->iconData[Tile_SPU::grass_Id] &&
+ !hasFixedTexture())) {
+ t->color(r3 * r, g3 * g, b3 * b);
+ renderEast(tt, x, y, z, GrassTile_SPU::getSideTextureOverlay());
+ }
+ changed = true;
+ }
+ return changed;
}
-bool TileRenderer_SPU::tesselateCactusInWorld( Tile_SPU* tt, int x, int y, int z )
-{
- int col = tt->getColor( level, x, y, z );
- float r = ( ( col >> 16 ) & 0xff ) / 255.0f;
- float g = ( ( col >> 8 ) & 0xff ) / 255.0f;
- float b = ( ( col )& 0xff ) / 255.0f;
+bool TileRenderer_SPU::tesselateCactusInWorld(Tile_SPU* tt, int x, int y,
+ int z) {
+ int col = tt->getColor(level, x, y, z);
+ float r = ((col >> 16) & 0xff) / 255.0f;
+ float g = ((col >> 8) & 0xff) / 255.0f;
+ float b = ((col) & 0xff) / 255.0f;
- if ( isAnaglyph3d() )
- {
- float cr = ( r * 30 + g * 59 + b * 11 ) / 100;
- float cg = ( r * 30 + g * 70 ) / ( 100 );
- float cb = ( r * 30 + b * 70 ) / ( 100 );
+ if (isAnaglyph3d()) {
+ float cr = (r * 30 + g * 59 + b * 11) / 100;
+ float cg = (r * 30 + g * 70) / (100);
+ float cb = (r * 30 + b * 70) / (100);
- r = cr;
- g = cg;
- b = cb;
- }
- return tesselateCactusInWorld( tt, x, y, z, r, g, b );
+ r = cr;
+ g = cg;
+ b = cb;
+ }
+ return tesselateCactusInWorld(tt, x, y, z, r, g, b);
}
-bool TileRenderer_SPU::tesselateCactusInWorld( Tile_SPU* tt, int x, int y, int z, float r, float g, float b )
-{
- Tesselator_SPU* t = getTesselator();
+bool TileRenderer_SPU::tesselateCactusInWorld(Tile_SPU* tt, int x, int y, int z,
+ float r, float g, float b) {
+ Tesselator_SPU* t = getTesselator();
- bool changed = false;
- float c10 = 0.5f;
- float c11 = 1;
- float c2 = 0.8f;
- float c3 = 0.6f;
+ bool changed = false;
+ float c10 = 0.5f;
+ float c11 = 1;
+ float c2 = 0.8f;
+ float c3 = 0.6f;
- float r10 = c10 * r;
- float r11 = c11 * r;
- float r2 = c2 * r;
- float r3 = c3 * r;
+ float r10 = c10 * r;
+ float r11 = c11 * r;
+ float r2 = c2 * r;
+ float r3 = c3 * r;
- float g10 = c10 * g;
- float g11 = c11 * g;
- float g2 = c2 * g;
- float g3 = c3 * g;
+ float g10 = c10 * g;
+ float g11 = c11 * g;
+ float g2 = c2 * g;
+ float g3 = c3 * g;
- float b10 = c10 * b;
- float b11 = c11 * b;
- float b2 = c2 * b;
- float b3 = c3 * b;
+ float b10 = c10 * b;
+ float b11 = c11 * b;
+ float b2 = c2 * b;
+ float b3 = c3 * b;
- float s = 1 / 16.0f;
+ float s = 1 / 16.0f;
- float centerBrightness = 0.0f;
- int centerColor = 0;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- centerColor = tt->getLightColor( level, x, y, z );
- }
- else
- {
- centerBrightness = tt->getBrightness( level, x, y, z );
- }
+ float centerBrightness = 0.0f;
+ int centerColor = 0;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ centerColor = tt->getLightColor(level, x, y, z);
+ } else {
+ centerBrightness = tt->getBrightness(level, x, y, z);
+ }
- if ( noCulling || tt->shouldRenderFace( level, x, y - 1, z, 0 ) )
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeY0 > 0 ? centerColor : tt->getLightColor( level, x, y - 1, z ) );
- t->color( r10, g10, b10 );
- }
- else
- {
- float br = tt->getBrightness( level, x, y - 1, z );
- t->color( r10 * br, g10 * br, b10 * br );
- }
- renderFaceDown( tt, x, y, z, getTexture( tt, level, x, y, z, 0 ) );
- changed = true;
- }
+ if (noCulling || tt->shouldRenderFace(level, x, y - 1, z, 0)) {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeY0 > 0 ? centerColor
+ : tt->getLightColor(level, x, y - 1, z));
+ t->color(r10, g10, b10);
+ } else {
+ float br = tt->getBrightness(level, x, y - 1, z);
+ t->color(r10 * br, g10 * br, b10 * br);
+ }
+ renderFaceDown(tt, x, y, z, getTexture(tt, level, x, y, z, 0));
+ changed = true;
+ }
- if ( noCulling || tt->shouldRenderFace( level, x, y + 1, z, 1 ) )
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeY1 < 1 ? centerColor : tt->getLightColor( level, x, y + 1, z ) );
- t->color( r11, g11, b11 );
- }
- else
- {
- float br = tt->getBrightness( level, x, y + 1, z );
- if ( tileShapeY1 != 1 && !tt->getMaterial()->isLiquid() ) br = centerBrightness;
- t->color( r11 * br, g11 * br, b11 * br );
- }
- renderFaceUp( tt, x, y, z, getTexture( tt, level, x, y, z, 1 ) );
- changed = true;
- }
+ if (noCulling || tt->shouldRenderFace(level, x, y + 1, z, 1)) {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeY1 < 1 ? centerColor
+ : tt->getLightColor(level, x, y + 1, z));
+ t->color(r11, g11, b11);
+ } else {
+ float br = tt->getBrightness(level, x, y + 1, z);
+ if (tileShapeY1 != 1 && !tt->getMaterial()->isLiquid())
+ br = centerBrightness;
+ t->color(r11 * br, g11 * br, b11 * br);
+ }
+ renderFaceUp(tt, x, y, z, getTexture(tt, level, x, y, z, 1));
+ changed = true;
+ }
- if ( noCulling || tt->shouldRenderFace( level, x, y, z - 1, 2 ) )
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeZ0 > 0 ? centerColor : tt->getLightColor( level, x, y, z - 1 ) );
- t->color( r2, g2, b2 );
- }
- else
- {
- float br = tt->getBrightness( level, x, y, z - 1 );
- if ( tileShapeZ0 > 0 ) br = centerBrightness;
- t->color( r2 * br, g2 * br, b2 * br );
- }
- t->addOffset( 0, 0, s );
- renderNorth( tt, x, y, z, getTexture(tt, level, x, y, z, 2 ) );
- t->addOffset( 0, 0, -s );
- changed = true;
- }
+ if (noCulling || tt->shouldRenderFace(level, x, y, z - 1, 2)) {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeZ0 > 0 ? centerColor
+ : tt->getLightColor(level, x, y, z - 1));
+ t->color(r2, g2, b2);
+ } else {
+ float br = tt->getBrightness(level, x, y, z - 1);
+ if (tileShapeZ0 > 0) br = centerBrightness;
+ t->color(r2 * br, g2 * br, b2 * br);
+ }
+ t->addOffset(0, 0, s);
+ renderNorth(tt, x, y, z, getTexture(tt, level, x, y, z, 2));
+ t->addOffset(0, 0, -s);
+ changed = true;
+ }
- if ( noCulling || tt->shouldRenderFace( level, x, y, z + 1, 3 ) )
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeZ1 < 1 ? centerColor : tt->getLightColor( level, x, y, z + 1 ) );
- t->color( r2, g2, b2 );
- }
- else
- {
- float br = tt->getBrightness( level, x, y, z + 1 );
- if ( tileShapeZ1 < 1 ) br = centerBrightness;
- t->color( r2 * br, g2 * br, b2 * br );
- }
+ if (noCulling || tt->shouldRenderFace(level, x, y, z + 1, 3)) {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeZ1 < 1 ? centerColor
+ : tt->getLightColor(level, x, y, z + 1));
+ t->color(r2, g2, b2);
+ } else {
+ float br = tt->getBrightness(level, x, y, z + 1);
+ if (tileShapeZ1 < 1) br = centerBrightness;
+ t->color(r2 * br, g2 * br, b2 * br);
+ }
- t->addOffset( 0, 0, -s );
- renderSouth( tt, x, y, z, getTexture(tt, level, x, y, z, 3 ) );
- t->addOffset( 0, 0, s );
- changed = true;
- }
+ t->addOffset(0, 0, -s);
+ renderSouth(tt, x, y, z, getTexture(tt, level, x, y, z, 3));
+ t->addOffset(0, 0, s);
+ changed = true;
+ }
- if ( noCulling || tt->shouldRenderFace( level, x - 1, y, z, 4 ) )
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeX0 > 0 ? centerColor : tt->getLightColor( level, x - 1, y, z ) );
- t->color( r3, g3, b3 );
- }
- else
- {
- float br = tt->getBrightness( level, x - 1, y, z );
- if ( tileShapeX0 > 0 ) br = centerBrightness;
- t->color( r3 * br, g3 * br, b3 * br );
- }
- t->addOffset( s, 0, 0 );
- renderWest( tt, x, y, z, getTexture(tt, level, x, y, z, 4 ) );
- t->addOffset( -s, 0, 0 );
- changed = true;
- }
+ if (noCulling || tt->shouldRenderFace(level, x - 1, y, z, 4)) {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeX0 > 0 ? centerColor
+ : tt->getLightColor(level, x - 1, y, z));
+ t->color(r3, g3, b3);
+ } else {
+ float br = tt->getBrightness(level, x - 1, y, z);
+ if (tileShapeX0 > 0) br = centerBrightness;
+ t->color(r3 * br, g3 * br, b3 * br);
+ }
+ t->addOffset(s, 0, 0);
+ renderWest(tt, x, y, z, getTexture(tt, level, x, y, z, 4));
+ t->addOffset(-s, 0, 0);
+ changed = true;
+ }
- if ( noCulling || tt->shouldRenderFace( level, x + 1, y, z, 5 ) )
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeX1 < 1 ? centerColor : tt->getLightColor( level, x + 1, y, z ) );
- t->color( r3, g3, b3 );
- }
- else
- {
- float br = tt->getBrightness( level, x + 1, y, z );
- if ( tileShapeX1 < 1 ) br = centerBrightness;
- t->color( r3 * br, g3 * br, b3 * br );
- }
- t->addOffset( -s, 0, 0 );
- renderEast( tt, x, y, z, getTexture(tt, level, x, y, z, 5 ) );
- t->addOffset( s, 0, 0 );
- changed = true;
- }
+ if (noCulling || tt->shouldRenderFace(level, x + 1, y, z, 5)) {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeX1 < 1 ? centerColor
+ : tt->getLightColor(level, x + 1, y, z));
+ t->color(r3, g3, b3);
+ } else {
+ float br = tt->getBrightness(level, x + 1, y, z);
+ if (tileShapeX1 < 1) br = centerBrightness;
+ t->color(r3 * br, g3 * br, b3 * br);
+ }
+ t->addOffset(-s, 0, 0);
+ renderEast(tt, x, y, z, getTexture(tt, level, x, y, z, 5));
+ t->addOffset(s, 0, 0);
+ changed = true;
+ }
- return changed;
+ return changed;
}
-bool TileRenderer_SPU::tesselateFenceInWorld( FenceTile_SPU* tt, int x, int y, int z )
-{
-// #ifdef DISABLE_TESS_FUNCS
- bool changed = false;
+bool TileRenderer_SPU::tesselateFenceInWorld(FenceTile_SPU* tt, int x, int y,
+ int z) {
+ // #ifdef DISABLE_TESS_FUNCS
+ bool changed = false;
- float a = 6 / 16.0f;
- float b = 10 / 16.0f;
-// EnterCriticalSection( &Tile_SPU::m_csShape );
- setShape( a, 0, a, b, 1, b );
- tesselateBlockInWorld( tt, x, y, z );
- changed = true;
+ float a = 6 / 16.0f;
+ float b = 10 / 16.0f;
+ // EnterCriticalSection( &Tile_SPU::m_csShape );
+ setShape(a, 0, a, b, 1, b);
+ tesselateBlockInWorld(tt, x, y, z);
+ changed = true;
- bool vertical = false;
- bool horizontal = false;
+ bool vertical = false;
+ bool horizontal = false;
- if (tt->connectsTo(level, x - 1, y, z) || tt->connectsTo(level, x + 1, y, z)) vertical = true;
- if (tt->connectsTo(level, x, y, z - 1) || tt->connectsTo(level, x, y, z + 1)) horizontal = true;
+ if (tt->connectsTo(level, x - 1, y, z) ||
+ tt->connectsTo(level, x + 1, y, z))
+ vertical = true;
+ if (tt->connectsTo(level, x, y, z - 1) ||
+ tt->connectsTo(level, x, y, z + 1))
+ horizontal = true;
- bool l = tt->connectsTo(level, x - 1, y, z);
- bool r = tt->connectsTo(level, x + 1, y, z);
- bool u = tt->connectsTo(level, x, y, z - 1);
- bool d = tt->connectsTo(level, x, y, z + 1);
+ bool l = tt->connectsTo(level, x - 1, y, z);
+ bool r = tt->connectsTo(level, x + 1, y, z);
+ bool u = tt->connectsTo(level, x, y, z - 1);
+ bool d = tt->connectsTo(level, x, y, z + 1);
- if ( !vertical && !horizontal ) vertical = true;
+ if (!vertical && !horizontal) vertical = true;
- a = 7 / 16.0f;
- b = 9 / 16.0f;
- float h0 = 12 / 16.0f;
- float h1 = 15 / 16.0f;
+ a = 7 / 16.0f;
+ b = 9 / 16.0f;
+ float h0 = 12 / 16.0f;
+ float h1 = 15 / 16.0f;
- float x0 = l ? 0 : a;
- float x1 = r ? 1 : b;
- float z0 = u ? 0 : a;
- float z1 = d ? 1 : b;
- if ( vertical )
- {
- setShape( x0, h0, a, x1, h1, b );
- tesselateBlockInWorld( tt, x, y, z );
- changed = true;
- }
- if ( horizontal )
- {
- setShape( a, h0, z0, b, h1, z1 );
- tesselateBlockInWorld( tt, x, y, z );
- changed = true;
- }
+ float x0 = l ? 0 : a;
+ float x1 = r ? 1 : b;
+ float z0 = u ? 0 : a;
+ float z1 = d ? 1 : b;
+ if (vertical) {
+ setShape(x0, h0, a, x1, h1, b);
+ tesselateBlockInWorld(tt, x, y, z);
+ changed = true;
+ }
+ if (horizontal) {
+ setShape(a, h0, z0, b, h1, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ changed = true;
+ }
- h0 = 6 / 16.0f;
- h1 = 9 / 16.0f;
- if ( vertical )
- {
- setShape( x0, h0, a, x1, h1, b );
- tesselateBlockInWorld( tt, x, y, z );
- changed = true;
- }
- if ( horizontal )
- {
- setShape( a, h0, z0, b, h1, z1 );
- tesselateBlockInWorld( tt, x, y, z );
- changed = true;
- }
+ h0 = 6 / 16.0f;
+ h1 = 9 / 16.0f;
+ if (vertical) {
+ setShape(x0, h0, a, x1, h1, b);
+ tesselateBlockInWorld(tt, x, y, z);
+ changed = true;
+ }
+ if (horizontal) {
+ setShape(a, h0, z0, b, h1, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ changed = true;
+ }
- tt->updateShape(level, x, y, z);
-// LeaveCriticalSection( &Tile_SPU::m_csShape );
- return changed;
-// #endif // #ifdef DISABLE_TESS_FUNCS
- return false;
+ tt->updateShape(level, x, y, z);
+ // LeaveCriticalSection( &Tile_SPU::m_csShape );
+ return changed;
+ // #endif // #ifdef DISABLE_TESS_FUNCS
+ return false;
}
-bool TileRenderer_SPU::tesselateWallInWorld(WallTile_SPU *tt, int x, int y, int z)
-{
- bool w = tt->connectsTo(level, x - 1, y, z);
- bool e = tt->connectsTo(level, x + 1, y, z);
- bool n = tt->connectsTo(level, x, y, z - 1);
- bool s = tt->connectsTo(level, x, y, z + 1);
+bool TileRenderer_SPU::tesselateWallInWorld(WallTile_SPU* tt, int x, int y,
+ int z) {
+ bool w = tt->connectsTo(level, x - 1, y, z);
+ bool e = tt->connectsTo(level, x + 1, y, z);
+ bool n = tt->connectsTo(level, x, y, z - 1);
+ bool s = tt->connectsTo(level, x, y, z + 1);
- bool vertical = (n && s && !w && !e);
- bool horizontal = (!n && !s && w && e);
- bool emptyAbove = level->isEmptyTile(x, y + 1, z);
+ bool vertical = (n && s && !w && !e);
+ bool horizontal = (!n && !s && w && e);
+ bool emptyAbove = level->isEmptyTile(x, y + 1, z);
- if ((!vertical && !horizontal) || !emptyAbove)
- {
- // center post
- setShape(.5f - WallTile_SPU::POST_WIDTH, 0, .5f - WallTile_SPU::POST_WIDTH, .5f + WallTile_SPU::POST_WIDTH, WallTile_SPU::POST_HEIGHT, .5f + WallTile_SPU::POST_WIDTH);
- tesselateBlockInWorld(tt, x, y, z);
+ if ((!vertical && !horizontal) || !emptyAbove) {
+ // center post
+ setShape(.5f - WallTile_SPU::POST_WIDTH, 0,
+ .5f - WallTile_SPU::POST_WIDTH, .5f + WallTile_SPU::POST_WIDTH,
+ WallTile_SPU::POST_HEIGHT, .5f + WallTile_SPU::POST_WIDTH);
+ tesselateBlockInWorld(tt, x, y, z);
- if (w)
- {
- setShape(0, 0, .5f - WallTile_SPU::WALL_WIDTH, .5f - WallTile_SPU::POST_WIDTH, WallTile_SPU::WALL_HEIGHT, .5f + WallTile_SPU::WALL_WIDTH);
- tesselateBlockInWorld(tt, x, y, z);
- }
- if (e)
- {
- setShape(.5f + WallTile_SPU::POST_WIDTH, 0, .5f - WallTile_SPU::WALL_WIDTH, 1, WallTile_SPU::WALL_HEIGHT, .5f + WallTile_SPU::WALL_WIDTH);
- tesselateBlockInWorld(tt, x, y, z);
- }
- if (n)
- {
- setShape(.5f - WallTile_SPU::WALL_WIDTH, 0, 0, .5f + WallTile_SPU::WALL_WIDTH, WallTile_SPU::WALL_HEIGHT, .5f - WallTile_SPU::POST_WIDTH);
- tesselateBlockInWorld(tt, x, y, z);
- }
- if (s)
- {
- setShape(.5f - WallTile_SPU::WALL_WIDTH, 0, .5f + WallTile_SPU::POST_WIDTH, .5f + WallTile_SPU::WALL_WIDTH, WallTile_SPU::WALL_HEIGHT, 1);
- tesselateBlockInWorld(tt, x, y, z);
- }
- }
- else if (vertical)
- {
- // north-south wall
- setShape(.5f - WallTile_SPU::WALL_WIDTH, 0, 0, .5f + WallTile_SPU::WALL_WIDTH, WallTile_SPU::WALL_HEIGHT, 1);
- tesselateBlockInWorld(tt, x, y, z);
- }
- else
- {
- // west-east wall
- setShape(0, 0, .5f - WallTile_SPU::WALL_WIDTH, 1, WallTile_SPU::WALL_HEIGHT, .5f + WallTile_SPU::WALL_WIDTH);
- tesselateBlockInWorld(tt, x, y, z);
- }
+ if (w) {
+ setShape(0, 0, .5f - WallTile_SPU::WALL_WIDTH,
+ .5f - WallTile_SPU::POST_WIDTH, WallTile_SPU::WALL_HEIGHT,
+ .5f + WallTile_SPU::WALL_WIDTH);
+ tesselateBlockInWorld(tt, x, y, z);
+ }
+ if (e) {
+ setShape(.5f + WallTile_SPU::POST_WIDTH, 0,
+ .5f - WallTile_SPU::WALL_WIDTH, 1,
+ WallTile_SPU::WALL_HEIGHT, .5f + WallTile_SPU::WALL_WIDTH);
+ tesselateBlockInWorld(tt, x, y, z);
+ }
+ if (n) {
+ setShape(.5f - WallTile_SPU::WALL_WIDTH, 0, 0,
+ .5f + WallTile_SPU::WALL_WIDTH, WallTile_SPU::WALL_HEIGHT,
+ .5f - WallTile_SPU::POST_WIDTH);
+ tesselateBlockInWorld(tt, x, y, z);
+ }
+ if (s) {
+ setShape(.5f - WallTile_SPU::WALL_WIDTH, 0,
+ .5f + WallTile_SPU::POST_WIDTH,
+ .5f + WallTile_SPU::WALL_WIDTH, WallTile_SPU::WALL_HEIGHT,
+ 1);
+ tesselateBlockInWorld(tt, x, y, z);
+ }
+ } else if (vertical) {
+ // north-south wall
+ setShape(.5f - WallTile_SPU::WALL_WIDTH, 0, 0,
+ .5f + WallTile_SPU::WALL_WIDTH, WallTile_SPU::WALL_HEIGHT, 1);
+ tesselateBlockInWorld(tt, x, y, z);
+ } else {
+ // west-east wall
+ setShape(0, 0, .5f - WallTile_SPU::WALL_WIDTH, 1,
+ WallTile_SPU::WALL_HEIGHT, .5f + WallTile_SPU::WALL_WIDTH);
+ tesselateBlockInWorld(tt, x, y, z);
+ }
- tt->updateShape(level, x, y, z);
- return true;
+ tt->updateShape(level, x, y, z);
+ return true;
}
-
-bool TileRenderer_SPU::tesselateEggInWorld(EggTile_SPU *tt, int x, int y, int z)
-{
- bool changed = false;
-// EnterCriticalSection( &Tile_SPU::m_csShape );
+bool TileRenderer_SPU::tesselateEggInWorld(EggTile_SPU* tt, int x, int y,
+ int z) {
+ bool changed = false;
+ // EnterCriticalSection( &Tile_SPU::m_csShape );
int y0 = 0;
- for (int i = 0; i < 8; i++)
- {
+ for (int i = 0; i < 8; i++) {
int ww = 0;
int hh = 1;
if (i == 0) ww = 2;
if (i == 1) ww = 3;
if (i == 2) ww = 4;
- if (i == 3)
- {
+ if (i == 3) {
ww = 5;
hh = 2;
}
- if (i == 4)
- {
+ if (i == 4) {
ww = 6;
hh = 3;
}
- if (i == 5)
- {
+ if (i == 5) {
ww = 7;
hh = 5;
}
- if (i == 6)
- {
+ if (i == 6) {
ww = 6;
hh = 2;
}
@@ -6539,12 +6517,12 @@ bool TileRenderer_SPU::tesselateEggInWorld(EggTile_SPU *tt, int x, int y, int z)
changed = true;
setShape(0, 0, 0, 1, 1, 1);
-// LeaveCriticalSection( &Tile_SPU::m_csShape );
+ // LeaveCriticalSection( &Tile_SPU::m_csShape );
return changed;
}
-bool TileRenderer_SPU::tesselateFenceGateInWorld(FenceGateTile_SPU *tt, int x, int y, int z)
-{
+bool TileRenderer_SPU::tesselateFenceGateInWorld(FenceGateTile_SPU* tt, int x,
+ int y, int z) {
bool changed = true;
#ifdef DISABLE_TESS_FUNCS
@@ -6559,25 +6537,28 @@ bool TileRenderer_SPU::tesselateFenceGateInWorld(FenceGateTile_SPU *tt, int x, i
float h20 = 5 / 16.0f;
float h21 = 16 / 16.0f;
- //if (((direction == Direction::NORTH || direction == Direction::SOUTH) && level->getTile(x - 1, y, z) == Tile_SPU::cobbleWall_Id && level->getTile(x + 1, y, z) == Tile_SPU::cobbleWall_Id)
- // || ((direction == Direction::EAST || direction == Direction::WEST) && level->getTile(x, y, z - 1) == Tile_SPU::cobbleWall_Id && level->getTile(x, y, z + 1) == Tile_SPU::cobbleWall_Id))
- //{
- // h00 -= 3.0f / 16.0f;
- // h01 -= 3.0f / 16.0f;
- // h10 -= 3.0f / 16.0f;
- // h11 -= 3.0f / 16.0f;
- // h20 -= 3.0f / 16.0f;
- // h21 -= 3.0f / 16.0f;
- //}
+ // if (((direction == Direction::NORTH || direction == Direction::SOUTH) &&
+ // level->getTile(x - 1, y, z) == Tile_SPU::cobbleWall_Id &&
+ // level->getTile(x + 1, y, z) == Tile_SPU::cobbleWall_Id)
+ // || ((direction == Direction::EAST || direction == Direction::WEST) &&
+ // level->getTile(x, y, z - 1) == Tile_SPU::cobbleWall_Id &&
+ // level->getTile(x, y, z + 1) == Tile_SPU::cobbleWall_Id))
+ //{
+ // h00 -= 3.0f / 16.0f;
+ // h01 -= 3.0f / 16.0f;
+ // h10 -= 3.0f / 16.0f;
+ // h11 -= 3.0f / 16.0f;
+ // h20 -= 3.0f / 16.0f;
+ // h21 -= 3.0f / 16.0f;
+ // }
- noCulling = true;
+ noCulling = true;
-// EnterCriticalSection( &Tile_SPU::m_csShape );
+ // EnterCriticalSection( &Tile_SPU::m_csShape );
// edge sticks
- if (direction == Direction::EAST || direction == Direction::WEST)
- {
- upFlip = FLIP_CW;
+ if (direction == Direction::EAST || direction == Direction::WEST) {
+ upFlip = FLIP_CW;
float x0 = 7 / 16.0f;
float x1 = 9 / 16.0f;
float z0 = 0 / 16.0f;
@@ -6589,10 +6570,8 @@ bool TileRenderer_SPU::tesselateFenceGateInWorld(FenceGateTile_SPU *tt, int x, i
z1 = 16 / 16.0f;
setShape(x0, h20, z0, x1, h21, z1);
tesselateBlockInWorld(tt, x, y, z);
- upFlip = FLIP_NONE;
- }
- else
- {
+ upFlip = FLIP_NONE;
+ } else {
float x0 = 0 / 16.0f;
float x1 = 2 / 16.0f;
float z0 = 7 / 16.0f;
@@ -6605,1031 +6584,1009 @@ bool TileRenderer_SPU::tesselateFenceGateInWorld(FenceGateTile_SPU *tt, int x, i
setShape(x0, h20, z0, x1, h21, z1);
tesselateBlockInWorld(tt, x, y, z);
}
- if (isOpen)
- {
- if (direction == Direction::NORTH || direction == Direction::SOUTH)
- {
- upFlip = FLIP_CW;
- }
- if (direction == Direction::EAST)
- {
+ if (isOpen) {
+ if (direction == Direction::NORTH || direction == Direction::SOUTH) {
+ upFlip = FLIP_CW;
+ }
+ if (direction == Direction::EAST) {
+ const float z00 = 0 / 16.0f;
+ const float z01 = 2 / 16.0f;
+ const float z10 = 14 / 16.0f;
+ const float z11 = 16 / 16.0f;
- const float z00 = 0 / 16.0f;
- const float z01 = 2 / 16.0f;
- const float z10 = 14 / 16.0f;
- const float z11 = 16 / 16.0f;
+ const float x0 = 9 / 16.0f;
+ const float x1 = 13 / 16.0f;
+ const float x2 = 15 / 16.0f;
- const float x0 = 9 / 16.0f;
- const float x1 = 13 / 16.0f;
- const float x2 = 15 / 16.0f;
+ setShape(x1, h00, z00, x2, h11, z01);
+ tesselateBlockInWorld(tt, x, y, z);
+ setShape(x1, h00, z10, x2, h11, z11);
+ tesselateBlockInWorld(tt, x, y, z);
- setShape(x1, h00, z00, x2, h11, z01);
- tesselateBlockInWorld(tt, x, y, z);
- setShape(x1, h00, z10, x2, h11, z11);
- tesselateBlockInWorld(tt, x, y, z);
+ setShape(x0, h00, z00, x1, h01, z01);
+ tesselateBlockInWorld(tt, x, y, z);
+ setShape(x0, h00, z10, x1, h01, z11);
+ tesselateBlockInWorld(tt, x, y, z);
- setShape(x0, h00, z00, x1, h01, z01);
- tesselateBlockInWorld(tt, x, y, z);
- setShape(x0, h00, z10, x1, h01, z11);
- tesselateBlockInWorld(tt, x, y, z);
+ setShape(x0, h10, z00, x1, h11, z01);
+ tesselateBlockInWorld(tt, x, y, z);
+ setShape(x0, h10, z10, x1, h11, z11);
+ tesselateBlockInWorld(tt, x, y, z);
+ } else if (direction == Direction::WEST) {
+ const float z00 = 0 / 16.0f;
+ const float z01 = 2 / 16.0f;
+ const float z10 = 14 / 16.0f;
+ const float z11 = 16 / 16.0f;
- setShape(x0, h10, z00, x1, h11, z01);
- tesselateBlockInWorld(tt, x, y, z);
- setShape(x0, h10, z10, x1, h11, z11);
- tesselateBlockInWorld(tt, x, y, z);
- }
- else if (direction == Direction::WEST)
- {
- const float z00 = 0 / 16.0f;
- const float z01 = 2 / 16.0f;
- const float z10 = 14 / 16.0f;
- const float z11 = 16 / 16.0f;
+ const float x0 = 1 / 16.0f;
+ const float x1 = 3 / 16.0f;
+ const float x2 = 7 / 16.0f;
- const float x0 = 1 / 16.0f;
- const float x1 = 3 / 16.0f;
- const float x2 = 7 / 16.0f;
+ setShape(x0, h00, z00, x1, h11, z01);
+ tesselateBlockInWorld(tt, x, y, z);
+ setShape(x0, h00, z10, x1, h11, z11);
+ tesselateBlockInWorld(tt, x, y, z);
- setShape(x0, h00, z00, x1, h11, z01);
- tesselateBlockInWorld(tt, x, y, z);
- setShape(x0, h00, z10, x1, h11, z11);
- tesselateBlockInWorld(tt, x, y, z);
+ setShape(x1, h00, z00, x2, h01, z01);
+ tesselateBlockInWorld(tt, x, y, z);
+ setShape(x1, h00, z10, x2, h01, z11);
+ tesselateBlockInWorld(tt, x, y, z);
- setShape(x1, h00, z00, x2, h01, z01);
- tesselateBlockInWorld(tt, x, y, z);
- setShape(x1, h00, z10, x2, h01, z11);
- tesselateBlockInWorld(tt, x, y, z);
+ setShape(x1, h10, z00, x2, h11, z01);
+ tesselateBlockInWorld(tt, x, y, z);
+ setShape(x1, h10, z10, x2, h11, z11);
+ tesselateBlockInWorld(tt, x, y, z);
+ } else if (direction == Direction::SOUTH) {
+ const float x00 = 0 / 16.0f;
+ const float x01 = 2 / 16.0f;
+ const float x10 = 14 / 16.0f;
+ const float x11 = 16 / 16.0f;
- setShape(x1, h10, z00, x2, h11, z01);
- tesselateBlockInWorld(tt, x, y, z);
- setShape(x1, h10, z10, x2, h11, z11);
- tesselateBlockInWorld(tt, x, y, z);
- }
- else if (direction == Direction::SOUTH)
- {
+ const float z0 = 9 / 16.0f;
+ const float z1 = 13 / 16.0f;
+ const float z2 = 15 / 16.0f;
- const float x00 = 0 / 16.0f;
- const float x01 = 2 / 16.0f;
- const float x10 = 14 / 16.0f;
- const float x11 = 16 / 16.0f;
+ setShape(x00, h00, z1, x01, h11, z2);
+ tesselateBlockInWorld(tt, x, y, z);
+ setShape(x10, h00, z1, x11, h11, z2);
+ tesselateBlockInWorld(tt, x, y, z);
- const float z0 = 9 / 16.0f;
- const float z1 = 13 / 16.0f;
- const float z2 = 15 / 16.0f;
+ setShape(x00, h00, z0, x01, h01, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ setShape(x10, h00, z0, x11, h01, z1);
+ tesselateBlockInWorld(tt, x, y, z);
- setShape(x00, h00, z1, x01, h11, z2);
- tesselateBlockInWorld(tt, x, y, z);
- setShape(x10, h00, z1, x11, h11, z2);
- tesselateBlockInWorld(tt, x, y, z);
+ setShape(x00, h10, z0, x01, h11, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ setShape(x10, h10, z0, x11, h11, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ } else if (direction == Direction::NORTH) {
+ const float x00 = 0 / 16.0f;
+ const float x01 = 2 / 16.0f;
+ const float x10 = 14 / 16.0f;
+ const float x11 = 16 / 16.0f;
- setShape(x00, h00, z0, x01, h01, z1);
- tesselateBlockInWorld(tt, x, y, z);
- setShape(x10, h00, z0, x11, h01, z1);
- tesselateBlockInWorld(tt, x, y, z);
+ const float z0 = 1 / 16.0f;
+ const float z1 = 3 / 16.0f;
+ const float z2 = 7 / 16.0f;
- setShape(x00, h10, z0, x01, h11, z1);
- tesselateBlockInWorld(tt, x, y, z);
- setShape(x10, h10, z0, x11, h11, z1);
- tesselateBlockInWorld(tt, x, y, z);
- }
- else if (direction == Direction::NORTH)
- {
- const float x00 = 0 / 16.0f;
- const float x01 = 2 / 16.0f;
- const float x10 = 14 / 16.0f;
- const float x11 = 16 / 16.0f;
+ setShape(x00, h00, z0, x01, h11, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ setShape(x10, h00, z0, x11, h11, z1);
+ tesselateBlockInWorld(tt, x, y, z);
- const float z0 = 1 / 16.0f;
- const float z1 = 3 / 16.0f;
- const float z2 = 7 / 16.0f;
+ setShape(x00, h00, z1, x01, h01, z2);
+ tesselateBlockInWorld(tt, x, y, z);
+ setShape(x10, h00, z1, x11, h01, z2);
+ tesselateBlockInWorld(tt, x, y, z);
- setShape(x00, h00, z0, x01, h11, z1);
- tesselateBlockInWorld(tt, x, y, z);
- setShape(x10, h00, z0, x11, h11, z1);
- tesselateBlockInWorld(tt, x, y, z);
-
- setShape(x00, h00, z1, x01, h01, z2);
- tesselateBlockInWorld(tt, x, y, z);
- setShape(x10, h00, z1, x11, h01, z2);
- tesselateBlockInWorld(tt, x, y, z);
-
- setShape(x00, h10, z1, x01, h11, z2);
- tesselateBlockInWorld(tt, x, y, z);
- setShape(x10, h10, z1, x11, h11, z2);
- tesselateBlockInWorld(tt, x, y, z);
- }
- }
- else
- {
- if (direction == Direction::EAST || direction == Direction::WEST)
- {
- upFlip = FLIP_CW;
- float x0 = 7 / 16.0f;
- float x1 = 9 / 16.0f;
- float z0 = 6 / 16.0f;
- float z1 = 8 / 16.0f;
- setShape(x0, h00, z0, x1, h11, z1);
- tesselateBlockInWorld(tt, x, y, z);
- z0 = 8 / 16.0f;
- z1 = 10 / 16.0f;
- setShape(x0, h00, z0, x1, h11, z1);
- tesselateBlockInWorld(tt, x, y, z);
- z0 = 10 / 16.0f;
- z1 = 14 / 16.0f;
- setShape(x0, h00, z0, x1, h01, z1);
- tesselateBlockInWorld(tt, x, y, z);
- setShape(x0, h10, z0, x1, h11, z1);
- tesselateBlockInWorld(tt, x, y, z);
- z0 = 2 / 16.0f;
- z1 = 6 / 16.0f;
- setShape(x0, h00, z0, x1, h01, z1);
- tesselateBlockInWorld(tt, x, y, z);
- setShape(x0, h10, z0, x1, h11, z1);
- tesselateBlockInWorld(tt, x, y, z);
- }
- else
- {
- float x0 = 6 / 16.0f;
- float x1 = 8 / 16.0f;
- float z0 = 7 / 16.0f;
- float z1 = 9 / 16.0f;
- setShape(x0, h00, z0, x1, h11, z1);
- tesselateBlockInWorld(tt, x, y, z);
- x0 = 8 / 16.0f;
- x1 = 10 / 16.0f;
- setShape(x0, h00, z0, x1, h11, z1);
- tesselateBlockInWorld(tt, x, y, z);
- x0 = 10 / 16.0f;
- x1 = 14 / 16.0f;
- setShape(x0, h00, z0, x1, h01, z1);
- tesselateBlockInWorld(tt, x, y, z);
- setShape(x0, h10, z0, x1, h11, z1);
- tesselateBlockInWorld(tt, x, y, z);
- x0 = 2 / 16.0f;
- x1 = 6 / 16.0f;
- setShape(x0, h00, z0, x1, h01, z1);
- tesselateBlockInWorld(tt, x, y, z);
- setShape(x0, h10, z0, x1, h11, z1);
- tesselateBlockInWorld(tt, x, y, z);
-
- }
- }
- noCulling = false;
- upFlip = FLIP_NONE;
+ setShape(x00, h10, z1, x01, h11, z2);
+ tesselateBlockInWorld(tt, x, y, z);
+ setShape(x10, h10, z1, x11, h11, z2);
+ tesselateBlockInWorld(tt, x, y, z);
+ }
+ } else {
+ if (direction == Direction::EAST || direction == Direction::WEST) {
+ upFlip = FLIP_CW;
+ float x0 = 7 / 16.0f;
+ float x1 = 9 / 16.0f;
+ float z0 = 6 / 16.0f;
+ float z1 = 8 / 16.0f;
+ setShape(x0, h00, z0, x1, h11, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ z0 = 8 / 16.0f;
+ z1 = 10 / 16.0f;
+ setShape(x0, h00, z0, x1, h11, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ z0 = 10 / 16.0f;
+ z1 = 14 / 16.0f;
+ setShape(x0, h00, z0, x1, h01, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ setShape(x0, h10, z0, x1, h11, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ z0 = 2 / 16.0f;
+ z1 = 6 / 16.0f;
+ setShape(x0, h00, z0, x1, h01, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ setShape(x0, h10, z0, x1, h11, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ } else {
+ float x0 = 6 / 16.0f;
+ float x1 = 8 / 16.0f;
+ float z0 = 7 / 16.0f;
+ float z1 = 9 / 16.0f;
+ setShape(x0, h00, z0, x1, h11, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ x0 = 8 / 16.0f;
+ x1 = 10 / 16.0f;
+ setShape(x0, h00, z0, x1, h11, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ x0 = 10 / 16.0f;
+ x1 = 14 / 16.0f;
+ setShape(x0, h00, z0, x1, h01, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ setShape(x0, h10, z0, x1, h11, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ x0 = 2 / 16.0f;
+ x1 = 6 / 16.0f;
+ setShape(x0, h00, z0, x1, h01, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ setShape(x0, h10, z0, x1, h11, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ }
+ }
+ noCulling = false;
+ upFlip = FLIP_NONE;
setShape(0, 0, 0, 1, 1, 1);
// LeaveCriticalSection( &Tile_SPU::m_csShape );
-#endif // #ifdef DISABLE_TESS_FUNCS
+#endif // #ifdef DISABLE_TESS_FUNCS
return changed;
}
-bool TileRenderer_SPU::tesselateStairsInWorld( StairTile_SPU* tt, int x, int y, int z )
-{
+bool TileRenderer_SPU::tesselateStairsInWorld(StairTile_SPU* tt, int x, int y,
+ int z) {
#ifdef DISABLE_TESS_FUNCS
- // EnterCriticalSection( &Tile_SPU::m_csShape );
- tt->setBaseShape(level, x, y, z);
- setShape(tt);
- tesselateBlockInWorld(tt, x, y, z);
+ // EnterCriticalSection( &Tile_SPU::m_csShape );
+ tt->setBaseShape(level, x, y, z);
+ setShape(tt);
+ tesselateBlockInWorld(tt, x, y, z);
- bool checkInnerPiece = tt->setStepShape(level, x, y, z);
- setShape(tt);
- tesselateBlockInWorld(tt, x, y, z);
+ bool checkInnerPiece = tt->setStepShape(level, x, y, z);
+ setShape(tt);
+ tesselateBlockInWorld(tt, x, y, z);
- if (checkInnerPiece)
- {
- if (tt->setInnerPieceShape(level, x, y, z))
- {
- setShape(tt);
- tesselateBlockInWorld(tt, x, y, z);
- }
- }
+ if (checkInnerPiece) {
+ if (tt->setInnerPieceShape(level, x, y, z)) {
+ setShape(tt);
+ tesselateBlockInWorld(tt, x, y, z);
+ }
+ }
// LeaveCriticalSection( &Tile_SPU::m_csShape );
-#endif // #ifdef DISABLE_TESS_FUNCS
- return true;
+#endif // #ifdef DISABLE_TESS_FUNCS
+ return true;
}
-bool TileRenderer_SPU::tesselateDoorInWorld( Tile_SPU* tt, int x, int y, int z )
-{
- Tesselator_SPU* t = getTesselator();
+bool TileRenderer_SPU::tesselateDoorInWorld(Tile_SPU* tt, int x, int y, int z) {
+ Tesselator_SPU* t = getTesselator();
- // skip rendering if the other half of the door is missing,
- // to avoid rendering doors that are about to be removed
- int data = level->getData(x, y, z);
- if ((data & DoorTile_SPU::UPPER_BIT) != 0)
- {
- if (level->getTile(x, y - 1, z) != tt->id)
- {
- return false;
- }
- }
- else {
- if (level->getTile(x, y + 1, z) != tt->id)
- {
- return false;
- }
- }
+ // skip rendering if the other half of the door is missing,
+ // to avoid rendering doors that are about to be removed
+ int data = level->getData(x, y, z);
+ if ((data & DoorTile_SPU::UPPER_BIT) != 0) {
+ if (level->getTile(x, y - 1, z) != tt->id) {
+ return false;
+ }
+ } else {
+ if (level->getTile(x, y + 1, z) != tt->id) {
+ return false;
+ }
+ }
- bool changed = false;
- float c10 = 0.5f;
- float c11 = 1;
- float c2 = 0.8f;
- float c3 = 0.6f;
+ bool changed = false;
+ float c10 = 0.5f;
+ float c11 = 1;
+ float c2 = 0.8f;
+ float c3 = 0.6f;
- int centerColor = 0;
- float centerBrightness = 0.0f;
+ int centerColor = 0;
+ float centerBrightness = 0.0f;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- centerColor = tt->getLightColor( level, x, y, z );
- }
- else
- {
- centerBrightness = tt->getBrightness( level, x, y, z );
- }
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ centerColor = tt->getLightColor(level, x, y, z);
+ } else {
+ centerBrightness = tt->getBrightness(level, x, y, z);
+ }
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeY0 > 0 ? centerColor
+ : tt->getLightColor(level, x, y - 1, z));
+ t->color(c10, c10, c10);
+ } else {
+ float br = tt->getBrightness(level, x, y - 1, z);
+ if (tileShapeY0 > 0) br = centerBrightness;
+ if (level->m_tileData.lightEmission[tt->id] > 0) br = 1.0f;
+ t->color(c10 * br, c10 * br, c10 * br);
+ }
+ renderFaceDown(tt, x, y, z, getTexture(tt, level, x, y, z, 0));
+ changed = true;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeY0 > 0 ? centerColor : tt->getLightColor( level, x, y - 1, z ) );
- t->color( c10, c10, c10 );
- }
- else
- {
- float br = tt->getBrightness( level, x, y - 1, z );
- if ( tileShapeY0 > 0 ) br = centerBrightness;
- if (level->m_tileData.lightEmission[tt->id] > 0 ) br = 1.0f;
- t->color( c10 * br, c10 * br, c10 * br );
- }
- renderFaceDown( tt, x, y, z, getTexture(tt, level, x, y, z, 0 ) );
- changed = true;
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeY1 < 1 ? centerColor
+ : tt->getLightColor(level, x, y + 1, z));
+ t->color(c11, c11, c11);
+ } else {
+ float br = tt->getBrightness(level, x, y + 1, z);
+ if (tileShapeY1 < 1) br = centerBrightness;
+ if (level->m_tileData.lightEmission[tt->id] > 0) br = 1.0f;
+ t->color(c11 * br, c11 * br, c11 * br);
+ }
+ renderFaceUp(tt, x, y, z, getTexture(tt, level, x, y, z, 1));
+ changed = true;
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeY1 < 1 ? centerColor : tt->getLightColor( level, x, y + 1, z ) );
- t->color( c11, c11, c11 );
- }
- else
- {
- float br = tt->getBrightness( level, x, y + 1, z );
- if ( tileShapeY1 < 1 ) br = centerBrightness;
- if ( level->m_tileData.lightEmission[tt->id] > 0 ) br = 1.0f;
- t->color( c11 * br, c11 * br, c11 * br );
- }
- renderFaceUp( tt, x, y, z, getTexture(tt, level, x, y, z, 1 ) );
- changed = true;
-
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeZ0 > 0 ? centerColor : tt->getLightColor( level, x, y, z - 1 ) );
- t->color( c2, c2, c2 );
- }
- else
- {
- float br = tt->getBrightness( level, x, y, z - 1 );
- if ( tileShapeZ0 > 0 ) br = centerBrightness;
- if ( level->m_tileData.lightEmission[tt->id] > 0 ) br = 1.0f;
- t->color( c2 * br, c2 * br, c2 * br );
- }
- Icon_SPU *tex = getTexture(tt, level, x, y, z, 2 );
- renderNorth( tt, x, y, z, tex );
- changed = true;
- xFlipTexture = false;
- }
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeZ1 < 1 ? centerColor : tt->getLightColor( level, x, y, z + 1 ) );
- t->color( c2, c2, c2 );
- }
- else
- {
- float br = tt->getBrightness( level, x, y, z + 1 );
- if ( tileShapeZ1 < 1 ) br = centerBrightness;
- if ( level->m_tileData.lightEmission[tt->id] > 0 ) br = 1.0f;
- t->color( c2 * br, c2 * br, c2 * br );
- }
- Icon_SPU *tex = getTexture( tt, level, x, y, z, 3 );
- renderSouth( tt, x, y, z, tex );
- changed = true;
- xFlipTexture = false;
- }
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeX0 > 0 ? centerColor : tt->getLightColor( level, x - 1, y, z ) );
- t->color( c3, c3, c3 );
- }
- else
- {
- float br = tt->getBrightness( level, x - 1, y, z );
- if ( tileShapeX0 > 0 ) br = centerBrightness;
- if ( level->m_tileData.lightEmission[tt->id] > 0 ) br = 1.0f;
- t->color( c3 * br, c3 * br, c3 * br );
- }
- Icon_SPU *tex = getTexture(tt, level, x, y, z, 4 );
- renderWest( tt, x, y, z, tex );
- changed = true;
- xFlipTexture = false;
- }
- {
- if ( SharedConstants::TEXTURE_LIGHTING )
- {
- t->tex2( tileShapeX1 < 1 ? centerColor : tt->getLightColor( level, x + 1, y, z ) );
- t->color( c3, c3, c3 );
- }
- else
- {
- float br = tt->getBrightness( level, x + 1, y, z );
- if ( tileShapeX1 < 1 ) br = centerBrightness;
- if ( level->m_tileData.lightEmission[tt->id] > 0 ) br = 1.0f;
- t->color( c3 * br, c3 * br, c3 * br );
- }
- Icon_SPU *tex = getTexture(tt, level, x, y, z, 5 );
- renderEast( tt, x, y, z, tex );
- changed = true;
- xFlipTexture = false;
- }
- return changed;
+ {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeZ0 > 0 ? centerColor
+ : tt->getLightColor(level, x, y, z - 1));
+ t->color(c2, c2, c2);
+ } else {
+ float br = tt->getBrightness(level, x, y, z - 1);
+ if (tileShapeZ0 > 0) br = centerBrightness;
+ if (level->m_tileData.lightEmission[tt->id] > 0) br = 1.0f;
+ t->color(c2 * br, c2 * br, c2 * br);
+ }
+ Icon_SPU* tex = getTexture(tt, level, x, y, z, 2);
+ renderNorth(tt, x, y, z, tex);
+ changed = true;
+ xFlipTexture = false;
+ }
+ {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeZ1 < 1 ? centerColor
+ : tt->getLightColor(level, x, y, z + 1));
+ t->color(c2, c2, c2);
+ } else {
+ float br = tt->getBrightness(level, x, y, z + 1);
+ if (tileShapeZ1 < 1) br = centerBrightness;
+ if (level->m_tileData.lightEmission[tt->id] > 0) br = 1.0f;
+ t->color(c2 * br, c2 * br, c2 * br);
+ }
+ Icon_SPU* tex = getTexture(tt, level, x, y, z, 3);
+ renderSouth(tt, x, y, z, tex);
+ changed = true;
+ xFlipTexture = false;
+ }
+ {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeX0 > 0 ? centerColor
+ : tt->getLightColor(level, x - 1, y, z));
+ t->color(c3, c3, c3);
+ } else {
+ float br = tt->getBrightness(level, x - 1, y, z);
+ if (tileShapeX0 > 0) br = centerBrightness;
+ if (level->m_tileData.lightEmission[tt->id] > 0) br = 1.0f;
+ t->color(c3 * br, c3 * br, c3 * br);
+ }
+ Icon_SPU* tex = getTexture(tt, level, x, y, z, 4);
+ renderWest(tt, x, y, z, tex);
+ changed = true;
+ xFlipTexture = false;
+ }
+ {
+ if (SharedConstants::TEXTURE_LIGHTING) {
+ t->tex2(tileShapeX1 < 1 ? centerColor
+ : tt->getLightColor(level, x + 1, y, z));
+ t->color(c3, c3, c3);
+ } else {
+ float br = tt->getBrightness(level, x + 1, y, z);
+ if (tileShapeX1 < 1) br = centerBrightness;
+ if (level->m_tileData.lightEmission[tt->id] > 0) br = 1.0f;
+ t->color(c3 * br, c3 * br, c3 * br);
+ }
+ Icon_SPU* tex = getTexture(tt, level, x, y, z, 5);
+ renderEast(tt, x, y, z, tex);
+ changed = true;
+ xFlipTexture = false;
+ }
+ return changed;
}
-void TileRenderer_SPU::renderFaceDown( Tile_SPU* tt, float x, float y, float z, Icon_SPU *tex )
-{
- Tesselator_SPU* t = getTesselator();
+void TileRenderer_SPU::renderFaceDown(Tile_SPU* tt, float x, float y, float z,
+ Icon_SPU* tex) {
+ Tesselator_SPU* t = getTesselator();
- if (hasFixedTexture()) tex = fixedTexture;
- float u00 = tex->getU(tileShapeX0 * 16.0f);
- float u11 = tex->getU(tileShapeX1 * 16.0f);
- float v00 = tex->getV(tileShapeZ0 * 16.0f);
- float v11 = tex->getV(tileShapeZ1 * 16.0f);
+ if (hasFixedTexture()) tex = fixedTexture;
+ float u00 = tex->getU(tileShapeX0 * 16.0f);
+ float u11 = tex->getU(tileShapeX1 * 16.0f);
+ float v00 = tex->getV(tileShapeZ0 * 16.0f);
+ float v11 = tex->getV(tileShapeZ1 * 16.0f);
- if ( tileShapeX0 < 0 || tileShapeX1 > 1 )
- {
- u00 = tex->getU0();
- u11 = tex->getU1();
- }
- if ( tileShapeZ0 < 0 || tileShapeZ1 > 1 )
- {
- v00 = tex->getV0();
- v11 = tex->getV1();
- }
+ if (tileShapeX0 < 0 || tileShapeX1 > 1) {
+ u00 = tex->getU0();
+ u11 = tex->getU1();
+ }
+ if (tileShapeZ0 < 0 || tileShapeZ1 > 1) {
+ v00 = tex->getV0();
+ v11 = tex->getV1();
+ }
- float u01 = u11, u10 = u00, v01 = v00, v10 = v11;
- if ( downFlip == FLIP_CCW )
- {
- u00 = tex->getU(tileShapeZ0 * 16.0f);
- v00 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeX1 * 16.0f);
- u11 = tex->getU(tileShapeZ1 * 16.0f);
- v11 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeX0 * 16.0f);
+ float u01 = u11, u10 = u00, v01 = v00, v10 = v11;
+ if (downFlip == FLIP_CCW) {
+ u00 = tex->getU(tileShapeZ0 * 16.0f);
+ v00 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeX1 * 16.0f);
+ u11 = tex->getU(tileShapeZ1 * 16.0f);
+ v11 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeX0 * 16.0f);
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- u01 = u00;
- u10 = u11;
- v00 = v11;
- v11 = v01;
- }
- else if ( downFlip == FLIP_CW )
- {
- // reshape
- u00 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeZ1 * 16.0f);
- v00 = tex->getV(tileShapeX0 * 16.0f);
- u11 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeZ0 * 16.0f);
- v11 = tex->getV(tileShapeX1 * 16.0f);
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ u01 = u00;
+ u10 = u11;
+ v00 = v11;
+ v11 = v01;
+ } else if (downFlip == FLIP_CW) {
+ // reshape
+ u00 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeZ1 * 16.0f);
+ v00 = tex->getV(tileShapeX0 * 16.0f);
+ u11 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeZ0 * 16.0f);
+ v11 = tex->getV(tileShapeX1 * 16.0f);
- // rotate
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- u00 = u01;
- u11 = u10;
- v01 = v11;
- v10 = v00;
- }
- else if ( downFlip == FLIP_180 )
- {
- u00 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeX0 * 16.0f);
- u11 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeX1 * 16.0f);
- v00 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeZ0 * 16.0f);
- v11 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeZ1 * 16.0f);
+ // rotate
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ u00 = u01;
+ u11 = u10;
+ v01 = v11;
+ v10 = v00;
+ } else if (downFlip == FLIP_180) {
+ u00 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeX0 * 16.0f);
+ u11 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeX1 * 16.0f);
+ v00 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeZ0 * 16.0f);
+ v11 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeZ1 * 16.0f);
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- }
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ }
- float x0 = x + tileShapeX0;
- float x1 = x + tileShapeX1;
- float y0 = y + tileShapeY0;
- float z0 = z + tileShapeZ0;
- float z1 = z + tileShapeZ1;
+ float x0 = x + tileShapeX0;
+ float x1 = x + tileShapeX1;
+ float y0 = y + tileShapeY0;
+ float z0 = z + tileShapeZ0;
+ float z1 = z + tileShapeZ1;
- if ( applyAmbienceOcclusion )
- {
- t->color( c1r, c1g, c1b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc1 );
- t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z1 ), ( float )( u10 ), ( float )( v10 ) );
- t->color( c2r, c2g, c2b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc2 );
- t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z0 ), ( float )( u00 ), ( float )( v00 ) );
- t->color( c3r, c3g, c3b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc3 );
- t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z0 ), ( float )( u01 ), ( float )( v01 ) );
- t->color( c4r, c4g, c4b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc4 );
- t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z1 ), ( float )( u11 ), ( float )( v11 ) );
- }
- else
- {
- t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z1 ), ( float )( u10 ), ( float )( v10 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z0 ), ( float )( u00 ), ( float )( v00 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z0 ), ( float )( u01 ), ( float )( v01 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z1 ), ( float )( u11 ), ( float )( v11 ) );
- }
+ if (applyAmbienceOcclusion) {
+ t->color(c1r, c1g, c1b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc1);
+ t->vertexUV((float)(x0), (float)(y0), (float)(z1), (float)(u10),
+ (float)(v10));
+ t->color(c2r, c2g, c2b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc2);
+ t->vertexUV((float)(x0), (float)(y0), (float)(z0), (float)(u00),
+ (float)(v00));
+ t->color(c3r, c3g, c3b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc3);
+ t->vertexUV((float)(x1), (float)(y0), (float)(z0), (float)(u01),
+ (float)(v01));
+ t->color(c4r, c4g, c4b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc4);
+ t->vertexUV((float)(x1), (float)(y0), (float)(z1), (float)(u11),
+ (float)(v11));
+ } else {
+ t->vertexUV((float)(x0), (float)(y0), (float)(z1), (float)(u10),
+ (float)(v10));
+ t->vertexUV((float)(x0), (float)(y0), (float)(z0), (float)(u00),
+ (float)(v00));
+ t->vertexUV((float)(x1), (float)(y0), (float)(z0), (float)(u01),
+ (float)(v01));
+ t->vertexUV((float)(x1), (float)(y0), (float)(z1), (float)(u11),
+ (float)(v11));
+ }
}
-void TileRenderer_SPU::renderFaceUp( Tile_SPU* tt, float x, float y, float z, Icon_SPU *tex )
-{
- Tesselator_SPU* t = getTesselator();
+void TileRenderer_SPU::renderFaceUp(Tile_SPU* tt, float x, float y, float z,
+ Icon_SPU* tex) {
+ Tesselator_SPU* t = getTesselator();
- if (hasFixedTexture()) tex = fixedTexture;
- float u00 = tex->getU(tileShapeX0 * 16.0f);
- float u11 = tex->getU(tileShapeX1 * 16.0f);
- float v00 = tex->getV(tileShapeZ0 * 16.0f);
- float v11 = tex->getV(tileShapeZ1 * 16.0f);
+ if (hasFixedTexture()) tex = fixedTexture;
+ float u00 = tex->getU(tileShapeX0 * 16.0f);
+ float u11 = tex->getU(tileShapeX1 * 16.0f);
+ float v00 = tex->getV(tileShapeZ0 * 16.0f);
+ float v11 = tex->getV(tileShapeZ1 * 16.0f);
- if ( tileShapeX0 < 0 || tileShapeX1 > 1 )
- {
- u00 = tex->getU0();
- u11 = tex->getU1();
- }
- if ( tileShapeZ0 < 0 || tileShapeZ1 > 1 )
- {
- v00 = tex->getV0();
- v11 = tex->getV1();
- }
+ if (tileShapeX0 < 0 || tileShapeX1 > 1) {
+ u00 = tex->getU0();
+ u11 = tex->getU1();
+ }
+ if (tileShapeZ0 < 0 || tileShapeZ1 > 1) {
+ v00 = tex->getV0();
+ v11 = tex->getV1();
+ }
- float u01 = u11, u10 = u00, v01 = v00, v10 = v11;
+ float u01 = u11, u10 = u00, v01 = v00, v10 = v11;
- if ( upFlip == FLIP_CW )
- {
- u00 = tex->getU(tileShapeZ0 * 16.0f);
- v00 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeX1 * 16.0f);
- u11 = tex->getU(tileShapeZ1 * 16.0f);
- v11 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeX0 * 16.0f);
+ if (upFlip == FLIP_CW) {
+ u00 = tex->getU(tileShapeZ0 * 16.0f);
+ v00 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeX1 * 16.0f);
+ u11 = tex->getU(tileShapeZ1 * 16.0f);
+ v11 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeX0 * 16.0f);
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- u01 = u00;
- u10 = u11;
- v00 = v11;
- v11 = v01;
- }
- else if ( upFlip == FLIP_CCW )
- {
- // reshape
- u00 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeZ1 * 16.0f);
- v00 = tex->getV(tileShapeX0 * 16.0f);
- u11 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeZ0 * 16.0f);
- v11 = tex->getV(tileShapeX1 * 16.0f);
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ u01 = u00;
+ u10 = u11;
+ v00 = v11;
+ v11 = v01;
+ } else if (upFlip == FLIP_CCW) {
+ // reshape
+ u00 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeZ1 * 16.0f);
+ v00 = tex->getV(tileShapeX0 * 16.0f);
+ u11 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeZ0 * 16.0f);
+ v11 = tex->getV(tileShapeX1 * 16.0f);
- // rotate
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- u00 = u01;
- u11 = u10;
- v01 = v11;
- v10 = v00;
- }
- else if ( upFlip == FLIP_180 )
- {
- u00 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeX0 * 16.0f);
- u11 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeX1 * 16.0f);
- v00 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeZ0 * 16.0f);
- v11 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeZ1 * 16.0f);
+ // rotate
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ u00 = u01;
+ u11 = u10;
+ v01 = v11;
+ v10 = v00;
+ } else if (upFlip == FLIP_180) {
+ u00 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeX0 * 16.0f);
+ u11 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeX1 * 16.0f);
+ v00 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeZ0 * 16.0f);
+ v11 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeZ1 * 16.0f);
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- }
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ }
+ float x0 = x + tileShapeX0;
+ float x1 = x + tileShapeX1;
+ float y1 = y + tileShapeY1;
+ float z0 = z + tileShapeZ0;
+ float z1 = z + tileShapeZ1;
- float x0 = x + tileShapeX0;
- float x1 = x + tileShapeX1;
- float y1 = y + tileShapeY1;
- float z0 = z + tileShapeZ0;
- float z1 = z + tileShapeZ1;
-
- if ( applyAmbienceOcclusion )
- {
- t->color( c1r, c1g, c1b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc1 );
- t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z1 ), ( float )( u11 ), ( float )( v11 ) );
- t->color( c2r, c2g, c2b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc2 );
- t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z0 ), ( float )( u01 ), ( float )( v01 ) );
- t->color( c3r, c3g, c3b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc3 );
- t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z0 ), ( float )( u00 ), ( float )( v00 ) );
- t->color( c4r, c4g, c4b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc4 );
- t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z1 ), ( float )( u10 ), ( float )( v10 ) );
- }
- else
- {
- t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z1 ), ( float )( u11 ), ( float )( v11 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z0 ), ( float )( u01 ), ( float )( v01 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z0 ), ( float )( u00 ), ( float )( v00 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z1 ), ( float )( u10 ), ( float )( v10 ) );
- }
-
+ if (applyAmbienceOcclusion) {
+ t->color(c1r, c1g, c1b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc1);
+ t->vertexUV((float)(x1), (float)(y1), (float)(z1), (float)(u11),
+ (float)(v11));
+ t->color(c2r, c2g, c2b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc2);
+ t->vertexUV((float)(x1), (float)(y1), (float)(z0), (float)(u01),
+ (float)(v01));
+ t->color(c3r, c3g, c3b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc3);
+ t->vertexUV((float)(x0), (float)(y1), (float)(z0), (float)(u00),
+ (float)(v00));
+ t->color(c4r, c4g, c4b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc4);
+ t->vertexUV((float)(x0), (float)(y1), (float)(z1), (float)(u10),
+ (float)(v10));
+ } else {
+ t->vertexUV((float)(x1), (float)(y1), (float)(z1), (float)(u11),
+ (float)(v11));
+ t->vertexUV((float)(x1), (float)(y1), (float)(z0), (float)(u01),
+ (float)(v01));
+ t->vertexUV((float)(x0), (float)(y1), (float)(z0), (float)(u00),
+ (float)(v00));
+ t->vertexUV((float)(x0), (float)(y1), (float)(z1), (float)(u10),
+ (float)(v10));
+ }
}
-void TileRenderer_SPU::renderNorth( Tile_SPU* tt, float x, float y, float z, Icon_SPU *tex )
-{
- Tesselator_SPU* t = getTesselator();
+void TileRenderer_SPU::renderNorth(Tile_SPU* tt, float x, float y, float z,
+ Icon_SPU* tex) {
+ Tesselator_SPU* t = getTesselator();
- if (hasFixedTexture()) tex = fixedTexture;
- float u00 = tex->getU(tileShapeX0 * 16.0f);
- float u11 = tex->getU(tileShapeX1 * 16.0f);
- float v00 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeY1 * 16.0f);
- float v11 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeY0 * 16.0f);
- if ( xFlipTexture )
- {
- float tmp = u00;
- u00 = u11;
- u11 = tmp;
- }
+ if (hasFixedTexture()) tex = fixedTexture;
+ float u00 = tex->getU(tileShapeX0 * 16.0f);
+ float u11 = tex->getU(tileShapeX1 * 16.0f);
+ float v00 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeY1 * 16.0f);
+ float v11 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeY0 * 16.0f);
+ if (xFlipTexture) {
+ float tmp = u00;
+ u00 = u11;
+ u11 = tmp;
+ }
- if ( tileShapeX0 < 0 || tileShapeX1 > 1 )
- {
- u00 = tex->getU0();
- u11 = tex->getU1();
- }
- if ( tileShapeY0 < 0 || tileShapeY1 > 1 )
- {
- v00 = tex->getV0();
- v11 = tex->getV1();
- }
+ if (tileShapeX0 < 0 || tileShapeX1 > 1) {
+ u00 = tex->getU0();
+ u11 = tex->getU1();
+ }
+ if (tileShapeY0 < 0 || tileShapeY1 > 1) {
+ v00 = tex->getV0();
+ v11 = tex->getV1();
+ }
- float u01 = u11, u10 = u00, v01 = v00, v10 = v11;
+ float u01 = u11, u10 = u00, v01 = v00, v10 = v11;
- if ( northFlip == FLIP_CCW )
- {
- u00 = tex->getU(tileShapeY0 * 16.0f);
- v00 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeX0 * 16.0f);
- u11 = tex->getU(tileShapeY1 * 16.0f);
- v11 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeX1 * 16.0f);
+ if (northFlip == FLIP_CCW) {
+ u00 = tex->getU(tileShapeY0 * 16.0f);
+ v00 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeX0 * 16.0f);
+ u11 = tex->getU(tileShapeY1 * 16.0f);
+ v11 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeX1 * 16.0f);
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- u01 = u00;
- u10 = u11;
- v00 = v11;
- v11 = v01;
- }
- else if ( northFlip == FLIP_CW )
- {
- // reshape
- u00 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeY1 * 16.0f);
- v00 = tex->getV(tileShapeX1 * 16.0f);
- u11 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeY0 * 16.0f);
- v11 = tex->getV(tileShapeX0 * 16.0f);
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ u01 = u00;
+ u10 = u11;
+ v00 = v11;
+ v11 = v01;
+ } else if (northFlip == FLIP_CW) {
+ // reshape
+ u00 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeY1 * 16.0f);
+ v00 = tex->getV(tileShapeX1 * 16.0f);
+ u11 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeY0 * 16.0f);
+ v11 = tex->getV(tileShapeX0 * 16.0f);
- // rotate
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- u00 = u01;
- u11 = u10;
- v01 = v11;
- v10 = v00;
- }
- else if ( northFlip == FLIP_180 )
- {
- u00 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeX0 * 16.0f);
- u11 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeX1 * 16.0f);
- v00 = tex->getV(tileShapeY1 * 16.0f);
- v11 = tex->getV(tileShapeY0 * 16.0f);
+ // rotate
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ u00 = u01;
+ u11 = u10;
+ v01 = v11;
+ v10 = v00;
+ } else if (northFlip == FLIP_180) {
+ u00 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeX0 * 16.0f);
+ u11 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeX1 * 16.0f);
+ v00 = tex->getV(tileShapeY1 * 16.0f);
+ v11 = tex->getV(tileShapeY0 * 16.0f);
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- }
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ }
+ float x0 = x + tileShapeX0;
+ float x1 = x + tileShapeX1;
+ float y0 = y + tileShapeY0;
+ float y1 = y + tileShapeY1;
+ float z0 = z + tileShapeZ0;
- float x0 = x + tileShapeX0;
- float x1 = x + tileShapeX1;
- float y0 = y + tileShapeY0;
- float y1 = y + tileShapeY1;
- float z0 = z + tileShapeZ0;
-
- if ( applyAmbienceOcclusion )
- {
- t->color( c1r, c1g, c1b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc1 );
- t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z0 ), ( float )( u01 ), ( float )( v01 ) );
- t->color( c2r, c2g, c2b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc2 );
- t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z0 ), ( float )( u00 ), ( float )( v00 ) );
- t->color( c3r, c3g, c3b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc3 );
- t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z0 ), ( float )( u10 ), ( float )( v10 ) );
- t->color( c4r, c4g, c4b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc4 );
- t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z0 ), ( float )( u11 ), ( float )( v11 ) );
- }
- else
- {
- t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z0 ), ( float )( u01 ), ( float )( v01 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z0 ), ( float )( u00 ), ( float )( v00 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z0 ), ( float )( u10 ), ( float )( v10 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z0 ), ( float )( u11 ), ( float )( v11 ) );
- }
-
+ if (applyAmbienceOcclusion) {
+ t->color(c1r, c1g, c1b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc1);
+ t->vertexUV((float)(x0), (float)(y1), (float)(z0), (float)(u01),
+ (float)(v01));
+ t->color(c2r, c2g, c2b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc2);
+ t->vertexUV((float)(x1), (float)(y1), (float)(z0), (float)(u00),
+ (float)(v00));
+ t->color(c3r, c3g, c3b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc3);
+ t->vertexUV((float)(x1), (float)(y0), (float)(z0), (float)(u10),
+ (float)(v10));
+ t->color(c4r, c4g, c4b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc4);
+ t->vertexUV((float)(x0), (float)(y0), (float)(z0), (float)(u11),
+ (float)(v11));
+ } else {
+ t->vertexUV((float)(x0), (float)(y1), (float)(z0), (float)(u01),
+ (float)(v01));
+ t->vertexUV((float)(x1), (float)(y1), (float)(z0), (float)(u00),
+ (float)(v00));
+ t->vertexUV((float)(x1), (float)(y0), (float)(z0), (float)(u10),
+ (float)(v10));
+ t->vertexUV((float)(x0), (float)(y0), (float)(z0), (float)(u11),
+ (float)(v11));
+ }
}
-void TileRenderer_SPU::renderSouth( Tile_SPU* tt, float x, float y, float z, Icon_SPU *tex )
-{
- Tesselator_SPU* t = getTesselator();
+void TileRenderer_SPU::renderSouth(Tile_SPU* tt, float x, float y, float z,
+ Icon_SPU* tex) {
+ Tesselator_SPU* t = getTesselator();
- if (hasFixedTexture()) tex = fixedTexture;
- float u00 = tex->getU(tileShapeX0 * 16.0f);
- float u11 = tex->getU(tileShapeX1 * 16.0f);
- float v00 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeY1 * 16.0f);
- float v11 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeY0 * 16.0f);
- if ( xFlipTexture )
- {
- float tmp = u00;
- u00 = u11;
- u11 = tmp;
- }
+ if (hasFixedTexture()) tex = fixedTexture;
+ float u00 = tex->getU(tileShapeX0 * 16.0f);
+ float u11 = tex->getU(tileShapeX1 * 16.0f);
+ float v00 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeY1 * 16.0f);
+ float v11 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeY0 * 16.0f);
+ if (xFlipTexture) {
+ float tmp = u00;
+ u00 = u11;
+ u11 = tmp;
+ }
- if ( tileShapeX0 < 0 || tileShapeX1 > 1 )
- {
- u00 = tex->getU0();
- u11 = tex->getU1();
- }
- if ( tileShapeY0 < 0 || tileShapeY1 > 1 )
- {
- v00 = tex->getV0();
- v11 = tex->getV1();
- }
+ if (tileShapeX0 < 0 || tileShapeX1 > 1) {
+ u00 = tex->getU0();
+ u11 = tex->getU1();
+ }
+ if (tileShapeY0 < 0 || tileShapeY1 > 1) {
+ v00 = tex->getV0();
+ v11 = tex->getV1();
+ }
- float u01 = u11, u10 = u00, v01 = v00, v10 = v11;
+ float u01 = u11, u10 = u00, v01 = v00, v10 = v11;
- if ( southFlip == FLIP_CW )
- {
- u00 = tex->getU(tileShapeY0 * 16.0f);
- v11 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeX0 * 16.0f);
- u11 = tex->getU(tileShapeY1 * 16.0f);
- v00 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeX1 * 16.0f);
+ if (southFlip == FLIP_CW) {
+ u00 = tex->getU(tileShapeY0 * 16.0f);
+ v11 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeX0 * 16.0f);
+ u11 = tex->getU(tileShapeY1 * 16.0f);
+ v00 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeX1 * 16.0f);
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- u01 = u00;
- u10 = u11;
- v00 = v11;
- v11 = v01;
- }
- else if ( southFlip == FLIP_CCW )
- {
- // reshape
- u00 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeY1 * 16.0f);
- v00 = tex->getV(tileShapeX0 * 16.0f);
- u11 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeY0 * 16.0f);
- v11 = tex->getV(tileShapeX1 * 16.0f);
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ u01 = u00;
+ u10 = u11;
+ v00 = v11;
+ v11 = v01;
+ } else if (southFlip == FLIP_CCW) {
+ // reshape
+ u00 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeY1 * 16.0f);
+ v00 = tex->getV(tileShapeX0 * 16.0f);
+ u11 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeY0 * 16.0f);
+ v11 = tex->getV(tileShapeX1 * 16.0f);
- // rotate
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- u00 = u01;
- u11 = u10;
- v01 = v11;
- v10 = v00;
- }
- else if ( southFlip == FLIP_180 )
- {
- u00 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeX0 * 16.0f);
- u11 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeX1 * 16.0f);
- v00 = tex->getV(tileShapeY1 * 16.0f);
- v11 = tex->getV(tileShapeY0 * 16.0f);
+ // rotate
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ u00 = u01;
+ u11 = u10;
+ v01 = v11;
+ v10 = v00;
+ } else if (southFlip == FLIP_180) {
+ u00 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeX0 * 16.0f);
+ u11 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeX1 * 16.0f);
+ v00 = tex->getV(tileShapeY1 * 16.0f);
+ v11 = tex->getV(tileShapeY0 * 16.0f);
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- }
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ }
+ float x0 = x + tileShapeX0;
+ float x1 = x + tileShapeX1;
+ float y0 = y + tileShapeY0;
+ float y1 = y + tileShapeY1;
+ float z1 = z + tileShapeZ1;
- float x0 = x + tileShapeX0;
- float x1 = x + tileShapeX1;
- float y0 = y + tileShapeY0;
- float y1 = y + tileShapeY1;
- float z1 = z + tileShapeZ1;
-
- if ( applyAmbienceOcclusion )
- {
- t->color( c1r, c1g, c1b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc1 );
- t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z1 ), ( float )( u00 ), ( float )( v00 ) );
- t->color( c2r, c2g, c2b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc2 );
- t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z1 ), ( float )( u10 ), ( float )( v10 ) );
- t->color( c3r, c3g, c3b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc3 );
- t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z1 ), ( float )( u11 ), ( float )( v11 ) );
- t->color( c4r, c4g, c4b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc4 );
- t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z1 ), ( float )( u01 ), ( float )( v01 ) );
- }
- else
- {
- t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z1 ), ( float )( u00 ), ( float )( v00 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z1 ), ( float )( u10 ), ( float )( v10 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z1 ), ( float )( u11 ), ( float )( v11 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z1 ), ( float )( u01 ), ( float )( v01 ) );
- }
-
+ if (applyAmbienceOcclusion) {
+ t->color(c1r, c1g, c1b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc1);
+ t->vertexUV((float)(x0), (float)(y1), (float)(z1), (float)(u00),
+ (float)(v00));
+ t->color(c2r, c2g, c2b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc2);
+ t->vertexUV((float)(x0), (float)(y0), (float)(z1), (float)(u10),
+ (float)(v10));
+ t->color(c3r, c3g, c3b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc3);
+ t->vertexUV((float)(x1), (float)(y0), (float)(z1), (float)(u11),
+ (float)(v11));
+ t->color(c4r, c4g, c4b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc4);
+ t->vertexUV((float)(x1), (float)(y1), (float)(z1), (float)(u01),
+ (float)(v01));
+ } else {
+ t->vertexUV((float)(x0), (float)(y1), (float)(z1), (float)(u00),
+ (float)(v00));
+ t->vertexUV((float)(x0), (float)(y0), (float)(z1), (float)(u10),
+ (float)(v10));
+ t->vertexUV((float)(x1), (float)(y0), (float)(z1), (float)(u11),
+ (float)(v11));
+ t->vertexUV((float)(x1), (float)(y1), (float)(z1), (float)(u01),
+ (float)(v01));
+ }
}
-void TileRenderer_SPU::renderWest( Tile_SPU* tt, float x, float y, float z, Icon_SPU *tex )
-{
- Tesselator_SPU* t = getTesselator();
+void TileRenderer_SPU::renderWest(Tile_SPU* tt, float x, float y, float z,
+ Icon_SPU* tex) {
+ Tesselator_SPU* t = getTesselator();
- if (hasFixedTexture()) tex = fixedTexture;
- float u00 = tex->getU(tileShapeZ0 * 16.0f);
- float u11 = tex->getU(tileShapeZ1 * 16.0f);
- float v00 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeY1 * 16.0f);
- float v11 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeY0 * 16.0f);
- if ( xFlipTexture )
- {
- float tmp = u00;
- u00 = u11;
- u11 = tmp;
- }
+ if (hasFixedTexture()) tex = fixedTexture;
+ float u00 = tex->getU(tileShapeZ0 * 16.0f);
+ float u11 = tex->getU(tileShapeZ1 * 16.0f);
+ float v00 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeY1 * 16.0f);
+ float v11 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeY0 * 16.0f);
+ if (xFlipTexture) {
+ float tmp = u00;
+ u00 = u11;
+ u11 = tmp;
+ }
- if ( tileShapeZ0 < 0 || tileShapeZ1 > 1 )
- {
- u00 = tex->getU0();
- u11 = tex->getU1();
- }
- if ( tileShapeY0 < 0 || tileShapeY1 > 1 )
- {
- v00 = tex->getV0();
- v11 = tex->getV1();
- }
+ if (tileShapeZ0 < 0 || tileShapeZ1 > 1) {
+ u00 = tex->getU0();
+ u11 = tex->getU1();
+ }
+ if (tileShapeY0 < 0 || tileShapeY1 > 1) {
+ v00 = tex->getV0();
+ v11 = tex->getV1();
+ }
- float u01 = u11, u10 = u00, v01 = v00, v10 = v11;
+ float u01 = u11, u10 = u00, v01 = v00, v10 = v11;
- if ( westFlip == FLIP_CW )
- {
- u00 = tex->getU(tileShapeY0 * 16.0f);
- v00 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeZ1 * 16.0f);
- u11 = tex->getU(tileShapeY1 * 16.0f);
- v11 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeZ0 * 16.0f);
+ if (westFlip == FLIP_CW) {
+ u00 = tex->getU(tileShapeY0 * 16.0f);
+ v00 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeZ1 * 16.0f);
+ u11 = tex->getU(tileShapeY1 * 16.0f);
+ v11 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeZ0 * 16.0f);
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- u01 = u00;
- u10 = u11;
- v00 = v11;
- v11 = v01;
- }
- else if ( westFlip == FLIP_CCW )
- {
- // reshape
- u00 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeY1 * 16.0f);
- v00 = tex->getV(tileShapeZ0 * 16.0f);
- u11 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeY0 * 16.0f);
- v11 = tex->getV(tileShapeZ1 * 16.0f);
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ u01 = u00;
+ u10 = u11;
+ v00 = v11;
+ v11 = v01;
+ } else if (westFlip == FLIP_CCW) {
+ // reshape
+ u00 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeY1 * 16.0f);
+ v00 = tex->getV(tileShapeZ0 * 16.0f);
+ u11 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeY0 * 16.0f);
+ v11 = tex->getV(tileShapeZ1 * 16.0f);
- // rotate
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- u00 = u01;
- u11 = u10;
- v01 = v11;
- v10 = v00;
- }
- else if ( westFlip == FLIP_180 )
- {
- u00 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeZ0 * 16.0f);
- u11 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeZ1 * 16.0f);
- v00 = tex->getV(tileShapeY1 * 16.0f);
- v11 = tex->getV(tileShapeY0 * 16.0f);
+ // rotate
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ u00 = u01;
+ u11 = u10;
+ v01 = v11;
+ v10 = v00;
+ } else if (westFlip == FLIP_180) {
+ u00 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeZ0 * 16.0f);
+ u11 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeZ1 * 16.0f);
+ v00 = tex->getV(tileShapeY1 * 16.0f);
+ v11 = tex->getV(tileShapeY0 * 16.0f);
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ }
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- }
-
- float x0 = x + tileShapeX0;
- float y0 = y + tileShapeY0;
- float y1 = y + tileShapeY1;
- float z0 = z + tileShapeZ0;
- float z1 = z + tileShapeZ1;
-
- if ( applyAmbienceOcclusion )
- {
- t->color( c1r, c1g, c1b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc1 );
- t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z1 ), ( float )( u01 ), ( float )( v01 ) );
- t->color( c2r, c2g, c2b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc2 );
- t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z0 ), ( float )( u00 ), ( float )( v00 ) );
- t->color( c3r, c3g, c3b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc3 );
- t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z0 ), ( float )( u10 ), ( float )( v10 ) );
- t->color( c4r, c4g, c4b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc4 );
- t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z1 ), ( float )( u11 ), ( float )( v11 ) );
- }
- else
- {
- t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z1 ), ( float )( u01 ), ( float )( v01 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y1 ), ( float )( z0 ), ( float )( u00 ), ( float )( v00 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z0 ), ( float )( u10 ), ( float )( v10 ) );
- t->vertexUV( ( float )( x0 ), ( float )( y0 ), ( float )( z1 ), ( float )( u11 ), ( float )( v11 ) );
- }
+ float x0 = x + tileShapeX0;
+ float y0 = y + tileShapeY0;
+ float y1 = y + tileShapeY1;
+ float z0 = z + tileShapeZ0;
+ float z1 = z + tileShapeZ1;
+ if (applyAmbienceOcclusion) {
+ t->color(c1r, c1g, c1b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc1);
+ t->vertexUV((float)(x0), (float)(y1), (float)(z1), (float)(u01),
+ (float)(v01));
+ t->color(c2r, c2g, c2b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc2);
+ t->vertexUV((float)(x0), (float)(y1), (float)(z0), (float)(u00),
+ (float)(v00));
+ t->color(c3r, c3g, c3b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc3);
+ t->vertexUV((float)(x0), (float)(y0), (float)(z0), (float)(u10),
+ (float)(v10));
+ t->color(c4r, c4g, c4b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc4);
+ t->vertexUV((float)(x0), (float)(y0), (float)(z1), (float)(u11),
+ (float)(v11));
+ } else {
+ t->vertexUV((float)(x0), (float)(y1), (float)(z1), (float)(u01),
+ (float)(v01));
+ t->vertexUV((float)(x0), (float)(y1), (float)(z0), (float)(u00),
+ (float)(v00));
+ t->vertexUV((float)(x0), (float)(y0), (float)(z0), (float)(u10),
+ (float)(v10));
+ t->vertexUV((float)(x0), (float)(y0), (float)(z1), (float)(u11),
+ (float)(v11));
+ }
}
-void TileRenderer_SPU::renderEast( Tile_SPU* tt, float x, float y, float z, Icon_SPU *tex )
-{
- Tesselator_SPU* t = getTesselator();
+void TileRenderer_SPU::renderEast(Tile_SPU* tt, float x, float y, float z,
+ Icon_SPU* tex) {
+ Tesselator_SPU* t = getTesselator();
- if (hasFixedTexture()) tex = fixedTexture;
- float u00 = tex->getU(tileShapeZ0 * 16.0f);
- float u11 = tex->getU(tileShapeZ1 * 16.0f);
- float v00 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeY1 * 16.0f);
- float v11 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeY0 * 16.0f);
- if ( xFlipTexture )
- {
- float tmp = u00;
- u00 = u11;
- u11 = tmp;
- }
+ if (hasFixedTexture()) tex = fixedTexture;
+ float u00 = tex->getU(tileShapeZ0 * 16.0f);
+ float u11 = tex->getU(tileShapeZ1 * 16.0f);
+ float v00 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeY1 * 16.0f);
+ float v11 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeY0 * 16.0f);
+ if (xFlipTexture) {
+ float tmp = u00;
+ u00 = u11;
+ u11 = tmp;
+ }
- if ( tileShapeZ0 < 0 || tileShapeZ1 > 1 )
- {
- u00 = tex->getU0();
- u11 = tex->getU1();
- }
- if ( tileShapeY0 < 0 || tileShapeY1 > 1 )
- {
- v00 = tex->getV0();
- v11 = tex->getV1();
- }
+ if (tileShapeZ0 < 0 || tileShapeZ1 > 1) {
+ u00 = tex->getU0();
+ u11 = tex->getU1();
+ }
+ if (tileShapeY0 < 0 || tileShapeY1 > 1) {
+ v00 = tex->getV0();
+ v11 = tex->getV1();
+ }
- float u01 = u11, u10 = u00, v01 = v00, v10 = v11;
+ float u01 = u11, u10 = u00, v01 = v00, v10 = v11;
- if ( eastFlip == FLIP_CCW )
- {
- u00 = tex->getU(tileShapeY0 * 16.0f);
- v00 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeZ0 * 16.0f);
- u11 = tex->getU(tileShapeY1 * 16.0f);
- v11 = tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeZ1 * 16.0f);
+ if (eastFlip == FLIP_CCW) {
+ u00 = tex->getU(tileShapeY0 * 16.0f);
+ v00 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeZ0 * 16.0f);
+ u11 = tex->getU(tileShapeY1 * 16.0f);
+ v11 =
+ tex->getV(SharedConstants::WORLD_RESOLUTION - tileShapeZ1 * 16.0f);
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- u01 = u00;
- u10 = u11;
- v00 = v11;
- v11 = v01;
- }
- else if ( eastFlip == FLIP_CW )
- {
- // reshape
- u00 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeY1 * 16.0f);
- v00 = tex->getV(tileShapeZ1 * 16.0f);
- u11 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeY0 * 16.0f);
- v11 = tex->getV(tileShapeZ0 * 16.0f);
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ u01 = u00;
+ u10 = u11;
+ v00 = v11;
+ v11 = v01;
+ } else if (eastFlip == FLIP_CW) {
+ // reshape
+ u00 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeY1 * 16.0f);
+ v00 = tex->getV(tileShapeZ1 * 16.0f);
+ u11 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeY0 * 16.0f);
+ v11 = tex->getV(tileShapeZ0 * 16.0f);
- // rotate
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- u00 = u01;
- u11 = u10;
- v01 = v11;
- v10 = v00;
- }
- else if ( eastFlip == FLIP_180 )
- {
- u00 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeZ0 * 16.0f);
- u11 = tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeZ1 * 16.0f);
- v00 = tex->getV(tileShapeY1 * 16.0f);
- v11 = tex->getV(tileShapeY0 * 16.0f);
+ // rotate
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ u00 = u01;
+ u11 = u10;
+ v01 = v11;
+ v10 = v00;
+ } else if (eastFlip == FLIP_180) {
+ u00 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeZ0 * 16.0f);
+ u11 =
+ tex->getU(SharedConstants::WORLD_RESOLUTION - tileShapeZ1 * 16.0f);
+ v00 = tex->getV(tileShapeY1 * 16.0f);
+ v11 = tex->getV(tileShapeY0 * 16.0f);
- u01 = u11;
- u10 = u00;
- v01 = v00;
- v10 = v11;
- }
+ u01 = u11;
+ u10 = u00;
+ v01 = v00;
+ v10 = v11;
+ }
- float x1 = x + tileShapeX1;
- float y0 = y + tileShapeY0;
- float y1 = y + tileShapeY1;
- float z0 = z + tileShapeZ0;
- float z1 = z + tileShapeZ1;
-
- if ( applyAmbienceOcclusion )
- {
- t->color( c1r, c1g, c1b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc1 );
- t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z1 ), ( float )( u10 ), ( float )( v10 ) );
- t->color( c2r, c2g, c2b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc2 );
- t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z0 ), ( float )( u11 ), ( float )( v11 ) );
- t->color( c3r, c3g, c3b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc3 );
- t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z0 ), ( float )( u01 ), ( float )( v01 ) );
- t->color( c4r, c4g, c4b );
- if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc4 );
- t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z1 ), ( float )( u00 ), ( float )( v00 ) );
- }
- else
- {
- t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z1 ), ( float )( u10 ), ( float )( v10 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y0 ), ( float )( z0 ), ( float )( u11 ), ( float )( v11 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z0 ), ( float )( u01 ), ( float )( v01 ) );
- t->vertexUV( ( float )( x1 ), ( float )( y1 ), ( float )( z1 ), ( float )( u00 ), ( float )( v00 ) );
- }
+ float x1 = x + tileShapeX1;
+ float y0 = y + tileShapeY0;
+ float y1 = y + tileShapeY1;
+ float z0 = z + tileShapeZ0;
+ float z1 = z + tileShapeZ1;
+ if (applyAmbienceOcclusion) {
+ t->color(c1r, c1g, c1b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc1);
+ t->vertexUV((float)(x1), (float)(y0), (float)(z1), (float)(u10),
+ (float)(v10));
+ t->color(c2r, c2g, c2b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc2);
+ t->vertexUV((float)(x1), (float)(y0), (float)(z0), (float)(u11),
+ (float)(v11));
+ t->color(c3r, c3g, c3b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc3);
+ t->vertexUV((float)(x1), (float)(y1), (float)(z0), (float)(u01),
+ (float)(v01));
+ t->color(c4r, c4g, c4b);
+ if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc4);
+ t->vertexUV((float)(x1), (float)(y1), (float)(z1), (float)(u00),
+ (float)(v00));
+ } else {
+ t->vertexUV((float)(x1), (float)(y0), (float)(z1), (float)(u10),
+ (float)(v10));
+ t->vertexUV((float)(x1), (float)(y0), (float)(z0), (float)(u11),
+ (float)(v11));
+ t->vertexUV((float)(x1), (float)(y1), (float)(z0), (float)(u01),
+ (float)(v01));
+ t->vertexUV((float)(x1), (float)(y1), (float)(z1), (float)(u00),
+ (float)(v00));
+ }
}
-bool TileRenderer_SPU::canRender( int renderShape )
-{
- if ( renderShape == Tile_SPU::SHAPE_BLOCK ) return true;
- if ( renderShape == Tile_SPU::SHAPE_TREE ) return true;
- if ( renderShape == Tile_SPU::SHAPE_QUARTZ) return true;
- if ( renderShape == Tile_SPU::SHAPE_CACTUS ) return true;
- if ( renderShape == Tile_SPU::SHAPE_STAIRS ) return true;
- if ( renderShape == Tile_SPU::SHAPE_FENCE ) return true;
- if ( renderShape == Tile_SPU::SHAPE_EGG) return true;
- if ( renderShape == Tile_SPU::SHAPE_ENTITYTILE_ANIMATED) return true;
- if ( renderShape == Tile_SPU::SHAPE_FENCE_GATE) return true;
- if ( renderShape == Tile_SPU::SHAPE_PISTON_BASE ) return true;
- if ( renderShape == Tile_SPU::SHAPE_PORTAL_FRAME ) return true;
- if ( renderShape == Tile_SPU::SHAPE_WALL) return true;
- if ( renderShape == Tile_SPU::SHAPE_ANVIL) return true;
- return false;
+bool TileRenderer_SPU::canRender(int renderShape) {
+ if (renderShape == Tile_SPU::SHAPE_BLOCK) return true;
+ if (renderShape == Tile_SPU::SHAPE_TREE) return true;
+ if (renderShape == Tile_SPU::SHAPE_QUARTZ) return true;
+ if (renderShape == Tile_SPU::SHAPE_CACTUS) return true;
+ if (renderShape == Tile_SPU::SHAPE_STAIRS) return true;
+ if (renderShape == Tile_SPU::SHAPE_FENCE) return true;
+ if (renderShape == Tile_SPU::SHAPE_EGG) return true;
+ if (renderShape == Tile_SPU::SHAPE_ENTITYTILE_ANIMATED) return true;
+ if (renderShape == Tile_SPU::SHAPE_FENCE_GATE) return true;
+ if (renderShape == Tile_SPU::SHAPE_PISTON_BASE) return true;
+ if (renderShape == Tile_SPU::SHAPE_PORTAL_FRAME) return true;
+ if (renderShape == Tile_SPU::SHAPE_WALL) return true;
+ if (renderShape == Tile_SPU::SHAPE_ANVIL) return true;
+ return false;
}
-Icon_SPU *TileRenderer_SPU::getTexture(Tile_SPU *tile, ChunkRebuildData *level, int x, int y, int z, int face)
-{
- return getTextureOrMissing(tile->getTexture(level, x, y, z, face));
+Icon_SPU* TileRenderer_SPU::getTexture(Tile_SPU* tile, ChunkRebuildData* level,
+ int x, int y, int z, int face) {
+ return getTextureOrMissing(tile->getTexture(level, x, y, z, face));
}
-Icon_SPU *TileRenderer_SPU::getTexture(Tile_SPU *tile, int face, int data)
-{
- return getTextureOrMissing(tile->getTexture(face, data));
+Icon_SPU* TileRenderer_SPU::getTexture(Tile_SPU* tile, int face, int data) {
+ return getTextureOrMissing(tile->getTexture(face, data));
}
-Icon_SPU *TileRenderer_SPU::getTexture(Tile_SPU *tile, int face)
-{
- return getTextureOrMissing(tile->getTexture(face));
+Icon_SPU* TileRenderer_SPU::getTexture(Tile_SPU* tile, int face) {
+ return getTextureOrMissing(tile->getTexture(face));
}
-Icon_SPU *TileRenderer_SPU::getTexture(Tile_SPU *tile)
-{
- return getTextureOrMissing(tile->getTexture(Facing::UP));
+Icon_SPU* TileRenderer_SPU::getTexture(Tile_SPU* tile) {
+ return getTextureOrMissing(tile->getTexture(Facing::UP));
}
-Icon_SPU *TileRenderer_SPU::getTextureOrMissing(Icon_SPU *Icon_SPU)
-{
- if (Icon_SPU == NULL)
- {
- assert(0);
- // return minecraft->textures->getMissingIcon_SPU(Icon_SPU::TYPE_TERRAIN);
- }
- return Icon_SPU;
-}
\ No newline at end of file
+Icon_SPU* TileRenderer_SPU::getTextureOrMissing(Icon_SPU* Icon_SPU) {
+ if (Icon_SPU == NULL) {
+ assert(0);
+ // return
+ // minecraft->textures->getMissingIcon_SPU(Icon_SPU::TYPE_TERRAIN);
+ }
+ return Icon_SPU;
+}
diff --git a/Minecraft.Client/Platform/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.cpp b/Minecraft.Client/Platform/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.cpp
index eb768ac4c..c12e1def6 100644
--- a/Minecraft.Client/Platform/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.cpp
+++ b/Minecraft.Client/Platform/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.cpp
@@ -96,36 +96,28 @@ TileData_SPU* Tile_SPU::ms_pTileData = NULL;
Tile_SPU Tile_SPU::m_tiles[256];
+int Tile_SPU::getRenderShape() { return SHAPE_BLOCK; }
-
-int Tile_SPU::getRenderShape()
-{
- return SHAPE_BLOCK;
+void Tile_SPU::setShape(float x0, float y0, float z0, float x1, float y1,
+ float z1) {
+ ms_pTileData->xx0[id] = x0;
+ ms_pTileData->yy0[id] = y0;
+ ms_pTileData->zz0[id] = z0;
+ ms_pTileData->xx1[id] = x1;
+ ms_pTileData->yy1[id] = y1;
+ ms_pTileData->zz1[id] = z1;
}
-
-void Tile_SPU::setShape(float x0, float y0, float z0, float x1, float y1, float z1)
-{
- ms_pTileData->xx0[id] = x0;
- ms_pTileData->yy0[id] = y0;
- ms_pTileData->zz0[id] = z0;
- ms_pTileData->xx1[id] = x1;
- ms_pTileData->yy1[id] = y1;
- ms_pTileData->zz1[id] = z1;
+float Tile_SPU::getBrightness(ChunkRebuildData* level, int x, int y, int z) {
+ return level->getBrightness(x, y, z, ms_pTileData->lightEmission[id]);
}
-
-float Tile_SPU::getBrightness(ChunkRebuildData *level, int x, int y, int z)
-{
- return level->getBrightness(x, y, z, ms_pTileData->lightEmission[id]);
-}
-//
+//
// // 4J - brought forward from 1.8.2
-int Tile_SPU::getLightColor(ChunkRebuildData *level, int x, int y, int z)
-{
- int tileID = level->getTile(x, y, z);
- return level->getLightColor(x, y, z, ms_pTileData->lightEmission[tileID]);
+int Tile_SPU::getLightColor(ChunkRebuildData* level, int x, int y, int z) {
+ int tileID = level->getTile(x, y, z);
+ return level->getLightColor(x, y, z, ms_pTileData->lightEmission[tileID]);
}
-//
+//
// bool Tile_SPU::isFaceVisible(Level *level, int x, int y, int z, int f)
// {
// if (f == 0) y--;
@@ -136,197 +128,198 @@ int Tile_SPU::getLightColor(ChunkRebuildData *level, int x, int y, int z)
// if (f == 5) x++;
// return !level->isSolidRenderTile(x, y, z);
// }
-//
-bool Tile_SPU::shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face)
-{
- if (face == 0 && getShapeY0() > 0) return true;
- if (face == 1 && getShapeY1() < 1) return true;
- if (face == 2 && getShapeZ0() > 0) return true;
- if (face == 3 && getShapeZ1() < 1) return true;
- if (face == 4 && getShapeX0() > 0) return true;
- if (face == 5 && getShapeX1() < 1) return true;
- return (!level->isSolidRenderTile(x, y, z));
+//
+bool Tile_SPU::shouldRenderFace(ChunkRebuildData* level, int x, int y, int z,
+ int face) {
+ if (face == 0 && getShapeY0() > 0) return true;
+ if (face == 1 && getShapeY1() < 1) return true;
+ if (face == 2 && getShapeZ0() > 0) return true;
+ if (face == 3 && getShapeZ1() < 1) return true;
+ if (face == 4 && getShapeX0() > 0) return true;
+ if (face == 5 && getShapeX1() < 1) return true;
+ return (!level->isSolidRenderTile(x, y, z));
}
-//
-bool Tile_SPU::isSolidFace(ChunkRebuildData *level, int x, int y, int z, int face)
-{
- return (level->getMaterial(x, y, z)->isSolid());
+//
+bool Tile_SPU::isSolidFace(ChunkRebuildData* level, int x, int y, int z,
+ int face) {
+ return (level->getMaterial(x, y, z)->isSolid());
}
-Icon_SPU *Tile_SPU::getTexture(ChunkRebuildData *level, int x, int y, int z, int face)
-{
- // 4J - addition here to make rendering big blocks of leaves more efficient. Normally leaves never consider themselves as solid, so
- // blocks of leaves will have all sides of each block completely visible. Changing to consider as solid if this block is surrounded by
- // other leaves. This is paired with another change in Level::isSolidRenderTile/Region::isSolidRenderTile which makes things solid
- // code-wise (ie for determining visible sides of neighbouring blocks). This change just makes the texture a solid one (tex + 1) which
- // we already have in the texture map for doing non-fancy graphics. Note: this tile-specific code is here rather than making some new virtual
- // method in the tiles, for the sake of efficiency - I don't imagine we'll be doing much more of this sort of thing
+Icon_SPU* Tile_SPU::getTexture(ChunkRebuildData* level, int x, int y, int z,
+ int face) {
+ // 4J - addition here to make rendering big blocks of leaves more efficient.
+ // Normally leaves never consider themselves as solid, so blocks of leaves
+ // will have all sides of each block completely visible. Changing to
+ // consider as solid if this block is surrounded by other leaves. This is
+ // paired with another change in
+ // Level::isSolidRenderTile/Region::isSolidRenderTile which makes things
+ // solid code-wise (ie for determining visible sides of neighbouring
+ // blocks). This change just makes the texture a solid one (tex + 1) which
+ // we already have in the texture map for doing non-fancy graphics. Note:
+ // this tile-specific code is here rather than making some new virtual
+ // method in the tiles, for the sake of efficiency - I don't imagine we'll
+ // be doing much more of this sort of thing
- int tileId = level->getTile(x, y, z);
- int tileData = level->getData(x, y, z);
+ int tileId = level->getTile(x, y, z);
+ int tileData = level->getData(x, y, z);
- if( tileId == Tile_SPU::leaves_Id )
- {
- bool opaque = true;
- int axo[6] = { 1,-1, 0, 0, 0, 0};
- int ayo[6] = { 0, 0, 1,-1, 0, 0};
- int azo[6] = { 0, 0, 0, 0, 1,-1};
- for( int i = 0; (i < 6) && opaque; i++ )
- {
- int t = level->getTile(x + axo[i], y + ayo[i] , z + azo[i]);
- if( ( t != Tile_SPU::leaves_Id ) && ( ( Tile_SPU::m_tiles[t].id == -1) || !Tile_SPU::m_tiles[t].isSolidRender() ) )
- {
- opaque = false;
- }
- }
+ if (tileId == Tile_SPU::leaves_Id) {
+ bool opaque = true;
+ int axo[6] = {1, -1, 0, 0, 0, 0};
+ int ayo[6] = {0, 0, 1, -1, 0, 0};
+ int azo[6] = {0, 0, 0, 0, 1, -1};
+ for (int i = 0; (i < 6) && opaque; i++) {
+ int t = level->getTile(x + axo[i], y + ayo[i], z + azo[i]);
+ if ((t != Tile_SPU::leaves_Id) &&
+ ((Tile_SPU::m_tiles[t].id == -1) ||
+ !Tile_SPU::m_tiles[t].isSolidRender())) {
+ opaque = false;
+ }
+ }
-
- Icon_SPU *icon = NULL;
- if(opaque)
- {
- LeafTile_SPU::setFancy(false);
- icon = getTexture(face, tileData);
- LeafTile_SPU::setFancy(true);
- }
- else
- {
- icon = getTexture(face, tileData);
- }
- return icon;
- }
- return getTexture(face, tileData);
+ Icon_SPU* icon = NULL;
+ if (opaque) {
+ LeafTile_SPU::setFancy(false);
+ icon = getTexture(face, tileData);
+ LeafTile_SPU::setFancy(true);
+ } else {
+ icon = getTexture(face, tileData);
+ }
+ return icon;
+ }
+ return getTexture(face, tileData);
}
-//
-Icon_SPU *Tile_SPU::getTexture(int face, int data)
-{
- return &ms_pTileData->iconData[id];
+//
+Icon_SPU* Tile_SPU::getTexture(int face, int data) {
+ return &ms_pTileData->iconData[id];
}
-//
-Icon_SPU *Tile_SPU::getTexture(int face)
-{
- return getTexture(face, 0);
-}
-//
+//
+Icon_SPU* Tile_SPU::getTexture(int face) { return getTexture(face, 0); }
+//
// AABB *Tile_SPU::getTileAABB(Level *level, int x, int y, int z)
// {
-// return AABB::newTemp(x + xx0, y + yy0, z + zz0, x + xx1, y + yy1, z + zz1);
+// return AABB::newTemp(x + xx0, y + yy0, z + zz0, x + xx1, y + yy1, z +
+// zz1);
// }
-//
-// void Tile_SPU::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, Entity *source)
+//
+// void Tile_SPU::addAABBs(Level *level, int x, int y, int z, AABB *box,
+// AABBList *boxes, Entity *source)
// {
// AABB *aabb = getAABB(level, x, y, z);
// if (aabb != NULL && box->intersects(aabb)) boxes->push_back(aabb);
// }
-//
-// void Tile_SPU::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes)
+//
+// void Tile_SPU::addAABBs(Level *level, int x, int y, int z, AABB *box,
+// AABBList *boxes)
// {
// AABB *aabb = getAABB(level, x, y, z);
// if (aabb != NULL && box->intersects(aabb)) boxes->push_back(aabb);
// }
-//
+//
// AABB *Tile_SPU::getAABB(Level *level, int x, int y, int z)
// {
-// return AABB::newTemp(x + xx0, y + yy0, z + zz0, x + xx1, y + yy1, z + zz1);
+// return AABB::newTemp(x + xx0, y + yy0, z + zz0, x + xx1, y + yy1, z +
+// zz1);
// }
-//
- bool Tile_SPU::isSolidRender(bool isServerLevel)
- {
- return true;
- }
-
+//
+bool Tile_SPU::isSolidRender(bool isServerLevel) { return true; }
// bool Tile_SPU::mayPick(int data, bool liquid)
// {
// return mayPick();
// }
-//
+//
// bool Tile_SPU::mayPick()
// {
// return true;
// }
-//
+//
// void Tile_SPU::tick(Level *level, int x, int y, int z, Random *random)
// {
// }
-//
+//
// void Tile_SPU::animateTick(Level *level, int x, int y, int z, Random *random)
// {
// }
-//
+//
// void Tile_SPU::destroy(Level *level, int x, int y, int z, int data)
// {
// }
-//
+//
// void Tile_SPU::neighborChanged(Level *level, int x, int y, int z, int type)
// {
// }
-//
+//
// void Tile_SPU::addLights(Level *level, int x, int y, int z)
// {
// }
-//
+//
// int Tile_SPU::getTickDelay()
// {
// return 10;
// }
-//
+//
// void Tile_SPU::onPlace(Level *level, int x, int y, int z)
// {
// }
-//
+//
// void Tile_SPU::onRemove(Level *level, int x, int y, int z)
// {
// }
-//
+//
// int Tile_SPU::getResourceCount(Random *random)
// {
// return 1;
// }
-//
+//
// int Tile_SPU::getResource(int data, Random *random, int playerBonusLevel)
// {
// return id;
// }
-//
+//
// float Tile_SPU::getDestroyProgress(std::shared_ptr player)
// {
// if (destroySpeed < 0) return 0;
// if (!player->canDestroy(this)) return 1 / destroySpeed / 100.0f;
// return (player->getDestroySpeed(this) / destroySpeed) / 30;
// }
-//
-// void Tile_SPU::spawnResources(Level *level, int x, int y, int z, int data, int playerBonusLevel)
+//
+// void Tile_SPU::spawnResources(Level *level, int x, int y, int z, int data,
+// int playerBonusLevel)
// {
// spawnResources(level, x, y, z, data, 1, playerBonusLevel);
// }
-//
-// void Tile_SPU::spawnResources(Level *level, int x, int y, int z, int data, float odds, int playerBonusLevel)
+//
+// void Tile_SPU::spawnResources(Level *level, int x, int y, int z, int data,
+// float odds, int playerBonusLevel)
// {
// if (level->isClientSide) return;
-// int count = getResourceCountForLootBonus(playerBonusLevel, level->random);
-// for (int i = 0; i < count; i++)
+// int count = getResourceCountForLootBonus(playerBonusLevel,
+// level->random); for (int i = 0; i < count; i++)
// {
// if (level->random->nextFloat() > odds) continue;
// int type = getResource(data, level->random, playerBonusLevel);
// if (type <= 0) continue;
-//
-// popResource(level, x, y, z, std::shared_ptr( new ItemInstance(type, 1, getSpawnResourcesAuxValue(data) ) ) );
+//
+// popResource(level, x, y, z, std::shared_ptr( new
+// ItemInstance(type, 1, getSpawnResourcesAuxValue(data) ) ) );
// }
// }
-//
-// void Tile_SPU::popResource(Level *level, int x, int y, int z, std::shared_ptr itemInstance)
+//
+// void Tile_SPU::popResource(Level *level, int x, int y, int z,
+// std::shared_ptr itemInstance)
// {
// if( level->isClientSide ) return;
-//
+//
// float s = 0.7f;
// double xo = level->random->nextFloat() * s + (1 - s) * 0.5;
// double yo = level->random->nextFloat() * s + (1 - s) * 0.5;
// double zo = level->random->nextFloat() * s + (1 - s) * 0.5;
-// std::shared_ptr item = std::shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, itemInstance ) );
-// item->throwTime = 10;
-// level->addEntity(item);
+// std::shared_ptr item = std::shared_ptr( new
+// ItemEntity(level, x + xo, y + yo, z + zo, itemInstance ) ); item->throwTime
+// = 10; level->addEntity(item);
// }
-//
+//
// // Brought forward for TU7
// void Tile_SPU::popExperience(Level *level, int x, int y, int z, int amount)
// {
@@ -334,184 +327,192 @@ Icon_SPU *Tile_SPU::getTexture(int face)
// {
// while (amount > 0)
// {
-// int newCount = ExperienceOrb::getExperienceValue(amount);
-// amount -= newCount;
-// level->addEntity(std::shared_ptr( new ExperienceOrb(level, x + .5, y + .5, z + .5, newCount)));
+// int newCount =
+// ExperienceOrb::getExperienceValue(amount); amount -=
+// newCount; level->addEntity(std::shared_ptr( new
+// ExperienceOrb(level, x + .5, y + .5, z + .5, newCount)));
// }
// }
// }
-//
+//
// int Tile_SPU::getSpawnResourcesAuxValue(int data)
// {
// return 0;
// }
-//
+//
// float Tile_SPU::getExplosionResistance(std::shared_ptr source)
// {
// return explosionResistance / 5.0f;
// }
-//
-// HitResult *Tile_SPU::clip(Level *level, int xt, int yt, int zt, Vec3 *a, Vec3 *b)
+//
+// HitResult *Tile_SPU::clip(Level *level, int xt, int yt, int zt, Vec3 *a, Vec3
+// *b)
// {
// EnterCriticalSection(&m_csShape);
// updateShape(level, xt, yt, zt);
-//
+//
// a = a->add(-xt, -yt, -zt);
// b = b->add(-xt, -yt, -zt);
-//
+//
// Vec3 *xh0 = a->clipX(b, xx0);
// Vec3 *xh1 = a->clipX(b, xx1);
-//
+//
// Vec3 *yh0 = a->clipY(b, yy0);
// Vec3 *yh1 = a->clipY(b, yy1);
-//
+//
// Vec3 *zh0 = a->clipZ(b, zz0);
// Vec3 *zh1 = a->clipZ(b, zz1);
-//
+//
// Vec3 *closest = NULL;
-//
-// if (containsX(xh0) && (closest == NULL || a->distanceTo(xh0) < a->distanceTo(closest))) closest = xh0;
-// if (containsX(xh1) && (closest == NULL || a->distanceTo(xh1) < a->distanceTo(closest))) closest = xh1;
-// if (containsY(yh0) && (closest == NULL || a->distanceTo(yh0) < a->distanceTo(closest))) closest = yh0;
-// if (containsY(yh1) && (closest == NULL || a->distanceTo(yh1) < a->distanceTo(closest))) closest = yh1;
-// if (containsZ(zh0) && (closest == NULL || a->distanceTo(zh0) < a->distanceTo(closest))) closest = zh0;
-// if (containsZ(zh1) && (closest == NULL || a->distanceTo(zh1) < a->distanceTo(closest))) closest = zh1;
-//
+//
+// if (containsX(xh0) && (closest == NULL || a->distanceTo(xh0) <
+// a->distanceTo(closest))) closest = xh0; if (containsX(xh1) && (closest
+// == NULL || a->distanceTo(xh1) < a->distanceTo(closest))) closest = xh1;
+// if (containsY(yh0) && (closest == NULL || a->distanceTo(yh0) <
+// a->distanceTo(closest))) closest = yh0; if (containsY(yh1) && (closest
+// == NULL || a->distanceTo(yh1) < a->distanceTo(closest))) closest = yh1;
+// if (containsZ(zh0) && (closest == NULL || a->distanceTo(zh0) <
+// a->distanceTo(closest))) closest = zh0; if (containsZ(zh1) && (closest
+// == NULL || a->distanceTo(zh1) < a->distanceTo(closest))) closest = zh1;
+//
// LeaveCriticalSection(&m_csShape);
-//
+//
// if (closest == NULL) return NULL;
-//
+//
// int face = -1;
-//
+//
// if (closest == xh0) face = 4;
// if (closest == xh1) face = 5;
// if (closest == yh0) face = 0;
// if (closest == yh1) face = 1;
// if (closest == zh0) face = 2;
// if (closest == zh1) face = 3;
-//
+//
// return new HitResult(xt, yt, zt, face, closest->add(xt, yt, zt));
// }
-//
+//
// bool Tile_SPU::containsX(Vec3 *v)
// {
// if( v == NULL) return false;
// return v->y >= yy0 && v->y <= yy1 && v->z >= zz0 && v->z <= zz1;
// }
-//
+//
// bool Tile_SPU::containsY(Vec3 *v)
// {
// if( v == NULL) return false;
// return v->x >= xx0 && v->x <= xx1 && v->z >= zz0 && v->z <= zz1;
// }
-//
+//
// bool Tile_SPU::containsZ(Vec3 *v)
// {
// if( v == NULL) return false;
// return v->x >= xx0 && v->x <= xx1 && v->y >= yy0 && v->y <= yy1;
// }
-//
+//
// void Tile_SPU::wasExploded(Level *level, int x, int y, int z)
// {
// }
-//
-int Tile_SPU::getRenderLayer()
-{
- return 0;
-}
-//
+//
+int Tile_SPU::getRenderLayer() { return 0; }
+//
// bool Tile_SPU::mayPlace(Level *level, int x, int y, int z, int face)
// {
// return mayPlace(level, x, y, z);
// }
-//
+//
// bool Tile_SPU::mayPlace(Level *level, int x, int y, int z)
// {
// int t = level->getTile(x, y, z);
// return t == 0 || Tile_SPU::tiles[t]->material->isReplaceable();
// }
-//
+//
// // 4J-PB - Adding a TestUse for tooltip display
// bool Tile_SPU::TestUse()
// {
// return false;
// }
-//
-// bool Tile_SPU::TestUse(Level *level, int x, int y, int z, std::shared_ptr player)
+//
+// bool Tile_SPU::TestUse(Level *level, int x, int y, int z,
+// std::shared_ptr player)
// {
// return false;
// }
-//
-// bool Tile_SPU::use(Level *level, int x, int y, int z, std::shared_ptr player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly/*=false*/) // 4J added soundOnly param
+//
+// bool Tile_SPU::use(Level *level, int x, int y, int z, std::shared_ptr
+// player, int clickedFace, float clickX, float clickY, float clickZ, bool
+// soundOnly/*=false*/) // 4J added soundOnly param
// {
// return false;
// }
-//
-// void Tile_SPU::stepOn(Level *level, int x, int y, int z, std::shared_ptr entity)
+//
+// void Tile_SPU::stepOn(Level *level, int x, int y, int z,
+// std::shared_ptr entity)
// {
// }
-//
+//
// void Tile_SPU::setPlacedOnFace(Level *level, int x, int y, int z, int face)
// {
// }
-//
+//
// void Tile_SPU::prepareRender(Level *level, int x, int y, int z)
// {
// }
-//
-// void Tile_SPU::attack(Level *level, int x, int y, int z, std::shared_ptr player)
+//
+// void Tile_SPU::attack(Level *level, int x, int y, int z,
+// std::shared_ptr player)
// {
// }
-//
-// void Tile_SPU::handleEntityInside(Level *level, int x, int y, int z, std::shared_ptr e, Vec3 *current)
+//
+// void Tile_SPU::handleEntityInside(Level *level, int x, int y, int z,
+// std::shared_ptr e, Vec3 *current)
// {
// }
-//
-void Tile_SPU::updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData, TileEntity* forceEntity) // 4J added forceData, forceEntity param
-{
-}
-//
+//
+void Tile_SPU::updateShape(
+ ChunkRebuildData* level, int x, int y, int z, int forceData,
+ TileEntity* forceEntity) // 4J added forceData, forceEntity param
+{}
+//
-int Tile_SPU::getColor(ChunkRebuildData *level, int x, int y, int z)
-{
- return 0xffffff;
+int Tile_SPU::getColor(ChunkRebuildData* level, int x, int y, int z) {
+ return 0xffffff;
}
-//
+//
// int Tile_SPU::getColor(LevelSource *level, int x, int y, int z, int data)
// {
// return 0xffffff;
// }
-//
+//
// bool Tile_SPU::getSignal(LevelSource *level, int x, int y, int z)
// {
// return false;
// }
-//
+//
// bool Tile_SPU::getSignal(LevelSource *level, int x, int y, int z, int dir)
// {
// return false;
// }
-//
+//
// bool Tile_SPU::isSignalSource()
// {
// return false;
// }
-//
-// void Tile_SPU::entityInside(Level *level, int x, int y, int z, std::shared_ptr entity)
+//
+// void Tile_SPU::entityInside(Level *level, int x, int y, int z,
+// std::shared_ptr entity)
// {
// }
-//
+//
// bool Tile_SPU::getDirectSignal(Level *level, int x, int y, int z, int dir)
// {
// return false;
// }
-//
-void Tile_SPU::updateDefaultShape()
-{
-}
-//
-// void Tile_SPU::playerDestroy(Level *level, std::shared_ptr player, int x, int y, int z, int data)
+//
+void Tile_SPU::updateDefaultShape() {}
+//
+// void Tile_SPU::playerDestroy(Level *level, std::shared_ptr player,
+// int x, int y, int z, int data)
// {
// // 4J Stu - Special case - only record a crop destroy if is fully grown
// if(id==Tile_SPU::crops_Id)
@@ -523,14 +524,16 @@ void Tile_SPU::updateDefaultShape()
// {
// player->awardStat(Stats::blocksMined[id], 1);
// }
-// player->awardStat(Stats::totalBlocksMined, 1); // 4J : WESTY : Added for other award.
-// player->causeFoodExhaustion(FoodConstants::EXHAUSTION_MINE);
-//
+// player->awardStat(Stats::totalBlocksMined, 1); // 4J : WESTY : Added
+// for other award.
+// player->causeFoodExhaustion(FoodConstants::EXHAUSTION_MINE);
+//
// if( id == Tile_SPU::treeTrunk_Id )
// player->awardStat(Achievements::mineWood);
-//
-//
-// if (isCubeShaped() && !isEntityTile[id] && EnchantmentHelper::hasSilkTouch(player->inventory))
+//
+//
+// if (isCubeShaped() && !isEntityTile[id] &&
+// EnchantmentHelper::hasSilkTouch(player->inventory))
// {
// std::shared_ptr item = getSilkTouchItemInstance(data);
// if (item != NULL)
@@ -540,360 +543,354 @@ void Tile_SPU::updateDefaultShape()
// }
// else
// {
-// int playerBonusLevel = EnchantmentHelper::getDiggingLootBonus(player->inventory);
+// int playerBonusLevel =
+// EnchantmentHelper::getDiggingLootBonus(player->inventory);
// spawnResources(level, x, y, z, data, playerBonusLevel);
// }
// }
-//
+//
// std::shared_ptr Tile_SPU::getSilkTouchItemInstance(int data)
// {
// int popData = 0;
-// if (id >= 0 && id < Item::items.length && Item::items[id]->isStackedByData())
+// if (id >= 0 && id < Item::items.length &&
+// Item::items[id]->isStackedByData())
// {
// popData = data;
// }
// return std::shared_ptr(new ItemInstance(id, 1, popData));
// }
-//
+//
// int Tile_SPU::getResourceCountForLootBonus(int bonusLevel, Random *random)
// {
// return getResourceCount(random);
// }
-//
+//
// bool Tile_SPU::canSurvive(Level *level, int x, int y, int z)
// {
// return true;
// }
-//
-// void Tile_SPU::setPlacedBy(Level *level, int x, int y, int z, std::shared_ptr by)
+//
+// void Tile_SPU::setPlacedBy(Level *level, int x, int y, int z,
+// std::shared_ptr by)
// {
// }
-//
+//
// Tile *Tile_SPU::setDescriptionId(unsigned int id)
// {
// this->descriptionId = id;
// return this;
// }
-//
+//
// std::wstring Tile_SPU::getName()
// {
// return I18n::get(getDescriptionId() + L".name");
// }
-//
+//
// unsigned int Tile_SPU::getDescriptionId(int iData /*= -1*/)
// {
// return descriptionId;
// }
-//
+//
// Tile *Tile_SPU::setUseDescriptionId(unsigned int id)
// {
// this->useDescriptionId = id;
// return this;
// }
-//
+//
// unsigned int Tile_SPU::getUseDescriptionId()
// {
// return useDescriptionId;
// }
-//
-// void Tile_SPU::triggerEvent(Level *level, int x, int y, int z, int b0, int b1)
+//
+// void Tile_SPU::triggerEvent(Level *level, int x, int y, int z, int b0, int
+// b1)
// {
// }
-//
+//
// bool Tile_SPU::isCollectStatistics()
// {
// return collectStatistics;
// }
-//
+//
// Tile *Tile_SPU::setNotCollectStatistics()
// {
// collectStatistics = false;
// return this;
// }
-//
+//
// int Tile_SPU::getPistonPushReaction()
// {
// return material->getPushReaction();
// }
-//
+//
// // 4J - brought forward from 1.8.2
-float Tile_SPU::getShadeBrightness(ChunkRebuildData *level, int x, int y, int z)
-{
- return level->isSolidBlockingTile(x, y, z) ? 0.2f : 1.0f;
+float Tile_SPU::getShadeBrightness(ChunkRebuildData* level, int x, int y,
+ int z) {
+ return level->isSolidBlockingTile(x, y, z) ? 0.2f : 1.0f;
}
-Tile_SPU* Tile_SPU::createFromID( int tileID )
-{
- if(tileID == 0)
- return NULL;
+Tile_SPU* Tile_SPU::createFromID(int tileID) {
+ if (tileID == 0) return NULL;
+
+ if (m_tiles[tileID].id != -1) return &m_tiles[tileID];
- if(m_tiles[tileID].id != -1)
- return &m_tiles[tileID];
-
#ifndef SN_TARGET_PS3_SPU
- app.DebugPrintf("missing tile ID %d\n", tileID);
+ app.DebugPrintf("missing tile ID %d\n", tileID);
#else
- spu_print("missing tile ID %d\n", tileID);
-#endif
- return &m_tiles[1];
-
+ spu_print("missing tile ID %d\n", tileID);
+#endif
+ return &m_tiles[1];
}
-Material_SPU* Tile_SPU::getMaterial()
-{
- int matID = ms_pTileData->materialIDs[id];
- return &ms_pTileData->materials[matID];
+Material_SPU* Tile_SPU::getMaterial() {
+ int matID = ms_pTileData->materialIDs[id];
+ return &ms_pTileData->materials[matID];
}
-//
-// void Tile_SPU::fallOn(Level *level, int x, int y, int z, std::shared_ptr entity, float fallDistance)
+//
+// void Tile_SPU::fallOn(Level *level, int x, int y, int z,
+// std::shared_ptr entity, float fallDistance)
// {
// }
-//
+//
// void Tile_SPU::registerIcons(IconRegister *iconRegister)
// {
// icon = iconRegister->registerIcon(m_textureName);
// }
-//
+//
// std::wstring Tile_SPU::getTileItemIconName()
// {
// return L"";
// }
-//
+//
// Tile *Tile_SPU::setTextureName(const std::wstring &name)
// {
// m_textureName = name;
// return this;
// }
+void Tile_SPU::initTilePointers() {
+#define CREATE_TILE_TYPE(index, className) \
+ new (&m_tiles[index]) className(index);
+ CREATE_TILE_TYPE(grass_Id, GrassTile_SPU);
+ CREATE_TILE_TYPE(stoneSlab_Id, StoneSlabTile_SPU);
+ CREATE_TILE_TYPE(stoneSlabHalf_Id, StoneSlabTile_SPU);
+ CREATE_TILE_TYPE(woodSlab_Id, WoodSlabTile_SPU);
+ CREATE_TILE_TYPE(woodSlabHalf_Id, WoodSlabTile_SPU);
-void Tile_SPU::initTilePointers()
-{
+ CREATE_TILE_TYPE(chest_Id, ChestTile_SPU);
-#define CREATE_TILE_TYPE(index, className) new (&m_tiles[index]) className(index);
+ CREATE_TILE_TYPE(ironFence_Id, ThinFenceTile_SPU);
+ CREATE_TILE_TYPE(thinGlass_Id, ThinFenceTile_SPU);
+ CREATE_TILE_TYPE(fence_Id, FenceTile_SPU);
+ CREATE_TILE_TYPE(netherFence_Id, FenceTile_SPU);
- CREATE_TILE_TYPE(grass_Id, GrassTile_SPU);
- CREATE_TILE_TYPE(stoneSlab_Id, StoneSlabTile_SPU);
- CREATE_TILE_TYPE(stoneSlabHalf_Id, StoneSlabTile_SPU);
- CREATE_TILE_TYPE(woodSlab_Id, WoodSlabTile_SPU);
- CREATE_TILE_TYPE(woodSlabHalf_Id, WoodSlabTile_SPU);
+ CREATE_TILE_TYPE(stairs_wood_Id, StairTile_SPU);
+ CREATE_TILE_TYPE(stairs_stone_Id, StairTile_SPU);
+ CREATE_TILE_TYPE(stairs_bricks_Id, StairTile_SPU);
+ CREATE_TILE_TYPE(stairs_stoneBrickSmooth_Id, StairTile_SPU);
+ CREATE_TILE_TYPE(stairs_netherBricks_Id, StairTile_SPU);
+ CREATE_TILE_TYPE(stairs_sandstone_Id, StairTile_SPU);
+ CREATE_TILE_TYPE(stairs_sprucewood_Id, StairTile_SPU);
+ CREATE_TILE_TYPE(stairs_birchwood_Id, StairTile_SPU);
+ CREATE_TILE_TYPE(stairs_junglewood_Id, StairTile_SPU);
- CREATE_TILE_TYPE(chest_Id, ChestTile_SPU);
+ CREATE_TILE_TYPE(dirt_Id, DirtTile_SPU);
- CREATE_TILE_TYPE(ironFence_Id, ThinFenceTile_SPU);
- CREATE_TILE_TYPE(thinGlass_Id, ThinFenceTile_SPU);
+ CREATE_TILE_TYPE(door_iron_Id, DoorTile_SPU);
+ CREATE_TILE_TYPE(door_wood_Id, DoorTile_SPU);
- CREATE_TILE_TYPE(fence_Id, FenceTile_SPU);
- CREATE_TILE_TYPE(netherFence_Id, FenceTile_SPU);
+ CREATE_TILE_TYPE(pressurePlate_stone_Id, PressurePlateTile_SPU);
+ CREATE_TILE_TYPE(pressurePlate_wood_Id, PressurePlateTile_SPU);
- CREATE_TILE_TYPE(stairs_wood_Id, StairTile_SPU);
- CREATE_TILE_TYPE(stairs_stone_Id, StairTile_SPU);
- CREATE_TILE_TYPE(stairs_bricks_Id, StairTile_SPU);
- CREATE_TILE_TYPE(stairs_stoneBrickSmooth_Id, StairTile_SPU);
- CREATE_TILE_TYPE(stairs_netherBricks_Id, StairTile_SPU);
- CREATE_TILE_TYPE(stairs_sandstone_Id, StairTile_SPU);
- CREATE_TILE_TYPE(stairs_sprucewood_Id, StairTile_SPU);
- CREATE_TILE_TYPE(stairs_birchwood_Id, StairTile_SPU);
- CREATE_TILE_TYPE(stairs_junglewood_Id, StairTile_SPU);
+ CREATE_TILE_TYPE(farmland_Id, FarmTile_SPU);
- CREATE_TILE_TYPE(dirt_Id, DirtTile_SPU);
+ CREATE_TILE_TYPE(flower_Id, Bush_SPU);
+ CREATE_TILE_TYPE(rose_Id, Bush_SPU);
+ CREATE_TILE_TYPE(deadBush_Id, Bush_SPU); // DeadBushTile
- CREATE_TILE_TYPE(door_iron_Id, DoorTile_SPU);
- CREATE_TILE_TYPE(door_wood_Id, DoorTile_SPU);
+ CREATE_TILE_TYPE(tallgrass_Id, TallGrass_SPU);
- CREATE_TILE_TYPE(pressurePlate_stone_Id, PressurePlateTile_SPU);
- CREATE_TILE_TYPE(pressurePlate_wood_Id, PressurePlateTile_SPU);
+ CREATE_TILE_TYPE(sandStone_Id, SandStoneTile_SPU);
- CREATE_TILE_TYPE(farmland_Id, FarmTile_SPU);
+ CREATE_TILE_TYPE(wood_Id, WoodTile_SPU);
- CREATE_TILE_TYPE(flower_Id, Bush_SPU);
- CREATE_TILE_TYPE(rose_Id, Bush_SPU);
- CREATE_TILE_TYPE(deadBush_Id, Bush_SPU); // DeadBushTile
+ CREATE_TILE_TYPE(treeTrunk_Id, TreeTile_SPU);
- CREATE_TILE_TYPE(tallgrass_Id, TallGrass_SPU);
+ CREATE_TILE_TYPE(leaves_Id, LeafTile_SPU);
- CREATE_TILE_TYPE(sandStone_Id, SandStoneTile_SPU);
+ CREATE_TILE_TYPE(crops_Id, CropTile_SPU);
- CREATE_TILE_TYPE(wood_Id, WoodTile_SPU);
+ CREATE_TILE_TYPE(reeds_Id, ReedTile_SPU);
- CREATE_TILE_TYPE(treeTrunk_Id, TreeTile_SPU);
+ CREATE_TILE_TYPE(torch_Id, TorchTile_SPU);
+ CREATE_TILE_TYPE(notGate_off_Id, TorchTile_SPU); // TorchTile->NotGateTile
+ CREATE_TILE_TYPE(notGate_on_Id, TorchTile_SPU); // TorchTile->NotGateTile
- CREATE_TILE_TYPE(leaves_Id, LeafTile_SPU);
+ CREATE_TILE_TYPE(mushroom1_Id, Mushroom_SPU);
+ CREATE_TILE_TYPE(mushroom2_Id, Mushroom_SPU);
- CREATE_TILE_TYPE(crops_Id, CropTile_SPU);
+ CREATE_TILE_TYPE(mobSpawner_Id, MobSpawnerTile_SPU);
+ CREATE_TILE_TYPE(musicBlock_Id, EntityTile_SPU); // MusicTile->EntityTile
- CREATE_TILE_TYPE(reeds_Id, ReedTile_SPU);
+ CREATE_TILE_TYPE(furnace_Id, FurnaceTile_SPU);
+ CREATE_TILE_TYPE(furnace_lit_Id, FurnaceTile_SPU);
- CREATE_TILE_TYPE(torch_Id, TorchTile_SPU);
- CREATE_TILE_TYPE(notGate_off_Id, TorchTile_SPU); // TorchTile->NotGateTile
- CREATE_TILE_TYPE(notGate_on_Id, TorchTile_SPU); // TorchTile->NotGateTile
+ CREATE_TILE_TYPE(web_Id, WebTile_SPU);
- CREATE_TILE_TYPE(mushroom1_Id, Mushroom_SPU);
- CREATE_TILE_TYPE(mushroom2_Id, Mushroom_SPU);
+ CREATE_TILE_TYPE(water_Id, LiquidTile_SPU);
+ CREATE_TILE_TYPE(lava_Id, LiquidTile_SPU);
+ CREATE_TILE_TYPE(calmLava_Id, LiquidTile_SPU); // LiquidTileStatic
+ CREATE_TILE_TYPE(calmWater_Id, LiquidTile_SPU); // LiquidTileStatic
- CREATE_TILE_TYPE(mobSpawner_Id, MobSpawnerTile_SPU);
- CREATE_TILE_TYPE(musicBlock_Id, EntityTile_SPU); // MusicTile->EntityTile
+ CREATE_TILE_TYPE(fire_Id, FireTile_SPU);
- CREATE_TILE_TYPE(furnace_Id, FurnaceTile_SPU);
- CREATE_TILE_TYPE(furnace_lit_Id, FurnaceTile_SPU);
+ CREATE_TILE_TYPE(sapling_Id, Sapling_SPU);
- CREATE_TILE_TYPE(web_Id, WebTile_SPU);
+ CREATE_TILE_TYPE(glass_Id, GlassTile_SPU);
- CREATE_TILE_TYPE(water_Id, LiquidTile_SPU);
- CREATE_TILE_TYPE(lava_Id, LiquidTile_SPU);
- CREATE_TILE_TYPE(calmLava_Id, LiquidTile_SPU); // LiquidTileStatic
- CREATE_TILE_TYPE(calmWater_Id, LiquidTile_SPU); // LiquidTileStatic
+ CREATE_TILE_TYPE(ice_Id, IceTile_SPU);
- CREATE_TILE_TYPE(fire_Id, FireTile_SPU);
+ CREATE_TILE_TYPE(portalTile_Id, PortalTile_SPU);
- CREATE_TILE_TYPE(sapling_Id, Sapling_SPU);
+ CREATE_TILE_TYPE(dispenser_Id, DispenserTile_SPU);
- CREATE_TILE_TYPE(glass_Id, GlassTile_SPU);
+ CREATE_TILE_TYPE(rail_Id, RailTile_SPU);
+ CREATE_TILE_TYPE(goldenRail_Id, RailTile_SPU);
- CREATE_TILE_TYPE(ice_Id, IceTile_SPU);
+ CREATE_TILE_TYPE(detectorRail_Id, DetectorRailTile_SPU);
- CREATE_TILE_TYPE(portalTile_Id, PortalTile_SPU);
+ CREATE_TILE_TYPE(tnt_Id, TntTile_SPU);
- CREATE_TILE_TYPE(dispenser_Id, DispenserTile_SPU);
+ CREATE_TILE_TYPE(bookshelf_Id, BookshelfTile_SPU);
- CREATE_TILE_TYPE(rail_Id, RailTile_SPU);
- CREATE_TILE_TYPE(goldenRail_Id, RailTile_SPU);
+ CREATE_TILE_TYPE(workBench_Id, WorkbenchTile_SPU);
- CREATE_TILE_TYPE(detectorRail_Id, DetectorRailTile_SPU);
+ CREATE_TILE_TYPE(sign_Id, SignTile_SPU);
+ CREATE_TILE_TYPE(wallSign_Id, SignTile_SPU);
- CREATE_TILE_TYPE(tnt_Id, TntTile_SPU);
+ CREATE_TILE_TYPE(ladder_Id, LadderTile_SPU);
- CREATE_TILE_TYPE(bookshelf_Id, BookshelfTile_SPU);
+ CREATE_TILE_TYPE(button_stone_Id, ButtonTile_SPU);
+ CREATE_TILE_TYPE(button_wood_Id, ButtonTile_SPU);
- CREATE_TILE_TYPE(workBench_Id, WorkbenchTile_SPU);
+ CREATE_TILE_TYPE(topSnow_Id, TopSnowTile_SPU);
- CREATE_TILE_TYPE(sign_Id, SignTile_SPU);
- CREATE_TILE_TYPE(wallSign_Id, SignTile_SPU);
+ CREATE_TILE_TYPE(cactus_Id, CactusTile_SPU);
- CREATE_TILE_TYPE(ladder_Id, LadderTile_SPU);
+ CREATE_TILE_TYPE(recordPlayer_Id, RecordPlayerTile_SPU);
- CREATE_TILE_TYPE(button_stone_Id, ButtonTile_SPU);
- CREATE_TILE_TYPE(button_wood_Id, ButtonTile_SPU);
+ CREATE_TILE_TYPE(pumpkin_Id, PumpkinTile_SPU);
+ CREATE_TILE_TYPE(litPumpkin_Id, PumpkinTile_SPU);
- CREATE_TILE_TYPE(topSnow_Id, TopSnowTile_SPU);
+ CREATE_TILE_TYPE(cake_Id, CakeTile_SPU);
- CREATE_TILE_TYPE(cactus_Id, CactusTile_SPU);
+ CREATE_TILE_TYPE(trapdoor_Id, TrapDoorTile_SPU);
- CREATE_TILE_TYPE(recordPlayer_Id, RecordPlayerTile_SPU);
+ CREATE_TILE_TYPE(monsterStoneEgg_Id, StoneMonsterTile_SPU);
- CREATE_TILE_TYPE(pumpkin_Id, PumpkinTile_SPU);
- CREATE_TILE_TYPE(litPumpkin_Id, PumpkinTile_SPU);
+ CREATE_TILE_TYPE(stoneBrickSmooth_Id, SmoothStoneBrickTile_SPU);
- CREATE_TILE_TYPE(cake_Id, CakeTile_SPU);
+ CREATE_TILE_TYPE(hugeMushroom1_Id, HugeMushroomTile_SPU);
+ CREATE_TILE_TYPE(hugeMushroom2_Id, HugeMushroomTile_SPU);
- CREATE_TILE_TYPE(trapdoor_Id, TrapDoorTile_SPU);
+ CREATE_TILE_TYPE(melon_Id, MelonTile_SPU);
- CREATE_TILE_TYPE(monsterStoneEgg_Id, StoneMonsterTile_SPU);
+ CREATE_TILE_TYPE(melonStem_Id, StemTile_SPU);
+ CREATE_TILE_TYPE(pumpkinStem_Id, StemTile_SPU);
- CREATE_TILE_TYPE(stoneBrickSmooth_Id, SmoothStoneBrickTile_SPU);
+ CREATE_TILE_TYPE(vine_Id, VineTile_SPU);
- CREATE_TILE_TYPE(hugeMushroom1_Id, HugeMushroomTile_SPU);
- CREATE_TILE_TYPE(hugeMushroom2_Id, HugeMushroomTile_SPU);
+ CREATE_TILE_TYPE(mycel_Id, MycelTile_SPU);
- CREATE_TILE_TYPE(melon_Id, MelonTile_SPU);
+ CREATE_TILE_TYPE(waterLily_Id, WaterlilyTile_SPU);
- CREATE_TILE_TYPE(melonStem_Id, StemTile_SPU);
- CREATE_TILE_TYPE(pumpkinStem_Id, StemTile_SPU);
+ CREATE_TILE_TYPE(netherStalk_Id, NetherStalkTile_SPU);
- CREATE_TILE_TYPE(vine_Id, VineTile_SPU);
+ CREATE_TILE_TYPE(enchantTable_Id, EnchantmentTableTile_SPU);
- CREATE_TILE_TYPE(mycel_Id, MycelTile_SPU);
+ CREATE_TILE_TYPE(brewingStand_Id, BrewingStandTile_SPU);
- CREATE_TILE_TYPE(waterLily_Id, WaterlilyTile_SPU);
+ CREATE_TILE_TYPE(diode_on_Id, DiodeTile_SPU);
+ CREATE_TILE_TYPE(diode_off_Id, DiodeTile_SPU);
- CREATE_TILE_TYPE(netherStalk_Id, NetherStalkTile_SPU);
+ CREATE_TILE_TYPE(redStoneDust_Id, RedStoneDustTile_SPU);
- CREATE_TILE_TYPE(enchantTable_Id, EnchantmentTableTile_SPU);
+ CREATE_TILE_TYPE(fenceGate_Id, FenceGateTile_SPU);
- CREATE_TILE_TYPE(brewingStand_Id, BrewingStandTile_SPU);
+ CREATE_TILE_TYPE(bed_Id, BedTile_SPU);
- CREATE_TILE_TYPE(diode_on_Id, DiodeTile_SPU);
- CREATE_TILE_TYPE(diode_off_Id, DiodeTile_SPU);
+ CREATE_TILE_TYPE(pistonBase_Id, PistonBaseTile_SPU);
+ CREATE_TILE_TYPE(pistonStickyBase_Id, PistonBaseTile_SPU);
- CREATE_TILE_TYPE(redStoneDust_Id, RedStoneDustTile_SPU);
+ CREATE_TILE_TYPE(pistonExtensionPiece_Id, PistonExtensionTile_SPU);
- CREATE_TILE_TYPE(fenceGate_Id, FenceGateTile_SPU);
+ CREATE_TILE_TYPE(pistonMovingPiece_Id, PistonMovingPiece_SPU);
- CREATE_TILE_TYPE(bed_Id, BedTile_SPU);
+ CREATE_TILE_TYPE(lever_Id, LeverTile_SPU);
- CREATE_TILE_TYPE(pistonBase_Id, PistonBaseTile_SPU);
- CREATE_TILE_TYPE(pistonStickyBase_Id, PistonBaseTile_SPU);
+ CREATE_TILE_TYPE(cauldron_Id, CauldronTile_SPU);
- CREATE_TILE_TYPE(pistonExtensionPiece_Id, PistonExtensionTile_SPU);
+ CREATE_TILE_TYPE(endPortalTile_Id, TheEndPortal_SPU);
- CREATE_TILE_TYPE(pistonMovingPiece_Id, PistonMovingPiece_SPU);
+ CREATE_TILE_TYPE(endPortalFrameTile_Id, TheEndPortalFrameTile_SPU);
- CREATE_TILE_TYPE(lever_Id, LeverTile_SPU);
+ CREATE_TILE_TYPE(dragonEgg_Id, EggTile_SPU);
- CREATE_TILE_TYPE(cauldron_Id, CauldronTile_SPU);
+ CREATE_TILE_TYPE(cocoa_Id, CocoaTile_SPU);
- CREATE_TILE_TYPE(endPortalTile_Id, TheEndPortal_SPU);
+ CREATE_TILE_TYPE(redstoneLight_Id, RedlightTile_SPU);
+ CREATE_TILE_TYPE(redstoneLight_lit_Id, RedlightTile_SPU);
- CREATE_TILE_TYPE(endPortalFrameTile_Id, TheEndPortalFrameTile_SPU);
+ CREATE_TILE_TYPE(skull_Id, SkullTile_SPU);
- CREATE_TILE_TYPE(dragonEgg_Id, EggTile_SPU);
+ // these tile types don't have any additional code that we need.
+ CREATE_TILE_TYPE(stoneBrick_Id, Tile_SPU); // Tile
+ CREATE_TILE_TYPE(lapisBlock_Id, Tile_SPU);
+ CREATE_TILE_TYPE(redBrick_Id, Tile_SPU);
+ CREATE_TILE_TYPE(mossStone_Id, Tile_SPU);
+ CREATE_TILE_TYPE(netherBrick_Id, Tile_SPU);
+ CREATE_TILE_TYPE(whiteStone_Id, Tile_SPU);
+ CREATE_TILE_TYPE(unbreakable_Id, Tile_SPU);
+ CREATE_TILE_TYPE(sponge_Id, Tile_SPU);
+ CREATE_TILE_TYPE(rock_Id, Tile_SPU); // StoneTile
+ CREATE_TILE_TYPE(obsidian_Id, Tile_SPU); // StoneTile->ObsidianTile
+ CREATE_TILE_TYPE(sand_Id, Tile_SPU); // HeavyTile
+ CREATE_TILE_TYPE(gravel_Id, Tile_SPU); // GravelTile
+ CREATE_TILE_TYPE(goldOre_Id, Tile_SPU); // OreTile
+ CREATE_TILE_TYPE(ironOre_Id, Tile_SPU); // OreTile
+ CREATE_TILE_TYPE(coalOre_Id, Tile_SPU); // OreTile
+ CREATE_TILE_TYPE(lapisOre_Id, Tile_SPU); // OreTile
+ CREATE_TILE_TYPE(diamondOre_Id, Tile_SPU); // OreTile
+ CREATE_TILE_TYPE(clay_Id, Tile_SPU); // ClayTile
+ CREATE_TILE_TYPE(redStoneOre_Id, Tile_SPU); // RedStoneOreTile
+ CREATE_TILE_TYPE(redStoneOre_lit_Id, Tile_SPU); // RedStoneOreTile
+ CREATE_TILE_TYPE(goldBlock_Id, Tile_SPU); // MetalTile
+ CREATE_TILE_TYPE(ironBlock_Id, Tile_SPU); // MetalTile
+ CREATE_TILE_TYPE(diamondBlock_Id, Tile_SPU); // MetalTile
+ CREATE_TILE_TYPE(snow_Id, Tile_SPU); // SnowTile
+ CREATE_TILE_TYPE(hellRock_Id, Tile_SPU); // HellStoneTile
+ CREATE_TILE_TYPE(hellSand_Id, Tile_SPU); // HellSandTile
+ CREATE_TILE_TYPE(lightGem_Id, Tile_SPU); // LightGemTile
+ CREATE_TILE_TYPE(aprilFoolsJoke_Id, Tile_SPU); // LockedChestTile
- CREATE_TILE_TYPE(cocoa_Id, CocoaTile_SPU);
+ CREATE_TILE_TYPE(cloth_Id, ClothTile_SPU); // wool
- CREATE_TILE_TYPE(redstoneLight_Id, RedlightTile_SPU);
- CREATE_TILE_TYPE(redstoneLight_lit_Id, RedlightTile_SPU);
-
- CREATE_TILE_TYPE(skull_Id, SkullTile_SPU);
-
- // these tile types don't have any additional code that we need.
- CREATE_TILE_TYPE(stoneBrick_Id, Tile_SPU); // Tile
- CREATE_TILE_TYPE(lapisBlock_Id, Tile_SPU);
- CREATE_TILE_TYPE(redBrick_Id, Tile_SPU);
- CREATE_TILE_TYPE(mossStone_Id, Tile_SPU);
- CREATE_TILE_TYPE(netherBrick_Id, Tile_SPU);
- CREATE_TILE_TYPE(whiteStone_Id, Tile_SPU);
- CREATE_TILE_TYPE(unbreakable_Id, Tile_SPU);
- CREATE_TILE_TYPE(sponge_Id, Tile_SPU);
- CREATE_TILE_TYPE(rock_Id, Tile_SPU); // StoneTile
- CREATE_TILE_TYPE(obsidian_Id, Tile_SPU); // StoneTile->ObsidianTile
- CREATE_TILE_TYPE(sand_Id, Tile_SPU); // HeavyTile
- CREATE_TILE_TYPE(gravel_Id, Tile_SPU); // GravelTile
- CREATE_TILE_TYPE(goldOre_Id, Tile_SPU); // OreTile
- CREATE_TILE_TYPE(ironOre_Id, Tile_SPU); // OreTile
- CREATE_TILE_TYPE(coalOre_Id, Tile_SPU); // OreTile
- CREATE_TILE_TYPE(lapisOre_Id, Tile_SPU); // OreTile
- CREATE_TILE_TYPE(diamondOre_Id, Tile_SPU); // OreTile
- CREATE_TILE_TYPE(clay_Id, Tile_SPU); // ClayTile
- CREATE_TILE_TYPE(redStoneOre_Id, Tile_SPU); // RedStoneOreTile
- CREATE_TILE_TYPE(redStoneOre_lit_Id, Tile_SPU); // RedStoneOreTile
- CREATE_TILE_TYPE(goldBlock_Id, Tile_SPU); // MetalTile
- CREATE_TILE_TYPE(ironBlock_Id, Tile_SPU); // MetalTile
- CREATE_TILE_TYPE(diamondBlock_Id, Tile_SPU); // MetalTile
- CREATE_TILE_TYPE(snow_Id, Tile_SPU); // SnowTile
- CREATE_TILE_TYPE(hellRock_Id, Tile_SPU); // HellStoneTile
- CREATE_TILE_TYPE(hellSand_Id, Tile_SPU); // HellSandTile
- CREATE_TILE_TYPE(lightGem_Id, Tile_SPU); // LightGemTile
- CREATE_TILE_TYPE(aprilFoolsJoke_Id, Tile_SPU); // LockedChestTile
-
- CREATE_TILE_TYPE(cloth_Id, ClothTile_SPU); // wool
-
-
- CREATE_TILE_TYPE(emeraldOre_Id, Tile_SPU); // OreTile
- CREATE_TILE_TYPE(enderChest_Id, EnderChestTile_SPU);
- CREATE_TILE_TYPE(tripWireSource_Id, TripWireSourceTile_SPU);
- CREATE_TILE_TYPE(tripWire_Id, TripWireTile_SPU);
-//
- CREATE_TILE_TYPE(emeraldBlock_Id, Tile_SPU); // MetalTile
- CREATE_TILE_TYPE(cobbleWall_Id, WallTile_SPU);
- CREATE_TILE_TYPE(flowerPot_Id, FlowerPotTile_SPU);
- CREATE_TILE_TYPE(carrots_Id, CarrotTile_SPU);
- CREATE_TILE_TYPE(potatoes_Id, PotatoTile_SPU);
- CREATE_TILE_TYPE(anvil_Id, AnvilTile_SPU);
- CREATE_TILE_TYPE(netherQuartz_Id, Tile_SPU); // OreTile
- CREATE_TILE_TYPE(quartzBlock_Id, QuartzBlockTile_SPU);
- CREATE_TILE_TYPE(stairs_quartz_Id, StairTile_SPU);
- CREATE_TILE_TYPE(woolCarpet_Id, WoolCarpetTile_SPU);
-
-};
\ No newline at end of file
+ CREATE_TILE_TYPE(emeraldOre_Id, Tile_SPU); // OreTile
+ CREATE_TILE_TYPE(enderChest_Id, EnderChestTile_SPU);
+ CREATE_TILE_TYPE(tripWireSource_Id, TripWireSourceTile_SPU);
+ CREATE_TILE_TYPE(tripWire_Id, TripWireTile_SPU);
+ //
+ CREATE_TILE_TYPE(emeraldBlock_Id, Tile_SPU); // MetalTile
+ CREATE_TILE_TYPE(cobbleWall_Id, WallTile_SPU);
+ CREATE_TILE_TYPE(flowerPot_Id, FlowerPotTile_SPU);
+ CREATE_TILE_TYPE(carrots_Id, CarrotTile_SPU);
+ CREATE_TILE_TYPE(potatoes_Id, PotatoTile_SPU);
+ CREATE_TILE_TYPE(anvil_Id, AnvilTile_SPU);
+ CREATE_TILE_TYPE(netherQuartz_Id, Tile_SPU); // OreTile
+ CREATE_TILE_TYPE(quartzBlock_Id, QuartzBlockTile_SPU);
+ CREATE_TILE_TYPE(stairs_quartz_Id, StairTile_SPU);
+ CREATE_TILE_TYPE(woolCarpet_Id, WoolCarpetTile_SPU);
+};
diff --git a/Minecraft.Client/Platform/PS3/Xbox_Minecraft.cpp b/Minecraft.Client/Platform/PS3/Xbox_Minecraft.cpp
index fb8e88016..90c153b8d 100644
--- a/Minecraft.Client/Platform/PS3/Xbox_Minecraft.cpp
+++ b/Minecraft.Client/Platform/PS3/Xbox_Minecraft.cpp
@@ -661,7 +661,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
Tesselator::CreateNewThreadStorage(1024 * 1024);
// Initialise TLS for AABB and Vec3 pools, for this main thread
AABB::CreateNewThreadStorage();
- Vec3::CreateNewThreadStorage();
Level::enableLightingCache();
Minecraft::main();
@@ -961,9 +960,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
#endif
// Fix for #7318 - Title crashes after short soak in the leaderboards
- // menu A memory leak was caused because the icon renderer kept creating
- // new Vec3's because the pool wasn't reset
- Vec3::resetPool();
}
// Free resources, unregister custom classes, and exit.
diff --git a/Minecraft.Client/Platform/PSVita/PSVita_Minecraft.cpp b/Minecraft.Client/Platform/PSVita/PSVita_Minecraft.cpp
index 1ee98dd99..9065eccb7 100644
--- a/Minecraft.Client/Platform/PSVita/PSVita_Minecraft.cpp
+++ b/Minecraft.Client/Platform/PSVita/PSVita_Minecraft.cpp
@@ -896,7 +896,6 @@ int main() {
Tesselator::CreateNewThreadStorage(1024 * 1024);
// Initialise TLS for AABB and Vec3 pools, for this main thread
AABB::CreateNewThreadStorage();
- Vec3::CreateNewThreadStorage();
Compression::CreateNewThreadStorage();
OldChunkStorage::CreateNewThreadStorage();
Level::enableLightingCache();
@@ -1250,9 +1249,6 @@ int main() {
app.SaveDataTick();
// Fix for #7318 - Title crashes after short soak in the leaderboards
- // menu A memory leak was caused because the icon renderer kept creating
- // new Vec3's because the pool wasn't reset
- Vec3::resetPool();
// sceRazorCpuSync();
#ifndef _CONTENT_PACKAGE
diff --git a/Minecraft.Client/Platform/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Platform/Windows64/Windows64_Minecraft.cpp
index e64afe754..0e009e4ce 100644
--- a/Minecraft.Client/Platform/Windows64/Windows64_Minecraft.cpp
+++ b/Minecraft.Client/Platform/Windows64/Windows64_Minecraft.cpp
@@ -941,7 +941,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
Tesselator::CreateNewThreadStorage(1024 * 1024);
// Initialise TLS for AABB and Vec3 pools, for this main thread
AABB::CreateNewThreadStorage();
- Vec3::CreateNewThreadStorage();
Compression::CreateNewThreadStorage();
OldChunkStorage::CreateNewThreadStorage();
Level::enableLightingCache();
@@ -1269,9 +1268,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
}
// Fix for #7318 - Title crashes after short soak in the leaderboards
- // menu A memory leak was caused because the icon renderer kept creating
- // new Vec3's because the pool wasn't reset
- Vec3::resetPool();
}
// Free resources, unregister custom classes, and exit.
diff --git a/Minecraft.Client/Platform/Xbox/Xbox_Minecraft.cpp b/Minecraft.Client/Platform/Xbox/Xbox_Minecraft.cpp
index 822fd717c..1b2cdd997 100644
--- a/Minecraft.Client/Platform/Xbox/Xbox_Minecraft.cpp
+++ b/Minecraft.Client/Platform/Xbox/Xbox_Minecraft.cpp
@@ -700,7 +700,6 @@ int __cdecl main() {
Tesselator::CreateNewThreadStorage(1024 * 1024);
// Initialise TLS for AABB and Vec3 pools, for this main thread
AABB::CreateNewThreadStorage();
- Vec3::CreateNewThreadStorage();
Compression::CreateNewThreadStorage();
OldChunkStorage::CreateNewThreadStorage();
Level::enableLightingCache();
@@ -1029,9 +1028,6 @@ int __cdecl main() {
}
// Fix for #7318 - Title crashes after short soak in the leaderboards
- // menu A memory leak was caused because the icon renderer kept creating
- // new Vec3's because the pool wasn't reset
- Vec3::resetPool();
}
// Free resources, unregister custom classes, and exit.
diff --git a/Minecraft.Client/Player/EntityTracker.cpp b/Minecraft.Client/Player/EntityTracker.cpp
index 81e6b020d..901054c14 100644
--- a/Minecraft.Client/Player/EntityTracker.cpp
+++ b/Minecraft.Client/Player/EntityTracker.cpp
@@ -17,7 +17,6 @@
#include "../../Minecraft.World/Headers/net.minecraft.network.packet.h"
#include "../../Minecraft.World/Headers/net.minecraft.network.h"
#include "../../Minecraft.World/Headers/net.minecraft.world.level.dimension.h"
-#include "../../Minecraft.World/Util/BasicTypeContainers.h"
#include "../../Minecraft.World/Headers/net.minecraft.world.level.chunk.h"
#include "../Network/PlayerConnection.h"
@@ -250,4 +249,4 @@ std::shared_ptr EntityTracker::getTracker(
return it->second;
}
return nullptr;
-}
\ No newline at end of file
+}
diff --git a/Minecraft.Client/Player/LocalPlayer.cpp b/Minecraft.Client/Player/LocalPlayer.cpp
index dbb47eaf1..4a8e126e5 100644
--- a/Minecraft.Client/Player/LocalPlayer.cpp
+++ b/Minecraft.Client/Player/LocalPlayer.cpp
@@ -404,25 +404,25 @@ void LocalPlayer::aiStep() {
if (abilities.flying) // minecraft->options->isFlying )
{
- Vec3* viewVector = getViewVector(1.0f);
+ Vec3 viewVector = getViewVector(1.0f);
// 4J-PB - To let the player build easily while flying, we need to
// change this
#ifdef _DEBUG_MENUS_ENABLED
if (abilities.debugflying) {
- flyX = (float)viewVector->x * input->ya;
- flyY = (float)viewVector->y * input->ya;
- flyZ = (float)viewVector->z * input->ya;
+ flyX = (float)viewVector.x * input->ya;
+ flyY = (float)viewVector.y * input->ya;
+ flyZ = (float)viewVector.z * input->ya;
} else
#endif
{
if (isSprinting()) {
// Accelrate up to full speed if we are sprinting, moving in the
// direction of the view vector
- flyX = (float)viewVector->x * input->ya;
- flyY = (float)viewVector->y * input->ya;
- flyZ = (float)viewVector->z * input->ya;
+ flyX = (float)viewVector.x * input->ya;
+ flyY = (float)viewVector.y * input->ya;
+ flyZ = (float)viewVector.z * input->ya;
float scale = ((float)(SPRINT_DURATION - sprintTime)) / 10.0f;
scale = scale * scale;
@@ -550,7 +550,8 @@ void LocalPlayer::closeContainer() {
void LocalPlayer::openTextEdit(std::shared_ptr tileEntity) {
#ifdef ENABLE_JAVA_GUIS
if (tileEntity->GetType() == eTYPE_SIGNTILEENTITY) {
- minecraft->setScreen(new TextEditScreen(std::dynamic_pointer_cast(tileEntity)));
+ minecraft->setScreen(new TextEditScreen(
+ std::dynamic_pointer_cast(tileEntity)));
bool success = true;
}
#else
@@ -782,8 +783,7 @@ void LocalPlayer::awardStat(Stat* stat, byteArray param) {
// storage device, so needs a primary player, and the player may not
// have been a primary player when they first 'got' the award so let the
// award manager figure it out
- if (!minecraft->stats[m_iPad]->hasTaken(ach))
- {
+ if (!minecraft->stats[m_iPad]->hasTaken(ach)) {
// 4J-PB - Don't display the java popup
#ifdef ENABLE_JAVA_GUIS
minecraft->achievementPopup->popup(ach);
@@ -1506,7 +1506,7 @@ bool LocalPlayer::handleMouseClick(int button) {
bool usedItem = false;
if (minecraft->gameMode->useItemOn(
minecraft->localplayers[GetXboxPad()], level, item, x, y, z,
- face, minecraft->hitResult->pos, false, &usedItem)) {
+ face, &minecraft->hitResult->pos, false, &usedItem)) {
// Presume that if we actually used the held item, then we've
// placed it
if (usedItem) {
diff --git a/Minecraft.Client/Rendering/Camera.cpp b/Minecraft.Client/Rendering/Camera.cpp
index 0b77091af..f728f3f09 100644
--- a/Minecraft.Client/Rendering/Camera.cpp
+++ b/Minecraft.Client/Rendering/Camera.cpp
@@ -91,10 +91,11 @@ zPlayerOffs = position->get(2);
TilePos* Camera::getCameraTilePos(std::shared_ptr player,
double alpha) {
- return new TilePos(getCameraPos(player, alpha));
+ Vec3 cam_pos = getCameraPos(player, alpha);
+ return new TilePos(&cam_pos);
}
-Vec3* Camera::getCameraPos(std::shared_ptr player, double alpha) {
+Vec3 Camera::getCameraPos(std::shared_ptr player, double alpha) {
double xx = player->xo + (player->x - player->xo) * alpha;
double yy =
player->yo + (player->y - player->yo) * alpha + player->getHeadHeight();
@@ -104,21 +105,21 @@ Vec3* Camera::getCameraPos(std::shared_ptr player, double alpha) {
double yt = yy + Camera::yPlayerOffs * 1;
double zt = zz + Camera::zPlayerOffs * 1;
- return Vec3::newTemp(xt, yt, zt);
+ return Vec3(xt, yt, zt);
}
int Camera::getBlockAt(Level* level, std::shared_ptr player,
float alpha) {
- Vec3* p = Camera::getCameraPos(player, alpha);
- TilePos tp = TilePos(p);
+ Vec3 p = Camera::getCameraPos(player, alpha);
+ TilePos tp = TilePos(&p);
int t = level->getTile(tp.x, tp.y, tp.z);
if (t != 0 && Tile::tiles[t]->material->isLiquid()) {
float hh =
LiquidTile::getHeight(level->getData(tp.x, tp.y, tp.z)) - 1 / 9.0f;
float h = tp.y + 1 - hh;
- if (p->y >= h) {
+ if (p.y >= h) {
t = level->getTile(tp.x, tp.y + 1, tp.z);
}
}
return t;
-}
\ No newline at end of file
+}
diff --git a/Minecraft.Client/Rendering/Camera.h b/Minecraft.Client/Rendering/Camera.h
index ce2dcb6ce..894a01967 100644
--- a/Minecraft.Client/Rendering/Camera.h
+++ b/Minecraft.Client/Rendering/Camera.h
@@ -26,8 +26,8 @@ public:
static TilePos* getCameraTilePos(std::shared_ptr player,
double alpha);
- static Vec3* getCameraPos(std::shared_ptr player,
- double alpha);
+ static Vec3 getCameraPos(std::shared_ptr player,
+ double alpha);
static int getBlockAt(Level* level, std::shared_ptr player,
float alpha);
-};
\ No newline at end of file
+};
diff --git a/Minecraft.Client/Rendering/Culling/DirtyChunkSorter.cpp b/Minecraft.Client/Rendering/Culling/DirtyChunkSorter.cpp
index 9901135a6..ed12da6ef 100644
--- a/Minecraft.Client/Rendering/Culling/DirtyChunkSorter.cpp
+++ b/Minecraft.Client/Rendering/Culling/DirtyChunkSorter.cpp
@@ -23,4 +23,4 @@ bool DirtyChunkSorter::operator()(const Chunk* c0, const Chunk* c1) const {
if (d0 > d1) return true;
return c0->id >= c1->id; // 4J - was c0.id < c1.id ? 1 : -1
-}
\ No newline at end of file
+}
diff --git a/Minecraft.Client/Rendering/EntityRenderers/FishingHookRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/FishingHookRenderer.cpp
index 9d4b7e0f1..1bd178e64 100644
--- a/Minecraft.Client/Rendering/EntityRenderers/FishingHookRenderer.cpp
+++ b/Minecraft.Client/Rendering/EntityRenderers/FishingHookRenderer.cpp
@@ -58,22 +58,22 @@ void FishingHookRenderer::render(std::shared_ptr _hook, double x,
float swing = hook->owner->getAttackAnim(a);
float swing2 = (float)Mth::sin(sqrt(swing) * PI);
- Vec3* vv = Vec3::newTemp(-0.5, 0.03, 0.8);
- vv->xRot(-(hook->owner->xRotO +
- (hook->owner->xRot - hook->owner->xRotO) * a) *
- PI / 180);
- vv->yRot(-(hook->owner->yRotO +
- (hook->owner->yRot - hook->owner->yRotO) * a) *
- PI / 180);
- vv->yRot(swing2 * 0.5f);
- vv->xRot(-swing2 * 0.7f);
+ Vec3 vv(-0.5, 0.03, 0.8);
+ vv.xRot(-(hook->owner->xRotO +
+ (hook->owner->xRot - hook->owner->xRotO) * a) *
+ PI / 180);
+ vv.yRot(-(hook->owner->yRotO +
+ (hook->owner->yRot - hook->owner->yRotO) * a) *
+ PI / 180);
+ vv.yRot(swing2 * 0.5f);
+ vv.xRot(-swing2 * 0.7f);
double xp =
- hook->owner->xo + (hook->owner->x - hook->owner->xo) * a + vv->x;
+ hook->owner->xo + (hook->owner->x - hook->owner->xo) * a + vv.x;
double yp =
- hook->owner->yo + (hook->owner->y - hook->owner->yo) * a + vv->y;
+ hook->owner->yo + (hook->owner->y - hook->owner->yo) * a + vv.y;
double zp =
- hook->owner->zo + (hook->owner->z - hook->owner->zo) * a + vv->z;
+ hook->owner->zo + (hook->owner->z - hook->owner->zo) * a + vv.z;
double yOffset = hook->owner == std::dynamic_pointer_cast(
Minecraft::GetInstance()->player)
? 0
diff --git a/Minecraft.Client/Rendering/EntityRenderers/LivingEntityRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/LivingEntityRenderer.cpp
index d2183890e..6be119c1b 100644
--- a/Minecraft.Client/Rendering/EntityRenderers/LivingEntityRenderer.cpp
+++ b/Minecraft.Client/Rendering/EntityRenderers/LivingEntityRenderer.cpp
@@ -613,4 +613,4 @@ void LivingEntityRenderer::renderNameTag(std::shared_ptr mob,
glDisable(GL_BLEND);
glColor4f(1, 1, 1, 1);
glPopMatrix();
-}
\ No newline at end of file
+}
diff --git a/Minecraft.Client/Rendering/EntityRenderers/MinecartRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/MinecartRenderer.cpp
index f1d7cd569..5868a654e 100644
--- a/Minecraft.Client/Rendering/EntityRenderers/MinecartRenderer.cpp
+++ b/Minecraft.Client/Rendering/EntityRenderers/MinecartRenderer.cpp
@@ -1,5 +1,6 @@
#include "../../Platform/stdafx.h"
#include "MinecartRenderer.h"
+#include
#include "../Models/MinecartModel.h"
#include "../../Textures/TextureAtlas.h"
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.item.h"
@@ -40,26 +41,27 @@ void MinecartRenderer::render(std::shared_ptr _cart, double x, double y,
double r = 0.3f;
- Vec3* p = cart->getPos(xx, yy, zz);
+ std::optional p = cart->getPos(xx, yy, zz);
float xRot = cart->xRotO + (cart->xRot - cart->xRotO) * a;
- if (p != NULL) {
- Vec3* p0 = cart->getPosOffs(xx, yy, zz, r);
- Vec3* p1 = cart->getPosOffs(xx, yy, zz, -r);
- if (p0 == NULL) p0 = p;
- if (p1 == NULL) p1 = p;
+ if (p.has_value()) {
+ auto p0 = cart->getPosOffs(xx, yy, zz, r);
+ auto p1 = cart->getPosOffs(xx, yy, zz, -r);
+ if (!p0.has_value()) p0 = p;
+ if (!p1.has_value()) p1 = p;
x += p->x - xx;
y += (p0->y + p1->y) / 2 - yy;
z += p->z - zz;
- Vec3* dir = p1->add(-p0->x, -p0->y, -p0->z);
- if (dir->length() == 0) {
+ Vec3 dir(-p0->x, -p0->y, -p0->z);
+ dir = dir.add(p1->x, p1->y, p1->z);
+ if (dir.length() == 0) {
} else {
- dir = dir->normalize();
- rot = (float)(atan2(dir->z, dir->x) * 180 / PI);
- xRot = (float)(atan(dir->y) * 73);
+ dir = dir.normalize();
+ rot = (float)(atan2(dir.z, dir.x) * 180 / PI);
+ xRot = (float)(atan(dir.y) * 73);
}
}
glTranslatef((float)x, (float)y, (float)z);
@@ -146,4 +148,4 @@ void MinecartRenderer::renderMinecartContents(std::shared_ptr cart,
glPushMatrix();
renderer->renderTile(tile, tileData, brightness);
glPopMatrix();
-}
\ No newline at end of file
+}
diff --git a/Minecraft.Client/Rendering/EntityRenderers/TileRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/TileRenderer.cpp
index e78b97a3d..3ee4ff71a 100644
--- a/Minecraft.Client/Rendering/EntityRenderers/TileRenderer.cpp
+++ b/Minecraft.Client/Rendering/EntityRenderers/TileRenderer.cpp
@@ -1,6 +1,7 @@
#include "../../Platform/stdafx.h"
#include "TileRenderer.h"
+#include
#include "../GameRenderer.h"
#include "../../Minecraft.h"
#include "../../Textures/Textures.h"
@@ -1045,9 +1046,8 @@ bool TileRenderer::tesselateAnvilInWorld(AnvilTile* tt, int x, int y, int z,
float TileRenderer::tesselateAnvilPiece(AnvilTile* tt, int x, int y, int z,
int part, float bottom, float width,
- float height, float length,
- bool rotate, bool render,
- int data) {
+ float height, float length, bool rotate,
+ bool render, int data) {
if (rotate) {
float swap = width;
width = length;
@@ -1818,58 +1818,58 @@ bool TileRenderer::tesselateLeverInWorld(Tile* tt, int x, int y, int z) {
float u1 = tex->getU1(true);
float v1 = tex->getV1(true);
- Vec3* corners[8];
+ std::array corners;
float xv = 1.0f / 16.0f;
float zv = 1.0f / 16.0f;
float yv = 10.0f / 16.0f;
- corners[0] = Vec3::newTemp(-xv, -0, -zv);
- corners[1] = Vec3::newTemp(+xv, -0, -zv);
- corners[2] = Vec3::newTemp(+xv, -0, +zv);
- corners[3] = Vec3::newTemp(-xv, -0, +zv);
- corners[4] = Vec3::newTemp(-xv, +yv, -zv);
- corners[5] = Vec3::newTemp(+xv, +yv, -zv);
- corners[6] = Vec3::newTemp(+xv, +yv, +zv);
- corners[7] = Vec3::newTemp(-xv, +yv, +zv);
+ corners[0] = Vec3(-xv, -0, -zv);
+ corners[1] = Vec3(+xv, -0, -zv);
+ corners[2] = Vec3(+xv, -0, +zv);
+ corners[3] = Vec3(-xv, -0, +zv);
+ corners[4] = Vec3(-xv, +yv, -zv);
+ corners[5] = Vec3(+xv, +yv, -zv);
+ corners[6] = Vec3(+xv, +yv, +zv);
+ corners[7] = Vec3(-xv, +yv, +zv);
for (int i = 0; i < 8; i++) {
if (flipped) {
- corners[i]->z -= 1 / 16.0f;
- corners[i]->xRot(40 * PI / 180);
+ corners[i].z -= 1 / 16.0f;
+ corners[i].xRot(40 * PI / 180);
} else {
- corners[i]->z += 1 / 16.0f;
- corners[i]->xRot(-40 * PI / 180);
+ corners[i].z += 1 / 16.0f;
+ corners[i].xRot(-40 * PI / 180);
}
if (dir == 0 || dir == 7) {
- corners[i]->zRot(180 * PI / 180);
+ corners[i].zRot(180 * PI / 180);
}
if (dir == 6 || dir == 0) {
- corners[i]->yRot(90 * PI / 180);
+ corners[i].yRot(90 * PI / 180);
}
if (dir > 0 && dir < 5) {
- corners[i]->y -= 6 / 16.0f;
- corners[i]->xRot(90 * PI / 180);
+ corners[i].y -= 6 / 16.0f;
+ corners[i].xRot(90 * PI / 180);
- if (dir == 4) corners[i]->yRot(0 * PI / 180);
- if (dir == 3) corners[i]->yRot(180 * PI / 180);
- if (dir == 2) corners[i]->yRot(90 * PI / 180);
- if (dir == 1) corners[i]->yRot(-90 * PI / 180);
+ if (dir == 4) corners[i].yRot(0 * PI / 180);
+ if (dir == 3) corners[i].yRot(180 * PI / 180);
+ if (dir == 2) corners[i].yRot(90 * PI / 180);
+ if (dir == 1) corners[i].yRot(-90 * PI / 180);
- corners[i]->x += x + 0.5;
- corners[i]->y += y + 8 / 16.0f;
- corners[i]->z += z + 0.5;
+ corners[i].x += x + 0.5;
+ corners[i].y += y + 8 / 16.0f;
+ corners[i].z += z + 0.5;
} else if (dir == 0 || dir == 7) {
- corners[i]->x += x + 0.5;
- corners[i]->y += y + 14 / 16.0f;
- corners[i]->z += z + 0.5;
+ corners[i].x += x + 0.5;
+ corners[i].y += y + 14 / 16.0f;
+ corners[i].z += z + 0.5;
} else {
- corners[i]->x += x + 0.5;
- corners[i]->y += y + 2 / 16.0f;
- corners[i]->z += z + 0.5;
+ corners[i].x += x + 0.5;
+ corners[i].y += y + 2 / 16.0f;
+ corners[i].z += z + 0.5;
}
}
- Vec3 *c0 = NULL, *c1 = NULL, *c2 = NULL, *c3 = NULL;
+ Vec3 c0, c1, c2, c3;
for (int i = 0; i < 6; i++) {
if (i == 0) {
u0 = tex->getU(7, true);
@@ -1913,13 +1913,13 @@ bool TileRenderer::tesselateLeverInWorld(Tile* tt, int x, int y, int z) {
c2 = corners[7];
c3 = corners[4];
}
- t->vertexUV((float)(c0->x), (float)(c0->y), (float)(c0->z), (float)(u0),
+ t->vertexUV((float)(c0.x), (float)(c0.y), (float)(c0.z), (float)(u0),
(float)(v1));
- t->vertexUV((float)(c1->x), (float)(c1->y), (float)(c1->z), (float)(u1),
+ t->vertexUV((float)(c1.x), (float)(c1.y), (float)(c1.z), (float)(u1),
(float)(v1));
- t->vertexUV((float)(c2->x), (float)(c2->y), (float)(c2->z), (float)(u1),
+ t->vertexUV((float)(c2.x), (float)(c2.y), (float)(c2.z), (float)(u1),
(float)(v0));
- t->vertexUV((float)(c3->x), (float)(c3->y), (float)(c3->z), (float)(u0),
+ t->vertexUV((float)(c3.x), (float)(c3.y), (float)(c3.z), (float)(u0),
(float)(v0));
}
return true;
@@ -1977,46 +1977,46 @@ bool TileRenderer::tesselateTripwireSourceInWorld(Tile* tt, int x, int y,
double u1 = tex->getU1();
double v1 = tex->getV1();
- Vec3* corners[8];
+ std::array corners;
float stickWidth = 0.75f / 16.0f;
float stickHeight = 0.75f / 16.0f;
float stickLength = 5 / 16.0f;
- corners[0] = Vec3::newTemp(-stickWidth, -0, -stickHeight);
- corners[1] = Vec3::newTemp(+stickWidth, -0, -stickHeight);
- corners[2] = Vec3::newTemp(+stickWidth, -0, +stickHeight);
- corners[3] = Vec3::newTemp(-stickWidth, -0, +stickHeight);
- corners[4] = Vec3::newTemp(-stickWidth, +stickLength, -stickHeight);
- corners[5] = Vec3::newTemp(+stickWidth, +stickLength, -stickHeight);
- corners[6] = Vec3::newTemp(+stickWidth, +stickLength, +stickHeight);
- corners[7] = Vec3::newTemp(-stickWidth, +stickLength, +stickHeight);
+ corners[0] = Vec3(-stickWidth, -0, -stickHeight);
+ corners[1] = Vec3(+stickWidth, -0, -stickHeight);
+ corners[2] = Vec3(+stickWidth, -0, +stickHeight);
+ corners[3] = Vec3(-stickWidth, -0, +stickHeight);
+ corners[4] = Vec3(-stickWidth, +stickLength, -stickHeight);
+ corners[5] = Vec3(+stickWidth, +stickLength, -stickHeight);
+ corners[6] = Vec3(+stickWidth, +stickLength, +stickHeight);
+ corners[7] = Vec3(-stickWidth, +stickLength, +stickHeight);
for (int i = 0; i < 8; i++) {
- corners[i]->z += 1 / 16.0f;
+ corners[i].z += 1 / 16.0f;
if (powered) {
- corners[i]->xRot(30 * PI / 180);
- corners[i]->y -= 7 / 16.0f;
+ corners[i].xRot(30 * PI / 180);
+ corners[i].y -= 7 / 16.0f;
} else if (attached) {
- corners[i]->xRot(5 * PI / 180);
- corners[i]->y -= 7 / 16.0f;
+ corners[i].xRot(5 * PI / 180);
+ corners[i].y -= 7 / 16.0f;
} else {
- corners[i]->xRot(-40 * PI / 180);
- corners[i]->y -= 6 / 16.0f;
+ corners[i].xRot(-40 * PI / 180);
+ corners[i].y -= 6 / 16.0f;
}
- corners[i]->xRot(90 * PI / 180);
+ corners[i].xRot(90 * PI / 180);
- if (dir == Direction::NORTH) corners[i]->yRot(0 * PI / 180);
- if (dir == Direction::SOUTH) corners[i]->yRot(180 * PI / 180);
- if (dir == Direction::WEST) corners[i]->yRot(90 * PI / 180);
- if (dir == Direction::EAST) corners[i]->yRot(-90 * PI / 180);
+ if (dir == Direction::NORTH) corners[i].yRot(0 * PI / 180);
+ if (dir == Direction::SOUTH) corners[i].yRot(180 * PI / 180);
+ if (dir == Direction::WEST) corners[i].yRot(90 * PI / 180);
+ if (dir == Direction::EAST) corners[i].yRot(-90 * PI / 180);
- corners[i]->x += x + 0.5;
- corners[i]->y += y + 5 / 16.0f;
- corners[i]->z += z + 0.5;
+ corners[i].x += x + 0.5;
+ corners[i].y += y + 5 / 16.0f;
+ corners[i].z += z + 0.5;
}
- Vec3 *c0 = NULL, *c1 = NULL, *c2 = NULL, *c3 = NULL;
+ Vec3 c0, c1, c2, c3;
int stickX0 = 7;
int stickX1 = 9;
int stickY0 = 9;
@@ -2062,47 +2062,47 @@ bool TileRenderer::tesselateTripwireSourceInWorld(Tile* tt, int x, int y,
c2 = corners[7];
c3 = corners[4];
}
- t->vertexUV(c0->x, c0->y, c0->z, u0, v1);
- t->vertexUV(c1->x, c1->y, c1->z, u1, v1);
- t->vertexUV(c2->x, c2->y, c2->z, u1, v0);
- t->vertexUV(c3->x, c3->y, c3->z, u0, v0);
+ t->vertexUV(c0.x, c0.y, c0.z, u0, v1);
+ t->vertexUV(c1.x, c1.y, c1.z, u1, v1);
+ t->vertexUV(c2.x, c2.y, c2.z, u1, v0);
+ t->vertexUV(c3.x, c3.y, c3.z, u0, v0);
}
float hoopWidth = 1.5f / 16.0f;
float hoopHeight = 1.5f / 16.0f;
float hoopLength = 0.5f / 16.0f;
- corners[0] = Vec3::newTemp(-hoopWidth, -0, -hoopHeight);
- corners[1] = Vec3::newTemp(+hoopWidth, -0, -hoopHeight);
- corners[2] = Vec3::newTemp(+hoopWidth, -0, +hoopHeight);
- corners[3] = Vec3::newTemp(-hoopWidth, -0, +hoopHeight);
- corners[4] = Vec3::newTemp(-hoopWidth, +hoopLength, -hoopHeight);
- corners[5] = Vec3::newTemp(+hoopWidth, +hoopLength, -hoopHeight);
- corners[6] = Vec3::newTemp(+hoopWidth, +hoopLength, +hoopHeight);
- corners[7] = Vec3::newTemp(-hoopWidth, +hoopLength, +hoopHeight);
+ corners[0] = Vec3(-hoopWidth, -0, -hoopHeight);
+ corners[1] = Vec3(+hoopWidth, -0, -hoopHeight);
+ corners[2] = Vec3(+hoopWidth, -0, +hoopHeight);
+ corners[3] = Vec3(-hoopWidth, -0, +hoopHeight);
+ corners[4] = Vec3(-hoopWidth, +hoopLength, -hoopHeight);
+ corners[5] = Vec3(+hoopWidth, +hoopLength, -hoopHeight);
+ corners[6] = Vec3(+hoopWidth, +hoopLength, +hoopHeight);
+ corners[7] = Vec3(-hoopWidth, +hoopLength, +hoopHeight);
for (int i = 0; i < 8; i++) {
- corners[i]->z += 3.5f / 16.0f;
+ corners[i].z += 3.5f / 16.0f;
if (powered) {
- corners[i]->y -= 1.5 / 16.0f;
- corners[i]->z -= 2.6 / 16.0f;
- corners[i]->xRot(0 * PI / 180);
+ corners[i].y -= 1.5 / 16.0f;
+ corners[i].z -= 2.6 / 16.0f;
+ corners[i].xRot(0 * PI / 180);
} else if (attached) {
- corners[i]->y += 0.25 / 16.0f;
- corners[i]->z -= 2.75 / 16.0f;
- corners[i]->xRot(10 * PI / 180);
+ corners[i].y += 0.25 / 16.0f;
+ corners[i].z -= 2.75 / 16.0f;
+ corners[i].xRot(10 * PI / 180);
} else {
- corners[i]->xRot(50 * PI / 180);
+ corners[i].xRot(50 * PI / 180);
}
- if (dir == Direction::NORTH) corners[i]->yRot(0 * PI / 180);
- if (dir == Direction::SOUTH) corners[i]->yRot(180 * PI / 180);
- if (dir == Direction::WEST) corners[i]->yRot(90 * PI / 180);
- if (dir == Direction::EAST) corners[i]->yRot(-90 * PI / 180);
+ if (dir == Direction::NORTH) corners[i].yRot(0 * PI / 180);
+ if (dir == Direction::SOUTH) corners[i].yRot(180 * PI / 180);
+ if (dir == Direction::WEST) corners[i].yRot(90 * PI / 180);
+ if (dir == Direction::EAST) corners[i].yRot(-90 * PI / 180);
- corners[i]->x += x + 0.5;
- corners[i]->y += y + 5 / 16.0f;
- corners[i]->z += z + 0.5;
+ corners[i].x += x + 0.5;
+ corners[i].y += y + 5 / 16.0f;
+ corners[i].z += z + 0.5;
}
int hoopX0 = 5;
@@ -2150,14 +2150,14 @@ bool TileRenderer::tesselateTripwireSourceInWorld(Tile* tt, int x, int y,
c2 = corners[7];
c3 = corners[4];
}
- t->vertexUV(c0->x, c0->y, c0->z, u0, v1);
- t->vertexUV(c1->x, c1->y, c1->z, u1, v1);
- t->vertexUV(c2->x, c2->y, c2->z, u1, v0);
- t->vertexUV(c3->x, c3->y, c3->z, u0, v0);
+ t->vertexUV(c0.x, c0.y, c0.z, u0, v1);
+ t->vertexUV(c1.x, c1.y, c1.z, u1, v1);
+ t->vertexUV(c2.x, c2.y, c2.z, u1, v0);
+ t->vertexUV(c3.x, c3.y, c3.z, u0, v0);
}
if (attached) {
- double hoopBottomY = corners[0]->y;
+ double hoopBottomY = corners[0].y;
float width = 0.5f / 16.0f;
float top = 0.5f - (width / 2);
float bottom = top + width;
@@ -4068,9 +4068,11 @@ bool TileRenderer::tesselateCrossInWorld(Tile* tt, int x, int y, int z) {
float zt = (float)z;
if (tt == Tile::tallgrass) {
- // 4jcraft add a bunch of casts to prevent overflow (i pray to god)
- int64_t seed = ((int64_t)x * 3129871) ^ ((int64_t)z * 116129781L) ^ ((int64_t)y);
- seed = (int64_t)(((uint64_t)seed * (uint64_t)seed * 42317861ULL) + ((uint64_t)seed * 11ULL));
+ // 4jcraft add a bunch of casts to prevent overflow (i pray to god)
+ int64_t seed =
+ ((int64_t)x * 3129871) ^ ((int64_t)z * 116129781L) ^ ((int64_t)y);
+ seed = (int64_t)(((uint64_t)seed * (uint64_t)seed * 42317861ULL) +
+ ((uint64_t)seed * 11ULL));
xt += ((((seed >> 16) & 0xf) / 15.0f) - 0.5f) * 0.5f;
yt += ((((seed >> 20) & 0xf) / 15.0f) - 1.0f) * 0.2f;
@@ -4326,8 +4328,10 @@ bool TileRenderer::tesselateLilypadInWorld(Tile* tt, int x, int y, int z) {
float v1 = tex->getV1(true);
// 4jcraft add a bunch of casts to prevent overflow (i pray to god)
- int64_t seed = ((int64_t)x * 3129871) ^ ((int64_t)z * 116129781L) ^ ((int64_t)y);
- seed = (int64_t)(((uint64_t)seed * (uint64_t)seed * 42317861ULL) + ((uint64_t)seed * 11ULL));
+ int64_t seed =
+ ((int64_t)x * 3129871) ^ ((int64_t)z * 116129781L) ^ ((int64_t)y);
+ seed = (int64_t)(((uint64_t)seed * (uint64_t)seed * 42317861ULL) +
+ ((uint64_t)seed * 11ULL));
int dir = (int)((seed >> 16) & 0x3);
diff --git a/Minecraft.Client/Rendering/GameRenderer.cpp b/Minecraft.Client/Rendering/GameRenderer.cpp
index 9455cc252..6364b2ba1 100644
--- a/Minecraft.Client/Rendering/GameRenderer.cpp
+++ b/Minecraft.Client/Rendering/GameRenderer.cpp
@@ -90,7 +90,7 @@ GameRenderer::GameRenderer(Minecraft* mc) {
tickSmoothYO = 0;
lastTickA = 0;
- cameraPos = Vec3::newPermanent(0.0f, 0.0f, 0.0f);
+ cameraPos = Vec3(0.0f, 0.0f, 0.0f);
fovOffset = 0;
fovOffsetO = 0;
@@ -291,7 +291,7 @@ void GameRenderer::pick(float a) {
}
double dist = range;
- Vec3* from = mc->cameraTargetPlayer->getPos(a);
+ Vec3 from = mc->cameraTargetPlayer->getPos(a);
if (mc->gameMode->hasFarPickRange()) {
dist = range = 6;
@@ -301,17 +301,18 @@ void GameRenderer::pick(float a) {
}
if (mc->hitResult != NULL) {
- dist = mc->hitResult->pos->distanceTo(from);
+ dist = mc->hitResult->pos.distanceTo(from);
}
- Vec3* b = mc->cameraTargetPlayer->getViewVector(a);
- Vec3* to = from->add(b->x * range, b->y * range, b->z * range);
+ Vec3 b = mc->cameraTargetPlayer->getViewVector(a);
+ Vec3 to(b.x * range, b.y * range, b.z * range);
+ to = to.add(from.x, from.y, from.z);
hovered = nullptr;
float overlap = 1;
std::vector >* objects = mc->level->getEntities(
mc->cameraTargetPlayer,
mc->cameraTargetPlayer->bb
- ->expand(b->x * (range), b->y * (range), b->z * (range))
+ ->expand(b.x * (range), b.y * (range), b.z * (range))
->grow(overlap, overlap, overlap));
double nearest = dist;
@@ -322,14 +323,14 @@ void GameRenderer::pick(float a) {
float rr = e->getPickRadius();
AABB* bb = e->bb->grow(rr, rr, rr);
- HitResult* p = bb->clip(from, to);
- if (bb->contains(from)) {
+ HitResult* p = bb->clip(&from, &to);
+ if (bb->contains(&from)) {
if (0 < nearest || nearest == 0) {
hovered = e;
nearest = 0;
}
} else if (p != NULL) {
- double dd = from->distanceTo(p->pos);
+ double dd = from.distanceTo(p->pos);
std::shared_ptr ridingEntity =
mc->cameraTargetPlayer->riding;
// 4jcraft: compare the mounted entity explicitly so riding the hit
@@ -523,11 +524,12 @@ void GameRenderer::moveCameraToPlayer(float a) {
// 4J - corrected bug here where zo was also added to x
// component
- HitResult* hr = mc->level->clip(
- Vec3::newTemp(x + xo, y + yo, z + zo),
- Vec3::newTemp(x - xd + xo, y - yd + yo, z - zd + zo));
+ Vec3 a(x + xo, y + yo, z + zo);
+ Vec3 b(x - xd + xo, y - yd + yo, z - zd + zo);
+ HitResult* hr = mc->level->clip(&a, &b);
if (hr != NULL) {
- double dist = hr->pos->distanceTo(Vec3::newTemp(x, y, z));
+ Vec3 p(x, y, z);
+ double dist = hr->pos.distanceTo(p);
if (dist < cameraDist) cameraDist = dist;
delete hr;
}
@@ -1113,7 +1115,6 @@ void GameRenderer::FinishedReassigning() {
int GameRenderer::runUpdate(void* lpParam) {
Minecraft* minecraft = Minecraft::GetInstance();
- Vec3::CreateNewThreadStorage();
AABB::CreateNewThreadStorage();
Tesselator::CreateNewThreadStorage(1024 * 1024);
Compression::UseDefaultThreadStorage();
@@ -1194,7 +1195,6 @@ int GameRenderer::runUpdate(void* lpParam) {
// PIXEndNamedEvent();
AABB::resetPool();
- Vec3::resetPool();
m_updateEvents->Set(eUpdateEventIsFinished);
}
@@ -1369,11 +1369,11 @@ void GameRenderer::renderLevel(float a, int64_t until) {
// storing the camera position Fix for #77745 - TU9: Content:
// Gameplay: Items and mobs not belonging to end world are
// disappearing when Enderdragon is damaged.
- Vec3* cameraPosTemp = cameraEntity->getPos(a);
- cameraPos->x = cameraPosTemp->x;
- cameraPos->y = cameraPosTemp->y;
- cameraPos->z = cameraPosTemp->z;
- levelRenderer->renderEntities(cameraPos, frustum, a);
+ Vec3 cameraPosTemp = cameraEntity->getPos(a);
+ cameraPos.x = cameraPosTemp.x;
+ cameraPos.y = cameraPosTemp.y;
+ cameraPos.z = cameraPosTemp.z;
+ levelRenderer->renderEntities(&cameraPos, frustum, a);
#ifdef __PSVITA__
// AP - make sure we're using the Alpha cut out effect for particles
glEnable(GL_ALPHA_TEST);
@@ -1853,21 +1853,20 @@ void GameRenderer::setupClearColor(float a) {
float whiteness = 1.0f / (4 - mc->options->viewDistance);
whiteness = 1 - (float)pow((double)whiteness, 0.25);
- Vec3* skyColor = level->getSkyColor(mc->cameraTargetPlayer, a);
- float sr = (float)skyColor->x;
- float sg = (float)skyColor->y;
- float sb = (float)skyColor->z;
+ Vec3 skyColor = level->getSkyColor(mc->cameraTargetPlayer, a);
+ float sr = (float)skyColor.x;
+ float sg = (float)skyColor.y;
+ float sb = (float)skyColor.z;
- Vec3* fogColor = level->getFogColor(a);
- fr = (float)fogColor->x;
- fg = (float)fogColor->y;
- fb = (float)fogColor->z;
+ Vec3 fogColor = level->getFogColor(a);
+ fr = (float)fogColor.x;
+ fg = (float)fogColor.y;
+ fb = (float)fogColor.z;
if (mc->options->viewDistance < 2) {
- Vec3* sunAngle = Mth::sin(level->getSunAngle(a)) > 0
- ? Vec3::newTemp(-1, 0, 0)
- : Vec3::newTemp(1, 0, 0);
- float d = (float)player->getViewVector(a)->dot(sunAngle);
+ Vec3 sunAngle = Mth::sin(level->getSunAngle(a)) > 0 ? Vec3(-1, 0, 0)
+ : Vec3(1, 0, 0);
+ float d = (float)player->getViewVector(a).dot(sunAngle);
if (d < 0) d = 0;
if (d > 0) {
float* c =
@@ -1903,10 +1902,10 @@ void GameRenderer::setupClearColor(float a) {
int t = Camera::getBlockAt(mc->level, player, a);
if (isInClouds) {
- Vec3* cc = level->getCloudColor(a);
- fr = (float)cc->x;
- fg = (float)cc->y;
- fb = (float)cc->z;
+ Vec3 cc = level->getCloudColor(a);
+ fr = (float)cc.x;
+ fg = (float)cc.y;
+ fb = (float)cc.z;
} else if (t != 0 && Tile::tiles[t]->material == Material::water) {
float clearness = EnchantmentHelper::getOxygenBonus(player) * 0.2f;
diff --git a/Minecraft.Client/Rendering/GameRenderer.h b/Minecraft.Client/Rendering/GameRenderer.h
index e3b4c0ca7..c359e45e2 100644
--- a/Minecraft.Client/Rendering/GameRenderer.h
+++ b/Minecraft.Client/Rendering/GameRenderer.h
@@ -50,7 +50,7 @@ private:
float thirdTiltO;
float accumulatedSmoothXO, accumulatedSmoothYO;
float tickSmoothXO, tickSmoothYO, lastTickA;
- Vec3* cameraPos; // 4J added
+ Vec3 cameraPos; // 4J added
// fov modification
float fovOffset;
diff --git a/Minecraft.Client/Rendering/LevelRenderer.cpp b/Minecraft.Client/Rendering/LevelRenderer.cpp
index 313922573..c20356003 100644
--- a/Minecraft.Client/Rendering/LevelRenderer.cpp
+++ b/Minecraft.Client/Rendering/LevelRenderer.cpp
@@ -1,5 +1,6 @@
#include "../Platform/stdafx.h"
#include "LevelRenderer.h"
+#include
#include "../Textures/Textures.h"
#include "../Textures/TextureAtlas.h"
#include "Tesselator.h"
@@ -59,7 +60,6 @@
#include "../Level/MultiPlayerLevel.h"
#include "../../Minecraft.World/Util/SoundTypes.h"
#include "FrustumCuller.h"
-#include "../../Minecraft.World/Util/BasicTypeContainers.h"
// #define DISABLE_SPU_CODE
@@ -1035,10 +1035,10 @@ void LevelRenderer::renderSky(float alpha) {
glDisable(GL_TEXTURE_2D);
int playerIndex = mc->player->GetXboxPad();
- Vec3* sc = level[playerIndex]->getSkyColor(mc->cameraTargetPlayer, alpha);
- float sr = (float)sc->x;
- float sg = (float)sc->y;
- float sb = (float)sc->z;
+ Vec3 sc = level[playerIndex]->getSkyColor(mc->cameraTargetPlayer, alpha);
+ float sr = (float)sc.x;
+ float sg = (float)sc.y;
+ float sb = (float)sc.z;
if (mc->options->anaglyph3d) {
float srr = (sr * 30 + sg * 59 + sb * 11) / 100;
@@ -1185,7 +1185,7 @@ void LevelRenderer::renderSky(float alpha) {
glColor3f(0, 0, 0);
double yy =
- mc->player->getPos(alpha)->y -
+ mc->player->getPos(alpha).y -
level[playerIndex]->getHorizonHeight(); // 4J - getHorizonHeight moved
// forward from 1.2.3
if (yy < 0) {
@@ -1259,10 +1259,10 @@ void LevelRenderer::renderHaloRing(float alpha) {
int playerIndex = mc->player->GetXboxPad();
- Vec3* sc = level[playerIndex]->getSkyColor(mc->cameraTargetPlayer, alpha);
- float sr = (float)sc->x;
- float sg = (float)sc->y;
- float sb = (float)sc->z;
+ Vec3 sc = level[playerIndex]->getSkyColor(mc->cameraTargetPlayer, alpha);
+ float sr = (float)sc.x;
+ float sg = (float)sc.y;
+ float sb = (float)sc.z;
// Rough lumninance calculation
float Y = (sr + sr + sb + sg + sg + sg) / 6;
@@ -1335,10 +1335,10 @@ void LevelRenderer::renderClouds(float alpha) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- Vec3* cc = level[playerIndex]->getCloudColor(alpha);
- float cr = (float)cc->x;
- float cg = (float)cc->y;
- float cb = (float)cc->z;
+ Vec3 cc = level[playerIndex]->getCloudColor(alpha);
+ float cr = (float)cc.x;
+ float cg = (float)cc.y;
+ float cb = (float)cc.z;
if (mc->options->anaglyph3d) {
float crr = (cr * 30 + cg * 59 + cb * 11) / 100;
@@ -1632,10 +1632,10 @@ void LevelRenderer::renderAdvancedClouds(float alpha) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- Vec3* cc = level[playerIndex]->getCloudColor(alpha);
- float cr = (float)cc->x;
- float cg = (float)cc->y;
- float cb = (float)cc->z;
+ Vec3 cc = level[playerIndex]->getCloudColor(alpha);
+ float cr = (float)cc.x;
+ float cg = (float)cc.y;
+ float cb = (float)cc.z;
if (mc->options->anaglyph3d) {
float crr = (cr * 30 + cg * 59 + cb * 11) / 100;
@@ -2920,9 +2920,9 @@ std::shared_ptr LevelRenderer::addParticleInternal(
// optimised PS3 code which reverses the logic on the comparison with
// particleDistanceSquared and gets the opposite result to what you might
// expect.
- if (Double::isNaN(x)) return nullptr;
- if (Double::isNaN(y)) return nullptr;
- if (Double::isNaN(z)) return nullptr;
+ if (std::isnan(x)) return nullptr;
+ if (std::isnan(y)) return nullptr;
+ if (std::isnan(z)) return nullptr;
int particleLevel = mc->options->particles;
@@ -4039,7 +4039,6 @@ void LevelRenderer::staticCtor() {
}
int LevelRenderer::rebuildChunkThreadProc(void* lpParam) {
- Vec3::CreateNewThreadStorage();
AABB::CreateNewThreadStorage();
Tesselator::CreateNewThreadStorage(1024 * 1024);
RenderManager.InitialiseContext();
diff --git a/Minecraft.Client/Rendering/Lighting.cpp b/Minecraft.Client/Rendering/Lighting.cpp
index c0eb8e562..4182a9fe3 100644
--- a/Minecraft.Client/Rendering/Lighting.cpp
+++ b/Minecraft.Client/Rendering/Lighting.cpp
@@ -22,14 +22,16 @@ void Lighting::turnOn() {
float d = 0.6f;
float s = 0.0f;
- Vec3* l = Vec3::newTemp(0.2f, 1.0f, -0.7f)->normalize();
- glLight(GL_LIGHT0, GL_POSITION, getBuffer(l->x, l->y, l->z, 0));
+ Vec3 l(0.2f, 1.0f, -0.7f);
+ l = l.normalize();
+ glLight(GL_LIGHT0, GL_POSITION, getBuffer(l.x, l.y, l.z, 0));
glLight(GL_LIGHT0, GL_DIFFUSE, getBuffer(d, d, d, 1));
glLight(GL_LIGHT0, GL_AMBIENT, getBuffer(0.0f, 0.0f, 0.0f, 1.0f));
glLight(GL_LIGHT0, GL_SPECULAR, getBuffer(s, s, s, 1.0f));
- l = Vec3::newTemp(-0.2f, 1.0f, 0.7f)->normalize();
- glLight(GL_LIGHT1, GL_POSITION, getBuffer(l->x, l->y, l->z, 0));
+ l = Vec3(-0.2f, 1.0f, 0.7f);
+ l = l.normalize();
+ glLight(GL_LIGHT1, GL_POSITION, getBuffer(l.x, l.y, l.z, 0));
glLight(GL_LIGHT1, GL_DIFFUSE, getBuffer(d, d, d, 1));
glLight(GL_LIGHT1, GL_AMBIENT, getBuffer(0.0f, 0.0f, 0.0f, 1.0f));
glLight(GL_LIGHT1, GL_SPECULAR, getBuffer(s, s, s, 1.0f));
@@ -55,4 +57,4 @@ void Lighting::turnOnGui() {
glRotatef(165, 1, 0, 0);
turnOn();
glPopMatrix();
-}
\ No newline at end of file
+}
diff --git a/Minecraft.Client/Rendering/Polygon.cpp b/Minecraft.Client/Rendering/Polygon.cpp
index 28c37260e..44d65648b 100644
--- a/Minecraft.Client/Rendering/Polygon.cpp
+++ b/Minecraft.Client/Rendering/Polygon.cpp
@@ -45,21 +45,21 @@ void _Polygon::mirror() {
}
void _Polygon::render(Tesselator* t, float scale) {
- Vec3* v0 = vertices[1]->pos->vectorTo(vertices[0]->pos);
- Vec3* v1 = vertices[1]->pos->vectorTo(vertices[2]->pos);
- Vec3* n = v1->cross(v0)->normalize();
+ Vec3 v0 = vertices[1]->pos.vectorTo(vertices[0]->pos);
+ Vec3 v1 = vertices[1]->pos.vectorTo(vertices[2]->pos);
+ Vec3 n = v1.cross(v0).normalize();
t->begin();
if (_flipNormal) {
- t->normal(-(float)n->x, -(float)n->y, -(float)n->z);
+ t->normal(-(float)n.x, -(float)n.y, -(float)n.z);
} else {
- t->normal((float)n->x, (float)n->y, (float)n->z);
+ t->normal((float)n.x, (float)n.y, (float)n.z);
}
for (int i = 0; i < 4; i++) {
Vertex* v = vertices[i];
- t->vertexUV((float)(v->pos->x * scale), (float)(v->pos->y * scale),
- (float)(v->pos->z * scale), (float)(v->u), (float)(v->v));
+ t->vertexUV((float)(v->pos.x * scale), (float)(v->pos.y * scale),
+ (float)(v->pos.z * scale), (float)(v->u), (float)(v->v));
}
t->end();
}
@@ -67,4 +67,4 @@ void _Polygon::render(Tesselator* t, float scale) {
_Polygon* _Polygon::flipNormal() {
_flipNormal = true;
return this;
-}
\ No newline at end of file
+}
diff --git a/Minecraft.Client/Rendering/Tesselator.cpp b/Minecraft.Client/Rendering/Tesselator.cpp
index a08a9f9b9..49e6f5669 100644
--- a/Minecraft.Client/Rendering/Tesselator.cpp
+++ b/Minecraft.Client/Rendering/Tesselator.cpp
@@ -1,6 +1,5 @@
#include "../Platform/stdafx.h"
#include "Tesselator.h"
-#include "../../Minecraft.World/Util/BasicTypeContainers.h"
#include "../../Minecraft.World/IO/Streams/FloatBuffer.h"
#include "../../Minecraft.World/IO/Streams/IntBuffer.h"
#include "../../Minecraft.World/IO/Streams/ByteBuffer.h"
diff --git a/Minecraft.Client/Rendering/Vertex.cpp b/Minecraft.Client/Rendering/Vertex.cpp
index b4c70ae19..7222ed172 100644
--- a/Minecraft.Client/Rendering/Vertex.cpp
+++ b/Minecraft.Client/Rendering/Vertex.cpp
@@ -2,7 +2,7 @@
#include "Vertex.h"
Vertex::Vertex(float x, float y, float z, float u, float v) {
- this->pos = Vec3::newPermanent(x, y, z);
+ this->pos = Vec3(x, y, z);
this->u = u;
this->v = v;
}
@@ -16,7 +16,7 @@ Vertex::Vertex(Vertex* vertex, float u, float v) {
}
Vertex::Vertex(Vec3* pos, float u, float v) {
- this->pos = pos;
+ this->pos = *pos;
this->u = u;
this->v = v;
-}
\ No newline at end of file
+}
diff --git a/Minecraft.Client/Rendering/Vertex.h b/Minecraft.Client/Rendering/Vertex.h
index 99166d1ee..7c4492a8d 100644
--- a/Minecraft.Client/Rendering/Vertex.h
+++ b/Minecraft.Client/Rendering/Vertex.h
@@ -3,7 +3,7 @@
class Vertex {
public:
- Vec3* pos;
+ Vec3 pos;
float u, v;
public:
@@ -11,4 +11,4 @@ public:
Vertex* remap(float u, float v);
Vertex(Vertex* vertex, float u, float v);
Vertex(Vec3* pos, float u, float v);
-};
\ No newline at end of file
+};
diff --git a/Minecraft.Client/UI/Screens/AbstractContainerScreen.cpp b/Minecraft.Client/UI/Screens/AbstractContainerScreen.cpp
index a3b16edc5..bf608e7ee 100644
--- a/Minecraft.Client/UI/Screens/AbstractContainerScreen.cpp
+++ b/Minecraft.Client/UI/Screens/AbstractContainerScreen.cpp
@@ -306,9 +306,10 @@ void AbstractContainerScreen::mouseClicked(int x, int y, int buttonNum) {
}
if (slotId != -1) {
- bool quickKey = slotId != AbstractContainerMenu::SLOT_CLICKED_OUTSIDE &&
- (Keyboard::isKeyDown(Keyboard::KEY_LSHIFT) ||
- Keyboard::isKeyDown(Keyboard::KEY_RSHIFT));
+ bool quickKey =
+ slotId != AbstractContainerMenu::SLOT_CLICKED_OUTSIDE &&
+ (Keyboard::isKeyDown(Keyboard::KEY_LSHIFT) ||
+ Keyboard::isKeyDown(Keyboard::KEY_RSHIFT));
minecraft->gameMode->handleInventoryMouseClick(
menu->containerId, slotId, buttonNum, quickKey,
minecraft->player);
@@ -341,4 +342,4 @@ void AbstractContainerScreen::tick() {
Screen::tick();
if (!minecraft->player->isAlive() || minecraft->player->removed)
minecraft->player->closeContainer();
-}
\ No newline at end of file
+}
diff --git a/Minecraft.Client/UI/Screens/AbstractContainerScreen.h b/Minecraft.Client/UI/Screens/AbstractContainerScreen.h
index da3d3e625..ace3ec4bf 100644
--- a/Minecraft.Client/UI/Screens/AbstractContainerScreen.h
+++ b/Minecraft.Client/UI/Screens/AbstractContainerScreen.h
@@ -42,4 +42,4 @@ public:
virtual void slotsChanged(std::shared_ptr container);
virtual bool isPauseScreen();
virtual void tick();
-};
\ No newline at end of file
+};
diff --git a/Minecraft.Client/UI/Screens/CreativeInventoryScreen.cpp b/Minecraft.Client/UI/Screens/CreativeInventoryScreen.cpp
index aea796309..98e2a3aec 100644
--- a/Minecraft.Client/UI/Screens/CreativeInventoryScreen.cpp
+++ b/Minecraft.Client/UI/Screens/CreativeInventoryScreen.cpp
@@ -15,513 +15,533 @@
#include
// Static member initialization
-int CreativeInventoryScreen::selectedTabIndex = IUIScene_CreativeMenu::eCreativeInventoryTab_BuildingBlocks;
-std::shared_ptr CreativeInventoryScreen::basicInventory = std::make_shared(0, L"", false, ITEMS_PER_PAGE);
+int CreativeInventoryScreen::selectedTabIndex =
+ IUIScene_CreativeMenu::eCreativeInventoryTab_BuildingBlocks;
+int CreativeInventoryScreen::tabIconIds
+ [IUIScene_CreativeMenu::eCreativeInventoryTab_COUNT] = {
+ // Building Blocks
+ Tile::redBrick_Id,
+
+ // Decorations
+ Tile::rose_Id,
+
+ // Redstone & Transportation
+ Item::redStone_Id,
+
+ // Materials
+ Item::stick_Id,
+
+ // Food
+ Item::apple_Id,
+
+// Fix for it not compiling with shiggy
+#ifdef ENABLE_JAVA_GUIS
+ // Search Items
+ Item::compass_Id,
+#endif
+
+ // Tools, Weapons & Armor
+ Item::hatchet_iron_Id,
+
+ // Brewing
+ Item::potion_Id,
+
+ // Materials
+ Item::bucket_lava_Id};
+std::shared_ptr CreativeInventoryScreen::basicInventory =
+ std::make_shared(0, L"", false, ITEMS_PER_PAGE);
+ItemRenderer* CreativeInventoryScreen::itemRenderer = new ItemRenderer();
+std::shared_ptr CreativeInventoryScreen::tabIcons
+ [IUIScene_CreativeMenu::eCreativeInventoryTab_COUNT];
// ContainerCreative implementation
-CreativeInventoryScreen::ContainerCreative::ContainerCreative(std::shared_ptr player) : AbstractContainerMenu()
-{
- std::shared_ptr inventoryplayer = player->inventory;
-
- // Add creative inventory slots (5 rows x 9 columns = 45 slots)
- for (int i = 0; i < ROWS; ++i)
- {
- for (int j = 0; j < COLUMNS; ++j)
- {
- addSlot(new Slot(basicInventory, i * COLUMNS + j, 9 + j * 18, 18 + i * 18));
- }
- }
-
- // Add hotbar slots (9 slots at bottom)
- for (int k = 0; k < 9; ++k)
- {
- addSlot(new Slot(inventoryplayer, k, 9 + k * 18, 112));
- }
-
- scrollTo(0.0f);
+CreativeInventoryScreen::ContainerCreative::ContainerCreative(
+ std::shared_ptr player)
+ : AbstractContainerMenu() {
+ std::shared_ptr inventoryplayer = player->inventory;
+
+ // Add creative inventory slots (5 rows x 9 columns = 45 slots)
+ for (int i = 0; i < ROWS; i++) {
+ for (int j = 0; j < COLUMNS; j++) {
+ addSlot(new Slot(basicInventory, i * COLUMNS + j, 9 + j * 18,
+ 18 + i * 18));
+ }
+ }
+
+ // Add hotbar slots (9 slots at bottom)
+ for (int k = 0; k < 9; k++) {
+ addSlot(new Slot(inventoryplayer, k, 9 + k * 18, 112));
+ }
+
+ scrollTo(0.0f);
+
+ for (int i = 0; i < IUIScene_CreativeMenu::eCreativeInventoryTab_COUNT;
+ i++) {
+ tabIcons[i] = std::shared_ptr(
+ new ItemInstance(tabIconIds[i], 1, 0));
+ }
}
-bool CreativeInventoryScreen::ContainerCreative::stillValid(std::shared_ptr player)
-{
- return true;
+bool CreativeInventoryScreen::ContainerCreative::stillValid(
+ std::shared_ptr player) {
+ return true;
}
-std::shared_ptr CreativeInventoryScreen::ContainerCreative::clicked(int slotIndex, int buttonNum, int clickType, std::shared_ptr player)
-{
- std::shared_ptr inventory = player->inventory;
- std::shared_ptr carried = inventory->getCarried();
-
- // Handle clicks outside the GUI
- if (slotIndex == SLOT_CLICKED_OUTSIDE)
- {
- // Drop the carried item
- if (carried != NULL)
- {
- if (buttonNum == 0)
- {
- player->drop(carried, true);
- inventory->setCarried(std::shared_ptr());
- }
- else if (buttonNum == 1)
- {
- std::shared_ptr single = carried->copy();
- single->count = 1;
- player->drop(single, true);
- carried->count--;
- if (carried->count <= 0)
- {
- inventory->setCarried(std::shared_ptr());
- }
- }
- }
- return std::shared_ptr();
- }
-
- // Validate slot index
- if (slotIndex < 0 || slotIndex >= (int)slots.size())
- {
- return std::shared_ptr();
- }
-
- Slot* slot = slots.at(slotIndex);
-
- // Handle creative inventory slots (0-44)
- if (slotIndex >= 0 && slotIndex < ITEMS_PER_PAGE)
- {
- std::shared_ptr slotItem = slot->getItem();
-
- // Handle SWAP (number key) - copy item to hotbar
- if (clickType == CLICK_SWAP)
- {
- if (slotItem != NULL && buttonNum >= 0 && buttonNum < 9)
- {
- std::shared_ptr copy = slotItem->copy();
- copy->count = copy->getMaxStackSize();
- inventory->setItem(buttonNum, copy);
- }
- return std::shared_ptr();
- }
-
- // Handle CLONE (middle click)
- if (clickType == CLICK_CLONE)
- {
- if (slotItem != NULL)
- {
- std::shared_ptr copy = slotItem->copy();
- copy->count = copy->getMaxStackSize();
- inventory->setCarried(copy);
- }
- return std::shared_ptr();
- }
-
- // Handle normal clicks
- if (slotItem != NULL)
- {
- if (buttonNum == 0) // Left click
- {
- std::shared_ptr copy = slotItem->copy();
- copy->count = copy->getMaxStackSize();
- inventory->setCarried(copy);
- }
- else if (buttonNum == 1) // Right click
- {
- std::shared_ptr copy = slotItem->copy();
- copy->count = 1;
- inventory->setCarried(copy);
- }
- }
- else if (carried != NULL)
- {
- // Clicking on empty creative slot with item - clear the carried item
- inventory->setCarried(std::shared_ptr());
- }
-
- return std::shared_ptr();
- }
-
- // For hotbar slots (45-53), use normal container behavior
- return AbstractContainerMenu::clicked(slotIndex, buttonNum, clickType, player);
+std::shared_ptr
+CreativeInventoryScreen::ContainerCreative::clicked(
+ int slotIndex, int buttonNum, int clickType,
+ std::shared_ptr player) {
+ std::shared_ptr inventory = player->inventory;
+ std::shared_ptr carried = inventory->getCarried();
+
+ // Handle clicks outside the GUI
+ if (slotIndex == SLOT_CLICKED_OUTSIDE) {
+ // Drop the carried item
+ if (carried != NULL) {
+ if (buttonNum == 0) {
+ player->drop(carried, true);
+ inventory->setCarried(std::shared_ptr());
+ } else if (buttonNum == 1) {
+ std::shared_ptr single = carried->copy();
+ single->count = 1;
+ player->drop(single, true);
+ carried->count--;
+ if (carried->count <= 0) {
+ inventory->setCarried(std::shared_ptr());
+ }
+ }
+ }
+ return std::shared_ptr();
+ }
+
+ // Validate slot index
+ if (slotIndex < 0 || slotIndex >= (int)slots.size()) {
+ return std::shared_ptr();
+ }
+
+ Slot* slot = slots.at(slotIndex);
+
+ // Handle creative inventory slots (0-44)
+ if (slotIndex >= 0 && slotIndex < ITEMS_PER_PAGE) {
+ std::shared_ptr slotItem = slot->getItem();
+
+ // Handle SWAP (number key) - copy item to hotbar
+ if (clickType == CLICK_SWAP) {
+ if (slotItem != NULL && buttonNum >= 0 && buttonNum < 9) {
+ std::shared_ptr copy = slotItem->copy();
+ copy->count = copy->getMaxStackSize();
+ inventory->setItem(buttonNum, copy);
+ }
+ return std::shared_ptr();
+ }
+
+ // Handle CLONE (middle click)
+ if (clickType == CLICK_CLONE) {
+ if (slotItem != NULL) {
+ std::shared_ptr copy = slotItem->copy();
+ copy->count = copy->getMaxStackSize();
+ inventory->setCarried(copy);
+ }
+ return std::shared_ptr();
+ }
+
+ // Handle normal clicks
+ if (slotItem != NULL) {
+ if (buttonNum == 0) // Left click
+ {
+ std::shared_ptr copy = slotItem->copy();
+ copy->count = copy->getMaxStackSize();
+ inventory->setCarried(copy);
+ } else if (buttonNum == 1) // Right click
+ {
+ std::shared_ptr copy = slotItem->copy();
+ copy->count = 1;
+ inventory->setCarried(copy);
+ }
+ } else if (carried != NULL) {
+ // Clicking on empty creative slot with item - clear the carried
+ // item
+ inventory->setCarried(std::shared_ptr());
+ }
+
+ return std::shared_ptr();
+ }
+
+ // For hotbar slots (45-53), use normal container behavior
+ return AbstractContainerMenu::clicked(slotIndex, buttonNum, clickType,
+ player);
}
-void CreativeInventoryScreen::ContainerCreative::scrollTo(float pos)
-{
- int i = (itemList.size() + COLUMNS - 1) / COLUMNS - ROWS;
- int j = (int)((double)(pos * (float)i) + 0.5);
-
- if (j < 0)
- {
- j = 0;
- }
-
- for (int k = 0; k < ROWS; ++k)
- {
- for (int l = 0; l < COLUMNS; ++l)
- {
- int i1 = l + (k + j) * COLUMNS;
-
- if (i1 >= 0 && i1 < (int)itemList.size())
- {
- basicInventory->setItem(l + k * COLUMNS, itemList[i1]);
- }
- else
- {
- basicInventory->setItem(l + k * COLUMNS, std::shared_ptr());
- }
- }
- }
+void CreativeInventoryScreen::ContainerCreative::scrollTo(float pos) {
+ int i = (itemList.size() + COLUMNS - 1) / COLUMNS - ROWS;
+ int j = (int)((double)(pos * (float)i) + 0.5);
+
+ if (j < 0) {
+ j = 0;
+ }
+
+ for (int k = 0; k < ROWS; k++) {
+ for (int l = 0; l < COLUMNS; l++) {
+ int i1 = l + (k + j) * COLUMNS;
+
+ if (i1 >= 0 && i1 < (int)itemList.size()) {
+ basicInventory->setItem(l + k * COLUMNS, itemList[i1]);
+ } else {
+ basicInventory->setItem(l + k * COLUMNS,
+ std::shared_ptr());
+ }
+ }
+ }
}
-bool CreativeInventoryScreen::ContainerCreative::canScroll()
-{
- return itemList.size() > ITEMS_PER_PAGE;
+bool CreativeInventoryScreen::ContainerCreative::canScroll() {
+ return itemList.size() > ITEMS_PER_PAGE;
}
-CreativeInventoryScreen::CreativeInventoryScreen(std::shared_ptr player)
- : AbstractContainerScreen(new ContainerCreative(player))
-{
- this->player = player;
- player->containerMenu = menu;
-
- currentScroll = 0.0f;
- isScrolling = false;
- wasClicking = false;
- isLeftMouseDown = false;
-
- imageHeight = 136;
- imageWidth = 195;
+CreativeInventoryScreen::CreativeInventoryScreen(std::shared_ptr player)
+ : AbstractContainerScreen(new ContainerCreative(player)) {
+ this->player = player;
+ player->containerMenu = menu;
+
+ currentScroll = 0.0f;
+ isScrolling = false;
+ wasClicking = false;
+ isLeftMouseDown = false;
+
+ imageHeight = 136;
+ imageWidth = 195;
}
-void CreativeInventoryScreen::removed()
-{
- AbstractContainerScreen::removed();
+void CreativeInventoryScreen::removed() { AbstractContainerScreen::removed(); }
+
+void CreativeInventoryScreen::init() {
+ buttons.clear();
+
+ int i = selectedTabIndex;
+ selectedTabIndex = -1;
+ setCurrentCreativeTab(i);
}
-void CreativeInventoryScreen::init()
-{
- buttons.clear();
-
- int i = selectedTabIndex;
- selectedTabIndex = -1;
- setCurrentCreativeTab(i);
-}
-
-void CreativeInventoryScreen::updateEvents()
-{
+void CreativeInventoryScreen::updateEvents() {
#ifdef ENABLE_JAVA_GUIS
- // Handle mouse wheel scrolling.
- // We use ButtonDown with the scroll actions rather than GetScrollDelta() because
- // both share s_scrollTicksForButtonPressed; whichever is called first in a tick
- // zeroes it, so GetScrollDelta() would return 0 if hotbar scroll ran first.
- // ButtonDown/ScrollSnap() snapshots once per tick so all callers see the same value.
- if (needsScrollBars())
- {
- ContainerCreative* container = (ContainerCreative*)menu;
- int totalRows = ((int)container->itemList.size() + COLUMNS - 1) / COLUMNS;
- int scrollableRows = totalRows - ROWS;
- if (scrollableRows > 0)
- {
- float step = 1.0f / (float)scrollableRows;
- if (InputManager.ButtonDown(0, MINECRAFT_ACTION_LEFT_SCROLL))
- {
- currentScroll -= step;
- currentScroll = std::max(0.0f, std::min(1.0f, currentScroll));
- container->scrollTo(currentScroll);
- }
- else if (InputManager.ButtonDown(0, MINECRAFT_ACTION_RIGHT_SCROLL))
- {
- currentScroll += step;
- currentScroll = std::max(0.0f, std::min(1.0f, currentScroll));
- container->scrollTo(currentScroll);
- }
- }
- }
+ // Handle mouse wheel scrolling.
+ // We use ButtonDown with the scroll actions rather than GetScrollDelta()
+ // because both share s_scrollTicksForButtonPressed; whichever is called
+ // first in a tick zeroes it, so GetScrollDelta() would return 0 if hotbar
+ // scroll ran first. ButtonDown/ScrollSnap() snapshots once per tick so all
+ // callers see the same value.
+ if (needsScrollBars()) {
+ ContainerCreative* container = (ContainerCreative*)menu;
+ int totalRows =
+ ((int)container->itemList.size() + COLUMNS - 1) / COLUMNS;
+ int scrollableRows = totalRows - ROWS;
+ if (scrollableRows > 0) {
+ float step = 1.0f / (float)scrollableRows;
+ if (InputManager.ButtonDown(0, MINECRAFT_ACTION_LEFT_SCROLL)) {
+ currentScroll -= step;
+ currentScroll = std::max(0.0f, std::min(1.0f, currentScroll));
+ container->scrollTo(currentScroll);
+ } else if (InputManager.ButtonDown(0,
+ MINECRAFT_ACTION_RIGHT_SCROLL)) {
+ currentScroll += step;
+ currentScroll = std::max(0.0f, std::min(1.0f, currentScroll));
+ container->scrollTo(currentScroll);
+ }
+ }
+ }
#endif
- Screen::updateEvents();
+ Screen::updateEvents();
}
-void CreativeInventoryScreen::containerTick()
-{
+void CreativeInventoryScreen::containerTick() {}
+
+void CreativeInventoryScreen::tick() { Screen::tick(); }
+
+void CreativeInventoryScreen::keyPressed(wchar_t eventCharacter, int eventKey) {
+ AbstractContainerScreen::keyPressed(eventCharacter, eventKey);
}
-void CreativeInventoryScreen::tick()
-{
- Screen::tick();
+void CreativeInventoryScreen::mouseClicked(int x, int y, int buttonNum) {
+ if (buttonNum == 0) isLeftMouseDown = true;
+
+ Screen::mouseClicked(x, y, buttonNum);
+
+ if (buttonNum == 0 || buttonNum == 1) {
+ int mouseX = x - (width - imageWidth) / 2;
+ int mouseY = y - (height - imageHeight) / 2;
+
+ // Check for tab clicks first; let mouseReleased handle the actual tab
+ // switch
+ for (int tab = 0;
+ tab < IUIScene_CreativeMenu::eCreativeInventoryTab_COUNT; tab++) {
+ if (isMouseOverTab(tab, mouseX, mouseY)) {
+ return;
+ }
+ }
+
+ // Determine which slot (if any) was clicked
+ Slot* slot = findSlot(x, y);
+
+ int xo = (width - imageWidth) / 2;
+ int yo = (height - imageHeight) / 2;
+ bool clickedOutside =
+ (x < xo || y < yo || x >= xo + imageWidth || y >= yo + imageHeight);
+
+ int slotId = -1;
+ if (slot != NULL) slotId = slot->index;
+ if (clickedOutside)
+ slotId = AbstractContainerMenu::SLOT_CLICKED_OUTSIDE;
+
+ if (slotId == -1) return;
+
+ bool quickKey = slotId != AbstractContainerMenu::SLOT_CLICKED_OUTSIDE &&
+ (Keyboard::isKeyDown(Keyboard::KEY_LSHIFT) ||
+ Keyboard::isKeyDown(Keyboard::KEY_RSHIFT));
+ int clickType = quickKey ? AbstractContainerMenu::CLICK_QUICK_MOVE
+ : AbstractContainerMenu::CLICK_PICKUP;
+
+ // 4jcraft: bypass AbstractContainerScreen::mouseClicked /
+ // handleInventoryMouseClick here intentionally. The normal path sends a
+ // ContainerClickPacket to the server, where player->containerMenu is
+ // still the InventoryMenu (45 slots). Creative slot indices 0-44 are
+ // valid in ContainerCreative but not in InventoryMenu, and hotbar
+ // indices 45-53 exceed InventoryMenu's slot count entirely, causing an
+ // out-of-range crash in AbstractContainerMenu::clicked on the server
+ // side. Instead we apply the click locally and sync hotbar changes via
+ // SetCreativeModeSlotPacket.
+ menu->clicked(slotId, buttonNum, clickType, minecraft->player);
+
+ // 4jcraft: sync hotbar slot changes to the server using
+ // SetCreativeModeSlotPacket. The packet handler
+ // (PlayerConnection::handleSetCreativeModeSlot) validates slots against
+ // InventoryMenu coordinates where the hotbar starts at
+ // USE_ROW_SLOT_START (36), so we must offset the local hotbar index
+ // (0-8) accordingly.
+ if (slotId >= ITEMS_PER_PAGE && slotId < ITEMS_PER_PAGE + 9) {
+ int hotbarSlot = slotId - ITEMS_PER_PAGE;
+ std::shared_ptr hotbarItem =
+ minecraft->player->inventory->getItem(hotbarSlot);
+ minecraft->gameMode->handleCreativeModeItemAdd(
+ hotbarItem, hotbarSlot + InventoryMenu::USE_ROW_SLOT_START);
+ }
+ }
}
-void CreativeInventoryScreen::keyPressed(wchar_t eventCharacter, int eventKey)
-{
- AbstractContainerScreen::keyPressed(eventCharacter, eventKey);
+void CreativeInventoryScreen::mouseReleased(int x, int y, int buttonNum) {
+ if (buttonNum == 0) isLeftMouseDown = false;
+
+ if (buttonNum == 0) {
+ int mouseX = x - (width - imageWidth) / 2;
+ int mouseY = y - (height - imageHeight) / 2;
+
+ // Check for tab clicks
+ for (int tab = 0;
+ tab < IUIScene_CreativeMenu::eCreativeInventoryTab_COUNT; tab++) {
+ if (isMouseOverTab(tab, mouseX, mouseY)) {
+ setCurrentCreativeTab(tab);
+ return;
+ }
+ }
+ }
+
+ AbstractContainerScreen::mouseReleased(x, y, buttonNum);
}
-void CreativeInventoryScreen::mouseClicked(int x, int y, int buttonNum)
-{
- if (buttonNum == 0) isLeftMouseDown = true;
+void CreativeInventoryScreen::render(int xm, int ym, float a) {
+ // Java: drawDefaultBackground()
+ renderBackground();
- Screen::mouseClicked(x, y, buttonNum);
+ // Handle scrollbar dragging
+ bool mouseDown = isLeftMouseDown;
+ int left = (width - imageWidth) / 2;
+ int top = (height - imageHeight) / 2;
+ int x1 = left + 175;
+ int y1 = top + 18;
+ int x2 = x1 + 14;
+ int y2 = y1 + 112;
- if (buttonNum == 0 || buttonNum == 1)
- {
- int i = x - (width - imageWidth) / 2;
- int j = y - (height - imageHeight) / 2;
+ if (!wasClicking && mouseDown && xm >= x1 && ym >= y1 && xm < x2 &&
+ ym < y2) {
+ isScrolling = needsScrollBars();
+ }
- // Check for tab clicks first; let mouseReleased handle the actual tab switch
- for (int tab = 0; tab < IUIScene_CreativeMenu::eCreativeInventoryTab_COUNT; ++tab)
- {
- if (isMouseOverTab(tab, i, j))
- {
- return;
- }
- }
+ if (!mouseDown) {
+ isScrolling = false;
+ }
- // Determine which slot (if any) was clicked
- Slot *slot = findSlot(x, y);
+ wasClicking = mouseDown;
- int xo = (width - imageWidth) / 2;
- int yo = (height - imageHeight) / 2;
- bool clickedOutside = (x < xo || y < yo || x >= xo + imageWidth || y >= yo + imageHeight);
+ if (isScrolling) {
+ currentScroll = ((float)(ym - y1) - 7.5f) / ((float)(y2 - y1) - 15.0f);
+ currentScroll = std::max(0.0f, std::min(1.0f, currentScroll));
+ ((ContainerCreative*)menu)->scrollTo(currentScroll);
+ }
- int slotId = -1;
- if (slot != NULL) slotId = slot->index;
- if (clickedOutside) slotId = AbstractContainerMenu::SLOT_CLICKED_OUTSIDE;
-
- if (slotId == -1) return;
-
- bool quickKey = slotId != AbstractContainerMenu::SLOT_CLICKED_OUTSIDE &&
- (Keyboard::isKeyDown(Keyboard::KEY_LSHIFT) || Keyboard::isKeyDown(Keyboard::KEY_RSHIFT));
- int clickType = quickKey ? AbstractContainerMenu::CLICK_QUICK_MOVE : AbstractContainerMenu::CLICK_PICKUP;
-
- // 4jcraft: bypass AbstractContainerScreen::mouseClicked / handleInventoryMouseClick
- // here intentionally. The normal path sends a ContainerClickPacket to the server,
- // where player->containerMenu is still the InventoryMenu (45 slots). Creative slot
- // indices 0-44 are valid in ContainerCreative but not in InventoryMenu, and hotbar
- // indices 45-53 exceed InventoryMenu's slot count entirely, causing an out-of-range
- // crash in AbstractContainerMenu::clicked on the server side.
- // Instead we apply the click locally and sync hotbar changes via SetCreativeModeSlotPacket.
- menu->clicked(slotId, buttonNum, clickType, minecraft->player);
-
- // 4jcraft: sync hotbar slot changes to the server using SetCreativeModeSlotPacket.
- // The packet handler (PlayerConnection::handleSetCreativeModeSlot) validates slots
- // against InventoryMenu coordinates where the hotbar starts at USE_ROW_SLOT_START (36),
- // so we must offset the local hotbar index (0-8) accordingly.
- if (slotId >= ITEMS_PER_PAGE && slotId < ITEMS_PER_PAGE + 9)
- {
- int hotbarSlot = slotId - ITEMS_PER_PAGE;
- std::shared_ptr hotbarItem = minecraft->player->inventory->getItem(hotbarSlot);
- minecraft->gameMode->handleCreativeModeItemAdd(hotbarItem, hotbarSlot + InventoryMenu::USE_ROW_SLOT_START);
- }
- }
+ AbstractContainerScreen::render(xm, ym, a);
}
-void CreativeInventoryScreen::mouseReleased(int x, int y, int buttonNum)
-{
- if (buttonNum == 0) isLeftMouseDown = false;
-
- if (buttonNum == 0)
- {
- int i = x - (width - imageWidth) / 2;
- int j = y - (height - imageHeight) / 2;
-
- // Check for tab clicks
- for (int tab = 0; tab < IUIScene_CreativeMenu::eCreativeInventoryTab_COUNT; ++tab)
- {
- if (isMouseOverTab(tab, i, j))
- {
- setCurrentCreativeTab(tab);
- return;
- }
- }
- }
-
- AbstractContainerScreen::mouseReleased(x, y, buttonNum);
-}
-
-void CreativeInventoryScreen::render(int xm, int ym, float a)
-{
- // Java: drawDefaultBackground()
- renderBackground();
-
- // Handle scrollbar dragging
- bool mouseDown = isLeftMouseDown;
- int i = (width - imageWidth) / 2;
- int j = (height - imageHeight) / 2;
- int k = i + 175;
- int l = j + 18;
- int i1 = k + 14;
- int j1 = l + 112;
-
- if (!wasClicking && mouseDown && xm >= k && ym >= l && xm < i1 && ym < j1)
- {
- isScrolling = needsScrollBars();
- }
-
- if (!mouseDown)
- {
- isScrolling = false;
- }
-
- wasClicking = mouseDown;
-
- if (isScrolling)
- {
- currentScroll = ((float)(ym - l) - 7.5f) / ((float)(j1 - l) - 15.0f);
- currentScroll = std::max(0.0f, std::min(1.0f, currentScroll));
- ((ContainerCreative*)menu)->scrollTo(currentScroll);
- }
-
- AbstractContainerScreen::render(xm, ym, a);
-}
-
-void CreativeInventoryScreen::renderLabels()
-{
+void CreativeInventoryScreen::renderLabels() {
#ifdef ENABLE_JAVA_GUIS
- if (IUIScene_CreativeMenu::specs && selectedTabIndex >= 0 && selectedTabIndex < IUIScene_CreativeMenu::eCreativeInventoryTab_COUNT)
- {
- IUIScene_CreativeMenu::TabSpec* spec = IUIScene_CreativeMenu::specs[selectedTabIndex];
- if (spec)
- {
- std::wstring tabName = app.GetString(spec->m_descriptionId);
- font->draw(tabName, 8, 6, 0x404040);
- }
- }
+ if (IUIScene_CreativeMenu::specs && selectedTabIndex >= 0 &&
+ selectedTabIndex < IUIScene_CreativeMenu::eCreativeInventoryTab_COUNT) {
+ IUIScene_CreativeMenu::TabSpec* spec =
+ IUIScene_CreativeMenu::specs[selectedTabIndex];
+ if (spec) {
+ std::wstring tabName = app.GetString(spec->m_descriptionId);
+ font->draw(tabName, 8, 6, 0x404040);
+ }
+ }
#endif
}
-void CreativeInventoryScreen::renderBg(float a)
-{
- int x = (width - imageWidth) / 2;
- int y = (height - imageHeight) / 2;
+void CreativeInventoryScreen::renderBg(float a) {
+ int x = (width - imageWidth) / 2;
+ int y = (height - imageHeight) / 2;
#ifdef ENABLE_JAVA_GUIS
- // Render all non-selected tabs first
- for (int tab = 0; tab < IUIScene_CreativeMenu::eCreativeInventoryTab_COUNT; ++tab)
- {
- if (tab != selectedTabIndex)
- {
- drawTab(tab);
- }
- }
-
- // Load and render main creative inventory background
- int tex = minecraft->textures->loadTexture(TN_GUI_CREATIVE_TAB_ITEMS);
- glColor4f(1, 1, 1, 1);
- minecraft->textures->bind(tex);
- blit(x, y, 0, 0, imageWidth, imageHeight);
-
- // Render scrollbar
- tex = minecraft->textures->loadTexture(TN_GUI_CREATIVE_TABS);
- minecraft->textures->bind(tex);
-
- int scrollX = x + 175;
- int scrollY = y + 18;
- int scrollHeight = 112;
-
- if (needsScrollBars())
- {
- int scrollPos = (int)((float)(scrollHeight - 17) * currentScroll);
- blit(scrollX, scrollY + scrollPos, 232, 0, 12, 15);
- }
- else
- {
- blit(scrollX, scrollY + (scrollHeight - 17) / 2, 244, 0, 12, 15);
- }
-
- // Render selected tab last (on top)
- drawTab(selectedTabIndex);
+ static int itemsTex =
+ minecraft->textures->loadTexture(TN_GUI_CREATIVE_TAB_ITEMS);
+ static int searchTex =
+ minecraft->textures->loadTexture(TN_GUI_CREATIVE_TAB_ITEM_SEARCH);
+ static int scrollTex =
+ minecraft->textures->loadTexture(TN_GUI_CREATIVE_TABS);
+ // Render all non-selected tabs first
+ for (int tab = 0; tab < IUIScene_CreativeMenu::eCreativeInventoryTab_COUNT;
+ tab++) {
+ if (tab != selectedTabIndex) {
+ drawTab(tab);
+ }
+ }
+
+ // Load and render main creative inventory background
+ glColor4f(1, 1, 1, 1);
+ minecraft->textures->bind((selectedTabIndex == 5) ? searchTex : itemsTex);
+ blit(x, y, 0, 0, imageWidth, imageHeight);
+
+ // Render scrollbar
+ minecraft->textures->bind(scrollTex);
+
+ int scrollX = x + 175;
+ int scrollY = y + 18;
+ int scrollHeight = 112;
+
+ if (needsScrollBars()) {
+ int scrollPos = (int)((float)(scrollHeight - 17) * currentScroll);
+ blit(scrollX, scrollY + scrollPos, 232, 0, 12, 15);
+ } else {
+ blit(scrollX, scrollY, 244, 0, 12, 15);
+ }
+
+ // Render selected tab last (on top)
+ drawTab(selectedTabIndex);
#endif
}
-void CreativeInventoryScreen::setCurrentCreativeTab(int tab)
-{
- if (tab < 0 || tab >= IUIScene_CreativeMenu::eCreativeInventoryTab_COUNT)
- return;
-
- int oldTab = selectedTabIndex;
- selectedTabIndex = tab;
-
- ContainerCreative* container = (ContainerCreative*)menu;
- container->itemList.clear();
-
- // Populate itemList from the tab's category groups
- if (IUIScene_CreativeMenu::specs && IUIScene_CreativeMenu::specs[tab])
- {
- IUIScene_CreativeMenu::TabSpec* spec = IUIScene_CreativeMenu::specs[tab];
-
- // Add items from static groups
- for (int i = 0; i < spec->m_staticGroupsCount; ++i)
- {
- int groupIdx = spec->m_staticGroupsA[i];
- if (groupIdx >= 0 && groupIdx < IUIScene_CreativeMenu::eCreativeInventoryGroupsCount)
- {
- auto& group = IUIScene_CreativeMenu::categoryGroups[groupIdx];
- for (auto& item : group)
- {
- container->itemList.push_back(item);
- }
- }
- }
- }
-
- currentScroll = 0.0f;
- container->scrollTo(0.0f);
+void CreativeInventoryScreen::setCurrentCreativeTab(int tab) {
+ if (tab < 0 || tab >= IUIScene_CreativeMenu::eCreativeInventoryTab_COUNT)
+ return;
+
+ int oldTab = selectedTabIndex;
+ selectedTabIndex = tab;
+
+ ContainerCreative* container = (ContainerCreative*)menu;
+ container->itemList.clear();
+
+ // Populate itemList from the tab's category groups
+ if (IUIScene_CreativeMenu::specs && IUIScene_CreativeMenu::specs[tab]) {
+ IUIScene_CreativeMenu::TabSpec* spec =
+ IUIScene_CreativeMenu::specs[tab];
+
+ // Add items from static groups
+ for (int i = 0; i < spec->m_staticGroupsCount; i++) {
+ int groupIdx = spec->m_staticGroupsA[i];
+ if (groupIdx >= 0 &&
+ groupIdx <
+ IUIScene_CreativeMenu::eCreativeInventoryGroupsCount) {
+ auto& group = IUIScene_CreativeMenu::categoryGroups[groupIdx];
+ for (auto& item : group) {
+ container->itemList.push_back(item);
+ }
+ }
+ }
+ }
+
+ currentScroll = 0.0f;
+ container->scrollTo(0.0f);
}
-void CreativeInventoryScreen::selectTab(int tab)
-{
- setCurrentCreativeTab(tab);
+void CreativeInventoryScreen::selectTab(int tab) { setCurrentCreativeTab(tab); }
+
+bool CreativeInventoryScreen::needsScrollBars() {
+ return ((ContainerCreative*)menu)->canScroll();
}
-bool CreativeInventoryScreen::needsScrollBars()
-{
- return ((ContainerCreative*)menu)->canScroll();
+bool CreativeInventoryScreen::isMouseOverTab(int tab, int mouseX, int mouseY) {
+ int tabColumn = tab % 6;
+ int x = tabColumn * 28;
+ int y = 0;
+
+ if (tabColumn == 5) {
+ x = imageWidth - 28 + 2;
+ } else if (tabColumn > 0) {
+ x += tabColumn;
+ }
+
+ if (tab < 6) {
+ y -= 32;
+ } else {
+ y = imageHeight;
+ }
+
+ return ((mouseX >= x && mouseX <= x + 28) &&
+ (mouseY >= y && mouseY <= y + 32));
}
-bool CreativeInventoryScreen::isMouseOverTab(int tab, int mouseX, int mouseY)
-{
- int i = tab;
- int j = 28 * i;
- int k = 0;
-
- if (i > 0)
- {
- j += i;
- }
-
- // Tabs are in the top row
- k = k - 32;
-
- return mouseX >= j && mouseX <= j + 28 && mouseY >= k && mouseY <= k + 32;
-}
-
-void CreativeInventoryScreen::drawTab(int tab)
-{
+void CreativeInventoryScreen::drawTab(int tab) {
#ifdef ENABLE_JAVA_GUIS
- bool isSelected = (tab == selectedTabIndex);
- int i = tab;
- int j = i * 28;
- int k = 0;
- int l = (width - imageWidth) / 2 + 28 * i;
- int i1 = (height - imageHeight) / 2;
- int j1 = 32;
-
- if (isSelected)
- {
- k += 32;
- }
-
- if (i > 0)
- {
- l += i;
- }
-
- // Tabs are in the top row
- i1 = i1 - 28;
-
- // Render tab background
- int tex = minecraft->textures->loadTexture(TN_GUI_CREATIVE_TABS);
- minecraft->textures->bind(tex);
- glColor4f(1, 1, 1, 1);
- blit(l, i1, j, k, 28, 32);
-
- // TODO: Render tab icon (would need item icons)
+ bool isSelected = (selectedTabIndex == tab);
+ bool tabFirstRow = (tab < 6);
+ int left = (width - imageWidth) / 2;
+ int top = (height - imageHeight) / 2;
+ int tabColumn = tab % 6;
+ int sy = 0;
+ int x = left + 28 * tabColumn;
+ int y = top;
+ static int tex = minecraft->textures->loadTexture(TN_GUI_CREATIVE_TABS);
+
+ if (isSelected) {
+ sy += 32;
+ }
+
+ if (tabColumn == 5) {
+ x = left + imageWidth - 28;
+ } else if (tabColumn > 0) {
+ x += tabColumn;
+ }
+
+ // Tabs are in the top row
+ if (tabFirstRow) {
+ y -= 28;
+ } else {
+ sy += 64;
+ y += imageHeight - 4;
+ }
+
+ // Render tab background
+ glDisable(GL_LIGHTING);
+ minecraft->textures->bind(tex);
+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+ blit(x, y, tabColumn * 28, sy, 28, 32);
+
+ // Render tab icon
+ x += 6;
+ y += 8 + (tabFirstRow ? 1 : -1);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_RESCALE_NORMAL);
+ Lighting::turnOnGui();
+ itemRenderer->renderGuiItem(font, minecraft->textures, tabIcons[tab], x, y);
+ itemRenderer->renderGuiItemDecorations(font, minecraft->textures,
+ tabIcons[tab], x, y);
+ glDisable(GL_LIGHTING);
#endif
-}
+}
\ No newline at end of file
diff --git a/Minecraft.Client/UI/Screens/CreativeInventoryScreen.h b/Minecraft.Client/UI/Screens/CreativeInventoryScreen.h
index 4ce1659f4..987ec9a88 100644
--- a/Minecraft.Client/UI/Screens/CreativeInventoryScreen.h
+++ b/Minecraft.Client/UI/Screens/CreativeInventoryScreen.h
@@ -9,63 +9,76 @@ class SimpleContainer;
class Inventory;
class Slot;
-class CreativeInventoryScreen : public AbstractContainerScreen
-{
+class CreativeInventoryScreen : public AbstractContainerScreen {
private:
- static constexpr int ROWS = 5;
- static constexpr int COLUMNS = 9;
- static constexpr int ITEMS_PER_PAGE = ROWS * COLUMNS; // 45 items (9x5 grid)
-
- // Currently selected creative tab index
- static int selectedTabIndex;
-
- // Temporary inventory for creative mode items
- static std::shared_ptr basicInventory;
-
- // Amount scrolled in Creative mode inventory (0 = top, 1 = bottom)
- float currentScroll;
-
- bool isScrolling;
-
- // True if the left mouse button is currently being held
- bool isLeftMouseDown;
+ static constexpr int ROWS = 5;
+ static constexpr int COLUMNS = 9;
+ static constexpr int ITEMS_PER_PAGE =
+ ROWS * COLUMNS; // 45 items (9x5 grid)
- // True if the left mouse button was held down last time render was called
- bool wasClicking;
+ // Currently selected creative tab index
+ static int selectedTabIndex;
+
+ // Array of item ids for the tab icons
+ static int tabIconIds[IUIScene_CreativeMenu::eCreativeInventoryTab_COUNT];
+
+ // Temporary inventory for creative mode items
+ static std::shared_ptr basicInventory;
+
+ // Item renderer for the tab icons
+ static ItemRenderer* itemRenderer;
+
+ // Array of tab icons
+ static std::shared_ptr
+ tabIcons[IUIScene_CreativeMenu::eCreativeInventoryTab_COUNT];
+
+ // Amount scrolled in Creative mode inventory (0 = top, 1 = bottom)
+ float currentScroll;
+
+ bool isScrolling;
+
+ // True if the left mouse button is currently being held
+ bool isLeftMouseDown;
+
+ // True if the left mouse button was held down last time render was called
+ bool wasClicking;
+
+ std::shared_ptr player;
- std::shared_ptr player;
-
public:
- class ContainerCreative : public AbstractContainerMenu
- {
- public:
- std::vector> itemList;
-
- ContainerCreative(std::shared_ptr player);
- virtual bool stillValid(std::shared_ptr player);
- virtual std::shared_ptr clicked(int slotIndex, int buttonNum, int clickType, std::shared_ptr player);
- void scrollTo(float pos);
- bool canScroll();
- };
-
+ class ContainerCreative : public AbstractContainerMenu {
+ public:
+ std::vector> itemList;
+
+ ContainerCreative(std::shared_ptr player);
+ virtual bool stillValid(std::shared_ptr player);
+ virtual std::shared_ptr clicked(
+ int slotIndex, int buttonNum, int clickType,
+ std::shared_ptr player);
+ void scrollTo(float pos);
+ bool canScroll();
+ };
+
public:
- CreativeInventoryScreen(std::shared_ptr player);
- virtual void removed();
- virtual void init();
- virtual void containerTick();
- virtual void tick();
- virtual void updateEvents();
- virtual void keyPressed(wchar_t eventCharacter, int eventKey);
- virtual void mouseClicked(int x, int y, int buttonNum);
- virtual void mouseReleased(int x, int y, int buttonNum);
- virtual void render(int xm, int ym, float a);
+ CreativeInventoryScreen(std::shared_ptr player);
+ virtual void removed();
+ virtual void init();
+ virtual void containerTick();
+ virtual void tick();
+ virtual void updateEvents();
+ virtual void keyPressed(wchar_t eventCharacter, int eventKey);
+ virtual void mouseClicked(int x, int y, int buttonNum);
+ virtual void mouseReleased(int x, int y, int buttonNum);
+ virtual void render(int xm, int ym, float a);
+
protected:
- virtual void renderLabels();
- virtual void renderBg(float a);
+ virtual void renderLabels();
+ virtual void renderBg(float a);
+
private:
- void setCurrentCreativeTab(int tab);
- void selectTab(int tab);
- bool needsScrollBars();
- bool isMouseOverTab(int tab, int mouseX, int mouseY);
- void drawTab(int tab);
+ void setCurrentCreativeTab(int tab);
+ void selectTab(int tab);
+ bool needsScrollBars();
+ bool isMouseOverTab(int tab, int mouseX, int mouseY);
+ void drawTab(int tab);
};
diff --git a/Minecraft.World/AI/Goals/AvoidPlayerGoal.cpp b/Minecraft.World/AI/Goals/AvoidPlayerGoal.cpp
index 1e2d3cb1d..59045d029 100644
--- a/Minecraft.World/AI/Goals/AvoidPlayerGoal.cpp
+++ b/Minecraft.World/AI/Goals/AvoidPlayerGoal.cpp
@@ -64,18 +64,18 @@ bool AvoidPlayerGoal::canUse() {
delete entities;
}
- Vec3* pos = RandomPos::getPosAvoid(
+ Vec3 avoid_pos(toAvoid.lock()->x, toAvoid.lock()->y, toAvoid.lock()->z);
+ auto pos = RandomPos::getPosAvoid(
std::dynamic_pointer_cast(mob->shared_from_this()), 16,
- 7,
- Vec3::newTemp(toAvoid.lock()->x, toAvoid.lock()->y, toAvoid.lock()->z));
- if (pos == NULL) return false;
+ 7, &avoid_pos);
+ if (!pos.has_value()) return false;
if (toAvoid.lock()->distanceToSqr(pos->x, pos->y, pos->z) <
toAvoid.lock()->distanceToSqr(mob->shared_from_this()))
return false;
delete path;
path = pathNav->createPath(pos->x, pos->y, pos->z);
if (path == NULL) return false;
- if (!path->endsInXZ(pos)) return false;
+ if (!path->endsInXZ(&*pos)) return false;
return true;
}
@@ -95,4 +95,4 @@ void AvoidPlayerGoal::tick() {
mob->getNavigation()->setSpeedModifier(sprintSpeedModifier);
else
mob->getNavigation()->setSpeedModifier(walkSpeedModifier);
-}
\ No newline at end of file
+}
diff --git a/Minecraft.World/AI/Goals/BegGoal.cpp b/Minecraft.World/AI/Goals/BegGoal.cpp
index de7992e6a..4c8c2bd28 100644
--- a/Minecraft.World/AI/Goals/BegGoal.cpp
+++ b/Minecraft.World/AI/Goals/BegGoal.cpp
@@ -54,4 +54,4 @@ bool BegGoal::playerHoldingInteresting(std::shared_ptr player) {
if (item == NULL) return false;
if (!wolf->isTame() && item->id == Item::bone_Id) return true;
return wolf->isFood(item);
-}
\ No newline at end of file
+}
diff --git a/Minecraft.World/AI/Goals/BreedGoal.cpp b/Minecraft.World/AI/Goals/BreedGoal.cpp
index 5281598d9..25281c61d 100644
--- a/Minecraft.World/AI/Goals/BreedGoal.cpp
+++ b/Minecraft.World/AI/Goals/BreedGoal.cpp
@@ -4,8 +4,8 @@
#include "../../Headers/net.minecraft.world.entity.animal.h"
#include "../../Headers/net.minecraft.world.level.h"
#include "../../Headers/net.minecraft.world.phys.h"
-#include "../../Util/BasicTypeContainers.h"
#include "BreedGoal.h"
+#include
#include "../../Entities/Mobs/ExperienceOrb.h"
#include "../../Stats/GenericStats.h"
@@ -50,7 +50,7 @@ std::shared_ptr BreedGoal::getFreePartner() {
float r = 8;
std::vector >* others =
level->getEntitiesOfClass(typeid(*animal), animal->bb->grow(r, r, r));
- double dist = Double::MAX_VALUE;
+ double dist = std::numeric_limits::max();
std::shared_ptr partner = nullptr;
for (AUTO_VAR(it, others->begin()); it != others->end(); ++it) {
std::shared_ptr p = std::dynamic_pointer_cast(*it);
diff --git a/Minecraft.World/AI/Goals/FleeSunGoal.cpp b/Minecraft.World/AI/Goals/FleeSunGoal.cpp
index 70a77fe77..fdddfd6e0 100644
--- a/Minecraft.World/AI/Goals/FleeSunGoal.cpp
+++ b/Minecraft.World/AI/Goals/FleeSunGoal.cpp
@@ -5,6 +5,7 @@
#include "../../Headers/net.minecraft.world.level.h"
#include "../../Headers/net.minecraft.world.phys.h"
#include "FleeSunGoal.h"
+#include
FleeSunGoal::FleeSunGoal(PathfinderMob* mob, double speedModifier) {
this->mob = mob;
@@ -20,8 +21,8 @@ bool FleeSunGoal::canUse() {
Mth::floor(mob->z)))
return false;
- Vec3* pos = getHidePos();
- if (pos == NULL) return false;
+ auto pos = getHidePos();
+ if (!pos.has_value()) return false;
wantedX = pos->x;
wantedY = pos->y;
wantedZ = pos->z;
@@ -34,7 +35,7 @@ void FleeSunGoal::start() {
mob->getNavigation()->moveTo(wantedX, wantedY, wantedZ, speedModifier);
}
-Vec3* FleeSunGoal::getHidePos() {
+std::optional FleeSunGoal::getHidePos() {
Random* random = mob->getRandom();
for (int i = 0; i < 10; i++) {
int xt = Mth::floor(mob->x + random->nextInt(20) - 10);
@@ -42,7 +43,7 @@ Vec3* FleeSunGoal::getHidePos() {
int zt = Mth::floor(mob->z + random->nextInt(20) - 10);
if (!level->canSeeSky(xt, yt, zt) &&
mob->getWalkTargetValue(xt, yt, zt) < 0)
- return Vec3::newTemp(xt, yt, zt);
+ return Vec3(xt, yt, zt);
}
- return NULL;
-}
\ No newline at end of file
+ return std::nullopt;
+}
diff --git a/Minecraft.World/AI/Goals/FleeSunGoal.h b/Minecraft.World/AI/Goals/FleeSunGoal.h
index cdd6f8612..e9cce5983 100644
--- a/Minecraft.World/AI/Goals/FleeSunGoal.h
+++ b/Minecraft.World/AI/Goals/FleeSunGoal.h
@@ -1,5 +1,8 @@
#pragma once
+#include
+
+#include "../../Util/Vec3.h"
#include "Goal.h"
class FleeSunGoal : public Goal {
@@ -17,10 +20,10 @@ public:
virtual void start();
private:
- Vec3* getHidePos();
+ std::optional getHidePos();
public:
// 4J Added override to update ai elements when loading entity from
// schematics
virtual void setLevel(Level* level) { this->level = level; }
-};
\ No newline at end of file
+};
diff --git a/Minecraft.World/AI/Goals/FollowOwnerGoal.cpp b/Minecraft.World/AI/Goals/FollowOwnerGoal.cpp
index 928f7e8ef..a0ddb3ccb 100644
--- a/Minecraft.World/AI/Goals/FollowOwnerGoal.cpp
+++ b/Minecraft.World/AI/Goals/FollowOwnerGoal.cpp
@@ -85,4 +85,4 @@ void FollowOwnerGoal::tick() {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Minecraft.World/AI/Goals/FollowParentGoal.cpp b/Minecraft.World/AI/Goals/FollowParentGoal.cpp
index 1bbe808a6..d60dd34a9 100644
--- a/Minecraft.World/AI/Goals/FollowParentGoal.cpp
+++ b/Minecraft.World/AI/Goals/FollowParentGoal.cpp
@@ -3,8 +3,8 @@
#include "../../Headers/net.minecraft.world.entity.ai.navigation.h"
#include "../../Headers/net.minecraft.world.level.h"
#include "../../Headers/net.minecraft.world.phys.h"
-#include "../../Util/BasicTypeContainers.h"
#include "FollowParentGoal.h"
+#include
FollowParentGoal::FollowParentGoal(Animal* animal, double speedModifier) {
timeToRecalcPath = 0;
@@ -21,7 +21,7 @@ bool FollowParentGoal::canUse() {
animal->bb->grow(8, 4, 8));
std::shared_ptr closest = nullptr;
- double closestDistSqr = Double::MAX_VALUE;
+ double closestDistSqr = std::numeric_limits::max();
for (AUTO_VAR(it, parents->begin()); it != parents->end(); ++it) {
std::shared_ptr parent = std::dynamic_pointer_cast(*it);
if (parent->getAge() < 0) continue;
@@ -53,4 +53,4 @@ void FollowParentGoal::tick() {
if (--timeToRecalcPath > 0) return;
timeToRecalcPath = 10;
animal->getNavigation()->moveTo(parent.lock(), speedModifier);
-}
\ No newline at end of file
+}
diff --git a/Minecraft.World/AI/Goals/LeapAtTargetGoal.cpp b/Minecraft.World/AI/Goals/LeapAtTargetGoal.cpp
index 9779984dd..fc59fda1f 100644
--- a/Minecraft.World/AI/Goals/LeapAtTargetGoal.cpp
+++ b/Minecraft.World/AI/Goals/LeapAtTargetGoal.cpp
@@ -34,4 +34,4 @@ void LeapAtTargetGoal::start() {
mob->xd += (xdd / dd * 0.5f) * 0.8f + mob->xd * 0.2f;
mob->zd += (zdd / dd * 0.5f) * 0.8f + mob->zd * 0.2f;
mob->yd = yd;
-}
\ No newline at end of file
+}
diff --git a/Minecraft.World/AI/Goals/LookAtPlayerGoal.cpp b/Minecraft.World/AI/Goals/LookAtPlayerGoal.cpp
index 631362809..32cd4d1d6 100644
--- a/Minecraft.World/AI/Goals/LookAtPlayerGoal.cpp
+++ b/Minecraft.World/AI/Goals/LookAtPlayerGoal.cpp
@@ -62,4 +62,4 @@ void LookAtPlayerGoal::tick() {
lookAt.lock()->x, lookAt.lock()->y + lookAt.lock()->getHeadHeight(),
lookAt.lock()->z, 10, mob->getMaxHeadXRot());
--lookTime;
-}
\ No newline at end of file
+}
diff --git a/Minecraft.World/AI/Goals/MoveIndoorsGoal.cpp b/Minecraft.World/AI/Goals/MoveIndoorsGoal.cpp
index db570665d..6451e21e4 100644
--- a/Minecraft.World/AI/Goals/MoveIndoorsGoal.cpp
+++ b/Minecraft.World/AI/Goals/MoveIndoorsGoal.cpp
@@ -44,13 +44,12 @@ void MoveIndoorsGoal::start() {
}
if (mob->distanceToSqr(_doorInfo->getIndoorX(), _doorInfo->y,
_doorInfo->getIndoorZ()) > 16 * 16) {
- Vec3* pos = RandomPos::getPosTowards(
+ Vec3 towards(_doorInfo->getIndoorX() + 0.5, _doorInfo->getIndoorY(),
+ _doorInfo->getIndoorZ() + 0.5);
+ auto pos = RandomPos::getPosTowards(
std::dynamic_pointer_cast(mob->shared_from_this()),
- 14, 3,
- Vec3::newTemp(_doorInfo->getIndoorX() + 0.5,
- _doorInfo->getIndoorY(),
- _doorInfo->getIndoorZ() + 0.5));
- if (pos != NULL)
+ 14, 3, &towards);
+ if (pos.has_value())
mob->getNavigation()->moveTo(pos->x, pos->y, pos->z, 1.0f);
} else
mob->getNavigation()->moveTo(_doorInfo->getIndoorX() + 0.5,
@@ -68,4 +67,4 @@ void MoveIndoorsGoal::stop() {
insideX = _doorInfo->getIndoorX();
insideZ = _doorInfo->getIndoorZ();
doorInfo = std::weak_ptr();
-}
\ No newline at end of file
+}
diff --git a/Minecraft.World/AI/Goals/MoveThroughVillageGoal.cpp b/Minecraft.World/AI/Goals/MoveThroughVillageGoal.cpp
index 1ef14e1ed..03fe6795a 100644
--- a/Minecraft.World/AI/Goals/MoveThroughVillageGoal.cpp
+++ b/Minecraft.World/AI/Goals/MoveThroughVillageGoal.cpp
@@ -5,8 +5,8 @@
#include "../../Headers/net.minecraft.world.entity.ai.village.h"
#include "../../Headers/net.minecraft.world.entity.h"
#include "../../Headers/net.minecraft.world.level.h"
-#include "../../Util/BasicTypeContainers.h"
#include "MoveThroughVillageGoal.h"
+#include
#include "../Navigation/Path.h"
MoveThroughVillageGoal::MoveThroughVillageGoal(PathfinderMob* mob,
@@ -47,10 +47,11 @@ bool MoveThroughVillageGoal::canUse() {
mob->getNavigation()->setCanOpenDoors(oldCanOpenDoors);
if (path != NULL) return true;
- Vec3* pos = RandomPos::getPosTowards(
+ Vec3 towards(_doorInfo->x, _doorInfo->y, _doorInfo->z);
+ auto pos = RandomPos::getPosTowards(
std::dynamic_pointer_cast(mob->shared_from_this()), 10,
- 7, Vec3::newTemp(_doorInfo->x, _doorInfo->y, _doorInfo->z));
- if (pos == NULL) return false;
+ 7, &towards);
+ if (!pos.has_value()) return false;
mob->getNavigation()->setCanOpenDoors(false);
delete path;
path = mob->getNavigation()->createPath(pos->x, pos->y, pos->z);
@@ -86,7 +87,7 @@ void MoveThroughVillageGoal::stop() {
std::shared_ptr MoveThroughVillageGoal::getNextDoorInfo(
std::shared_ptr village) {
std::shared_ptr closest = nullptr;
- int closestDistSqr = Integer::MAX_VALUE;
+ int closestDistSqr = std::numeric_limits::max();
std::vector >* doorInfos =
village->getDoorInfos();
// for (DoorInfo di : doorInfos)
@@ -120,4 +121,4 @@ bool MoveThroughVillageGoal::hasVisited(std::shared_ptr di) {
void MoveThroughVillageGoal::updateVisited() {
if (visited.size() > 15) visited.erase(visited.begin());
-}
\ No newline at end of file
+}
diff --git a/Minecraft.World/AI/Goals/MoveTowardsRestrictionGoal.cpp b/Minecraft.World/AI/Goals/MoveTowardsRestrictionGoal.cpp
index b8c2f9de6..cb52d4c3b 100644
--- a/Minecraft.World/AI/Goals/MoveTowardsRestrictionGoal.cpp
+++ b/Minecraft.World/AI/Goals/MoveTowardsRestrictionGoal.cpp
@@ -17,11 +17,12 @@ MoveTowardsRestrictionGoal::MoveTowardsRestrictionGoal(PathfinderMob* mob,
bool MoveTowardsRestrictionGoal::canUse() {
if (mob->isWithinRestriction()) return false;
- Pos* towards = mob->getRestrictCenter();
- Vec3* pos = RandomPos::getPosTowards(
+ Pos* toward = mob->getRestrictCenter();
+ Vec3 towards(toward->x, toward->y, toward->z);
+ auto pos = RandomPos::getPosTowards(
std::dynamic_pointer_cast(mob->shared_from_this()), 16,
- 7, Vec3::newTemp(towards->x, towards->y, towards->z));
- if (pos == NULL) return false;
+ 7, &towards);
+ if (!pos.has_value()) return false;
wantedX = pos->x;
wantedY = pos->y;
wantedZ = pos->z;
@@ -34,4 +35,4 @@ bool MoveTowardsRestrictionGoal::canContinueToUse() {
void MoveTowardsRestrictionGoal::start() {
mob->getNavigation()->moveTo(wantedX, wantedY, wantedZ, speedModifier);
-}
\ No newline at end of file
+}
diff --git a/Minecraft.World/AI/Goals/MoveTowardsTargetGoal.cpp b/Minecraft.World/AI/Goals/MoveTowardsTargetGoal.cpp
index d00147b38..22babe6ca 100644
--- a/Minecraft.World/AI/Goals/MoveTowardsTargetGoal.cpp
+++ b/Minecraft.World/AI/Goals/MoveTowardsTargetGoal.cpp
@@ -20,10 +20,11 @@ bool MoveTowardsTargetGoal::canUse() {
if (target.lock() == NULL) return false;
if (target.lock()->distanceToSqr(mob->shared_from_this()) > within * within)
return false;
- Vec3* pos = RandomPos::getPosTowards(
+ Vec3 towards(target.lock()->x, target.lock()->y, target.lock()->z);
+ auto pos = RandomPos::getPosTowards(
std::dynamic_pointer_cast(mob->shared_from_this()), 16,
- 7, Vec3::newTemp(target.lock()->x, target.lock()->y, target.lock()->z));
- if (pos == NULL) return false;
+ 7, &towards);
+ if (!pos.has_value()) return false;
wantedX = pos->x;
wantedY = pos->y;
wantedZ = pos->z;
@@ -41,4 +42,4 @@ void MoveTowardsTargetGoal::stop() { target = std::weak_ptr(); }
void MoveTowardsTargetGoal::start() {
mob->getNavigation()->moveTo(wantedX, wantedY, wantedZ, speedModifier);
-}
\ No newline at end of file
+}
diff --git a/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.cpp b/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.cpp
index bdb2d72e2..a67f91cf9 100644
--- a/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.cpp
+++ b/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.cpp
@@ -74,4 +74,4 @@ bool NearestAttackableTargetGoal::canUse() {
void NearestAttackableTargetGoal::start() {
mob->setTarget(target.lock());
TargetGoal::start();
-}
\ No newline at end of file
+}
diff --git a/Minecraft.World/AI/Goals/OcelotAttackGoal.cpp b/Minecraft.World/AI/Goals/OcelotAttackGoal.cpp
index 5f56a3712..d14d3bc9d 100644
--- a/Minecraft.World/AI/Goals/OcelotAttackGoal.cpp
+++ b/Minecraft.World/AI/Goals/OcelotAttackGoal.cpp
@@ -57,4 +57,4 @@ void OcelotAttackGoal::tick() {
if (attackTime > 0) return;
attackTime = 20;
mob->doHurtTarget(target.lock());
-}
\ No newline at end of file
+}
diff --git a/Minecraft.World/AI/Goals/OcelotSitOnTileGoal.cpp b/Minecraft.World/AI/Goals/OcelotSitOnTileGoal.cpp
index 134fc71fb..058565138 100644
--- a/Minecraft.World/AI/Goals/OcelotSitOnTileGoal.cpp
+++ b/Minecraft.World/AI/Goals/OcelotSitOnTileGoal.cpp
@@ -6,9 +6,9 @@
#include "../../Headers/net.minecraft.world.level.h"
#include "../../Headers/net.minecraft.world.level.tile.h"
#include "../../Headers/net.minecraft.world.level.tile.entity.h"
-#include "../../Util/BasicTypeContainers.h"
#include "../../Util/Arrays.h"
#include "OcelotSitOnTileGoal.h"
+#include |