aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate')
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/AnvilTile_SPU.h50
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/BedTile_SPU.h28
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/BookshelfTile_SPU.h17
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/BrewingStandTile_SPU.h14
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Bush_SPU.h12
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ButtonTile_SPU.h54
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CactusTile_SPU.h18
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CakeTile_SPU.h31
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CarrotTile_SPU.h28
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CauldronTile_SPU.h14
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChestTile_SPU.h10
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkRebuildData.cpp894
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkRebuildData.h129
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkUpdate.spu.vcxproj267
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkUpdate.spu.vcxproj.filters170
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkUpdate.spu.vcxproj.vspscc10
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ClothTile_SPU.h11
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CocoaTile_SPU.h18
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CropTile_SPU.h19
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DetectorRailTile_SPU.h17
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DiodeTile_SPU.cpp5
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DiodeTile_SPU.h44
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Direction_SPU.cpp62
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Direction_SPU.h32
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DirectionalTile_SPU.h16
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DirtTile_SPU.h8
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DispenserTile_SPU.h38
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DoorTile_SPU.cpp136
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DoorTile_SPU.h37
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/EggTile_SPU.h13
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/EnchantmentTableTile_SPU.h17
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/EnderChestTile_SPU.h13
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/EntityTile_SPU.h8
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Facing_SPU.cpp22
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Facing_SPU.h17
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FarmTile_SPU.h22
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceGateTile_SPU.h32
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceTile_SPU.cpp75
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceTile_SPU.h14
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FireTile_SPU.h44
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FlowerPotTile_SPU.h32
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FurnaceTile_SPU.h20
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/GlassTile_SPU.h18
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/GrassTile_SPU.cpp65
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/GrassTile_SPU.h23
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfSlabTile_SPU.cpp77
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfSlabTile_SPU.h19
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfTransparentTile_SPU.h11
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HugeMushroomTile_SPU.h43
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/IceTile_SPU.h17
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Icon_SPU.cpp1
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Icon_SPU.h56
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LadderTile_SPU.h13
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LeafTile_SPU.cpp88
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LeafTile_SPU.h38
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LeverTile_SPU.h12
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LiquidTile_SPU.cpp224
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LiquidTile_SPU.h47
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Makefile16
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Material_SPU.h74
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/MelonTile_SPU.h14
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/MobSpawnerTile_SPU.h12
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Mushroom_SPU.h8
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/MycelTile_SPU.h25
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/NetherStalkTile_SPU.h29
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonBaseTile_SPU.h18
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonExtensionTile_SPU.h13
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonMovingPiece_SPU.h17
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PortalTile_SPU.h48
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PotatoTile_SPU.h28
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PressurePlateTile_SPU.cpp41
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PressurePlateTile_SPU.h21
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PumpkinTile_SPU.h30
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/QuartzBlockTile_SPU.h65
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RailTile_SPU.h58
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RecordPlayerTile_SPU.h18
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RedStoneDustTile_SPU.h48
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RedlightTile_SPU.h9
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ReedTile_SPU.h15
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SandStoneTile_SPU.h32
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Sapling_SPU.h14
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SignTile_SPU.h38
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SkullTile_SPU.h47
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SmoothStoneBrickTile_SPU.h25
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StairTile_SPU.cpp292
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StairTile_SPU.h30
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StemTile_SPU.h62
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StoneMonsterTile_SPU.h32
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StoneSlabTile_SPU.h60
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TallGrass_SPU.cpp35
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TallGrass_SPU.h22
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp796
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.h167
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TheEndPortalFrameTile_SPU.h12
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TheEndPortal_SPU.h17
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.cpp83
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.h17
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.cpp7635
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.h205
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.cpp899
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.h510
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TntTile_SPU.h18
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TopSnowTile_SPU.h61
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TorchTile_SPU.h12
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TrapDoorTile_SPU.h51
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TreeTile_SPU.h40
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TripWireSourceTile_SPU.h20
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TripWireTile_SPU.h70
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/VineTile_SPU.h99
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WallTile_SPU.h105
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WaterLilyTile_SPU.h15
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WebTile_SPU.h15
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WoodSlabTile_SPU.h15
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WoodTile_SPU.h19
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WoolCarpetTile_SPU.h30
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WorkbenchTile_SPU.h18
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/stdafx.h0
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/stubs_SPU.h263
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/task.cpp80
119 files changed, 15838 insertions, 0 deletions
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/AnvilTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/AnvilTile_SPU.h
new file mode 100644
index 00000000..6b3afe69
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/AnvilTile_SPU.h
@@ -0,0 +1,50 @@
+#pragma once
+
+#include "Tile_SPU.h"
+
+class FallingTile;
+
+class AnvilTile_SPU : public Tile_SPU
+{
+public:
+ static const int PART_BASE = 0;
+ static const int PART_JOINT = 1;
+ static const int PART_COLUMN = 2;
+ static const int PART_TOP = 3;
+
+ static const int ANVIL_NAMES_LENGTH = 3;
+
+
+// public:
+ //int part;
+
+ AnvilTile_SPU(int id) : Tile_SPU(id) {}
+
+public:
+ bool isCubeShaped() { return false; }
+ bool isSolidRender(bool isServerLevel = false) { return false; }
+ Icon_SPU *getTexture(int face, int data)
+ {
+ if (ms_pTileData->anvilPart == PART_TOP && face == Facing::UP)
+ {
+ int damage = (data >> 2) % ANVIL_NAMES_LENGTH;
+ return &ms_pTileData->anvil_icons[damage];
+ }
+ return icon();
+ }
+ int getRenderShape() { return Tile_SPU::SHAPE_ANVIL; }
+ void updateShape(ChunkRebuildData *level, int x, int y, int z)
+ {
+ int dir = level->getData(x, y, z) & 3;
+ if (dir == Direction::EAST || dir == Direction::WEST)
+ {
+ setShape(0, 0, 2 / 16.0f, 1, 1, 1 - 2 / 16.0f);
+ }
+ else
+ {
+ setShape(2 / 16.0f, 0, 0, 1 - 2 / 16.0f, 1, 1);
+ }
+ }
+
+ bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face) { return true; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/BedTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/BedTile_SPU.h
new file mode 100644
index 00000000..8196032e
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/BedTile_SPU.h
@@ -0,0 +1,28 @@
+#pragma once
+#include "Tile_SPU.h"
+
+
+
+// TileRenderer not implemented, so minimum of stuff here
+class BedTile_SPU : public Tile_SPU
+{
+public:
+// static const int PART_FOOT = 0;
+// static const int PART_HEAD = 1;
+//
+// static const int HEAD_PIECE_DATA = 0x8;
+// static const int OCCUPIED_DATA = 0x4;
+//
+// static int HEAD_DIRECTION_OFFSETS[4][2];
+
+ BedTile_SPU(int id) : Tile_SPU(id) {}
+
+ virtual Icon_SPU *getTexture(int face, int data) { return NULL; }
+ virtual int getRenderShape() { return Tile_SPU::SHAPE_BED; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param
+ {
+ setShape();
+ }
+ void setShape() { Tile_SPU::setShape(0, 0, 0, 1, 9 / 16.0f, 1); }
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/BookshelfTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/BookshelfTile_SPU.h
new file mode 100644
index 00000000..6a320a5f
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/BookshelfTile_SPU.h
@@ -0,0 +1,17 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class Random;
+
+class BookshelfTile_SPU : public Tile_SPU
+{
+public:
+ BookshelfTile_SPU(int id) : Tile_SPU(id) {}
+
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ if (face == Facing::UP || face == Facing::DOWN)
+ return TileRef_SPU(wood_Id)->getTexture(face);
+ return Tile_SPU::getTexture(face, data);
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/BrewingStandTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/BrewingStandTile_SPU.h
new file mode 100644
index 00000000..1cbae3aa
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/BrewingStandTile_SPU.h
@@ -0,0 +1,14 @@
+#pragma once
+#include "EntityTile_SPU.h"
+
+
+class BrewingStandTile_SPU : public EntityTile_SPU
+{
+public:
+ BrewingStandTile_SPU(int id) : EntityTile_SPU(id) {}
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual int getRenderShape() { return SHAPE_BREWING_STAND; }
+ virtual bool isCubeShaped() { return false; }
+ virtual void updateDefaultShape() { setShape(0, 0, 0, 1, 2.0f / 16.0f, 1); }
+ Icon_SPU *getBaseTexture() { return &ms_pTileData->brewingStand_iconBase; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Bush_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Bush_SPU.h
new file mode 100644
index 00000000..fa88e6a7
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Bush_SPU.h
@@ -0,0 +1,12 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class Bush_SPU : public Tile_SPU
+{
+public:
+ Bush_SPU(int id) : Tile_SPU(id) {}
+
+ virtual bool blocksLight() { return false; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual int getRenderShape() { return Tile_SPU::SHAPE_CROSS_TEXTURE; }
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ButtonTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ButtonTile_SPU.h
new file mode 100644
index 00000000..f34a5ec9
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ButtonTile_SPU.h
@@ -0,0 +1,54 @@
+#pragma once
+#include "Tile_SPU.h"
+
+
+class ButtonTile_SPU : public Tile_SPU
+{
+
+public:
+ ButtonTile_SPU(int id) : Tile_SPU(id) {}
+
+ Icon_SPU *getTexture(int face, int data)
+ {
+ if(id == Tile_SPU::button_wood_Id)
+ return TileRef_SPU(wood_Id)->getTexture(Facing::UP);
+ else
+ return TileRef_SPU(rock_Id)->getTexture(Facing::UP);
+ }
+ virtual bool blocksLight() { return false; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual bool isCubeShaped() { return false; }
+ virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param
+ {
+ int data = level->getData(x, y, z);
+ int dir = data & 7;
+ bool pressed = (data & 8) > 0;
+
+ float h0 = 6 / 16.0f;
+ float h1 = 10 / 16.0f;
+ float r = 3 / 16.0f;
+ float d = 2 / 16.0f;
+ if (pressed) d = 1 / 16.0f;
+
+ if (dir == 1)
+ {
+ setShape(0, h0, 0.5f - r, d, h1, 0.5f + r);
+ } else if (dir == 2)
+ {
+ setShape(1 - d, h0, 0.5f - r, 1, h1, 0.5f + r);
+ } else if (dir == 3)
+ {
+ setShape(0.5f - r, h0, 0, 0.5f + r, h1, d);
+ } else if (dir == 4)
+ {
+ setShape(0.5f - r, h0, 1 - d, 0.5f + r, h1, 1);
+ }
+ }
+ virtual void updateDefaultShape()
+ {
+ float x = 3 / 16.0f;
+ float y = 2 / 16.0f;
+ float z = 2 / 16.0f;
+ setShape(0.5f - x, 0.5f - y, 0.5f - z, 0.5f + x, 0.5f + y, 0.5f + z);
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CactusTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CactusTile_SPU.h
new file mode 100644
index 00000000..0f264670
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CactusTile_SPU.h
@@ -0,0 +1,18 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class CactusTile_SPU : public Tile_SPU
+{
+public:
+ CactusTile_SPU(int id) : Tile_SPU(id) {}
+
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ if (face == Facing::UP) return &ms_pTileData->cactusTile_iconTop;
+ if (face == Facing::DOWN) return &ms_pTileData->cactusTile_iconBottom;
+ else return icon();
+ }
+ virtual bool isCubeShaped() { return false; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false;}
+ virtual int getRenderShape() { return Tile_SPU::SHAPE_CACTUS; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CakeTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CakeTile_SPU.h
new file mode 100644
index 00000000..07eb3d86
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CakeTile_SPU.h
@@ -0,0 +1,31 @@
+#pragma once
+#include "Tile_SPU.h"
+#include "ChunkRebuildData.h"
+class CakeTile_SPU : public Tile_SPU
+{
+public:
+ CakeTile_SPU(int id) : Tile_SPU(id) {}
+ virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param
+ {
+ int d = level->getData(x, y, z);
+ float r = 1 / 16.0f;
+ float r2 = (1 + d * 2) / 16.0f;
+ float h = 8 / 16.0f;
+ this->setShape(r2, 0, r, 1 - r, h, 1 - r);
+ }
+ virtual void updateDefaultShape()
+ {
+ float r = 1 / 16.0f;
+ float h = 8 / 16.0f;
+ this->setShape(r, 0, r, 1 - r, h, 1 - r);
+ }
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ if (face == Facing::UP) return &ms_pTileData->cakeTile_iconTop;
+ if (face == Facing::DOWN) return &ms_pTileData->cakeTile_iconBottom;
+ if (data > 0 && face == Facing::WEST) return &ms_pTileData->cakeTile_iconInner;
+ return icon();
+ }
+ virtual bool isCubeShaped() { return false; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CarrotTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CarrotTile_SPU.h
new file mode 100644
index 00000000..d349b71f
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CarrotTile_SPU.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "CropTile_SPU.h"
+
+class CarrotTile_SPU : public CropTile_SPU
+{
+private:
+// Icon *icons[4];
+public:
+ CarrotTile_SPU(int id) : CropTile_SPU(id) {}
+
+ Icon_SPU *getTexture(int face, int data)
+ {
+ if (data < 7)
+ {
+ if (data == 6)
+ {
+ data = 5;
+ }
+ return &ms_pTileData->carrot_icons[data >> 1];
+ }
+ else
+ {
+ return &ms_pTileData->carrot_icons[3];
+ }
+ }
+
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CauldronTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CauldronTile_SPU.h
new file mode 100644
index 00000000..2854b48b
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CauldronTile_SPU.h
@@ -0,0 +1,14 @@
+#pragma once
+#include "Tile_SPU.h"
+
+
+class CauldronTile_SPU : public Tile_SPU
+{
+public:
+ CauldronTile_SPU(int id) : Tile_SPU(id) {}
+ virtual Icon_SPU *getTexture(int face, int data) { return NULL; }
+ //@Override
+// virtual void updateDefaultShape();
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual int getRenderShape() { return SHAPE_CAULDRON; }
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChestTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChestTile_SPU.h
new file mode 100644
index 00000000..10fb1da5
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChestTile_SPU.h
@@ -0,0 +1,10 @@
+#pragma once
+#include "EntityTile_SPU.h"
+
+class ChestTile_SPU : public EntityTile_SPU
+{
+public:
+ ChestTile_SPU(int id) : EntityTile_SPU(id) {}
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual int getRenderShape() { return Tile_SPU::SHAPE_ENTITYTILE_ANIMATED; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkRebuildData.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkRebuildData.cpp
new file mode 100644
index 00000000..1cb5e2ee
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkRebuildData.cpp
@@ -0,0 +1,894 @@
+#include "stdafx.h"
+#ifdef __PS3__
+#ifndef SN_TARGET_PS3_SPU
+// #include "..\..\..\stdafx.h"
+#endif
+#endif
+
+#include "ChunkRebuildData.h"
+#include "Tesselator_SPU.h"
+
+
+#ifndef SN_TARGET_PS3_SPU
+#include "..\..\..\..\Minecraft.World\Tile.h"
+#include "..\..\..\..\Minecraft.World\Level.h"
+#include "..\..\..\..\Minecraft.World\Dimension.h"
+//
+// #include "..\..\..\Chunk.h"
+// #include "..\..\..\TileRenderer.h"
+// #include "..\..\..\TileEntityRenderDispatcher.h"
+// #include "..\..\..\LevelRenderer.h"
+#include "..\..\..\..\Minecraft.World\net.minecraft.world.level.h"
+#include "..\..\..\..\Minecraft.World\net.minecraft.world.level.chunk.h"
+#include "..\..\..\..\Minecraft.World\net.minecraft.world.level.tile.h"
+#include "..\..\..\..\Minecraft.World\net.minecraft.world.level.tile.entity.h"
+#include "..\..\..\..\Minecraft.World\Icon.h"
+#include "..\..\..\..\Minecraft.World\BiomeSource.h"
+
+#else
+
+#include "..\Common\spu_assert.h"
+
+#endif //SN_TARGET_PS3_SPU
+
+static const int Level_maxBuildHeight = 256;
+static const int Level_MAX_LEVEL_SIZE = 30000000;
+static const int Level_MAX_BRIGHTNESS = 15;
+
+
+#include "TileRenderer_SPU.h"
+#include "Tile_SPU.h"
+#include "ChunkRebuildData.h"
+TileData_SPU g_tileSPUData;
+
+static const int MAX_LEVEL_SIZE = 30000000;
+static const int MAX_BRIGHTNESS = 15;
+
+#if 0 //def SN_TARGET_PS3_SPU
+int ChunkRebuildData::getTile( int x, int y, int z ) { return m_tileIds[getTileIdx(x,y,z)]; }
+int ChunkRebuildData::getBrightnessSky(int x, int y, int z) { return m_brightness[getTileIdx(x,y,z)] & 0x0f; }
+int ChunkRebuildData::getBrightnessBlock(int x, int y, int z) { return m_brightness[getTileIdx(x,y,z)] >> 4; }
+int ChunkRebuildData::getData(int x, int y, int z) { return m_data_flags[getTileIdx(x,y,z)] & 0x0f; }
+int ChunkRebuildData::getGrassColor( int x, int z ) { return m_grassColor[getTileIdx(x,z)]; }
+int ChunkRebuildData::getFoliageColor( int x, int z ) { return m_foliageColor[getTileIdx(x,z)]; }
+int ChunkRebuildData::getFlags(int x, int y, int z) { return m_data_flags[getTileIdx(x,y,z)] >> 4; }
+void ChunkRebuildData::setFlag(int x, int y, int z, int flag) { m_data_flags[getTileIdx(x,y,z)] |= (flag<<4);}
+#endif
+
+
+
+void ChunkRebuildData::disableUnseenTiles()
+{
+ // We now go through the vertical section of this level chunk that we are interested in and try and establish
+ // (1) if it is completely empty
+ // (2) if any of the tiles can be quickly determined to not need rendering because they are in the middle of other tiles and
+ // so can't be seen. A large amount (> 60% in tests) of tiles that call tesselateInWorld in the unoptimised version
+ // of this function fall into this category. By far the largest category of these are tiles in solid regions of rock.
+ int startX = m_x0+2; // beginning of the chunk
+ int startY = m_y0+2; // beginning of the chunk
+ int startZ = m_z0+2; // beginning of the chunk
+
+ for(int iX=startX; iX<(startX+16); iX++)
+ {
+ for(int iY=startY; iY<(startY+16); iY++)
+ {
+ for(int iZ=startZ; iZ<(startZ+16); iZ++)
+ {
+ int tileID = getTile(iX,iY,iZ);
+ if( tileID == 0 ) continue;
+ m_flags &= ~e_flag_EmptyChunk;
+
+
+ // Don't bother trying to work out neighbours for this tile if we are at the edge of the chunk - apart from the very
+ // bottom of the world where we shouldn't ever be able to see
+ if( iY == 127 ) continue;
+ if(( iX-startX == 0 ) || ( iX-startX == 15 )) continue;
+ if(( iZ-startZ == 0 ) || ( iZ-startZ == 15 )) continue;
+
+ int flags = getFlags(iX, iY, iZ);
+
+ // Establish whether this tile and its neighbours are all made of rock, dirt, unbreakable tiles, or have already
+ // been determined to meet this criteria themselves and have a tile of 255 set.
+ if( !( ( tileID == Tile_SPU::rock_Id ) || ( tileID == Tile_SPU::dirt_Id ) || ( tileID == Tile_SPU::unbreakable_Id ) || ( flags & e_flag_NoRender) ) ) continue;
+ tileID = getTile(iX-1, iY, iZ);
+ flags = getFlags(iX-1, iY, iZ);
+ if( !( ( tileID == Tile_SPU::rock_Id ) || ( tileID == Tile_SPU::dirt_Id ) || ( tileID == Tile_SPU::unbreakable_Id ) || ( flags & e_flag_NoRender) ) ) continue;
+ tileID = getTile(iX+1, iY, iZ);
+ flags = getFlags(iX+1, iY, iZ);
+ if( !( ( tileID == Tile_SPU::rock_Id ) || ( tileID == Tile_SPU::dirt_Id ) || ( tileID == Tile_SPU::unbreakable_Id ) || ( flags & e_flag_NoRender) ) ) continue;
+ tileID = getTile(iX, iY, iZ-1);
+ flags = getFlags(iX, iY, iZ-1);
+ if( !( ( tileID == Tile_SPU::rock_Id ) || ( tileID == Tile_SPU::dirt_Id ) || ( tileID == Tile_SPU::unbreakable_Id ) || ( flags & e_flag_NoRender) ) ) continue;
+ tileID = getTile(iX, iY, iZ+1);
+ flags = getFlags(iX, iY, iZ+1);
+ if( !( ( tileID == Tile_SPU::rock_Id ) || ( tileID == Tile_SPU::dirt_Id ) || ( tileID == Tile_SPU::unbreakable_Id ) || ( flags & e_flag_NoRender) ) ) continue;
+ // Treat the bottom of the world differently - we shouldn't ever be able to look up at this, so consider tiles as invisible
+ // if they are surrounded on sides other than the bottom
+ if( iY > 0 )
+ {
+ tileID = getTile(iX, iY-1, iZ);
+ flags = getFlags(iX, iY-1, iZ);
+ if( !( ( tileID == Tile_SPU::rock_Id ) || ( tileID == Tile_SPU::dirt_Id ) || ( tileID == Tile_SPU::unbreakable_Id ) || ( flags & e_flag_NoRender) ) ) continue;
+ }
+ tileID = getTile(iX, iY+1, iZ);
+ flags = getFlags(iX, iY+1, iZ);
+ if( !( ( tileID == Tile_SPU::rock_Id ) || ( tileID == Tile_SPU::dirt_Id ) || ( tileID == Tile_SPU::unbreakable_Id ) || ( flags & e_flag_NoRender) ) ) continue;
+
+ // This tile is surrounded. Flag it as not requiring to be rendered by setting its id to 255.
+ setFlag(iX, iY, iZ, e_flag_NoRender);
+ }
+ }
+ }
+}
+
+#ifndef SN_TARGET_PS3_SPU
+
+void setIconSPUFromIcon(Icon_SPU* iconSpu, Icon* icon)
+{
+ iconSpu->set(icon->getX(), icon->getY(), icon->getWidth(), icon->getHeight(), icon->getSourceWidth(), icon->getSourceHeight());
+}
+
+void ChunkRebuildData::buildMaterial(int matSPUIndex, Material* mat)
+{
+ Material_SPU* matSPU = &m_tileData.materials[matSPUIndex];
+ matSPU->id = matSPUIndex;
+ matSPU->color = mat->color->col;
+ matSPU->flags =0;
+ matSPU->flags |= mat->isFlammable() ? Material_SPU::e_flammable : 0;
+ matSPU->flags |= mat->isReplaceable() ? Material_SPU::e_replaceable : 0;
+ matSPU->flags |= mat->_neverBuildable ? Material_SPU::e_neverBuildable : 0;
+ matSPU->flags |= mat->isSolid() ? Material_SPU::e_isSolid : 0;
+ matSPU->flags |= mat->isLiquid() ? Material_SPU::e_isLiquid : 0;
+ matSPU->flags |= mat->blocksLight() ? Material_SPU::e_blocksLight : 0;
+ matSPU->flags |= mat->blocksMotion() ? Material_SPU::e_blocksMotion : 0;
+}
+
+void ChunkRebuildData::buildMaterials()
+{
+ buildMaterial(Material_SPU::air_Id, Material::air);
+ buildMaterial(Material_SPU::grass_Id, Material::grass);
+ buildMaterial(Material_SPU::dirt_Id, Material::dirt);
+ buildMaterial(Material_SPU::wood_Id, Material::wood);
+ buildMaterial(Material_SPU::stone_Id, Material::stone);
+ buildMaterial(Material_SPU::metal_Id, Material::metal);
+ buildMaterial(Material_SPU::water_Id, Material::water);
+ buildMaterial(Material_SPU::lava_Id, Material::lava);
+ buildMaterial(Material_SPU::leaves_Id, Material::leaves);
+ buildMaterial(Material_SPU::plant_Id, Material::plant);
+ buildMaterial(Material_SPU::replaceable_plant_Id, Material::replaceable_plant);
+ buildMaterial(Material_SPU::sponge_Id, Material::sponge);
+ buildMaterial(Material_SPU::cloth_Id, Material::cloth);
+ buildMaterial(Material_SPU::fire_Id, Material::fire);
+ buildMaterial(Material_SPU::sand_Id, Material::sand);
+ buildMaterial(Material_SPU::decoration_Id, Material::decoration);
+ buildMaterial(Material_SPU::clothDecoration_Id, Material::clothDecoration);
+ buildMaterial(Material_SPU::glass_Id, Material::glass);
+ buildMaterial(Material_SPU::explosive_Id, Material::explosive);
+ buildMaterial(Material_SPU::coral_Id, Material::coral);
+ buildMaterial(Material_SPU::ice_Id, Material::ice);
+ buildMaterial(Material_SPU::topSnow_Id, Material::topSnow);
+ buildMaterial(Material_SPU::snow_Id, Material::snow);
+ buildMaterial(Material_SPU::cactus_Id, Material::cactus);
+ buildMaterial(Material_SPU::clay_Id, Material::clay);
+ buildMaterial(Material_SPU::vegetable_Id, Material::vegetable);
+ buildMaterial(Material_SPU::egg_Id, Material::egg);
+ buildMaterial(Material_SPU::portal_Id, Material::portal);
+ buildMaterial(Material_SPU::cake_Id, Material::cake);
+ buildMaterial(Material_SPU::web_Id, Material::web);
+ buildMaterial(Material_SPU::piston_Id, Material::piston);
+ buildMaterial(Material_SPU::buildable_glass_Id, Material::buildable_glass);
+ buildMaterial(Material_SPU::heavyMetal_Id, Material::heavyMetal);
+}
+
+int ChunkRebuildData::getMaterialID(Tile* pTile)
+{
+ Material* m = pTile->material;
+ if(m == Material::air) return Material_SPU::air_Id;
+ if(m == Material::grass) return Material_SPU::grass_Id;
+ if(m == Material::dirt) return Material_SPU::dirt_Id;
+ if(m == Material::wood) return Material_SPU::wood_Id;
+ if(m == Material::stone) return Material_SPU::stone_Id;
+ if(m == Material::metal) return Material_SPU::metal_Id;
+ if(m == Material::water) return Material_SPU::water_Id;
+ if(m == Material::lava) return Material_SPU::lava_Id;
+ if(m == Material::leaves) return Material_SPU::leaves_Id;
+ if(m == Material::plant) return Material_SPU::plant_Id;
+ if(m == Material::replaceable_plant)return Material_SPU::replaceable_plant_Id;
+ if(m == Material::sponge) return Material_SPU::sponge_Id;
+ if(m == Material::cloth) return Material_SPU::cloth_Id;
+ if(m == Material::fire) return Material_SPU::fire_Id;
+ if(m == Material::sand) return Material_SPU::sand_Id;
+ if(m == Material::decoration) return Material_SPU::decoration_Id;
+ if(m == Material::clothDecoration) return Material_SPU::clothDecoration_Id;
+ if(m == Material::glass) return Material_SPU::glass_Id;
+ if(m == Material::explosive) return Material_SPU::explosive_Id;
+ if(m == Material::coral) return Material_SPU::coral_Id;
+ if(m == Material::ice) return Material_SPU::ice_Id;
+ if(m == Material::topSnow) return Material_SPU::topSnow_Id;
+ if(m == Material::snow) return Material_SPU::snow_Id;
+ if(m == Material::cactus) return Material_SPU::cactus_Id;
+ if(m == Material::clay) return Material_SPU::clay_Id;
+ if(m == Material::vegetable) return Material_SPU::vegetable_Id;
+ if(m == Material::egg) return Material_SPU::egg_Id;
+ if(m == Material::portal) return Material_SPU::portal_Id;
+ if(m == Material::cake) return Material_SPU::cake_Id;
+ if(m == Material::web) return Material_SPU::web_Id;
+ if(m == Material::piston) return Material_SPU::piston_Id;
+ if(m == Material::buildable_glass) return Material_SPU::buildable_glass_Id;
+ if(m == Material::heavyMetal) return Material_SPU::heavyMetal_Id;
+ assert(0);
+ return Material_SPU::air_Id;
+}
+
+
+void ChunkRebuildData::createTileData()
+{
+ // build the material data
+ buildMaterials();
+
+ // build the tile data
+ for(int i=0;i<256;i++)
+ {
+ m_tileData.mipmapEnable.set(i, Tile::mipmapEnable[i]);
+ m_tileData.solid.set(i, Tile::solid[i]);
+ m_tileData.transculent.set(i, Tile::transculent[i]);
+// m_tileData._sendTileData.set(i, Tile::_sendTileData[i]);
+ m_tileData.propagate.set(i, Tile::propagate[i]);
+ m_tileData.lightBlock[i] = Tile::lightBlock[i];
+ m_tileData.lightEmission[i] = Tile::lightEmission[i];
+ if(Tile::tiles[i])
+ {
+ m_tileData.signalSource.set(i, Tile::tiles[i]->isSignalSource());
+ m_tileData.cubeShaped.set(i, Tile::tiles[i]->isCubeShaped());
+
+ m_tileData.xx0[i] = (float)Tile::tiles[i]->getShapeX0();
+ m_tileData.yy0[i] = (float)Tile::tiles[i]->getShapeY0();
+ m_tileData.zz0[i] = (float)Tile::tiles[i]->getShapeZ0();
+ m_tileData.xx1[i] = (float)Tile::tiles[i]->getShapeX1();
+ m_tileData.yy1[i] = (float)Tile::tiles[i]->getShapeY1();
+ m_tileData.zz1[i] = (float)Tile::tiles[i]->getShapeZ1();
+ Icon* pTex = Tile::tiles[i]->icon;
+ if(pTex)
+ {
+ setIconSPUFromIcon(&m_tileData.iconData[i], pTex);
+ }
+ m_tileData.materialIDs[i] = getMaterialID(Tile::tiles[i]);
+ }
+ }
+ m_tileData.leafTile_allowSame = Tile::leaves->allowSame;
+ m_tileData.leafTile_fancyTextureSet = Tile::leaves->fancyTextureSet;
+
+
+ // Custom tile textures
+ // get the width and height of any texture, since everything uses the same texture
+ m_tileData.iconTexWidth = Tile::grass->iconTop->getSourceWidth();
+ m_tileData.iconTexHeight = Tile::grass->iconTop->getSourceHeight();
+ // Grass tile
+ setIconSPUFromIcon(&m_tileData.grass_iconTop, Tile::grass->iconTop);
+ setIconSPUFromIcon(&m_tileData.grass_iconSnowSide, Tile::grass->iconSnowSide);
+ setIconSPUFromIcon(&m_tileData.grass_iconSideOverlay, Tile::grass->iconSideOverlay);
+
+ // ThinFence
+ setIconSPUFromIcon(&m_tileData.ironFence_EdgeTexture, ((ThinFenceTile*)Tile::ironFence)->getEdgeTexture());
+ setIconSPUFromIcon(&m_tileData.thinGlass_EdgeTexture, ((ThinFenceTile*)Tile::thinGlass)->getEdgeTexture());
+
+ //FarmTile
+ setIconSPUFromIcon(&m_tileData.farmTile_Dry, ((FarmTile*)Tile::farmland)->iconDry);
+ setIconSPUFromIcon(&m_tileData.farmTile_Wet, ((FarmTile*)Tile::farmland)->iconWet);
+
+ // DoorTile
+ for(int i=0;i<8; i++)
+ {
+ setIconSPUFromIcon(&m_tileData.doorTile_Icons[i], ((DoorTile*)Tile::door_wood)->icons[i]);
+ // we're not supporting flipped icons, so manually flip here
+ if(i>=4)
+ m_tileData.doorTile_Icons[i].flipHorizontal();
+ }
+
+ // TallGrass
+ for(int i=0;i<3; i++)
+ setIconSPUFromIcon(&m_tileData.tallGrass_Icons[i], Tile::tallgrass->icons[i]);
+
+ // SandStoneTile
+ for(int i=0;i<3; i++)
+ setIconSPUFromIcon(&m_tileData.sandStone_icons[i], ((SandStoneTile*)Tile::sandStone)->icons[i]);
+ setIconSPUFromIcon(&m_tileData.sandStone_iconTop, ((SandStoneTile*)Tile::sandStone)->iconTop);
+ setIconSPUFromIcon(&m_tileData.sandStone_iconBottom, ((SandStoneTile*)Tile::sandStone)->iconBottom);
+
+ // WoodTile
+// assert(WoodTile_SPU::WOOD_NAMES_LENGTH == 4);
+ for(int i=0;i<4; i++)
+ setIconSPUFromIcon(&m_tileData.woodTile_icons[i], ((WoodTile*)Tile::wood)->icons[i]);
+
+ // TreeTile
+// assert(TreeTile_SPU::TREE_NAMES_LENGTH == 4);
+ for(int i=0;i<4; i++)
+ setIconSPUFromIcon(&m_tileData.treeTile_icons[i], ((TreeTile*)Tile::treeTrunk)->icons[i]);
+ setIconSPUFromIcon(&m_tileData.treeTile_iconTop, ((TreeTile*)Tile::treeTrunk)->iconTop);
+
+ // LeafTile
+ for(int i=0;i<2; i++)
+ for(int j=0;j<4;j++)
+ setIconSPUFromIcon(&m_tileData.leafTile_icons[i][j], ((LeafTile*)Tile::leaves)->icons[i][j]);
+
+ // CropTile
+ for(int i=0;i<8; i++)
+ setIconSPUFromIcon(&m_tileData.cropTile_icons[i], ((CropTile*)Tile::crops)->icons[i]);
+
+ // FurnaceTile
+ setIconSPUFromIcon(&m_tileData.furnaceTile_iconTop, ((FurnaceTile*)Tile::furnace)->iconTop);
+ setIconSPUFromIcon(&m_tileData.furnaceTile_iconFront, ((FurnaceTile*)Tile::furnace)->iconFront);
+ setIconSPUFromIcon(&m_tileData.furnaceTile_iconFront_lit, ((FurnaceTile*)Tile::furnace_lit)->iconFront);
+
+ //LiquidTile
+ setIconSPUFromIcon(&m_tileData.liquidTile_iconWaterStill, (Tile::water)->icons[0]);
+ setIconSPUFromIcon(&m_tileData.liquidTile_iconWaterFlow, (Tile::water)->icons[1]);
+ setIconSPUFromIcon(&m_tileData.liquidTile_iconLavaStill, (Tile::lava)->icons[0]);
+ setIconSPUFromIcon(&m_tileData.liquidTile_iconLavaFlow, (Tile::lava)->icons[1]);
+
+ //FireTile
+ for(int i=0;i<2;i++)
+ setIconSPUFromIcon(&m_tileData.fireTile_icons[i], (Tile::fire)->icons[i]);
+
+ // Sapling
+ for(int i=0;i<4;i++)
+ setIconSPUFromIcon(&m_tileData.sapling_icons[i], ((Sapling*)Tile::sapling)->icons[i]);
+
+ m_tileData.glassTile_allowSame = ((GlassTile*)Tile::glass)->allowSame;
+ m_tileData.iceTile_allowSame = ((IceTile*)Tile::ice)->allowSame;
+
+ // DispenserTile
+ setIconSPUFromIcon(&m_tileData.dispenserTile_iconTop, ((DispenserTile*)Tile::dispenser)->iconTop);
+ setIconSPUFromIcon(&m_tileData.dispenserTile_iconFront, ((DispenserTile*)Tile::dispenser)->iconFront);
+ setIconSPUFromIcon(&m_tileData.dispenserTile_iconFrontVertical, ((DispenserTile*)Tile::dispenser)->iconFrontVertical);
+
+ // RailTile
+ setIconSPUFromIcon(&m_tileData.railTile_iconTurn, ((RailTile*)Tile::rail)->iconTurn);
+ setIconSPUFromIcon(&m_tileData.railTile_iconTurnGolden, ((RailTile*)Tile::goldenRail)->iconTurn);
+
+ for(int i=0;i<2;i++)
+ setIconSPUFromIcon(&m_tileData.detectorRailTile_icons[i], ((DetectorRailTile*)Tile::detectorRail)->icons[i]);
+
+ // tntTile
+ setIconSPUFromIcon(&m_tileData.tntTile_iconBottom, ((TntTile*)Tile::tnt)->iconBottom);
+ setIconSPUFromIcon(&m_tileData.tntTile_iconTop, ((TntTile*)Tile::tnt)->iconTop);
+
+ // workbenchTile
+ setIconSPUFromIcon(&m_tileData.workBench_iconFront, ((WorkbenchTile*)Tile::workBench)->iconFront);
+ setIconSPUFromIcon(&m_tileData.workBench_iconTop, ((WorkbenchTile*)Tile::workBench)->iconTop);
+
+ // cactusTile
+ setIconSPUFromIcon(&m_tileData.cactusTile_iconTop, ((CactusTile*)Tile::cactus)->iconTop);
+ setIconSPUFromIcon(&m_tileData.cactusTile_iconBottom, ((CactusTile*)Tile::cactus)->iconBottom);
+
+ // recordPlayer
+ setIconSPUFromIcon(&m_tileData.recordPlayer_iconTop, ((RecordPlayerTile*)Tile::recordPlayer)->iconTop);
+
+ // pumpkin
+ setIconSPUFromIcon(&m_tileData.pumpkinTile_iconTop, ((PumpkinTile*)Tile::pumpkin)->iconTop);
+ setIconSPUFromIcon(&m_tileData.pumpkinTile_iconFace, ((PumpkinTile*)Tile::pumpkin)->iconFace);
+ setIconSPUFromIcon(&m_tileData.pumpkinTile_iconFaceLit, ((PumpkinTile*)Tile::litPumpkin)->iconFace);
+
+ // cakeTile
+ setIconSPUFromIcon(&m_tileData.cakeTile_iconTop, ((CakeTile*)Tile::cake)->iconTop);
+ setIconSPUFromIcon(&m_tileData.cakeTile_iconBottom, ((CakeTile*)Tile::cake)->iconBottom);
+ setIconSPUFromIcon(&m_tileData.cakeTile_iconInner, ((CakeTile*)Tile::cake)->iconInner);
+
+ // SmoothStoneBrickTile
+ for(int i=0;i<4;i++)
+ setIconSPUFromIcon(&m_tileData.smoothStoneBrick_icons[i], ((SmoothStoneBrickTile*)Tile::stoneBrickSmooth)->icons[i]);
+
+ // HugeMushroomTile
+ for(int i=0;i<2;i++)
+ setIconSPUFromIcon(&m_tileData.hugeMushroom_icons[i], ((HugeMushroomTile*)Tile::hugeMushroom1)->icons[i]);
+ setIconSPUFromIcon(&m_tileData.hugeMushroom_iconStem, ((HugeMushroomTile*)Tile::hugeMushroom1)->iconStem);
+ setIconSPUFromIcon(&m_tileData.hugeMushroom_iconInside, ((HugeMushroomTile*)Tile::hugeMushroom1)->iconInside);
+
+
+ // MelonTile
+ setIconSPUFromIcon(&m_tileData.melonTile_iconTop, ((MelonTile*)Tile::melon)->iconTop);
+
+ // StemTile
+ setIconSPUFromIcon(&m_tileData.stemTile_iconAngled, ((StemTile*)Tile::melonStem)->iconAngled);
+
+ // MycelTile
+ setIconSPUFromIcon(&m_tileData.mycelTile_iconTop, (Tile::mycel)->iconTop);
+ setIconSPUFromIcon(&m_tileData.mycelTile_iconSnowSide, (Tile::mycel)->iconSnowSide);
+
+ // NetherStalkTile
+ for(int i=0;i<3;i++)
+ setIconSPUFromIcon(&m_tileData.netherStalk_icons[i], ((NetherStalkTile*)Tile::netherStalk)->icons[i]);
+
+ // EnchantmentTableTile
+ setIconSPUFromIcon(&m_tileData.enchantmentTable_iconTop, ((EnchantmentTableTile*)Tile::enchantTable)->iconTop);
+ setIconSPUFromIcon(&m_tileData.enchantmentTable_iconBottom, ((EnchantmentTableTile*)Tile::enchantTable)->iconBottom);
+
+ //BrewingStandTile
+ setIconSPUFromIcon(&m_tileData.brewingStand_iconBase, ((BrewingStandTile*)Tile::brewingStand)->iconBase);
+
+ //RedStoneDust
+ setIconSPUFromIcon(&m_tileData.redStoneDust_iconCross, (Tile::redStoneDust)->iconCross);
+ setIconSPUFromIcon(&m_tileData.redStoneDust_iconCross, (Tile::redStoneDust)->iconLine);
+ setIconSPUFromIcon(&m_tileData.redStoneDust_iconCrossOver, (Tile::redStoneDust)->iconCrossOver);
+ setIconSPUFromIcon(&m_tileData.redStoneDust_iconLineOver, (Tile::redStoneDust)->iconLineOver);
+
+ setIconSPUFromIcon(&m_tileData.stoneSlab_iconSide, ((StoneSlabTile*)(Tile::stoneSlab))->iconSide);
+
+ for(int i=0;i<16;i++)
+ setIconSPUFromIcon(&m_tileData.clothTile_icons[i], ((ClothTile*)Tile::cloth)->icons[i]);
+
+ // CarrotTile
+ for(int i=0;i<4;i++)
+ setIconSPUFromIcon(&m_tileData.carrot_icons[i], ((CarrotTile*)Tile::carrots)->icons[i]);
+
+ // PotatoTile
+ for(int i=0;i<4;i++)
+ setIconSPUFromIcon(&m_tileData.potato_icons[i], ((PotatoTile*)Tile::potatoes)->icons[i]);
+
+ // AnvilTile
+ for(int i=0;i<3;i++)
+ setIconSPUFromIcon(&m_tileData.anvil_icons[i], ((AnvilTile*)Tile::anvil)->icons[i]);
+
+
+ // QuartzBlockTile
+ for(int i=0;i<5;i++)
+ setIconSPUFromIcon(&m_tileData.quartzBlock_icons[i], ((QuartzBlockTile*)Tile::quartzBlock)->icons[i]);
+
+ setIconSPUFromIcon(&m_tileData.quartzBlock_iconChiseledTop, ((QuartzBlockTile*)Tile::quartzBlock)->iconChiseledTop);
+ setIconSPUFromIcon(&m_tileData.quartzBlock_iconLinesTop, ((QuartzBlockTile*)Tile::quartzBlock)->iconLinesTop);
+ setIconSPUFromIcon(&m_tileData.quartzBlock_iconTop, ((QuartzBlockTile*)Tile::quartzBlock)->iconTop);
+ setIconSPUFromIcon(&m_tileData.quartzBlock_iconBottom, ((QuartzBlockTile*)Tile::quartzBlock)->iconBottom);
+}
+
+// extern int g_lastHitBlockX;
+// extern int g_lastHitBlockY;
+// extern int g_lastHitBlockZ;
+
+void ChunkRebuildData::buildForChunk( Region* region, Level* level, int x0, int y0, int z0 )
+{
+ static bool bCreatedTileData = false;
+ if(!bCreatedTileData)
+ {
+ createTileData();
+ bCreatedTileData = true;
+ }
+
+ m_tileData.stemTile_minColour = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Tile_StemMin );
+ m_tileData.stemTile_maxColour = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Tile_StemMax );
+ m_tileData.waterLily_colour = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Tile_WaterLily );
+
+ m_tileData.foliageColor_evergreenColor = FoliageColor::getEvergreenColor();
+ m_tileData.foliageColor_birchColor = FoliageColor::getBirchColor();
+
+
+// m_lastHitBlockX = g_lastHitBlockX;
+// m_lastHitBlockY = g_lastHitBlockY;
+// m_lastHitBlockZ = g_lastHitBlockZ;
+
+ m_x0 = x0-2;
+ m_y0 = y0-2;
+ m_z0 = z0-2;
+ m_pRegion = region;
+ m_flags = 0;//e_flag_EmptyChunk;
+
+// for(int iX=m_x0; iX<(m_x0+sc_size); iX++)
+// {
+// for(int iY=m_y0; iY<(m_y0+sc_size); iY++)
+// {
+// for(int iZ=m_z0; iZ<(m_z0+sc_size); iZ++)
+// {
+// buildTile(iX, iY, iZ);
+// }
+// }
+// }
+
+ BiomeCache::Block* cacheBlocks[9];
+ cacheBlocks[0] = region->getBiomeSource()->getBlockAt(m_x0, m_z0);
+ cacheBlocks[1] = region->getBiomeSource()->getBlockAt(m_x0+2, m_z0);
+ cacheBlocks[2] = region->getBiomeSource()->getBlockAt(m_x0+18, m_z0);
+
+ cacheBlocks[3] = region->getBiomeSource()->getBlockAt(m_x0, m_z0+2);
+ cacheBlocks[4] = region->getBiomeSource()->getBlockAt(m_x0+2, m_z0+2);
+ cacheBlocks[5] = region->getBiomeSource()->getBlockAt(m_x0+18, m_z0+2);
+
+ cacheBlocks[6] = region->getBiomeSource()->getBlockAt(m_x0, m_z0+18);
+ cacheBlocks[7] = region->getBiomeSource()->getBlockAt(m_x0+2, m_z0+18);
+ cacheBlocks[8] = region->getBiomeSource()->getBlockAt(m_x0+18, m_z0+18);
+
+ int cacheMap[20] = { 0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 2,2};
+
+ ColourTable* pColourTable = Minecraft::GetInstance()->getColourTable();
+
+ for(int iX=m_x0; iX<(m_x0+sc_size); iX++)
+ {
+ for(int iZ=m_z0; iZ<(m_z0+sc_size); iZ++)
+ {
+ int newX = ( iX - m_x0 );
+ int newZ = ( iZ - m_z0 );
+ int index = (newX*sc_size) + newZ;
+// assert(index < 400);
+ int cacheBlockIndex = (cacheMap[iZ-m_z0]*3) + cacheMap[iX-m_x0];
+ BiomeCache::Block* pCacheBlock = cacheBlocks[cacheBlockIndex];
+// assert(region->getBiomeSource()->getBlockAt(iX, iZ) == pCacheBlock);
+ Biome* pBiome = pCacheBlock->getBiome(iX, iZ);
+ m_grassColor[index] = pColourTable->getColor(pBiome->m_grassColor);
+ m_foliageColor[index] = pColourTable->getColor(pBiome->m_foliageColor);
+ m_waterColor[index] = pColourTable->getColor(pBiome->m_waterColor);
+ }
+ }
+
+ if(isEmptyChunk())
+ return;
+
+
+ if(level->dimension->hasCeiling)
+ m_flags |= e_flag_HasCeiling;
+ for(int i=0;i<16;i++)
+ m_brightnessRamp[i] = level->dimension->brightnessRamp[i];
+ m_levelSkyDarken = level->skyDarken;
+}
+
+void ChunkRebuildData::copyFromTesselator()
+{
+ Tesselator* t = Tesselator::getInstance(); // 4J - added - static initialiser being set at the wrong time
+
+ m_tesselator.m_PPUArray = t->_array->data;
+ assert(t->p == 0);
+ m_tesselator.m_PPUOffset = 0;
+
+ // copy tesselator vars over
+ m_tesselator.vertices = t->vertices;
+ m_tesselator.u = t->u;
+ m_tesselator.v = t->v;
+ m_tesselator._tex2 = t->_tex2;
+ m_tesselator.col = t->col;
+ m_tesselator.hasColor = t->hasColor;
+ m_tesselator.hasTexture = t->hasTexture;
+ m_tesselator.hasTexture2 = t->hasTexture2;
+ m_tesselator.hasNormal = t->hasNormal;
+ m_tesselator.p = t->p;
+ m_tesselator.useCompactFormat360 = t->useCompactFormat360;
+ m_tesselator.useProjectedTexturePixelShader = t->useProjectedTexturePixelShader;
+ m_tesselator.count = t->count;
+ m_tesselator._noColor = t->_noColor;
+ m_tesselator.mode = t->mode;
+ m_tesselator.xo = t->xo;
+ m_tesselator.yo = t->yo;
+ m_tesselator.zo = t->zo;
+ m_tesselator.count = t->count ;
+ m_tesselator._normal = t->_normal;
+ m_tesselator.tesselating = t->tesselating;
+ m_tesselator.mipmapEnable = t->mipmapEnable; // 4J added
+ m_tesselator.vboId = t->vboId;
+ m_tesselator.vboCounts = t->vboCounts;
+ m_tesselator.size = t->size;
+ for(int i=0;i<6;i++)
+ m_tesselator.bounds.boundingBox[i] = t->bounds.boundingBox[i];
+
+}
+
+
+void ChunkRebuildData::buildTile(int x, int y, int z)
+{
+ int newX = ( x - m_x0 );
+ int newY = ( y - m_y0 );
+ int newZ = ( z - m_z0 );
+
+ int index = (newX*sc_size*sc_size) + (newY*sc_size) + newZ;
+
+ m_tileIds[index] = m_pRegion->getTile(x, y, z);
+ m_brightness[index] = m_pRegion->getBrightness(LightLayer::Sky, x, y, z);
+ m_brightness[index] |= (m_pRegion->getBrightness(LightLayer::Block, x, y, z)) << 4;
+ m_data_flags[index] = m_pRegion->getData(x,y,z);
+}
+
+
+void ChunkRebuildData::storeInTesselator()
+{
+ Tesselator* t = Tesselator::getInstance(); // 4J - added - static initialiser being set at the wrong time
+
+ // copy tesselator vars over
+ t->vertices = m_tesselator.vertices;
+ t->u = m_tesselator.u;
+ t->v = m_tesselator.v;
+ t->_tex2 = m_tesselator._tex2;
+ t->col = m_tesselator.col;
+ t->hasColor = m_tesselator.hasColor;
+ t->hasTexture = m_tesselator.hasTexture;
+ t->hasTexture2 = m_tesselator.hasTexture2;
+ t->hasNormal = m_tesselator.hasNormal;
+ t->p = m_tesselator.m_PPUOffset/4;
+ t->useCompactFormat360 = m_tesselator.useCompactFormat360;
+ t->useProjectedTexturePixelShader = m_tesselator.useProjectedTexturePixelShader;
+ t->count = m_tesselator.count;
+ t->_noColor = m_tesselator._noColor;
+ t->mode = m_tesselator.mode;
+ t->xo = m_tesselator.xo;
+ t->yo = m_tesselator.yo;
+ t->zo = m_tesselator.zo;
+ t->count = m_tesselator.count;
+ t->_normal = m_tesselator._normal;
+ t->tesselating = m_tesselator.tesselating;
+ t->mipmapEnable = m_tesselator.mipmapEnable; // 4J added
+ t->vboId = m_tesselator.vboId;
+ t->vboCounts = m_tesselator.vboCounts;
+ t->size = m_tesselator.size;
+ for(int i=0;i<6;i++)
+ t->bounds.boundingBox[i] = m_tesselator.bounds.boundingBox[i];
+}
+#endif // SN_TARGET_PS3_SPU
+
+
+
+void ChunkRebuildData::tesselateAllTiles(TileRenderer_SPU* pTileRenderer)
+{
+ Tile_SPU::ms_pTileData = &m_tileData;
+ // 4J - changed loop order here to leave y as the innermost loop for better cache performance
+ bool renderNextLayer = false;
+ bool rendered = false;
+ int numRenderedLayer0 = 0;
+ int startX = m_x0+2; // beginning of the chunk
+ int startY = m_y0+2; // beginning of the chunk
+ int startZ = m_z0+2; // beginning of the chunk
+
+ m_tesselator.beginData();
+ for (int z = startZ; z < (startZ+16); z++)
+ {
+ for (int x = startX; x < (startX+16); x++)
+ {
+ for (int y = startY; y < (startY+16); y++)
+ {
+ // 4J - get tile from those copied into our local array in earlier optimisation
+ int flags = getFlags(x,y,z);
+ if(flags & ChunkRebuildData::e_flag_NoRender)
+ continue;
+ unsigned char tileId = getTile(x,y,z);
+ if (tileId > 0)
+ {
+// if (m_currentLayer == 0 && m_tileData.isEntityTile[tileId])
+// {
+// shared_ptr<TileEntity> et = region->getTileEntity(x, y, z);
+// if (TileEntityRenderDispatcher::instance->hasRenderer(et))
+// {
+// renderableTileEntities.push_back(et);
+// }
+// }
+ TileRef_SPU tile(tileId);
+ int renderLayer = tile->getRenderLayer();
+
+ if (renderLayer != m_currentLayer)
+ {
+ renderNextLayer = true;
+ }
+ else //if (renderLayer == m_currentLayer)
+ {
+ if(pTileRenderer->hasRenderer(tile.getPtr()))
+ {
+ numRenderedLayer0++;
+ rendered |= pTileRenderer->tesselateInWorld(tile.getPtr(), x, y, z);
+ }
+ else
+ {
+ setFlag(x, y, z, e_flag_SPURenderCodeMissing);
+// #ifdef SN_TARGET_PS3_SPU
+// spu_print("Render code missing for tile ID %d : render shape %d\n", tile->id, tile->getRenderShape());
+// #endif
+
+ }
+ }
+ }
+ }
+ }
+ }
+ if(rendered)
+ m_flags |= e_flag_Rendered;
+
+// spu_print("(%d,%d,%d) SPU num rendered : %d\n", m_x0+2, m_y0+2, m_z0+2, numRenderedLayer0);
+
+ m_tesselator.endData();
+}
+
+bool ChunkRebuildData::isEmptyTile(int x, int y, int z)
+{
+ return getTile(x, y, z) == 0;
+}
+
+bool ChunkRebuildData::isSolidRenderTile(int x, int y, int z)
+{
+ TileRef_SPU tile(getTile(x,y,z));
+ if (tile.getPtr() == NULL) return false;
+
+
+ // 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 Tile::getTexture which makes such solid tiles actually visibly solid (these
+ // textures exist already for 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
+ if( tile->id == Tile_SPU::leaves_Id )
+ {
+ 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; i++ )
+ {
+ int t = 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() ) )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ return tile->isSolidRender();
+}
+
+
+bool ChunkRebuildData::isSolidBlockingTile(int x, int y, int z)
+{
+ TileRef_SPU tile(getTile(x, y, z));
+ if (tile.getPtr() == NULL) return false;
+ bool ret = tile->getMaterial()->blocksMotion() && tile->isCubeShaped();
+ return ret;
+}
+
+float ChunkRebuildData::getBrightness(int x, int y, int z, int emitt)
+{
+ int n = getRawBrightness(x, y, z);
+ if (n < emitt) n = emitt;
+ return m_brightnessRamp[n];
+}
+
+float ChunkRebuildData::getBrightness(int x, int y, int z)
+{
+ return m_brightnessRamp[getRawBrightness(x, y, z)];
+}
+
+// 4J - brought forward from 1.8.2
+int ChunkRebuildData::getBrightness(LightLayer::variety layer, int x, int y, int z)
+{
+#ifndef SN_TARGET_PS3_SPU
+ assert(Level_MAX_LEVEL_SIZE == Level::MAX_LEVEL_SIZE);
+ assert(Level_maxBuildHeight == Level::maxBuildHeight);
+ assert(Level_MAX_BRIGHTNESS == Level::MAX_BRIGHTNESS);
+#endif
+
+ if (y < 0) y = 0;
+ if (y >= Level_maxBuildHeight) y = Level_maxBuildHeight - 1;
+ if (y < 0 || y >= Level_maxBuildHeight || x < -Level_MAX_LEVEL_SIZE || z < -Level_MAX_LEVEL_SIZE || x >= Level_MAX_LEVEL_SIZE || z > Level_MAX_LEVEL_SIZE)
+ {
+ // 4J Stu - The java LightLayer was an enum class type with a member "surrounding" which is what we
+ // were returning here. Surrounding has the same value as the enum value in our C++ code, so just cast
+ // it to an int
+ return (int)layer;
+ }
+
+ if(layer == LightLayer::Sky)
+ return getBrightnessSky(x, y, z);
+ return getBrightnessBlock(x, y, z);
+}
+
+// 4J - brought forward from 1.8.2
+int ChunkRebuildData::getBrightnessPropagate(LightLayer::variety layer, int x, int y, int z)
+{
+ if (y < 0) y = 0;
+ if (y >= Level_maxBuildHeight) y = Level_maxBuildHeight - 1;
+ if (y < 0 || y >= Level_maxBuildHeight || x < -Level_MAX_LEVEL_SIZE || z < -Level_MAX_LEVEL_SIZE || x >= Level_MAX_LEVEL_SIZE || z > Level_MAX_LEVEL_SIZE)
+ {
+ // 4J Stu - The java LightLayer was an enum class type with a member "surrounding" which is what we
+ // were returning here. Surrounding has the same value as the enum value in our C++ code, so just cast
+ // it to an int
+ return (int)layer;
+ }
+
+ {
+ int id = getTile(x, y, z);
+ if (m_tileData.propagate[getTile(x, y, z)])
+ {
+ int br = getBrightness(layer, x, y + 1, z);
+ int br1 = getBrightness(layer, x + 1, y, z);
+ int br2 = getBrightness(layer, x - 1, y, z);
+ int br3 = getBrightness(layer, x, y, z + 1);
+ int br4 = getBrightness(layer, x, y, z - 1);
+ if (br1 > br) br = br1;
+ if (br2 > br) br = br2;
+ if (br3 > br) br = br3;
+ if (br4 > br) br = br4;
+ return br;
+ }
+ }
+
+ if(layer == LightLayer::Sky)
+ return getBrightnessSky(x, y, z);
+ return getBrightnessBlock(x, y, z);
+
+}
+int ChunkRebuildData::getLightColor(int x, int y, int z, int emitt) // 4J - change brought forward from 1.8.2
+{
+ int s = getBrightnessPropagate(LightLayer::Sky, x, y, z);
+ int b = getBrightnessPropagate(LightLayer::Block, x, y, z);
+ if (b < emitt) b = emitt;
+ return s << 20 | b << 4;
+}
+
+
+int ChunkRebuildData::getRawBrightness(int x, int y, int z)
+{
+ return getRawBrightness(x, y, z, true);
+}
+
+
+int ChunkRebuildData::getRawBrightness(int x, int y, int z, bool propagate)
+{
+ if (x < -Level_MAX_LEVEL_SIZE || z < -Level_MAX_LEVEL_SIZE || x >= Level_MAX_LEVEL_SIZE || z > Level_MAX_LEVEL_SIZE)
+ {
+ return Level_MAX_BRIGHTNESS;
+ }
+
+ if (propagate)
+ {
+ int id = getTile(x, y, z);
+ switch(id)
+ {
+ case Tile_SPU::stoneSlabHalf_Id:
+ case Tile_SPU::woodSlabHalf_Id:
+ case Tile_SPU::farmland_Id:
+ case Tile_SPU::stairs_stone_Id:
+ case Tile_SPU::stairs_wood_Id:
+ {
+ int br = getRawBrightness(x, y + 1, z, false);
+ int br1 = getRawBrightness(x + 1, y, z, false);
+ int br2 = getRawBrightness(x - 1, y, z, false);
+ int br3 = getRawBrightness(x, y, z + 1, false);
+ int br4 = getRawBrightness(x, y, z - 1, false);
+ if (br1 > br) br = br1;
+ if (br2 > br) br = br2;
+ if (br3 > br) br = br3;
+ if (br4 > br) br = br4;
+ return br;
+ }
+ break;
+ }
+ }
+
+ if (y < 0) return 0;
+ if (y >= Level_maxBuildHeight)
+ {
+ int br = Level_MAX_BRIGHTNESS - m_levelSkyDarken;
+ if (br < 0) br = 0;
+ return br;
+ }
+
+ return LevelChunk_getRawBrightness(x, y, z, m_levelSkyDarken);
+}
+
+int ChunkRebuildData::LevelChunk_getRawBrightness(int x, int y, int z, int skyDampen)
+{
+ int light = (m_flags & e_flag_HasCeiling) ? 0 : getBrightnessSky(x, y, z);
+ if (light > 0)
+ m_flags |= e_flag_TouchedSky;
+ light -= skyDampen;
+ int block = getBrightnessBlock(x, y, z);
+ if (block > light) light = block;
+
+ /*
+ * int xd = (absFloor(level.player.x-(this->x*16+x))); int yd =
+ * (absFloor(level.player.y-(y))); int zd =
+ * (absFloor(level.player.z-(this->z*16+z))); int dd = xd+yd+zd; if
+ * (dd<15){ int carried = 15-dd; if (carried<0) carried = 0; if
+ * (carried>15) carried = 15; if (carried > light) light = carried; }
+ */
+
+ return light;
+
+}
+
+
+Material_SPU *ChunkRebuildData::getMaterial(int x, int y, int z)
+{
+ int t = getTile(x, y, z);
+ int matID = Material_SPU::air_Id;
+ if (t != 0)
+ matID = m_tileData.materialIDs[t];
+ return &m_tileData.materials[matID];
+}
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkRebuildData.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkRebuildData.h
new file mode 100644
index 00000000..c733a928
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkRebuildData.h
@@ -0,0 +1,129 @@
+
+#pragma once
+#ifndef SN_TARGET_PS3_SPU
+#include "..\..\..\stdafx.h"
+#include "..\..\..\..\Minecraft.World\Region.h"
+#include "..\..\..\Tesselator.h"
+#include "..\..\..\..\Minecraft.World\LightLayer.h"
+#endif // SN_TARGET_PS3_SPU
+
+#include "..\..\..\..\Minecraft.World\LightLayer.h"
+#include "Tile_SPU.h"
+#include "Tesselator_SPU.h"
+
+class TileRenderer_SPU;
+
+
+
+class ChunkRebuildData
+{
+public:
+ enum tileFlags
+ {
+ e_flag_NoRender = 0x01,
+ e_flag_SPURenderCodeMissing = 0x02
+ };
+
+ enum chunkFlags
+ {
+ e_flag_EmptyChunk = 0x01,
+ e_flag_HasCeiling = 0x02,
+ e_flag_TouchedSky = 0x04,
+ e_flag_Rendered = 0x08
+ };
+
+// private:
+ static const int sc_size = 20;
+ unsigned char m_tileIds[sc_size*sc_size*sc_size]; // byte
+ unsigned char m_brightness[sc_size*sc_size*sc_size]; // 2x 4bit
+ unsigned char m_data_flags[sc_size*sc_size*sc_size]; // 2x 4bit
+ int m_grassColor[sc_size*sc_size];
+ int m_foliageColor[sc_size*sc_size];
+ int m_waterColor[sc_size*sc_size];
+
+ TileData_SPU m_tileData;
+ Tesselator_SPU m_tesselator;
+
+#ifdef SN_TARGET_PS3_SPU
+ void* m_pRegion;
+#else
+ Region* m_pRegion;
+#endif // SN_TARGET_PS3_SPU
+ int m_x0;
+ int m_y0;
+ int m_z0;
+ float m_brightnessRamp[16];
+ int m_levelSkyDarken;
+ unsigned int m_flags;
+ unsigned int m_currentLayer;
+ int m_lastHitBlockX;
+ int m_lastHitBlockY;
+ int m_lastHitBlockZ;
+ unsigned int m_pad[3];// padding to 16 byte alignment
+
+
+ int getTileIdx(int x, int y, int z) { return (( x - m_x0 )*sc_size*sc_size) + (( y - m_y0 )*sc_size) + ( z - m_z0 ); }
+ int getTileIdx(int x, int z) { return (( x - m_x0 )*sc_size) + ( z - m_z0 ); }
+
+ void buildTile(int x, int y, int z);
+ void disableUnseenTiles();
+ void createTileData();
+public:
+
+#if 0 //def SN_TARGET_PS3_SPU
+ int getTile(int x, int y, int z);
+ int getBrightnessSky(int x, int y, int z);
+ int getBrightnessBlock(int x, int y, int z);
+ int getData(int x, int y, int z);
+ int getFlags(int x, int y, int z);
+
+ void setFlag(int x, int y, int z, int flag);
+ int getGrassColor(int x, int z);
+ int getFoliageColor(int x, int z);
+
+#else
+ int getTile( int x, int y, int z ) { return m_tileIds[getTileIdx(x,y,z)]; }
+ int getBrightnessSky(int x, int y, int z) { return m_brightness[getTileIdx(x,y,z)] & 0x0f; }
+ int getBrightnessBlock(int x, int y, int z) { return m_brightness[getTileIdx(x,y,z)] >> 4; }
+ int getData(int x, int y, int z) { return m_data_flags[getTileIdx(x,y,z)] & 0x0f; }
+ int getFlags(int x, int y, int z) { return m_data_flags[getTileIdx(x,y,z)] >> 4; }
+
+ void setFlag(int x, int y, int z, int flag) { m_data_flags[getTileIdx(x,y,z)] |= (flag<<4); }
+ int getGrassColor( int x, int z ) { return m_grassColor[getTileIdx(x,z)]; }
+ int getFoliageColor( int x, int z ) { return m_foliageColor[getTileIdx(x,z)]; }
+ int getWaterColor( int x, int z ) { return m_waterColor[getTileIdx(x,z)]; }
+#endif
+
+
+#ifndef SN_TARGET_PS3_SPU
+ void buildMaterials();
+ void buildMaterial(int matSPUIndex, Material* mat);
+ int getMaterialID(Tile* pTile);
+ void buildForChunk(Region* region, Level* level, int x0, int y0, int z0);
+ void copyFromTesselator();
+ void storeInTesselator();
+#endif
+ bool isEmptyTile(int x, int y, int z);
+ bool isEmptyChunk() { return m_flags & e_flag_EmptyChunk;}
+ bool isSolidRenderTile(int x, int y, int z);
+ bool isSolidBlockingTile(int x, int y, int z);
+ float getBrightness(int x, int y, int z, int emitt);
+ float getBrightness(int x, int y, int z);
+
+ // 4J - changes brought forward from 1.8.2
+ int getBrightness(LightLayer::variety layer, int x, int y, int z);
+ int getBrightnessPropagate(LightLayer::variety layer, int x, int y, int z);
+
+ int getLightColor(int x, int y, int z, int emitt); // 4J - change brought forward from 1.8.2
+ int getRawBrightness(int x, int y, int z);
+ int getRawBrightness(int x, int y, int z, bool propagate);
+
+ int LevelChunk_getRawBrightness(int x, int y, int z, int skyDampen);
+ Material_SPU* getMaterial(int x, int y, int z);
+
+
+ void tesselateAllTiles(TileRenderer_SPU* pTileRenderer);
+
+};
+
+
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkUpdate.spu.vcxproj b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkUpdate.spu.vcxproj
new file mode 100644
index 00000000..3827cb66
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkUpdate.spu.vcxproj
@@ -0,0 +1,267 @@
+<?xml version="1.0" encoding="us-ascii"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="ContentPackage|PS3">
+ <Configuration>ContentPackage</Configuration>
+ <Platform>PS3</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|PS3">
+ <Configuration>Debug</Configuration>
+ <Platform>PS3</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|PS3">
+ <Configuration>Release</Configuration>
+ <Platform>PS3</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="AnvilTile_SPU.h" />
+ <ClInclude Include="BedTile_SPU.h" />
+ <ClInclude Include="BookshelfTile_SPU.h" />
+ <ClInclude Include="BrewingStandTile_SPU.h" />
+ <ClInclude Include="Bush_SPU.h" />
+ <ClInclude Include="ButtonTile_SPU.h" />
+ <ClInclude Include="CactusTile_SPU.h" />
+ <ClInclude Include="CakeTile_SPU.h" />
+ <ClInclude Include="CarrotTile_SPU.h" />
+ <ClInclude Include="CauldronTile_SPU.h" />
+ <ClInclude Include="ChestTile_SPU.h" />
+ <ClInclude Include="ChunkRebuildData.h" />
+ <ClInclude Include="ClothTile_SPU.h" />
+ <ClInclude Include="CocoaTile_SPU.h" />
+ <ClInclude Include="CropTile_SPU.h" />
+ <ClInclude Include="DetectorRailTile_SPU.h" />
+ <ClInclude Include="DiodeTile_SPU.h" />
+ <ClInclude Include="DirectionalTile_SPU.h" />
+ <ClInclude Include="Direction_SPU.h" />
+ <ClInclude Include="DirtTile_SPU.h" />
+ <ClInclude Include="DispenserTile_SPU.h" />
+ <ClInclude Include="DoorTile_SPU.h" />
+ <ClInclude Include="EggTile_SPU.h" />
+ <ClInclude Include="EnchantmentTableTile_SPU.h" />
+ <ClInclude Include="EnderChestTile_SPU.h" />
+ <ClInclude Include="EntityTile_SPU.h" />
+ <ClInclude Include="Facing_SPU.h" />
+ <ClInclude Include="FarmTile_SPU.h" />
+ <ClInclude Include="FenceGateTile_SPU.h" />
+ <ClInclude Include="FenceTile_SPU.h" />
+ <ClInclude Include="FireTile_SPU.h" />
+ <ClInclude Include="FlowerPotTile_SPU.h" />
+ <ClInclude Include="FurnaceTile_SPU.h" />
+ <ClInclude Include="GlassTile_SPU.h" />
+ <ClInclude Include="GrassTile_SPU.h" />
+ <ClInclude Include="HalfSlabTile_SPU.h" />
+ <ClInclude Include="HalfTransparentTile_SPU.h" />
+ <ClInclude Include="HugeMushroomTile_SPU.h" />
+ <ClInclude Include="IceTile_SPU.h" />
+ <ClInclude Include="Icon_SPU.h" />
+ <ClInclude Include="Item_SPU.h" />
+ <ClInclude Include="LadderTile_SPU.h" />
+ <ClInclude Include="LeafTile_SPU.h" />
+ <ClInclude Include="LeverTile_SPU.h" />
+ <ClInclude Include="LiquidTile_SPU.h" />
+ <ClInclude Include="Material_SPU.h" />
+ <ClInclude Include="MelonTile_SPU.h" />
+ <ClInclude Include="MobSpawnerTile_SPU.h" />
+ <ClInclude Include="Mushroom_SPU.h" />
+ <ClInclude Include="MycelTile_SPU.h" />
+ <ClInclude Include="NetherStalkTile_SPU.h" />
+ <ClInclude Include="PistonBaseTile_SPU.h" />
+ <ClInclude Include="PistonExtensionTile_SPU.h" />
+ <ClInclude Include="PistonMovingPiece_SPU.h" />
+ <ClInclude Include="PortalTile_SPU.h" />
+ <ClInclude Include="PotatoTile_SPU.h" />
+ <ClInclude Include="PressurePlateTile_SPU.h" />
+ <ClInclude Include="PumpkinTile_SPU.h" />
+ <ClInclude Include="QuartzBlockTile_SPU.h" />
+ <ClInclude Include="RailTile_SPU.h" />
+ <ClInclude Include="RecordPlayerTile_SPU.h" />
+ <ClInclude Include="RedlightTile_SPU.h" />
+ <ClInclude Include="RedStoneDustTile_SPU.h" />
+ <ClInclude Include="ReedTile_SPU.h" />
+ <ClInclude Include="SandStoneTile_SPU.h" />
+ <ClInclude Include="Sapling_SPU.h" />
+ <ClInclude Include="SignTile_SPU.h" />
+ <ClInclude Include="SkullTile_SPU.h" />
+ <ClInclude Include="SmoothStoneBrickTile_SPU.h" />
+ <ClInclude Include="StairTile_SPU.h" />
+ <ClInclude Include="stdafx.h" />
+ <ClInclude Include="StemTile_SPU.h" />
+ <ClInclude Include="StoneMonsterTile_SPU.h" />
+ <ClInclude Include="StoneSlabTile_SPU.h" />
+ <ClInclude Include="stubs_SPU.h" />
+ <ClInclude Include="TallGrass_SPU.h" />
+ <ClInclude Include="Tesselator_SPU.h" />
+ <ClInclude Include="TheEndPortalFrameTile_SPU.h" />
+ <ClInclude Include="TheEndPortal_SPU.h" />
+ <ClInclude Include="ThinFenceTile_SPU.h" />
+ <ClInclude Include="TileItem_SPU.h" />
+ <ClInclude Include="TileRenderer_SPU.h" />
+ <ClInclude Include="Tile_SPU.h" />
+ <ClInclude Include="TntTile_SPU.h" />
+ <ClInclude Include="TopSnowTile_SPU.h" />
+ <ClInclude Include="TorchTile_SPU.h" />
+ <ClInclude Include="TrapDoorTile_SPU.h" />
+ <ClInclude Include="TreeTile_SPU.h" />
+ <ClInclude Include="TripWireSourceTile_SPU.h" />
+ <ClInclude Include="TripWireTile_SPU.h" />
+ <ClInclude Include="VineTile_SPU.h" />
+ <ClInclude Include="WallTile_SPU.h" />
+ <ClInclude Include="WaterLilyTile_SPU.h" />
+ <ClInclude Include="WebTile_SPU.h" />
+ <ClInclude Include="WoodSlabTile_SPU.h" />
+ <ClInclude Include="WoodTile_SPU.h" />
+ <ClInclude Include="WoolCarpetTile_SPU.h" />
+ <ClInclude Include="WorkbenchTile_SPU.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="ChunkRebuildData.cpp" />
+ <ClCompile Include="DiodeTile_SPU.cpp" />
+ <ClCompile Include="Direction_SPU.cpp" />
+ <ClCompile Include="DoorTile_SPU.cpp" />
+ <ClCompile Include="Facing_SPU.cpp" />
+ <ClCompile Include="FenceTile_SPU.cpp" />
+ <ClCompile Include="GrassTile_SPU.cpp" />
+ <ClCompile Include="HalfSlabTile_SPU.cpp" />
+ <ClCompile Include="Icon_SPU.cpp" />
+ <ClCompile Include="LeafTile_SPU.cpp" />
+ <ClCompile Include="LiquidTile_SPU.cpp" />
+ <ClCompile Include="PressurePlateTile_SPU.cpp" />
+ <ClCompile Include="StairTile_SPU.cpp" />
+ <ClCompile Include="TallGrass_SPU.cpp" />
+ <ClCompile Include="task.cpp" />
+ <ClCompile Include="Tesselator_SPU.cpp" />
+ <ClCompile Include="ThinFenceTile_SPU.cpp" />
+ <ClCompile Include="TileRenderer_SPU.cpp" />
+ <ClCompile Include="Tile_SPU.cpp" />
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{4B7786BE-4F10-4FAA-A75A-631DF39570DD}</ProjectGuid>
+ <ProjectName>ChunkUpdate</ProjectName>
+ <SccProjectName>SAK</SccProjectName>
+ <SccAuxPath>SAK</SccAuxPath>
+ <SccLocalPath>SAK</SccLocalPath>
+ <SccProvider>SAK</SccProvider>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|PS3'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>SPU</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>SPU</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>SPU</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|PS3'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">PS3_Debug\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">PS3_Debug\</IntDir>
+ <ExtensionsToDeleteOnClean Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">*.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);undefined;$(ExtensionsToDeleteOnClean)</ExtensionsToDeleteOnClean>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'" />
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">PS3_Release\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'">PS3_ContentPackage\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">PS3_Release\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'">PS3_ContentPackage\</IntDir>
+ <ExtensionsToDeleteOnClean Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">*.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);undefined;$(ExtensionsToDeleteOnClean)</ExtensionsToDeleteOnClean>
+ <ExtensionsToDeleteOnClean Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'">*.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);undefined;$(ExtensionsToDeleteOnClean)</ExtensionsToDeleteOnClean>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|PS3'" />
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'" />
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">false</GenerateManifest>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'">false</GenerateManifest>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">$(ProjectName)</TargetName>
+ <SpursUsage>SpursInit</SpursUsage>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">$(ProjectName)</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'">$(ProjectName)</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">
+ <ClCompile>
+ <AdditionalOptions>-ffunction-sections -fdata-sections -fstack-check %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalIncludeDirectories>$(SN_PS3_PATH)\spu\include\sn;$(SCE_PS3_ROOT)\target\spu\include;$(SCE_PS3_ROOT)\target\common\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <PreprocessorDefinitions>SN_TARGET_PS3_SPU;_DEBUG;__GCC__;SPU;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <OptimizationLevel>Level3</OptimizationLevel>
+ </ClCompile>
+ <ProjectReference>
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>
+ </ProjectReference>
+ <Link>
+ <AdditionalOptions>-Wl,--gc-sections -g %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalDependencies>-ldma;-lspurs_jq;%(AdditionalDependencies)</AdditionalDependencies>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ <SpuElfConversion>
+ <EmbedFormat>JobBin2</EmbedFormat>
+ <OutputFile>..\ObjFiles\Debug\$(TargetName).ppu$(ObjectExt)</OutputFile>
+ </SpuElfConversion>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">
+ <ClCompile>
+ <AdditionalOptions>-ffunction-sections -fdata-sections -fstack-check %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalIncludeDirectories>$(SN_PS3_PATH)\spu\include\sn;$(SCE_PS3_ROOT)\target\spu\include;$(SCE_PS3_ROOT)\target\common\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <OptimizationLevel>Level3</OptimizationLevel>
+ <PreprocessorDefinitions>SN_TARGET_PS3_SPU;NDEBUG;__GCC__;SPU;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <ProjectReference>
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>
+ </ProjectReference>
+ <Link>
+ <AdditionalOptions>-Wl,--gc-sections -g %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalDependencies>-ldma;-lspurs_jq;%(AdditionalDependencies)</AdditionalDependencies>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ <SpuElfConversion>
+ <EmbedFormat>JobBin2</EmbedFormat>
+ <OutputFile>..\ObjFiles\Release\$(TargetName).ppu$(ObjectExt)</OutputFile>
+ </SpuElfConversion>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'">
+ <ClCompile>
+ <AdditionalOptions>-ffunction-sections -fdata-sections -fstack-check %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalIncludeDirectories>$(SN_PS3_PATH)\spu\include\sn;$(SCE_PS3_ROOT)\target\spu\include;$(SCE_PS3_ROOT)\target\common\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <OptimizationLevel>Level3</OptimizationLevel>
+ <PreprocessorDefinitions>SN_TARGET_PS3_SPU;NDEBUG;__GCC__;SPU;_CONTENT_PACKAGE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <ProjectReference>
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>
+ </ProjectReference>
+ <Link>
+ <AdditionalOptions>-Wl,--gc-sections -g %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalDependencies>-ldma;-lspurs_jq;%(AdditionalDependencies)</AdditionalDependencies>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ <SpuElfConversion>
+ <EmbedFormat>JobBin2</EmbedFormat>
+ <OutputFile>..\ObjFiles\ContentPackage\$(TargetName).ppu$(ObjectExt)</OutputFile>
+ <StripMode>Hard</StripMode>
+ </SpuElfConversion>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkUpdate.spu.vcxproj.filters b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkUpdate.spu.vcxproj.filters
new file mode 100644
index 00000000..e6e17009
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkUpdate.spu.vcxproj.filters
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{881f28ee-ca74-4afc-94a6-2346cb88f86d}</UniqueIdentifier>
+ <Extensions>cpp;c;cxx;cc;s;asm</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="stdafx.h" />
+ <ClInclude Include="StemTile_SPU.h" />
+ <ClInclude Include="StoneMonsterTile_SPU.h" />
+ <ClInclude Include="stubs_SPU.h" />
+ <ClInclude Include="TallGrass_SPU.h" />
+ <ClInclude Include="Tesselator_SPU.h" />
+ <ClInclude Include="TheEndPortal_SPU.h" />
+ <ClInclude Include="TheEndPortalFrameTile_SPU.h" />
+ <ClInclude Include="ThinFenceTile_SPU.h" />
+ <ClInclude Include="Tile_SPU.h" />
+ <ClInclude Include="TileRenderer_SPU.h" />
+ <ClInclude Include="TntTile_SPU.h" />
+ <ClInclude Include="TopSnowTile_SPU.h" />
+ <ClInclude Include="TorchTile_SPU.h" />
+ <ClInclude Include="TrapDoorTile_SPU.h" />
+ <ClInclude Include="TreeTile_SPU.h" />
+ <ClInclude Include="VineTile_SPU.h" />
+ <ClInclude Include="WaterLilyTile_SPU.h" />
+ <ClInclude Include="WebTile_SPU.h" />
+ <ClInclude Include="WoodTile_SPU.h" />
+ <ClInclude Include="WorkbenchTile_SPU.h" />
+ <ClInclude Include="BedTile_SPU.h" />
+ <ClInclude Include="BookshelfTile_SPU.h" />
+ <ClInclude Include="BrewingStandTile_SPU.h" />
+ <ClInclude Include="Bush_SPU.h" />
+ <ClInclude Include="ButtonTile_SPU.h" />
+ <ClInclude Include="CactusTile_SPU.h" />
+ <ClInclude Include="CakeTile_SPU.h" />
+ <ClInclude Include="CauldronTile_SPU.h" />
+ <ClInclude Include="ChestTile_SPU.h" />
+ <ClInclude Include="ChunkRebuildData.h" />
+ <ClInclude Include="CocoaTile_SPU.h" />
+ <ClInclude Include="CropTile_SPU.h" />
+ <ClInclude Include="DetectorRailTile_SPU.h" />
+ <ClInclude Include="DiodeTile_SPU.h" />
+ <ClInclude Include="Direction_SPU.h" />
+ <ClInclude Include="DirectionalTile_SPU.h" />
+ <ClInclude Include="DirtTile_SPU.h" />
+ <ClInclude Include="DispenserTile_SPU.h" />
+ <ClInclude Include="DoorTile_SPU.h" />
+ <ClInclude Include="EggTile_SPU.h" />
+ <ClInclude Include="EnchantmentTableTile_SPU.h" />
+ <ClInclude Include="EntityTile_SPU.h" />
+ <ClInclude Include="Facing_SPU.h" />
+ <ClInclude Include="FarmTile_SPU.h" />
+ <ClInclude Include="FenceGateTile_SPU.h" />
+ <ClInclude Include="FenceTile_SPU.h" />
+ <ClInclude Include="FireTile_SPU.h" />
+ <ClInclude Include="FurnaceTile_SPU.h" />
+ <ClInclude Include="GlassTile_SPU.h" />
+ <ClInclude Include="GrassTile_SPU.h" />
+ <ClInclude Include="HalfSlabTile_SPU.h" />
+ <ClInclude Include="HalfTransparentTile_SPU.h" />
+ <ClInclude Include="HugeMushroomTile_SPU.h" />
+ <ClInclude Include="IceTile_SPU.h" />
+ <ClInclude Include="Icon_SPU.h" />
+ <ClInclude Include="LadderTile_SPU.h" />
+ <ClInclude Include="LeafTile_SPU.h" />
+ <ClInclude Include="LeverTile_SPU.h" />
+ <ClInclude Include="LiquidTile_SPU.h" />
+ <ClInclude Include="Material_SPU.h" />
+ <ClInclude Include="MelonTile_SPU.h" />
+ <ClInclude Include="Mushroom_SPU.h" />
+ <ClInclude Include="MycelTile_SPU.h" />
+ <ClInclude Include="NetherStalkTile_SPU.h" />
+ <ClInclude Include="PistonBaseTile_SPU.h" />
+ <ClInclude Include="PistonExtensionTile_SPU.h" />
+ <ClInclude Include="PistonMovingPiece_SPU.h" />
+ <ClInclude Include="PortalTile_SPU.h" />
+ <ClInclude Include="PressurePlateTile_SPU.h" />
+ <ClInclude Include="PumpkinTile_SPU.h" />
+ <ClInclude Include="RailTile_SPU.h" />
+ <ClInclude Include="RecordPlayerTile_SPU.h" />
+ <ClInclude Include="RedlightTile_SPU.h" />
+ <ClInclude Include="RedStoneDustTile_SPU.h" />
+ <ClInclude Include="ReedTile_SPU.h" />
+ <ClInclude Include="SandStoneTile_SPU.h" />
+ <ClInclude Include="Sapling_SPU.h" />
+ <ClInclude Include="SignTile_SPU.h" />
+ <ClInclude Include="SmoothStoneBrickTile_SPU.h" />
+ <ClInclude Include="StairTile_SPU.h" />
+ <ClInclude Include="TileItem_SPU.h" />
+ <ClInclude Include="Item_SPU.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="ClothTile_SPU.h" />
+ <ClInclude Include="SkullTile_SPU.h" />
+ <ClInclude Include="WoodSlabTile_SPU.h" />
+ <ClInclude Include="StoneSlabTile_SPU.h" />
+ <ClInclude Include="MobSpawnerTile_SPU.h" />
+ <ClInclude Include="FlowerPotTile_SPU.h" />
+ <ClInclude Include="TripWireSourceTile_SPU.h" />
+ <ClInclude Include="TripWireTile_SPU.h" />
+ <ClInclude Include="WallTile_SPU.h" />
+ <ClInclude Include="QuartzBlockTile_SPU.h" />
+ <ClInclude Include="PotatoTile_SPU.h" />
+ <ClInclude Include="CarrotTile_SPU.h" />
+ <ClInclude Include="AnvilTile_SPU.h" />
+ <ClInclude Include="EnderChestTile_SPU.h" />
+ <ClInclude Include="WoolCarpetTile_SPU.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="ChunkRebuildData.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="DiodeTile_SPU.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Direction_SPU.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="DoorTile_SPU.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Facing_SPU.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="FenceTile_SPU.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="GrassTile_SPU.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="HalfSlabTile_SPU.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Icon_SPU.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="LeafTile_SPU.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="LiquidTile_SPU.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="PressurePlateTile_SPU.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="StairTile_SPU.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="TallGrass_SPU.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="task.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Tesselator_SPU.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="ThinFenceTile_SPU.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Tile_SPU.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="TileRenderer_SPU.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkUpdate.spu.vcxproj.vspscc b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkUpdate.spu.vcxproj.vspscc
new file mode 100644
index 00000000..b6d32892
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ChunkUpdate.spu.vcxproj.vspscc
@@ -0,0 +1,10 @@
+""
+{
+"FILE_VERSION" = "9237"
+"ENLISTMENT_CHOICE" = "NEVER"
+"PROJECT_FILE_RELATIVE_PATH" = ""
+"NUMBER_OF_EXCLUDED_FILES" = "0"
+"ORIGINAL_PROJECT_FILE_PATH" = ""
+"NUMBER_OF_NESTED_PROJECTS" = "0"
+"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
+}
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ClothTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ClothTile_SPU.h
new file mode 100644
index 00000000..3fd1c5f4
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ClothTile_SPU.h
@@ -0,0 +1,11 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class ClothTile_SPU : public Tile_SPU
+{
+public:
+ ClothTile_SPU(int id) : Tile_SPU(id) {}
+ virtual Icon_SPU *getTexture(int face, int data) { return &ms_pTileData->clothTile_icons[data]; }
+
+
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CocoaTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CocoaTile_SPU.h
new file mode 100644
index 00000000..0ae787a5
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CocoaTile_SPU.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "DirectionalTile_SPU.h"
+
+class CocoaTile_SPU : public DirectionalTile_SPU
+{
+public:
+ static const int COCOA_TEXTURES_LENGTH = 3;
+
+public:
+ CocoaTile_SPU(int id) : DirectionalTile_SPU(id) {}
+
+// virtual Icon *getTexture(int face, int data);
+// virtual Icon *getTextureForAge(int age);
+ virtual int getRenderShape() { return SHAPE_COCOA; }
+ virtual bool isCubeShaped() { return false; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CropTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CropTile_SPU.h
new file mode 100644
index 00000000..41634de1
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/CropTile_SPU.h
@@ -0,0 +1,19 @@
+#pragma once
+#include "Bush_SPU.h"
+
+
+class CropTile_SPU : public Bush_SPU
+{
+public:
+ CropTile_SPU(int id) : Bush_SPU(id) {}
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ if (data < 0 || data > 7) data = 7;
+ return &ms_pTileData->cropTile_icons[data];
+ }
+
+ virtual int getRenderShape()
+ {
+ return Tile_SPU::SHAPE_ROWS;
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DetectorRailTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DetectorRailTile_SPU.h
new file mode 100644
index 00000000..ef5b759b
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DetectorRailTile_SPU.h
@@ -0,0 +1,17 @@
+#pragma once
+#include "RailTile_SPU.h"
+
+
+class DetectorRailTile_SPU : public RailTile_SPU
+{
+public:
+ DetectorRailTile_SPU(int id) : RailTile_SPU(id) {}
+ Icon_SPU *getTexture(int face, int data)
+ {
+ if ((data & RAIL_DATA_BIT) != 0)
+ {
+ return &ms_pTileData->detectorRailTile_icons[1];
+ }
+ return &ms_pTileData->detectorRailTile_icons[0];
+ }
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DiodeTile_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DiodeTile_SPU.cpp
new file mode 100644
index 00000000..14547cfc
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DiodeTile_SPU.cpp
@@ -0,0 +1,5 @@
+#include "stdafx.h"
+#include "DiodeTile_SPU.h"
+
+const double DiodeTile_SPU::DELAY_RENDER_OFFSETS[4] = { -1.0f / 16.0f, 1.0f / 16.0f, 3.0f / 16.0f, 5.0f / 16.0f };
+const int DiodeTile_SPU::DELAYS[4] = { 1, 2, 3, 4 };
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DiodeTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DiodeTile_SPU.h
new file mode 100644
index 00000000..131bd490
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DiodeTile_SPU.h
@@ -0,0 +1,44 @@
+#pragma once
+#include "Tile_SPU.h"
+#include "Facing_SPU.h"
+
+class DiodeTile_SPU : public Tile_SPU
+{
+public:
+ static const int DIRECTION_MASK = 0x3;
+ static const int DELAY_MASK = 0xC;
+ static const int DELAY_SHIFT = 2;
+
+ static const double DELAY_RENDER_OFFSETS[4];
+ static const int DELAYS[4];
+
+public:
+ DiodeTile_SPU(int id) : Tile_SPU(id) {}
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ // down is used by the torch tesselator
+ if (face == Facing::DOWN)
+ {
+ if (id==diode_on_Id)
+ {
+ return TileRef_SPU(notGate_on_Id)->getTexture(face);
+ }
+ return TileRef_SPU(notGate_off_Id)->getTexture(face);
+ }
+ if (face == Facing::UP)
+ {
+ return icon();
+ }
+ // edge of stone half-step
+ return TileRef_SPU(stoneSlab_Id)->getTexture(Facing::UP);
+ }
+ virtual bool shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
+ {
+ if (face == Facing::DOWN || face == Facing::UP)
+ return false;
+ return true;
+ }
+
+ virtual int getRenderShape() { return SHAPE_DIODE; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Direction_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Direction_SPU.cpp
new file mode 100644
index 00000000..2dedce20
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Direction_SPU.cpp
@@ -0,0 +1,62 @@
+#include "stdafx.h"
+#include "Direction_SPU.h"
+#include "Facing_SPU.h"
+
+const int Direction::STEP_X[] =
+{
+ 0, -1, 0, 1
+};
+
+const int Direction::STEP_Z[] =
+{
+ 1, 0, -1, 0
+};
+
+// for [direction] it gives [tile-face]
+int Direction::DIRECTION_FACING[4] =
+{
+ Facing::SOUTH, Facing::WEST, Facing::NORTH, Facing::EAST
+};
+
+// for [facing] it gives [direction]
+int Direction::FACING_DIRECTION[] =
+{
+ UNDEFINED, UNDEFINED, NORTH, SOUTH, WEST, EAST
+};
+
+int Direction::DIRECTION_OPPOSITE[4] =
+{
+ Direction::NORTH, Direction::EAST, Direction::SOUTH, Direction::WEST
+};
+
+// for [direction] it gives [90 degrees clockwise direction]
+int Direction::DIRECTION_CLOCKWISE[] =
+{
+ Direction::WEST, Direction::NORTH, Direction::EAST, Direction::SOUTH
+};
+
+// for [direction] it gives [90 degrees counter clockwise direction]
+int Direction::DIRECTION_COUNTER_CLOCKWISE[] =
+{
+ Direction::EAST, Direction::SOUTH, Direction::WEST, Direction::NORTH
+};
+
+int Direction::RELATIVE_DIRECTION_FACING[4][6] =
+{
+ // south
+ {
+ Facing::UP, Facing::DOWN, Facing::SOUTH, Facing::NORTH, Facing::EAST, Facing::WEST
+ },
+ // west
+ {
+ Facing::UP, Facing::DOWN, Facing::EAST, Facing::WEST, Facing::NORTH, Facing::SOUTH
+ },
+ // north
+ {
+ Facing::UP, Facing::DOWN, Facing::NORTH, Facing::SOUTH, Facing::WEST, Facing::EAST
+ },
+ // east
+ {
+ Facing::UP, Facing::DOWN, Facing::WEST, Facing::EAST, Facing::SOUTH, Facing::NORTH
+ }
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Direction_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Direction_SPU.h
new file mode 100644
index 00000000..aadd2bbb
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Direction_SPU.h
@@ -0,0 +1,32 @@
+#pragma once
+
+class Direction
+{
+public:
+ static const int UNDEFINED = -1;
+ static const int SOUTH = 0;
+ static const int WEST = 1;
+ static const int NORTH = 2;
+ static const int EAST = 3;
+
+ static const int STEP_X[];
+ static const int STEP_Z[];
+
+ // for [direction] it gives [tile-face]
+ static int DIRECTION_FACING[];
+
+ // for [facing] it gives [direction]
+ static int FACING_DIRECTION[];
+
+ // for [direction] it gives [opposite direction]
+ static int DIRECTION_OPPOSITE[];
+
+ // for [direction] it gives [90 degrees clockwise direction]
+ static int DIRECTION_CLOCKWISE[];
+
+ // for [direction] it gives [90 degrees counter-clockwise direction]
+ static int DIRECTION_COUNTER_CLOCKWISE[];
+
+ // for [direction][world-facing] it gives [tile-facing]
+ static int RELATIVE_DIRECTION_FACING[4][6];
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DirectionalTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DirectionalTile_SPU.h
new file mode 100644
index 00000000..5ad4f197
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DirectionalTile_SPU.h
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "Tile_SPU.h"
+
+class DirectionalTile_SPU : public Tile_SPU
+{
+public:
+ static const int DIRECTION_MASK = 0x3;
+ static const int DIRECTION_INV_MASK = 0xC;
+
+protected:
+ DirectionalTile_SPU(int id) : Tile_SPU(id) {}
+
+public:
+ static int getDirection(int data) { return data & DIRECTION_MASK; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DirtTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DirtTile_SPU.h
new file mode 100644
index 00000000..f03434fb
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DirtTile_SPU.h
@@ -0,0 +1,8 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class DirtTile_SPU : public Tile_SPU
+{
+public:
+ DirtTile_SPU(int id) : Tile_SPU(id) {}
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DispenserTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DispenserTile_SPU.h
new file mode 100644
index 00000000..a308336e
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DispenserTile_SPU.h
@@ -0,0 +1,38 @@
+#pragma once
+#include "EntityTile_SPU.h"
+
+
+class DispenserTile_SPU : public EntityTile_SPU
+{
+
+public:
+ static const int FACING_MASK = 0x7;
+ DispenserTile_SPU(int id) : EntityTile_SPU(id) {}
+
+public:
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ int dir = data & FACING_MASK;
+ if (face == dir)
+ {
+ if (dir == Facing::UP || dir == Facing::DOWN)
+ {
+ return &ms_pTileData->dispenserTile_iconFrontVertical;
+ }
+ else
+ {
+ return &ms_pTileData->dispenserTile_iconFront;
+ }
+ }
+
+ if (dir == Facing::UP || dir == Facing::DOWN)
+ {
+ return &ms_pTileData->dispenserTile_iconTop;
+ }
+ else if (face == Facing::UP || face == Facing::DOWN)
+ {
+ return &ms_pTileData->dispenserTile_iconTop;
+ }
+ return icon();
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DoorTile_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DoorTile_SPU.cpp
new file mode 100644
index 00000000..360b236b
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DoorTile_SPU.cpp
@@ -0,0 +1,136 @@
+#include "stdafx.h"
+#include "DoorTile_SPU.h"
+#include "Facing_SPU.h"
+#include "ChunkRebuildData.h"
+
+
+
+Icon_SPU *DoorTile_SPU::getTexture(int face, int data)
+{
+ int texBase;
+ if (getMaterial()->getID() == Material_SPU::metal_Id)
+ texBase = 2;
+ else
+ texBase = 0;
+
+ return &ms_pTileData->doorTile_Icons[texBase];
+}
+
+Icon_SPU *DoorTile_SPU::getTexture(ChunkRebuildData *level, int x, int y, int z, int face)
+{
+ int texBase;
+ if (getMaterial()->getID() == Material_SPU::metal_Id)
+ texBase = 2;
+ else
+ texBase = 0;
+
+ if (face == Facing::UP || face == Facing::DOWN) return &ms_pTileData->doorTile_Icons[texBase];
+
+ int compositeData = getCompositeData(level, x, y, z);
+ int dir = compositeData & C_DIR_MASK;
+ bool isOpen = (compositeData & C_OPEN_MASK) != 0;
+ bool flip = false;
+ bool upper = (compositeData & C_IS_UPPER_MASK) != 0;
+
+ if (isOpen)
+ {
+ if (dir == 0 && face == 2) flip = !flip;
+ else if (dir == 1 && face == 5) flip = !flip;
+ else if (dir == 2 && face == 3) flip = !flip;
+ else if (dir == 3 && face == 4) flip = !flip;
+ }
+ else
+ {
+ if (dir == 0 && face == 5) flip = !flip;
+ else if (dir == 1 && face == 3) flip = !flip;
+ else if (dir == 2 && face == 4) flip = !flip;
+ else if (dir == 3 && face == 2) flip = !flip;
+ if ((compositeData & C_RIGHT_HINGE_MASK) != 0) flip = !flip;
+ }
+
+ return &ms_pTileData->doorTile_Icons[texBase + (flip ? DOOR_TILE_TEXTURE_COUNT : 0) + (upper ? 1 : 0)];
+}
+
+void DoorTile_SPU::updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData, TileEntity* forceEntity) // 4J added forceData, forceEntity param
+{
+ setShape(getCompositeData(level,x, y, z));
+}
+
+bool DoorTile_SPU::isOpen(ChunkRebuildData *level, int x, int y, int z)
+{
+ return (getCompositeData(level, x, y, z) & C_OPEN_MASK) != 0;
+}
+
+void DoorTile_SPU::setShape(int compositeData)
+{
+ float r = 3 / 16.0f;
+ Tile_SPU::setShape(0, 0, 0, 1, 2, 1);
+ int dir = compositeData & C_DIR_MASK;
+ bool open = (compositeData & C_OPEN_MASK) != 0;
+ bool hasRightHinge = (compositeData & C_RIGHT_HINGE_MASK) != 0;
+ if (dir == 0)
+ {
+ if (open)
+ {
+ if (!hasRightHinge) setShape(0, 0, 0, 1, 1, r);
+ else setShape(0, 0, 1 - r, 1, 1, 1);
+ }
+ else setShape(0, 0, 0, r, 1, 1);
+ }
+ else if (dir == 1)
+ {
+ if (open)
+ {
+ if (!hasRightHinge) setShape(1 - r, 0, 0, 1, 1, 1);
+ else setShape(0, 0, 0, r, 1, 1);
+ }
+ else setShape(0, 0, 0, 1, 1, r);
+ }
+ else if (dir == 2)
+ {
+ if (open)
+ {
+ if (!hasRightHinge) setShape(0, 0, 1 - r, 1, 1, 1);
+ else setShape(0, 0, 0, 1, 1, r);
+ }
+ else setShape(1 - r, 0, 0, 1, 1, 1);
+ }
+ else if (dir == 3)
+ {
+ if (open)
+ {
+ if (!hasRightHinge) setShape(0, 0, 0, r, 1, 1);
+ else setShape(1 - r, 0, 0, 1, 1, 1);
+ }
+ else setShape(0, 0, 1 - r, 1, 1, 1);
+ }
+}
+
+
+bool DoorTile_SPU::isOpen(int data)
+{
+ return (data & 4) != 0;
+}
+
+
+int DoorTile_SPU::getCompositeData(ChunkRebuildData *level, int x, int y, int z)
+{
+ int data = level->getData(x, y, z);
+ bool isUpper = (data & UPPER_BIT) != 0;
+ int lowerData;
+ int upperData;
+ if (isUpper)
+ {
+ lowerData = level->getData(x, y - 1, z);
+ upperData = data;
+ }
+ else
+ {
+ lowerData = data;
+ upperData = level->getData(x, y + 1, z);
+ }
+
+ // bits: dir, dir, open/closed, isUpper, isRightHinge
+ bool isRightHinge = (upperData & 1) != 0;
+ return lowerData & C_LOWER_DATA_MASK | (isUpper ? 8 : 0) | (isRightHinge ? 16 : 0);
+} \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DoorTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DoorTile_SPU.h
new file mode 100644
index 00000000..f6671db4
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/DoorTile_SPU.h
@@ -0,0 +1,37 @@
+#pragma once
+#include "Tile_SPU.h"
+
+
+class DoorTile_SPU : public Tile_SPU
+{
+public:
+ static const int UPPER_BIT = 8;
+ static const int C_DIR_MASK = 3;
+ static const int C_OPEN_MASK = 4;
+ static const int C_LOWER_DATA_MASK = 7;
+ static const int C_IS_UPPER_MASK = 8;
+ static const int C_RIGHT_HINGE_MASK = 16;
+
+private:
+ static const int DOOR_TILE_TEXTURE_COUNT = 4;
+
+public:
+ DoorTile_SPU(int id) : Tile_SPU(id){}
+ virtual Icon_SPU *getTexture(int face, int data);
+ //@Override
+ Icon_SPU *getTexture(ChunkRebuildData *level, int x, int y, int z, int face);
+ //@Override
+ virtual bool blocksLight() { return false; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual int getRenderShape() { return Tile_SPU::SHAPE_DOOR; }
+ virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL); // 4J added forceData, forceEntity param
+
+ int getDir(ChunkRebuildData *level, int x, int y, int z);
+ bool isOpen(ChunkRebuildData *level, int x, int y, int z);
+private:
+ using Tile_SPU::setShape;
+ virtual void setShape(int compositeData);
+public:
+ static bool isOpen(int data);
+ int getCompositeData(ChunkRebuildData *level, int x, int y, int z);
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/EggTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/EggTile_SPU.h
new file mode 100644
index 00000000..9a9997cc
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/EggTile_SPU.h
@@ -0,0 +1,13 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class EggTile_SPU : public Tile_SPU
+{
+public:
+ EggTile_SPU(int id) : Tile_SPU(id) {}
+ virtual bool blocksLight() { return false; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual int getRenderShape() { return Tile_SPU::SHAPE_EGG; }
+ virtual bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face) { return true; }
+
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/EnchantmentTableTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/EnchantmentTableTile_SPU.h
new file mode 100644
index 00000000..4afcdb92
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/EnchantmentTableTile_SPU.h
@@ -0,0 +1,17 @@
+#pragma once
+#include "EntityTile_SPU.h"
+
+class EnchantmentTableTile_SPU : public EntityTile_SPU
+{
+public:
+ EnchantmentTableTile_SPU(int id) : EntityTile_SPU(id) {}
+
+ bool isCubeShaped() { return false; }
+ bool isSolidRender(bool isServerLevel = false) { return false; }
+ Icon_SPU *getTexture(int face, int data)
+ {
+ if (face == Facing::DOWN) return &ms_pTileData->enchantmentTable_iconBottom;
+ if (face == Facing::UP) return &ms_pTileData->enchantmentTable_iconTop;
+ return icon();
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/EnderChestTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/EnderChestTile_SPU.h
new file mode 100644
index 00000000..737d1678
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/EnderChestTile_SPU.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include "EntityTile_SPU.h"
+
+class EnderChestTile_SPU : public EntityTile_SPU
+{
+public:
+ EnderChestTile_SPU(int id) : EntityTile_SPU(id) {}
+
+ bool isSolidRender(bool isServerLevel = false) { return false; }
+ bool isCubeShaped() { return false; }
+ int getRenderShape() { return Tile_SPU::SHAPE_ENTITYTILE_ANIMATED; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/EntityTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/EntityTile_SPU.h
new file mode 100644
index 00000000..ee5a6bc4
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/EntityTile_SPU.h
@@ -0,0 +1,8 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class EntityTile_SPU : public Tile_SPU
+{
+public:
+ EntityTile_SPU(int id) : Tile_SPU(id) {}
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Facing_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Facing_SPU.cpp
new file mode 100644
index 00000000..07421644
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Facing_SPU.cpp
@@ -0,0 +1,22 @@
+#include "stdafx.h"
+#include "Facing_SPU.h"
+
+const int Facing::OPPOSITE_FACING[6] =
+{
+ UP, DOWN, SOUTH, NORTH, EAST, WEST
+};
+
+const int Facing::STEP_X[6] =
+{
+ 0, 0, 0, 0, -1, 1
+};
+
+const int Facing::STEP_Y[6] =
+{
+ -1, 1, 0, 0, 0, 0
+};
+
+const int Facing::STEP_Z[6] =
+{
+ 0, 0, -1, 1, 0, 0
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Facing_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Facing_SPU.h
new file mode 100644
index 00000000..1c4cfdf3
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Facing_SPU.h
@@ -0,0 +1,17 @@
+#pragma once
+
+class Facing
+{
+public:
+ static const int DOWN = 0;
+ static const int UP = 1;
+ static const int NORTH = 2;
+ static const int SOUTH = 3;
+ static const int WEST = 4;
+ static const int EAST = 5;
+
+ static const int OPPOSITE_FACING[6];
+ static const int STEP_X[6];
+ static const int STEP_Y[6];
+ static const int STEP_Z[6];
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FarmTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FarmTile_SPU.h
new file mode 100644
index 00000000..5aa70926
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FarmTile_SPU.h
@@ -0,0 +1,22 @@
+#pragma once
+#include "Tile_SPU.h"
+#include "Facing_SPU.h"
+
+class FarmTile_SPU : public Tile_SPU
+{
+public:
+ FarmTile_SPU(int id): Tile_SPU(id) {}
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ if (face == Facing::UP)
+ {
+ if(data > 0)
+ return &ms_pTileData->farmTile_Wet;
+ else
+ return &ms_pTileData->farmTile_Dry;
+ }
+ return TileRef_SPU(dirt_Id)->getTexture(face);
+ }
+ virtual bool blocksLight() { return true; }
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceGateTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceGateTile_SPU.h
new file mode 100644
index 00000000..6e86d1f0
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceGateTile_SPU.h
@@ -0,0 +1,32 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class FenceGateTile_SPU : public Tile_SPU
+{
+private:
+ static const int DIRECTION_MASK = 3;
+ static const int OPEN_BIT = 4;
+
+public:
+ FenceGateTile_SPU(int id) : Tile_SPU(id) {}
+ Icon_SPU *getTexture(int face, int data) { return TileRef_SPU(wood_Id)->getTexture(face); }
+ static int getDirection(int data) { return (data & DIRECTION_MASK); }
+
+ virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param // Brought forward from 1.2.3
+ {
+ int data = getDirection(level->getData(x, y, z));
+ if (data == Direction::NORTH || data == Direction::SOUTH)
+ {
+ setShape(0, 0, 6.0f / 16.0f, 1, 1.0f, 10.0f / 16.0f);
+ }
+ else
+ {
+ setShape(6.0f / 16.0f, 0, 0, 10.0f / 16.0f, 1.0f, 1);
+ }
+ }
+ virtual bool blocksLight() { return false; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual int getRenderShape() { return Tile_SPU::SHAPE_FENCE_GATE; }
+ virtual bool shouldRenderFace(LevelSource *level, int x, int y, int z, int face){ return true; }
+ static bool isOpen(int data) { return (data & OPEN_BIT) != 0; }
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceTile_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceTile_SPU.cpp
new file mode 100644
index 00000000..fcb3baef
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceTile_SPU.cpp
@@ -0,0 +1,75 @@
+#include "stdafx.h"
+#include "FenceTile_SPU.h"
+#include "ChunkRebuildData.h"
+
+
+
+void FenceTile_SPU::updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData, TileEntity* forceEntity) // 4J added forceData, forceEntity param
+{
+ bool n = connectsTo(level, x, y, z - 1);
+ bool s = connectsTo(level, x, y, z + 1);
+ bool w = connectsTo(level, x - 1, y, z);
+ bool e = connectsTo(level, x + 1, y, z);
+
+ float west = 6.0f / 16.0f;
+ float east = 10.0f / 16.0f;
+ float north = 6.0f / 16.0f;
+ float south = 10.0f / 16.0f;
+
+ if (n)
+ {
+ north = 0;
+ }
+ if (s)
+ {
+ south = 1;
+ }
+ if (w)
+ {
+ west = 0;
+ }
+ if (e)
+ {
+ east = 1;
+ }
+
+ setShape(west, 0, north, east, 1.0f, south);
+}
+
+bool FenceTile_SPU::blocksLight()
+{
+ return false;
+}
+
+bool FenceTile_SPU::isSolidRender(bool isServerLevel)
+{
+ return false;
+}
+
+int FenceTile_SPU::getRenderShape()
+{
+ return Tile_SPU::SHAPE_FENCE;
+}
+
+bool FenceTile_SPU::connectsTo(ChunkRebuildData *level, int x, int y, int z)
+{
+ int tile = level->getTile(x, y, z);
+ if (tile == id || tile == Tile_SPU::fenceGate_Id)
+ {
+ return true;
+ }
+ TileRef_SPU tileInstance(tile);
+ if (tileInstance.getPtr() != NULL)
+ {
+ if (tileInstance->getMaterial()->isSolidBlocking() && tileInstance->isCubeShaped())
+ {
+ return tileInstance->getMaterial()->getID() != Material_SPU::vegetable_Id;
+ }
+ }
+ return false;
+}
+
+bool FenceTile_SPU::shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face)
+{
+ return true;
+} \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceTile_SPU.h
new file mode 100644
index 00000000..50a775fb
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FenceTile_SPU.h
@@ -0,0 +1,14 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class FenceTile_SPU : public Tile_SPU
+{
+public:
+ FenceTile_SPU(int id) : Tile_SPU(id) {}
+ virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL); // 4J added forceData, forceEntity param
+ virtual bool blocksLight();
+ virtual bool isSolidRender(bool isServerLevel = false);
+ virtual int getRenderShape();
+ virtual bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face);
+ bool connectsTo(ChunkRebuildData *level, int x, int y, int z);
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FireTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FireTile_SPU.h
new file mode 100644
index 00000000..1be5377e
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FireTile_SPU.h
@@ -0,0 +1,44 @@
+#pragma once
+#include "Tile_SPU.h"
+
+
+class FireTile_SPU : public Tile_SPU
+{
+public:
+ FireTile_SPU(int id) : Tile_SPU(id) {}
+
+ virtual bool blocksLight() { return false; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual bool isCubeShaped() { return false; }
+ virtual int getRenderShape() {return Tile_SPU::SHAPE_FIRE; }
+
+ Icon_SPU *getTextureLayer(int layer) { return &ms_pTileData->fireTile_icons[layer];}
+ Icon_SPU *getTexture(int face, int data) { return &ms_pTileData->fireTile_icons[0];}
+
+ static bool canBurn(ChunkRebuildData *level, int x, int y, int z)
+ {
+ int id = level->getTile(x, y, z);
+ switch (id)
+ {
+ case Tile_SPU::wood_Id:
+ case Tile_SPU::woodSlab_Id:
+ case Tile_SPU::woodSlabHalf_Id:
+ case Tile_SPU::fence_Id:
+ case Tile_SPU::stairs_wood_Id:
+ case Tile_SPU::stairs_birchwood_Id:
+ case Tile_SPU::stairs_sprucewood_Id:
+ case Tile_SPU::stairs_junglewood_Id:
+ case Tile_SPU::treeTrunk_Id:
+ case Tile_SPU::leaves_Id:
+ case Tile_SPU::bookshelf_Id:
+ case Tile_SPU::tnt_Id:
+ case Tile_SPU::tallgrass_Id:
+ case Tile_SPU::cloth_Id:
+ case Tile_SPU::vine_Id:
+ return true;
+ default:
+ return false;
+ }
+ return false;
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FlowerPotTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FlowerPotTile_SPU.h
new file mode 100644
index 00000000..1a75019d
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FlowerPotTile_SPU.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "Tile_SPU.h"
+
+class FlowerPotTile_SPU : public Tile_SPU
+{
+public:
+ static const int TYPE_FLOWER_RED = 1;
+ static const int TYPE_FLOWER_YELLOW = 2;
+ static const int TYPE_SAPLING_DEFAULT = 3;
+ static const int TYPE_SAPLING_EVERGREEN = 4;
+ static const int TYPE_SAPLING_BIRCH = 5;
+ static const int TYPE_SAPLING_JUNGLE = 6;
+ static const int TYPE_MUSHROOM_RED = 7;
+ static const int TYPE_MUSHROOM_BROWN = 8;
+ static const int TYPE_CACTUS = 9;
+ static const int TYPE_DEAD_BUSH = 10;
+ static const int TYPE_FERN = 11;
+
+ FlowerPotTile_SPU(int id) : Tile_SPU(id) {}
+
+ void updateDefaultShape()
+ {
+ float size = 6.0f / 16.0f;
+ float half = size / 2;
+ setShape(0.5f - half, 0, 0.5f - half, 0.5f + half, size, 0.5f + half);
+ }
+
+ bool isSolidRender(bool isServerLevel = false) { return false; }
+ int getRenderShape() { return SHAPE_FLOWER_POT; }
+ bool isCubeShaped() { return false; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FurnaceTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FurnaceTile_SPU.h
new file mode 100644
index 00000000..5d677b44
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/FurnaceTile_SPU.h
@@ -0,0 +1,20 @@
+#pragma once
+#include "EntityTile_SPU.h"
+#include "Facing_SPU.h"
+
+class FurnaceTile_SPU : public EntityTile_SPU
+{
+public:
+ FurnaceTile_SPU(int id) : EntityTile_SPU(id){}
+ Icon_SPU *getTexture(int face, int data)
+ {
+ if (face == Facing::UP) return &ms_pTileData->furnaceTile_iconTop;
+ if (face == Facing::DOWN) return &ms_pTileData->furnaceTile_iconTop;
+
+ if (face != data) return icon();
+ if(id == furnace_Id)
+ return &ms_pTileData->furnaceTile_iconFront;
+ else //furnace_lit_Id
+ return &ms_pTileData->furnaceTile_iconFront_lit;
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/GlassTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/GlassTile_SPU.h
new file mode 100644
index 00000000..c79d0534
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/GlassTile_SPU.h
@@ -0,0 +1,18 @@
+#pragma once
+#include "HalfTransparentTile_SPU.h"
+
+class GlassTile_SPU : public HalfTransparentTile_SPU
+{
+public:
+ GlassTile_SPU(int id) : HalfTransparentTile_SPU(id) {}
+
+ virtual bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face) // from parent class, here because it needs storgage
+ {
+ int id = level->getTile(x, y, z);
+ if (!ms_pTileData->glassTile_allowSame && id == this->id) return false;
+ return Tile_SPU::shouldRenderFace(level, x, y, z, face);
+
+ }
+
+ virtual int getRenderLayer() { return 0; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/GrassTile_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/GrassTile_SPU.cpp
new file mode 100644
index 00000000..833025ad
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/GrassTile_SPU.cpp
@@ -0,0 +1,65 @@
+#include "stdafx.h"
+#include "GrassTile_SPU.h"
+// #include "net.minecraft.world.level.h"
+// #include "net.minecraft.world.level.biome.h"
+// #include "net.minecraft.h"
+// #include "net.minecraft.world.h"
+
+#include "Facing_SPU.h"
+#include "ChunkRebuildData.h"
+
+
+Icon_SPU *GrassTile_SPU::getTexture(int face, int data)
+{
+ if (face == Facing::UP) return &ms_pTileData->grass_iconTop;
+ if (face == Facing::DOWN) return TileRef_SPU(dirt_Id)->getTexture(face);
+ return icon();
+}
+
+Icon_SPU *GrassTile_SPU::getTexture(ChunkRebuildData *level, int x, int y, int z, int face)
+{
+ if (face == Facing::UP) return &ms_pTileData->grass_iconTop;
+ if (face == Facing::DOWN) return TileRef_SPU(dirt_Id)->getTexture(face);
+ Material_SPU *above = level->getMaterial(x, y + 1, z);
+ if (above->getID() == Material_SPU::topSnow_Id || above->getID() == Material_SPU::snow_Id)
+ return &ms_pTileData->grass_iconSnowSide;
+ else
+ return icon();
+}
+
+
+int GrassTile_SPU::getColor(ChunkRebuildData *level, int x, int y, int z)
+{
+ return getColor( level, x, y, z, level->getData( x, y, z ) );
+}
+
+// 4J - changed interface to have data passed in, and put existing interface as wrapper above
+int GrassTile_SPU::getColor(ChunkRebuildData *level, int x, int y, int z, int data)
+{
+ //return level->getBiomeSource()->getBiome(x, z)->getGrassColor(level, x, y, z);
+
+ int totalRed = 0;
+ int totalGreen = 0;
+ int totalBlue = 0;
+
+ for (int oz = -1; oz <= 1; oz++)
+ {
+ for (int ox = -1; ox <= 1; ox++)
+ {
+ int grassColor = level->getGrassColor(x + ox, z + oz);
+ totalRed += (grassColor & 0xff0000) >> 16;
+ totalGreen += (grassColor & 0xff00) >> 8;
+ totalBlue += (grassColor & 0xff);
+ }
+ }
+
+ // return level.getBiomeSource().getBiome(x, z).getGrassColor(level, x, y, z);
+ return (((totalRed / 9) & 0xFF) << 16) | (((totalGreen / 9) & 0xFF) << 8) | (((totalBlue / 9) & 0xFF));
+}
+
+
+Icon_SPU *GrassTile_SPU::getSideTextureOverlay()
+{
+ return &ms_pTileData->grass_iconSideOverlay;
+}
+
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/GrassTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/GrassTile_SPU.h
new file mode 100644
index 00000000..07be4779
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/GrassTile_SPU.h
@@ -0,0 +1,23 @@
+#pragma once
+#include "Tile_SPU.h"
+
+
+class GrassTile_SPU : public Tile_SPU
+{
+ friend class Tile_SPU;
+private:
+// Icon *iconTop;
+// Icon *iconSnowSide;
+// Icon *iconSideOverlay;
+public:
+ static const int MIN_BRIGHTNESS = 4;
+
+protected:
+ GrassTile_SPU(int id) : Tile_SPU(id) {}
+public:
+ virtual Icon_SPU *getTexture(int face, int data);
+ virtual Icon_SPU *getTexture(ChunkRebuildData *level, int x, int y, int z, int face);
+ virtual int getColor(ChunkRebuildData *level, int x, int y, int z);
+ virtual int getColor(ChunkRebuildData *level, int x, int y, int z, int data); // 4J added
+ static Icon_SPU *getSideTextureOverlay();
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfSlabTile_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfSlabTile_SPU.cpp
new file mode 100644
index 00000000..1cf83821
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfSlabTile_SPU.cpp
@@ -0,0 +1,77 @@
+#include "stdafx.h"
+#include "HalfSlabTile_SPU.h"
+#include "Facing_SPU.h"
+#include "ChunkRebuildData.h"
+
+void HalfSlabTile_SPU::updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData /* = -1 */, TileEntity* forceEntity /* = NULL */)
+{
+ if (fullSize())
+ {
+ setShape(0, 0, 0, 1, 1, 1);
+ }
+ else
+ {
+ bool upper = (level->getData(x, y, z) & TOP_SLOT_BIT) != 0;
+ if (upper)
+ {
+ setShape(0, 0.5f, 0, 1, 1, 1);
+ }
+ else
+ {
+ setShape(0, 0, 0, 1, 0.5f, 1);
+ }
+ }
+}
+
+void HalfSlabTile_SPU::updateDefaultShape()
+{
+ if (fullSize())
+ {
+ setShape(0, 0, 0, 1, 1, 1);
+ }
+ else
+ {
+ setShape(0, 0, 0, 1, 0.5f, 1);
+ }
+}
+
+bool HalfSlabTile_SPU::isSolidRender(bool isServerLevel)
+{
+ return fullSize();
+}
+
+bool HalfSlabTile_SPU::shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face)
+{
+ if (fullSize()) return Tile_SPU::shouldRenderFace(level, x, y, z, face);
+
+ if (face != Facing::UP && face != Facing::DOWN && !Tile_SPU::shouldRenderFace(level, x, y, z, face))
+ {
+ return false;
+ }
+
+ int ox = x, oy = y, oz = z;
+ ox += Facing::STEP_X[Facing::OPPOSITE_FACING[face]];
+ oy += Facing::STEP_Y[Facing::OPPOSITE_FACING[face]];
+ oz += Facing::STEP_Z[Facing::OPPOSITE_FACING[face]];
+
+ bool isUpper = (level->getData(ox, oy, oz) & TOP_SLOT_BIT) != 0;
+ if (isUpper)
+ {
+ if (face == Facing::DOWN) return true;
+ if (face == Facing::UP && Tile_SPU::shouldRenderFace(level, x, y, z, face)) return true;
+ return !(isHalfSlab(level->getTile(x, y, z)) && (level->getData(x, y, z) & TOP_SLOT_BIT) != 0);
+ }
+ else
+ {
+ if (face == Facing::UP) return true;
+ if (face == Facing::DOWN && Tile_SPU::shouldRenderFace(level, x, y, z, face)) return true;
+ return !(isHalfSlab(level->getTile(x, y, z)) && (level->getData(x, y, z) & TOP_SLOT_BIT) == 0);
+ }
+}
+
+bool HalfSlabTile_SPU::isHalfSlab(int tileId)
+{
+ return tileId == Tile_SPU::stoneSlabHalf_Id || tileId == Tile_SPU::woodSlabHalf_Id;
+}
+
+
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfSlabTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfSlabTile_SPU.h
new file mode 100644
index 00000000..fd525e96
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfSlabTile_SPU.h
@@ -0,0 +1,19 @@
+#pragma once
+#include "Tile_SPU.h"
+
+
+class HalfSlabTile_SPU : public Tile_SPU
+{
+public:
+ static const int TYPE_MASK = 7;
+ static const int TOP_SLOT_BIT = 8;
+
+ HalfSlabTile_SPU(int id) : Tile_SPU(id) {}
+ virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL); // 4J added forceData, forceEntity param
+ virtual void updateDefaultShape();
+ virtual bool isSolidRender(bool isServerLevel);
+ virtual bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face);
+
+ bool fullSize() { return !isHalfSlab(id); }
+ static bool isHalfSlab(int tileId);
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfTransparentTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfTransparentTile_SPU.h
new file mode 100644
index 00000000..bc5e3305
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HalfTransparentTile_SPU.h
@@ -0,0 +1,11 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class HalfTransparentTile_SPU : public Tile_SPU
+{
+public:
+ HalfTransparentTile_SPU(int id) : Tile_SPU(id) {}
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face) = 0; // make sure the inherited class defines this, as it needs some storage (allowSame)
+ virtual bool blocksLight() { return false; }
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HugeMushroomTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HugeMushroomTile_SPU.h
new file mode 100644
index 00000000..89aad1aa
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/HugeMushroomTile_SPU.h
@@ -0,0 +1,43 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class HugeMushroomTile_SPU : public Tile_SPU
+{
+public:
+// static const wstring TEXTURE_STEM;
+// static const wstring TEXTURE_INSIDE;
+
+private:
+ static const int HUGE_MUSHROOM_TEXTURE_COUNT = 2;
+public:
+ HugeMushroomTile_SPU(int id) : Tile_SPU(id) {}
+ Icon_SPU *getTexture(int face, int data)
+ {
+ Icon_SPU* icons = ms_pTileData->hugeMushroom_icons;
+ int type = 0; // hugeMushroom1_Id
+ if(id == hugeMushroom2_Id)
+ type = 1;
+ // 123
+ // 456 10
+ // 789
+ if (data == 10 && face > 1) return &ms_pTileData->hugeMushroom_iconStem;
+ if (data >= 1 && data <= 9 && face == 1) return &icons[type];
+ if (data >= 1 && data <= 3 && face == 2) return &icons[type];
+ if (data >= 7 && data <= 9 && face == 3) return &icons[type];
+
+ if ((data == 1 || data == 4 || data == 7) && face == 4) return &icons[type];
+ if ((data == 3 || data == 6 || data == 9) && face == 5) return &icons[type];
+
+ // two special cases requested by rhodox (painterly pack)
+ if (data == 14)
+ {
+ return &icons[type];
+ }
+ if (data == 15)
+ {
+ return &ms_pTileData->hugeMushroom_iconStem;
+ }
+
+ return &ms_pTileData->hugeMushroom_iconInside;
+ }
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/IceTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/IceTile_SPU.h
new file mode 100644
index 00000000..4d5f9e3c
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/IceTile_SPU.h
@@ -0,0 +1,17 @@
+#pragma once
+#include "HalfTransparentTile_SPU.h"
+
+class Random;
+
+class IceTile_SPU : public HalfTransparentTile_SPU
+{
+public:
+ IceTile_SPU(int id) : HalfTransparentTile_SPU(id) {}
+ virtual int getRenderLayer() { return 1; }
+ virtual bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face)
+ {
+ int id = level->getTile(x, y, z);
+ if (!ms_pTileData->iceTile_allowSame && id == this->id) return false;
+ return Tile_SPU::shouldRenderFace(level, x, y, z, 1 - face);
+ }
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Icon_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Icon_SPU.cpp
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Icon_SPU.cpp
@@ -0,0 +1 @@
+
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Icon_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Icon_SPU.h
new file mode 100644
index 00000000..f4ba6ccf
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Icon_SPU.h
@@ -0,0 +1,56 @@
+#pragma once
+
+#include <stdint.h>
+
+class Icon_SPU
+{
+
+ int16_t x0;
+ int16_t y0;
+ int16_t x1;
+ int16_t y1;
+
+public:
+
+// static const int TYPE_TERRAIN = 0;
+// static const int TYPE_ITEM = 1;
+//
+ static const float UVAdjust = (1.0f/16.0f)/256.0f;
+
+// int getX() const { return x; }
+// int getY() const { return y; }
+// int getWidth() const { return (w<0) ? -w : w; } // can be negative, to support flipped icons (only doors for now).
+// int getHeight() const { return h; }
+
+ void set(int16_t _x, int16_t _y, int16_t _w, int16_t _h, int texWidth, int texHeight)
+ {
+ x0 = (int16_t)(4096 * (float(_x) / texWidth));
+ y0 = (int16_t)(4096 * (float(_y) / texHeight));
+ x1 = x0 + (int16_t)(4096 * (float(_w) / texWidth));
+ y1 = y0 + (int16_t)(4096 * (float(_h) / texHeight));
+ }
+
+ void flipHorizontal() { int16_t temp = x0; x0 = x1; x1 = temp; }
+ void flipVertical() { int16_t temp = y0; y0 = y1; y1 = temp; }
+
+ float getU0() const { return (float(x0) / 4096) + UVAdjust; }//sc_texWidth) + getUAdjust(); }
+ float getU1() const { return (float(x1) / 4096.0f) - UVAdjust; } //sc_texWidth) - getUAdjust(); }
+ float getU(double offset) const
+ {
+ float diff = getU1() - getU0();
+ return getU0() + (diff * ((float) offset / 16));//SharedConstants::WORLD_RESOLUTION));
+ }
+
+ float getV0() const { return (float(y0) / 4096.0f) + UVAdjust; } //sc_texHeight) + getVAdjust(); }
+ float getV1() const { return (float(y1) / 4096.0f) - UVAdjust; } //sc_texHeight) - getVAdjust(); }
+ float getV(double offset) const
+ {
+ float diff = getV1() - getV0();
+ return getV0() + (diff * ((float) offset / 16)); //SharedConstants::WORLD_RESOLUTION));
+ }
+
+// virtual wstring getName() const = 0;
+// virtual int getSourceWidth() const = 0;
+// virtual int getSourceHeight() const = 0;
+};
+
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LadderTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LadderTile_SPU.h
new file mode 100644
index 00000000..fb52009f
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LadderTile_SPU.h
@@ -0,0 +1,13 @@
+#pragma once
+#include "Tile_SPU.h"
+
+
+class LadderTile_SPU : public Tile_SPU
+{
+public:
+ LadderTile_SPU(int id) : Tile_SPU(id) {}
+ virtual bool blocksLight() { return false; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual bool isCubeShaped() { return false; }
+ virtual int getRenderShape() { return Tile_SPU::SHAPE_LADDER; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LeafTile_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LeafTile_SPU.cpp
new file mode 100644
index 00000000..67373265
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LeafTile_SPU.cpp
@@ -0,0 +1,88 @@
+#include "stdafx.h"
+#include "LeafTile_SPU.h"
+#include "ChunkRebuildData.h"
+
+
+// const unsigned int LeafTile::LEAF_NAMES[LEAF_NAMES_LENGTH] = { IDS_TILE_LEAVES_OAK,
+// IDS_TILE_LEAVES_SPRUCE,
+// IDS_TILE_LEAVES_BIRCH,
+// };
+//
+// const wstring LeafTile::TEXTURES[2][4] = { {L"leaves", L"leaves_spruce", L"leaves", L"leaves_jungle"}, {L"leaves_opaque", L"leaves_spruce_opaque", L"leaves_opaque", L"leaves_jungle_opaque"},};
+
+
+// from TransparentTile, since we're no longer inheriting
+bool LeafTile_SPU::shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face)
+{
+ int id = level->getTile(x, y, z);
+ if (!ms_pTileData->leafTile_allowSame && id == this->id) return false;
+ return Tile_SPU::shouldRenderFace(level, x, y, z, face);
+}
+
+int LeafTile_SPU::getColor(ChunkRebuildData *level, int x, int y, int z)
+{
+ return getColor(level, x, y, z, level->getData(x, y, z) );
+}
+
+// 4J - changed interface to have data passed in, and put existing interface as wrapper above
+int LeafTile_SPU::getColor(ChunkRebuildData *level, int x, int y, int z, int data)
+{
+ if ((data & LEAF_TYPE_MASK) == EVERGREEN_LEAF)
+ {
+ return ms_pTileData->foliageColor_evergreenColor; //FoliageColor::getEvergreenColor();
+ }
+ if ((data & LEAF_TYPE_MASK) == BIRCH_LEAF)
+ {
+ return ms_pTileData->foliageColor_birchColor;//FoliageColor::getBirchColor();
+ }
+
+ //return level->getBiomeSource()->getBiome(x, z)->getFolageColor(level, x, y, z);
+
+ int totalRed = 0;
+ int totalGreen = 0;
+ int totalBlue = 0;
+
+ for (int oz = -1; oz <= 1; oz++)
+ {
+ for (int ox = -1; ox <= 1; ox++)
+ {
+ int foliageColor = level->getFoliageColor(x + ox, z + oz);
+
+ totalRed += (foliageColor & 0xff0000) >> 16;
+ totalGreen += (foliageColor & 0xff00) >> 8;
+ totalBlue += (foliageColor & 0xff);
+ }
+ }
+
+ // return level.getBiomeSource().getBiome(x, z).getGrassColor(level, x, y, z);
+ return (((totalRed / 9) & 0xFF) << 16) | (((totalGreen / 9) & 0xFF) << 8) | (((totalBlue / 9) & 0xFF));
+}
+
+
+
+bool LeafTile_SPU::isSolidRender(bool isServerLevel)
+{
+ // 4J Stu - The server level shouldn't care how the tile is rendered!
+ // Fix for #9407 - Gameplay: Destroying a block of snow on top of trees, removes any adjacent snow.
+ if(isServerLevel) return true;
+ return !ms_pTileData->leafTile_allowSame;
+}
+
+Icon_SPU *LeafTile_SPU::getTexture(int face, int data)
+{
+ if ((data & LEAF_TYPE_MASK) == EVERGREEN_LEAF)
+ {
+ return &ms_pTileData->leafTile_icons[ms_pTileData->leafTile_fancyTextureSet][EVERGREEN_LEAF];
+ }
+ if ((data & LEAF_TYPE_MASK) == JUNGLE_LEAF)
+ {
+ return &ms_pTileData->leafTile_icons[ms_pTileData->leafTile_fancyTextureSet][JUNGLE_LEAF];
+ }
+ return &ms_pTileData->leafTile_icons[ms_pTileData->leafTile_fancyTextureSet][0];
+}
+
+void LeafTile_SPU::setFancy(bool fancyGraphics)
+{
+ ms_pTileData->leafTile_allowSame = fancyGraphics;
+ ms_pTileData->leafTile_fancyTextureSet = (fancyGraphics ? 0 : 1);
+}
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LeafTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LeafTile_SPU.h
new file mode 100644
index 00000000..7315addf
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LeafTile_SPU.h
@@ -0,0 +1,38 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class LeafTile_SPU : public Tile_SPU
+{
+ friend class Tile;
+public:
+ static const int REQUIRED_WOOD_RANGE = 4;
+ static const int UPDATE_LEAF_BIT = 8;
+ static const int PERSISTENT_LEAF_BIT = 4; // player-placed
+ static const int NORMAL_LEAF = 0;
+ static const int EVERGREEN_LEAF = 1;
+ static const int BIRCH_LEAF = 2;
+ static const int JUNGLE_LEAF = 3;
+
+ static const int LEAF_NAMES_LENGTH = 3;
+
+ static const int LEAF_TYPE_MASK = 3;
+
+ // pppppppppp ppppppppppp pppppppppp ppppppp
+ // ssssssssss sssssssssss s
+
+ LeafTile_SPU(int id) : Tile_SPU(id) {}
+public:
+ virtual bool isSolidRender(bool isServerLevel = false);
+ virtual bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face); // from TransparentTile, since we're no longer inheriting
+ virtual bool blocksLight() { return false; }
+
+
+// virtual int getColor() const;
+// virtual int getColor(int data);
+ virtual int getColor(ChunkRebuildData *level, int x, int y, int z);
+ virtual int getColor(ChunkRebuildData *level, int x, int y, int z, int data); // 4J added
+
+public:
+ virtual Icon_SPU *getTexture(int face, int data);
+ static void setFancy(bool fancyGraphics);
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LeverTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LeverTile_SPU.h
new file mode 100644
index 00000000..06dda5bb
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LeverTile_SPU.h
@@ -0,0 +1,12 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class LeverTile_SPU : public Tile_SPU
+{
+public:
+ LeverTile_SPU(int id) : Tile_SPU(id) {}
+ virtual bool blocksLight() { return false; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual int getRenderShape() { return Tile_SPU::SHAPE_LEVER; }
+// virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, shared_ptr<TileEntity> forceEntity = shared_ptr<TileEntity>()); // 4J added forceData, forceEntity param
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LiquidTile_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LiquidTile_SPU.cpp
new file mode 100644
index 00000000..7f13fd4f
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LiquidTile_SPU.cpp
@@ -0,0 +1,224 @@
+#include "stdafx.h"
+#include "LiquidTile_SPU.h"
+#include "Facing_SPU.h"
+#include "ChunkRebuildData.h"
+
+#ifdef SN_TARGET_PS3_SPU
+#include "..\Common\spu_assert.h"
+#endif
+
+// const wstring LiquidTile::TEXTURE_LAVA_STILL = L"lava";
+// const wstring LiquidTile::TEXTURE_WATER_STILL = L"water";
+// const wstring LiquidTile::TEXTURE_WATER_FLOW = L"water_flow";
+// const wstring LiquidTile::TEXTURE_LAVA_FLOW = L"lava_flow";
+
+#define MATH_PI (3.141592654f)
+
+
+int LiquidTile_SPU::getColor(ChunkRebuildData *level, int x, int y, int z)
+{
+
+ return getColor(level, x, y, z, 0);
+}
+
+int LiquidTile_SPU::getColor(ChunkRebuildData *level, int x, int y, int z, int d)
+{
+ // MGH - TODO
+ if (getMaterial()->getID() == Material_SPU::water_Id)
+ {
+ // Biome b = level.getBiomeSource().getBiome(x, z);
+ // return b.waterColor;
+
+ int totalRed = 0;
+ int totalGreen = 0;
+ int totalBlue = 0;
+
+ for (int oz = -1; oz <= 1; oz++)
+ {
+ for (int ox = -1; ox <= 1; ox++)
+ {
+ int waterColor = level->getWaterColor(x + ox, z + oz);
+
+ totalRed += (waterColor & 0xff0000) >> 16;
+ totalGreen += (waterColor & 0xff00) >> 8;
+ totalBlue += (waterColor & 0xff);
+ }
+ }
+
+ // return level.getBiomeSource().getBiome(x, z).getGrassColor(level, x, y, z);
+ return (((totalRed / 9) & 0xFF) << 16) | (((totalGreen / 9) & 0xFF) << 8) | (((totalBlue / 9) & 0xFF));
+ }
+ return 0xffffff;
+}
+
+float LiquidTile_SPU::getHeight(int d)
+{
+ // if (d == 0) d++;
+ if (d >= 8) d = 0;
+ return (d + 1) / 9.0f;
+}
+
+Icon_SPU *LiquidTile_SPU::getTexture(int face, int data)
+{
+ if (face == Facing::DOWN || face == Facing::UP)
+ {
+ if(id == water_Id || id == calmWater_Id)
+ return &ms_pTileData->liquidTile_iconWaterStill;
+ else //(id == lava_Id || id == calmLava_Id)
+ return &ms_pTileData->liquidTile_iconLavaStill;
+ }
+ else
+ {
+ if(id == water_Id || id == calmWater_Id)
+ return &ms_pTileData->liquidTile_iconWaterFlow;
+ else //(id == lava_Id || id == calmLava_Id)
+ return &ms_pTileData->liquidTile_iconLavaFlow;
+ }
+}
+
+int LiquidTile_SPU::getDepth(ChunkRebuildData *level, int x, int y, int z)
+{
+ if (level->getMaterial(x, y, z)->getID() != getMaterial()->getID()) return -1;
+ else return -1;;
+}
+
+int LiquidTile_SPU::getRenderedDepth(ChunkRebuildData *level, int x, int y, int z)
+{
+ if (level->getMaterial(x, y, z)->getID() != getMaterial()->getID()) return -1;
+ int d = level->getData(x, y, z);
+ if (d >= 8) d = 0;
+ return d;
+}
+
+
+bool LiquidTile_SPU::isSolidRender(bool isServerLevel)
+{
+ return false;
+}
+
+bool LiquidTile_SPU::isSolidFace(ChunkRebuildData *level, int x, int y, int z, int face)
+{
+ Material_SPU *m = level->getMaterial(x, y, z);
+ if (m->getID() == this->getMaterial()->getID()) return false;
+ if (face == Facing::UP) return true;
+ if (m->getID() == Material_SPU::ice_Id) return false;
+
+ return Tile_SPU::isSolidFace(level, x, y, z, face);
+}
+
+bool LiquidTile_SPU::shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face)
+{
+ Material_SPU *m = level->getMaterial(x, y, z);
+ if (m->getID() == this->getMaterial()->getID()) return false;
+ if (face == Facing::UP) return true;
+ if (m->getID() == Material_SPU::ice_Id) return false;
+ return Tile_SPU::shouldRenderFace(level, x, y, z, face);
+}
+
+int LiquidTile_SPU::getRenderShape()
+{
+ return Tile_SPU::SHAPE_WATER;
+}
+
+
+Vec3_SPU LiquidTile_SPU::getFlow(ChunkRebuildData *level, int x, int y, int z)
+{
+ Vec3_SPU flow = Vec3_SPU(0,0,0);
+ int mid = getRenderedDepth(level, x, y, z);
+ for (int d = 0; d < 4; d++)
+ {
+
+ int xt = x;
+ int yt = y;
+ int zt = z;
+
+ if (d == 0) xt--;
+ if (d == 1) zt--;
+ if (d == 2) xt++;
+ if (d == 3) zt++;
+
+ int t = getRenderedDepth(level, xt, yt, zt);
+ if (t < 0)
+ {
+ if (!level->getMaterial(xt, yt, zt)->blocksMotion())
+ {
+ t = getRenderedDepth(level, xt, yt - 1, zt);
+ if (t >= 0)
+ {
+ int dir = t - (mid - 8);
+ flow = flow.add((xt - x) * dir, (yt - y) * dir, (zt - z) * dir);
+ }
+ }
+ } else
+ {
+ if (t >= 0)
+ {
+ int dir = t - mid;
+ flow = flow.add((xt - x) * dir, (yt - y) * dir, (zt - z) * dir);
+ }
+ }
+
+ }
+ if (level->getData(x, y, z) >= 8)
+ {
+ bool ok = false;
+ if (ok || isSolidFace(level, x, y, z - 1, 2)) ok = true;
+ if (ok || isSolidFace(level, x, y, z + 1, 3)) ok = true;
+ if (ok || isSolidFace(level, x - 1, y, z, 4)) ok = true;
+ if (ok || isSolidFace(level, x + 1, y, z, 5)) ok = true;
+ if (ok || isSolidFace(level, x, y + 1, z - 1, 2)) ok = true;
+ if (ok || isSolidFace(level, x, y + 1, z + 1, 3)) ok = true;
+ if (ok || isSolidFace(level, x - 1, y + 1, z, 4)) ok = true;
+ if (ok || isSolidFace(level, x + 1, y + 1, z, 5)) ok = true;
+ if (ok) flow = flow.normalize().add(0, -6, 0);
+ }
+ flow = flow.normalize();
+ return flow;
+}
+
+
+// 4J - change brought forward from 1.8.2
+int LiquidTile_SPU::getLightColor(ChunkRebuildData *level, int x, int y, int z)
+{
+ int a = level->getLightColor(x, y, z, 0);
+ int b = level->getLightColor(x, y + 1, z, 0);
+
+ int aa = a & 0xff;
+ int ba = b & 0xff;
+ int ab = (a >> 16) & 0xff;
+ int bb = (b >> 16) & 0xff;
+
+ return (aa > ba ? aa : ba) | ((ab > bb ? ab : bb) << 16);
+}
+
+float LiquidTile_SPU::getBrightness(ChunkRebuildData *level, int x, int y, int z)
+{
+ float a = level->getBrightness(x, y, z);
+ float b = level->getBrightness(x, y + 1, z);
+ return a > b ? a : b;
+}
+
+
+int LiquidTile_SPU::getRenderLayer()
+{
+ return getMaterial()->getID() == Material_SPU::water_Id ? 1 : 0;
+}
+
+
+double LiquidTile_SPU::getSlopeAngle(ChunkRebuildData *level, int x, int y, int z, Material_SPU *m)
+{
+ Vec3_SPU flow = Vec3_SPU(0,0,0);
+ if (m->getID() == Material_SPU::water_Id)
+ {
+ TileRef_SPU tRef(Tile_SPU::water_Id);
+ flow = ((LiquidTile_SPU*)tRef.getPtr())->getFlow(level, x, y, z);
+ }
+ if (m->getID() == Material_SPU::lava_Id)
+ {
+ TileRef_SPU tRef(Tile_SPU::lava_Id);
+ flow = ((LiquidTile_SPU*)tRef.getPtr())->getFlow(level, x, y, z);
+ }
+ if (flow.x == 0 && flow.z == 0) return -1000;
+ return atan2(flow.z, flow.x) - MATH_PI / 2;
+}
+
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LiquidTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LiquidTile_SPU.h
new file mode 100644
index 00000000..31e3e64a
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/LiquidTile_SPU.h
@@ -0,0 +1,47 @@
+#pragma once
+#include "Tile_SPU.h"
+#include <math.h>
+
+class Vec3_SPU
+{
+public:
+ float x,y,z;
+ Vec3_SPU(float xVal, float yVal, float zVal) :x(xVal), y(yVal), z(zVal) {}
+ Vec3_SPU normalize()
+ {
+ float dist = sqrtf(x * x + y * y + z * z);
+ if (dist < 0.0001) return Vec3_SPU(0, 0, 0);
+ return Vec3_SPU(x / dist, y / dist, z / dist);
+ }
+ Vec3_SPU add(float x, float y, float z)
+ {
+ return Vec3_SPU(this->x+x, this->y+y, this->z+z);
+ }
+
+};
+
+
+class LiquidTile_SPU : public Tile_SPU
+{
+public:
+
+ LiquidTile_SPU(int id) : Tile_SPU(id) {}
+public:
+// virtual int getColor() const;
+ virtual int getColor(ChunkRebuildData *level, int x, int y, int z);
+ virtual int getColor(ChunkRebuildData *level, int x, int y, int z, int data); // 4J added
+ static float getHeight(int d);
+ static double getSlopeAngle(ChunkRebuildData *level, int x, int y, int z, Material_SPU *m);
+ virtual Icon_SPU *getTexture(int face, int data);
+ virtual int getDepth(ChunkRebuildData *level, int x, int y, int z);
+ virtual int getRenderedDepth(ChunkRebuildData *level, int x, int y, int z);
+ virtual bool isSolidRender(bool isServerLevel = false);
+ virtual bool isSolidFace(ChunkRebuildData *level, int x, int y, int z, int face);
+ virtual bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face);
+ virtual int getRenderShape();
+ virtual Vec3_SPU getFlow(ChunkRebuildData *level, int x, int y, int z);
+ virtual int getRenderLayer();
+ virtual int getLightColor(ChunkRebuildData *level, int x, int y, int z); // 4J - brought forward from 1.8.2
+ virtual float getBrightness(ChunkRebuildData *level, int x, int y, int z);
+private:
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Makefile b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Makefile
new file mode 100644
index 00000000..970f755f
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Makefile
@@ -0,0 +1,16 @@
+#########################################################
+# SCE CONFIDENTIAL
+# PlayStation(R)3 Programmer Tool Runtime Library 430.001
+# Copyright (C) 2010 Sony Computer Entertainment Inc.
+# All Rights Reserved.
+#########################################################
+
+CELL_MK_DIR ?= $(CELL_SDK)/samples/mk
+include $(CELL_MK_DIR)/sdk.makedef.mk
+
+SPU_SRCS = task.cpp
+SPU_TARGET = task_hello.spu.elf
+SPU_CFLAGS = -mspurs-task
+SPU_LDFLAGS = -mspurs-task
+
+include $(CELL_MK_DIR)/sdk.target.mk
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Material_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Material_SPU.h
new file mode 100644
index 00000000..e7cf34b8
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Material_SPU.h
@@ -0,0 +1,74 @@
+#pragma once
+
+#include <stdint.h>
+
+class ChunkRebuildData;
+class Material_SPU
+{
+ friend class ChunkRebuildData;
+public:
+ static const int air_Id = 0;
+ static const int grass_Id = 1;
+ static const int dirt_Id = 2;
+ static const int wood_Id = 3;
+ static const int stone_Id = 4;
+ static const int metal_Id = 5;
+ static const int water_Id = 6;
+ static const int lava_Id = 7;
+ static const int leaves_Id = 8;
+ static const int plant_Id = 9;
+ static const int replaceable_plant_Id = 10;
+ static const int sponge_Id = 11;
+ static const int cloth_Id = 12;
+ static const int fire_Id = 13;
+ static const int sand_Id = 14;
+ static const int decoration_Id = 15;
+ static const int glass_Id = 16;
+ static const int explosive_Id = 17;
+ static const int coral_Id = 18;
+ static const int ice_Id = 19;
+ static const int topSnow_Id = 20;
+ static const int snow_Id = 21;
+ static const int cactus_Id = 22;
+ static const int clay_Id = 23;
+ static const int vegetable_Id = 24;
+ static const int egg_Id = 25;
+ static const int portal_Id = 26;
+ static const int cake_Id = 27;
+ static const int web_Id = 28;
+ static const int piston_Id = 29;
+ static const int buildable_glass_Id = 30;
+ static const int heavyMetal_Id = 31;
+ static const int clothDecoration_Id = 32;
+ static const int num_Ids = 32;
+
+ enum Flags
+ {
+ e_flammable = 0x01,
+ e_replaceable = 0x02,
+ e_neverBuildable = 0x04,
+ e_isSolid = 0x08,
+ e_isLiquid = 0x10,
+ e_blocksLight = 0x20,
+ e_blocksMotion = 0x40
+ };
+
+private:
+ uint16_t id;
+ uint16_t flags;
+
+public:
+ int color;
+
+public:
+ int getID() { return id;}
+ bool isLiquid() { return (flags & e_isLiquid) != 0; }
+ bool letsWaterThrough() { return (!isLiquid() && !isSolid()); }
+ bool isSolid() { return (flags & e_isSolid) != 0;}
+ bool blocksLight() { return (flags & e_blocksLight) != 0; }
+ bool blocksMotion() { return (flags & e_blocksMotion) != 0; }
+ bool isFlammable() { return (flags & e_flammable) != 0; }
+ bool isReplaceable(){ return (flags & e_replaceable) != 0; }
+ bool isSolidBlocking(){ if (flags & e_neverBuildable) return false; return blocksMotion(); }
+};
+
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/MelonTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/MelonTile_SPU.h
new file mode 100644
index 00000000..a0ddf45a
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/MelonTile_SPU.h
@@ -0,0 +1,14 @@
+#pragma once
+#include "Tile_SPU.h"
+
+
+class MelonTile_SPU : public Tile_SPU
+{
+public:
+ MelonTile_SPU(int id) : Tile_SPU(id) {}
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ if (face == Facing::UP || face == Facing::DOWN) return &ms_pTileData->melonTile_iconTop;
+ return icon();
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/MobSpawnerTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/MobSpawnerTile_SPU.h
new file mode 100644
index 00000000..4b703e74
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/MobSpawnerTile_SPU.h
@@ -0,0 +1,12 @@
+#pragma once
+#include "EntityTile_SPU.h"
+
+class Random;
+
+class MobSpawnerTile_SPU : public EntityTile_SPU
+{
+public:
+ MobSpawnerTile_SPU(int id) : EntityTile_SPU(id) {}
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual bool blocksLight() { return false; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Mushroom_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Mushroom_SPU.h
new file mode 100644
index 00000000..39abcd47
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Mushroom_SPU.h
@@ -0,0 +1,8 @@
+#pragma once
+#include "Bush_SPU.h"
+
+class Mushroom_SPU : public Bush_SPU
+{
+public:
+ Mushroom_SPU(int id) : Bush_SPU(id){}
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/MycelTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/MycelTile_SPU.h
new file mode 100644
index 00000000..999bdf49
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/MycelTile_SPU.h
@@ -0,0 +1,25 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class MycelTile_SPU : public Tile_SPU
+{
+public:
+ MycelTile_SPU(int id) : Tile_SPU(id) {}
+
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ if (face == Facing::UP) return &ms_pTileData->mycelTile_iconTop;
+ if (face == Facing::DOWN) return TileRef_SPU(dirt_Id)->getTexture(face);
+ return icon();
+ }
+ virtual Icon_SPU *getTexture(ChunkRebuildData *level, int x, int y, int z, int face)
+ {
+ if (face == Facing::UP) return &ms_pTileData->mycelTile_iconTop;
+ if (face == Facing::DOWN) return TileRef_SPU(dirt_Id)->getTexture(face);
+ Material_SPU *above = level->getMaterial(x, y + 1, z);
+ if (above->getID() == Material_SPU::topSnow_Id || above->getID() == Material_SPU::snow_Id)
+ return &ms_pTileData->mycelTile_iconSnowSide;
+ else return icon();
+
+ }
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/NetherStalkTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/NetherStalkTile_SPU.h
new file mode 100644
index 00000000..40c25f4e
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/NetherStalkTile_SPU.h
@@ -0,0 +1,29 @@
+#pragma once
+#include "Bush_SPU.h"
+
+class NetherStalkTile_SPU : public Bush_SPU
+{
+private:
+ static const int MAX_AGE = 3;
+ static const int NETHER_STALK_TEXTURE_COUNT = 3;
+
+
+public:
+ NetherStalkTile_SPU(int id) : Bush_SPU(id) {}
+
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ Icon_SPU* icons = ms_pTileData->netherStalk_icons;
+ if (data >= MAX_AGE)
+ {
+ return &icons[2];
+ }
+ if (data > 0)
+ {
+ return &icons[1];
+ }
+ return &icons[0];
+
+ }
+ virtual int getRenderShape() { return Tile_SPU::SHAPE_ROWS; }
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonBaseTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonBaseTile_SPU.h
new file mode 100644
index 00000000..e8411c88
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonBaseTile_SPU.h
@@ -0,0 +1,18 @@
+#pragma once
+#include "Tile_SPU.h"
+
+// TileRenderer not implemented, so minimum of stuff here
+class PistonBaseTile_SPU : public Tile_SPU
+{
+
+public:
+ PistonBaseTile_SPU(int id) : Tile_SPU(id) {}
+// virtual void updateShape(float x0, float y0, float z0, float x1, float y1, float z1);
+ virtual Icon_SPU *getTexture(int face, int data) { return NULL; }
+ virtual int getRenderShape() { return SHAPE_PISTON_BASE; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+
+ // virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, shared_ptr<TileEntity> forceEntity = shared_ptr<TileEntity>()); // 4J added forceData, forceEntity param
+// virtual void updateDefaultShape();
+
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonExtensionTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonExtensionTile_SPU.h
new file mode 100644
index 00000000..d5460492
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonExtensionTile_SPU.h
@@ -0,0 +1,13 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class PistonExtensionTile_SPU : public Tile_SPU
+{
+
+public:
+ PistonExtensionTile_SPU(int id) : Tile_SPU(id) {}
+ virtual Icon_SPU *getTexture(int face, int data) { return NULL; }
+ virtual int getRenderShape() { return SHAPE_PISTON_EXTENSION; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+// virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, shared_ptr<TileEntity> forceEntity = shared_ptr<TileEntity>()); // 4J added forceData, forceEntity param
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonMovingPiece_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonMovingPiece_SPU.h
new file mode 100644
index 00000000..48fc52e9
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PistonMovingPiece_SPU.h
@@ -0,0 +1,17 @@
+
+#pragma once
+#include "EntityTile_SPU.h"
+
+
+class PistonMovingPiece_SPU : public EntityTile_SPU
+{
+public:
+ PistonMovingPiece_SPU(int id) : EntityTile_SPU(id) {}
+
+ virtual int getRenderShape() { return SHAPE_INVISIBLE; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param
+ {
+ // should never get here.
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PortalTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PortalTile_SPU.h
new file mode 100644
index 00000000..f01313a1
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PortalTile_SPU.h
@@ -0,0 +1,48 @@
+#pragma once
+#include "HalfTransparentTile_SPU.h"
+
+class PortalTile_SPU : public HalfTransparentTile_SPU
+{
+public:
+ PortalTile_SPU(int id): HalfTransparentTile_SPU(id) {}
+ virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param
+ {
+ if (level->getTile(x - 1, y, z) == id || level->getTile(x + 1, y, z) == id)
+ {
+ float xr = 8 / 16.0f;
+ float yr = 2 / 16.0f;
+ this->setShape(0.5f - xr, 0, 0.5f - yr, 0.5f + xr, 1, 0.5f + yr);
+ }
+ else
+ {
+ float xr = 2 / 16.0f;
+ float yr = 8 / 16.0f;
+ this->setShape(0.5f - xr, 0, 0.5f - yr, 0.5f + xr, 1, 0.5f + yr);
+ }
+
+ }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual bool isCubeShaped() { return false; }
+ virtual bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face)
+ {
+ if (level->getTile(x, y, z) == id) return false;
+
+ bool w = level->getTile(x - 1, y, z) == id && level->getTile(x - 2, y, z) != id;
+ bool e = level->getTile(x + 1, y, z) == id && level->getTile(x + 2, y, z) != id;
+
+ bool n = level->getTile(x, y, z - 1) == id && level->getTile(x, y, z - 2) != id;
+ bool s = level->getTile(x, y, z + 1) == id && level->getTile(x, y, z + 2) != id;
+
+ bool we = w || e;
+ bool ns = n || s;
+
+ if (we && face == 4) return true;
+ if (we && face == 5) return true;
+ if (ns && face == 2) return true;
+ if (ns && face == 3) return true;
+
+ return false;
+ }
+
+ virtual int getRenderLayer() { return 1; }
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PotatoTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PotatoTile_SPU.h
new file mode 100644
index 00000000..eb2362fa
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PotatoTile_SPU.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "CropTile_SPU.h"
+
+class PotatoTile_SPU : public CropTile_SPU
+{
+private:
+// Icon *icons[4];
+
+public:
+ PotatoTile_SPU(int id) : CropTile_SPU(id) {}
+
+ Icon_SPU *getTexture(int face, int data)
+ {
+ if (data < 7)
+ {
+ if (data == 6)
+ {
+ data = 5;
+ }
+ return &ms_pTileData->potato_icons[data >> 1];
+ }
+ else
+ {
+ return &ms_pTileData->potato_icons[3];
+ }
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PressurePlateTile_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PressurePlateTile_SPU.cpp
new file mode 100644
index 00000000..e73cd0d9
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PressurePlateTile_SPU.cpp
@@ -0,0 +1,41 @@
+#include "stdafx.h"
+#include "PressurePlateTile_SPU.h"
+#include "ChunkRebuildData.h"
+
+
+bool PressurePlateTile_SPU::isSolidRender(bool isServerLevel)
+{
+ return false;
+}
+
+bool PressurePlateTile_SPU::blocksLight()
+{
+ return false;
+}
+
+
+void PressurePlateTile_SPU::updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData, TileEntity* forceEntity) // 4J added forceData, forceEntity param
+{
+ bool pressed = level->getData(x, y, z) == 1;
+
+ float o = 1 / 16.0f;
+ if (pressed)
+ {
+ this->setShape(o, 0, o, 1 - o, 0.5f / 16.0f, 1 - o);
+ }
+ else
+ {
+ setShape(o, 0, o, 1 - o, 1 / 16.0f, 1 - o);
+ }
+}
+
+
+void PressurePlateTile_SPU::updateDefaultShape()
+{
+ float x = 8 / 16.0f;
+ float y = 2 / 16.0f;
+ float z = 8 / 16.0f;
+ setShape(0.5f - x, 0.5f - y, 0.5f - z, 0.5f + x, 0.5f + y, 0.5f + z);
+
+}
+
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PressurePlateTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PressurePlateTile_SPU.h
new file mode 100644
index 00000000..133ec52e
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PressurePlateTile_SPU.h
@@ -0,0 +1,21 @@
+#pragma once
+#include "Tile_SPU.h"
+
+
+class PressurePlateTile_SPU : public Tile_SPU
+{
+public:
+ enum Sensitivity
+ {
+ everything,
+ mobs,
+ players
+ };
+
+ PressurePlateTile_SPU(int id) : Tile_SPU(id) {}
+ virtual bool isSolidRender(bool isServerLevel = false);
+ virtual bool blocksLight();
+
+ virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL); // 4J added forceData, forceEntity param
+ virtual void updateDefaultShape();
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PumpkinTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PumpkinTile_SPU.h
new file mode 100644
index 00000000..9e248e23
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/PumpkinTile_SPU.h
@@ -0,0 +1,30 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class PumpkinTile_SPU : public Tile_SPU
+{
+public:
+ static const int DIR_SOUTH = 0;
+ static const int DIR_WEST = 1;
+ static const int DIR_NORTH = 2;
+ static const int DIR_EAST = 3;
+
+public:
+ PumpkinTile_SPU(int id) : Tile_SPU(id) {}
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ if (face == Facing::UP) return &ms_pTileData->pumpkinTile_iconTop;
+ if (face == Facing::DOWN) return &ms_pTileData->pumpkinTile_iconTop;
+
+ Icon_SPU* iconFace = &ms_pTileData->pumpkinTile_iconFace;
+ if(id == litPumpkin_Id)
+ iconFace = &ms_pTileData->pumpkinTile_iconFaceLit;
+
+ if (data == DIR_NORTH && face == Facing::NORTH) return iconFace;
+ if (data == DIR_EAST && face == Facing::EAST) return iconFace;
+ if (data == DIR_SOUTH && face == Facing::SOUTH) return iconFace;
+ if (data == DIR_WEST && face == Facing::WEST) return iconFace;
+
+ else return icon();
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/QuartzBlockTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/QuartzBlockTile_SPU.h
new file mode 100644
index 00000000..788d61d9
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/QuartzBlockTile_SPU.h
@@ -0,0 +1,65 @@
+#pragma once
+
+#include "Tile_SPU.h"
+
+class QuartzBlockTile_SPU : public Tile_SPU
+{
+public:
+ static const int TYPE_DEFAULT = 0;
+ static const int TYPE_CHISELED = 1;
+ static const int TYPE_LINES_Y = 2;
+ static const int TYPE_LINES_X = 3;
+ static const int TYPE_LINES_Z = 4;
+
+ static const int QUARTZ_BLOCK_NAMES = 3;
+
+private:
+ static const int QUARTZ_BLOCK_TEXTURES = 5;
+
+// Icon *icons[QUARTZ_BLOCK_TEXTURES];
+// Icon *iconChiseledTop;
+// Icon *iconLinesTop;
+// Icon *iconTop;
+// Icon *iconBottom;
+
+public:
+ QuartzBlockTile_SPU(int id) : Tile_SPU(id) {}
+
+ Icon_SPU *getTexture(int face, int data)
+ {
+ if (data == TYPE_LINES_Y || data == TYPE_LINES_X || data == TYPE_LINES_Z)
+ {
+ if (data == TYPE_LINES_Y && (face == Facing::UP || face == Facing::DOWN))
+ {
+ return &ms_pTileData->quartzBlock_iconLinesTop;
+ }
+ else if (data == TYPE_LINES_X && (face == Facing::EAST || face == Facing::WEST))
+ {
+ return &ms_pTileData->quartzBlock_iconLinesTop;
+ }
+ else if (data == TYPE_LINES_Z && (face == Facing::NORTH || face == Facing::SOUTH))
+ {
+ return &ms_pTileData->quartzBlock_iconLinesTop;
+ }
+
+ return &ms_pTileData->quartzBlock_icons[data];
+ }
+
+ if (face == Facing::UP || (face == Facing::DOWN && data == TYPE_CHISELED))
+ {
+ if (data == TYPE_CHISELED)
+ {
+ return &ms_pTileData->quartzBlock_iconChiseledTop;
+ }
+ return &ms_pTileData->quartzBlock_iconTop;
+ }
+ if (face == Facing::DOWN)
+ {
+ return &ms_pTileData->quartzBlock_iconBottom;
+ }
+ if (data < 0 || data >= QUARTZ_BLOCK_TEXTURES) data = 0;
+ return &ms_pTileData->quartzBlock_icons[data];
+ }
+
+ int getRenderShape() { return Tile_SPU::SHAPE_QUARTZ; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RailTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RailTile_SPU.h
new file mode 100644
index 00000000..615ebec9
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RailTile_SPU.h
@@ -0,0 +1,58 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class RailTile_SPU : public Tile_SPU
+{
+
+public:
+ static const int RAIL_DATA_BIT = 8;
+ static const int RAIL_DIRECTION_MASK = 7;
+
+ RailTile_SPU(int id) : Tile_SPU(id) {}
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param
+ {
+ int data = level->getData(x, y, z);
+ if (data >= 2 && data <= 5)
+ {
+ setShape(0, 0, 0, 1, 2 / 16.0f + 0.5f, 1);
+ } else
+ {
+ setShape(0, 0, 0, 1, 2 / 16.0f, 1);
+ }
+ }
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ bool usesDataBit = false;
+ Icon_SPU* iconTurn = &ms_pTileData->railTile_iconTurn;
+ if(id == goldenRail_Id)
+ {
+ usesDataBit = true;
+ iconTurn = &ms_pTileData->railTile_iconTurnGolden;
+ }
+
+ if (usesDataBit)
+ {
+// if (id == Tile::goldenRail_Id)
+// {
+ if ((data & RAIL_DATA_BIT) == 0)
+ {
+ return icon();
+ }
+ else
+ {
+ return iconTurn; // Actually the powered rail on version
+ }
+// }
+ } else if (data >= 6) return iconTurn;
+ return icon();
+
+ }
+ virtual int getRenderShape() { return Tile_SPU::SHAPE_RAIL; }
+ bool isUsesDataBit()
+ {
+ if(id == goldenRail_Id || id == detectorRail_Id)
+ return true;
+ return false;
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RecordPlayerTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RecordPlayerTile_SPU.h
new file mode 100644
index 00000000..9da9af3c
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RecordPlayerTile_SPU.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "EntityTile_SPU.h"
+
+
+class RecordPlayerTile_SPU : public EntityTile_SPU
+{
+public:
+ RecordPlayerTile_SPU(int id) : EntityTile_SPU(id) {}
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ if (face == Facing::UP)
+ {
+ return &ms_pTileData->recordPlayer_iconTop;
+ }
+ return icon();
+ }
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RedStoneDustTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RedStoneDustTile_SPU.h
new file mode 100644
index 00000000..0e461118
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RedStoneDustTile_SPU.h
@@ -0,0 +1,48 @@
+#pragma once
+#include "Tile_SPU.h"
+#include "DiodeTile_SPU.h"
+
+class RedStoneDustTile_SPU : public Tile_SPU
+{
+public:
+ static const int TEXTURE_CROSS = 0;
+ static const int TEXTURE_LINE = 1;
+ static const int TEXTURE_CROSS_OVERLAY = 2;
+ static const int TEXTURE_LINE_OVERLAY = 3;
+
+ RedStoneDustTile_SPU(int id) : Tile_SPU(id) {}
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual bool isCubeShaped() { return false; }
+ virtual int getRenderShape() { return Tile_SPU::SHAPE_RED_DUST; }
+ virtual int getColor() const { return 0x800000; }// 4J Added
+ virtual int getColor(LevelSource *level, int x, int y, int z) { return 0x800000; }
+ virtual int getColor(LevelSource *level, int x, int y, int z, int data) { return 0x800000; } // 4J added
+ static Icon_SPU *getTextureByName(int name)
+ {
+ switch(name)
+ {
+ case TEXTURE_CROSS: return &ms_pTileData->redStoneDust_iconCross;
+ case TEXTURE_LINE: return &ms_pTileData->redStoneDust_iconLine;
+ case TEXTURE_CROSS_OVERLAY: return &ms_pTileData->redStoneDust_iconCrossOver;
+ case TEXTURE_LINE_OVERLAY: return &ms_pTileData->redStoneDust_iconLineOver;
+ }
+ return NULL;
+ }
+
+ static bool shouldConnectTo(ChunkRebuildData *level, int x, int y, int z, int direction)
+ {
+ int t = level->getTile(x, y, z);
+ if (t == Tile_SPU::redStoneDust_Id) return true;
+ if (t == 0) return false;
+ if (t == Tile_SPU::diode_off_Id || t == Tile_SPU::diode_on_Id)
+ {
+ int data = level->getData(x, y, z);
+ return direction == (data & DiodeTile_SPU::DIRECTION_MASK) || direction == Direction::DIRECTION_OPPOSITE[data & DiodeTile_SPU::DIRECTION_MASK];
+ }
+ else if (TileRef_SPU(t)->isSignalSource() && direction != Direction::UNDEFINED) return true;
+
+ return false;
+
+ }
+
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RedlightTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RedlightTile_SPU.h
new file mode 100644
index 00000000..9a584537
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/RedlightTile_SPU.h
@@ -0,0 +1,9 @@
+#pragma once
+
+#include "Tile_SPU.h"
+
+class RedlightTile_SPU : public Tile_SPU
+{
+public:
+ RedlightTile_SPU(int id) : Tile_SPU(id) {}
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ReedTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ReedTile_SPU.h
new file mode 100644
index 00000000..d6a4c89d
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ReedTile_SPU.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include "Tile_SPU.h"
+
+
+class ReedTile_SPU : public Tile_SPU
+{
+public:
+ ReedTile_SPU(int id) : Tile_SPU(id) {}
+
+ bool blocksLight() { return false; }
+ bool isSolidRender(bool isServerLevel = false) { return false; }
+ bool isCubeShaped() { return false; }
+ int getRenderShape() { return Tile_SPU::SHAPE_CROSS_TEXTURE; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SandStoneTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SandStoneTile_SPU.h
new file mode 100644
index 00000000..d0273d99
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SandStoneTile_SPU.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "Tile_SPU.h"
+#include "Facing_SPU.h"
+
+class SandStoneTile_SPU : public Tile_SPU
+{
+public:
+ static const int TYPE_DEFAULT = 0;
+ static const int TYPE_HEIROGLYPHS = 1;
+ static const int TYPE_SMOOTHSIDE = 2;
+
+ // Add this in when we need it
+ //static final String[] SANDSTONE_NAMES = {"default", "chiseled", "smooth"};
+
+private:
+ static const int SANDSTONE_TILE_TEXTURE_COUNT = 3;
+public:
+ SandStoneTile_SPU(int id) : Tile_SPU(id) {}
+
+public:
+ Icon_SPU *getTexture(int face, int data)
+ {
+ if (face == Facing::UP || (face == Facing::DOWN && (data == TYPE_HEIROGLYPHS || data == TYPE_SMOOTHSIDE)))
+ return &ms_pTileData->sandStone_iconTop;
+ if (face == Facing::DOWN)
+ return &ms_pTileData->sandStone_iconBottom;
+ if (data < 0 || data >= SANDSTONE_TILE_TEXTURE_COUNT)
+ data = 0;
+ return &ms_pTileData->sandStone_icons[data];
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Sapling_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Sapling_SPU.h
new file mode 100644
index 00000000..7e594b28
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Sapling_SPU.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include "Bush_SPU.h"
+
+class Random;
+
+class Sapling_SPU : public Bush_SPU
+{
+ static const int TYPE_MASK = 3;
+
+public:
+ Sapling_SPU(int id) : Bush_SPU(id) {}
+ Icon_SPU *getTexture(int face, int data) { data = data & TYPE_MASK; return &ms_pTileData->sapling_icons[data]; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SignTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SignTile_SPU.h
new file mode 100644
index 00000000..7fe54d99
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SignTile_SPU.h
@@ -0,0 +1,38 @@
+#pragma once
+
+#include "EntityTile_SPU.h"
+
+
+class SignTile_SPU : public EntityTile_SPU
+{
+public:
+ SignTile_SPU(int id) : EntityTile_SPU(id) {}
+ bool onGround()
+ {
+ if(id == wallSign_Id)
+ return false;
+ // sign_Id
+ return true;
+ }
+
+ Icon_SPU *getTexture(int face, int data){ return TileRef_SPU(wood_Id)->getTexture(face); }
+ void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param
+ {
+ if (onGround()) return;
+ int face = level->getData(x, y, z);
+ float h0 = (4 + 0.5f) / 16.0f;
+ float h1 = (12 + 0.5f) / 16.0f;
+ float w0 = 0 / 16.0f;
+ float w1 = 16 / 16.0f;
+ float d0 = 2 / 16.0f;
+ setShape(0, 0, 0, 1, 1, 1);
+ if (face == 2) setShape(w0, h0, 1 - d0, w1, h1, 1);
+ if (face == 3) setShape(w0, h0, 0, w1, h1, d0);
+ if (face == 4) setShape(1 - d0, h0, w0, 1, h1, w1);
+ if (face == 5) setShape(0, h0, w0, d0, h1, w1);
+ }
+
+ int getRenderShape() { return Tile_SPU::SHAPE_INVISIBLE; }
+ bool isCubeShaped() { return false; }
+ bool isSolidRender(bool isServerLevel = false) { return false; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SkullTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SkullTile_SPU.h
new file mode 100644
index 00000000..da207639
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SkullTile_SPU.h
@@ -0,0 +1,47 @@
+#pragma once
+
+#include "Tile_SPU.h"
+#include "EntityTile_SPU.h"
+
+
+class SkullTile_SPU : public EntityTile_SPU
+{
+public:
+ static const int MAX_SKULL_TILES = 40;
+public:
+ static const int PLACEMENT_MASK = 0x7;
+ static const int NO_DROP_BIT = 0x8;
+
+ SkullTile_SPU(int id) : EntityTile_SPU(id) {}
+
+public:
+ int getRenderShape() { return SHAPE_INVISIBLE; }
+ bool isSolidRender(bool isServerLevel = false) { return false; }
+ bool isCubeShaped() { return false; }
+ void updateShape(ChunkRebuildData *level, int x, int y, int z)
+ {
+ int data = level->getData(x, y, z) & PLACEMENT_MASK;
+
+ switch (data)
+ {
+ default:
+ case Facing::UP:
+ setShape(4.0f / 16.0f, 0, 4.0f / 16.0f, 12.0f / 16.0f, .5f, 12.0f / 16.0f);
+ break;
+ case Facing::NORTH:
+ setShape(4.0f / 16.0f, 4.0f / 16.0f, .5f, 12.0f / 16.0f, 12.0f / 16.0f, 1);
+ break;
+ case Facing::SOUTH:
+ setShape(4.0f / 16.0f, 4.0f / 16.0f, 0, 12.0f / 16.0f, 12.0f / 16.0f, .5f);
+ break;
+ case Facing::WEST:
+ setShape(.5f, 4.0f / 16.0f, 4.0f / 16.0f, 1, 12.0f / 16.0f, 12.0f / 16.0f);
+ break;
+ case Facing::EAST:
+ setShape(0, 4.0f / 16.0f, 4.0f / 16.0f, .5f, 12.0f / 16.0f, 12.0f / 16.0f);
+ break;
+ }
+ }
+
+ Icon_SPU *getTexture(int face, int data) { return TileRef_SPU(hellSand_Id)->getTexture(face); }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SmoothStoneBrickTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SmoothStoneBrickTile_SPU.h
new file mode 100644
index 00000000..b64ab28f
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/SmoothStoneBrickTile_SPU.h
@@ -0,0 +1,25 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class SmoothStoneBrickTile_SPU : public Tile_SPU
+{
+public:
+ static const int TYPE_DEFAULT = 0;
+ static const int TYPE_MOSSY = 1;
+ static const int TYPE_CRACKED = 2;
+ static const int TYPE_DETAIL = 3;
+
+ static const int SMOOTH_STONE_BRICK_NAMES_LENGTH = 4;
+
+
+public:
+
+ SmoothStoneBrickTile_SPU(int id) : Tile_SPU(id) {}
+
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ if (data < 0 || data >= SMOOTH_STONE_BRICK_NAMES_LENGTH) data = 0;
+ return &ms_pTileData->smoothStoneBrick_icons[data];
+ }
+
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StairTile_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StairTile_SPU.cpp
new file mode 100644
index 00000000..5bdbdf4a
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StairTile_SPU.cpp
@@ -0,0 +1,292 @@
+#include "stdafx.h"
+#include "StairTile_SPU.h"
+#include "ChunkRebuildData.h"
+
+
+void StairTile_SPU::updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData, TileEntity* forceEntity) // 4J added forceData, forceEntity param
+{
+ setShape(0, 0, 0, 1, 1, 1);
+}
+
+bool StairTile_SPU::isSolidRender(bool isServerLevel)
+{
+ return false;
+}
+
+int StairTile_SPU::getRenderShape()
+{
+ return Tile_SPU::SHAPE_STAIRS;
+}
+
+void StairTile_SPU::setBaseShape(ChunkRebuildData *level, int x, int y, int z)
+{
+ int data = level->getData(x, y, z);
+
+ if ((data & UPSIDEDOWN_BIT) != 0)
+ {
+ setShape(0, .5f, 0, 1, 1, 1);
+ }
+ else
+ {
+ setShape(0, 0, 0, 1, .5f, 1);
+ }
+}
+
+bool StairTile_SPU::isStairs(int id)
+{
+ switch(id)
+ {
+ case Tile_SPU::stairs_wood_Id:
+ case Tile_SPU::stairs_stone_Id:
+ case Tile_SPU::stairs_bricks_Id:
+ case Tile_SPU::stairs_stoneBrickSmooth_Id:
+ case Tile_SPU::stairs_netherBricks_Id:
+ case Tile_SPU::stairs_sandstone_Id:
+ case Tile_SPU::stairs_sprucewood_Id:
+ case Tile_SPU::stairs_birchwood_Id:
+ return true;
+ default:
+ return false;
+ }
+ return false;
+}
+
+bool StairTile_SPU::isLockAttached(ChunkRebuildData *level, int x, int y, int z, int data)
+{
+ int lockTile = level->getTile(x, y, z);
+ if (isStairs(lockTile) && level->getData(x, y, z) == data)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+bool StairTile_SPU::setStepShape(ChunkRebuildData *level, int x, int y, int z)
+{
+ int data = level->getData(x, y, z);
+ int dir = data & 0x3;
+
+ float bottom = 0.5f;
+ float top = 1.0f;
+
+ if ((data & UPSIDEDOWN_BIT) != 0)
+ {
+ bottom = 0;
+ top = .5f;
+ }
+
+ float west = 0;
+ float east = 1;
+ float north = 0;
+ float south = .5f;
+
+ bool checkInnerPiece = true;
+
+ if (dir == DIR_EAST)
+ {
+ west = .5f;
+ south = 1;
+
+ int backTile = level->getTile(x + 1, y, z);
+ int backData = level->getData(x + 1, y, z);
+ if (isStairs(backTile) && ((data & UPSIDEDOWN_BIT) == (backData & UPSIDEDOWN_BIT)))
+ {
+ int backDir = backData & 0x3;
+ if (backDir == DIR_NORTH && !isLockAttached(level, x, y, z + 1, data))
+ {
+ south = .5f;
+ checkInnerPiece = false;
+ }
+ else if (backDir == DIR_SOUTH && !isLockAttached(level, x, y, z - 1, data))
+ {
+ north = .5f;
+ checkInnerPiece = false;
+ }
+ }
+ }
+ else if (dir == DIR_WEST)
+ {
+ east = .5f;
+ south = 1;
+
+ int backTile = level->getTile(x - 1, y, z);
+ int backData = level->getData(x - 1, y, z);
+ if (isStairs(backTile) && ((data & UPSIDEDOWN_BIT) == (backData & UPSIDEDOWN_BIT)))
+ {
+ int backDir = backData & 0x3;
+ if (backDir == DIR_NORTH && !isLockAttached(level, x, y, z + 1, data))
+ {
+ south = .5f;
+ checkInnerPiece = false;
+ }
+ else if (backDir == DIR_SOUTH && !isLockAttached(level, x, y, z - 1, data))
+ {
+ north = .5f;
+ checkInnerPiece = false;
+ }
+ }
+ }
+ else if (dir == DIR_SOUTH)
+ {
+ north = .5f;
+ south = 1;
+
+ int backTile = level->getTile(x, y, z + 1);
+ int backData = level->getData(x, y, z + 1);
+ if (isStairs(backTile) && ((data & UPSIDEDOWN_BIT) == (backData & UPSIDEDOWN_BIT)))
+ {
+ int backDir = backData & 0x3;
+ if (backDir == DIR_WEST && !isLockAttached(level, x + 1, y, z, data))
+ {
+ east = .5f;
+ checkInnerPiece = false;
+ }
+ else if (backDir == DIR_EAST && !isLockAttached(level, x - 1, y, z, data))
+ {
+ west = .5f;
+ checkInnerPiece = false;
+ }
+ }
+ }
+ else if (dir == DIR_NORTH)
+ {
+ int backTile = level->getTile(x, y, z - 1);
+ int backData = level->getData(x, y, z - 1);
+ if (isStairs(backTile) && ((data & UPSIDEDOWN_BIT) == (backData & UPSIDEDOWN_BIT)))
+ {
+ int backDir = backData & 0x3;
+ if (backDir == DIR_WEST && !isLockAttached(level, x + 1, y, z, data))
+ {
+ east = .5f;
+ checkInnerPiece = false;
+ }
+ else if (backDir == DIR_EAST && !isLockAttached(level, x - 1, y, z, data))
+ {
+ west = .5f;
+ checkInnerPiece = false;
+ }
+ }
+ }
+
+ setShape(west, bottom, north, east, top, south);
+ return checkInnerPiece;
+}
+
+/*
+* This method adds an extra 1/8 block if the stairs can attach as an
+* "inner corner."
+*/
+bool StairTile_SPU::setInnerPieceShape(ChunkRebuildData *level, int x, int y, int z)
+{
+ int data = level->getData(x, y, z);
+ int dir = data & 0x3;
+
+ float bottom = 0.5f;
+ float top = 1.0f;
+
+ if ((data & UPSIDEDOWN_BIT) != 0)
+ {
+ bottom = 0;
+ top = .5f;
+ }
+
+ float west = 0;
+ float east = .5f;
+ float north = .5f;
+ float south = 1.0f;
+
+ bool hasInnerPiece = false;
+
+ if (dir == DIR_EAST)
+ {
+ int frontTile = level->getTile(x - 1, y, z);
+ int frontData = level->getData(x - 1, y, z);
+ if (isStairs(frontTile) && ((data & UPSIDEDOWN_BIT) == (frontData & UPSIDEDOWN_BIT)))
+ {
+ int frontDir = frontData & 0x3;
+ if (frontDir == DIR_NORTH && !isLockAttached(level, x, y, z - 1, data))
+ {
+ north = 0;
+ south = .5f;
+ hasInnerPiece = true;
+ }
+ else if (frontDir == DIR_SOUTH && !isLockAttached(level, x, y, z + 1, data))
+ {
+ north = .5f;
+ south = 1;
+ hasInnerPiece = true;
+ }
+ }
+ }
+ else if (dir == DIR_WEST)
+ {
+ int frontTile = level->getTile(x + 1, y, z);
+ int frontData = level->getData(x + 1, y, z);
+ if (isStairs(frontTile) && ((data & UPSIDEDOWN_BIT) == (frontData & UPSIDEDOWN_BIT)))
+ {
+ west = .5f;
+ east = 1.0f;
+ int frontDir = frontData & 0x3;
+ if (frontDir == DIR_NORTH && !isLockAttached(level, x, y, z - 1, data))
+ {
+ north = 0;
+ south = .5f;
+ hasInnerPiece = true;
+ }
+ else if (frontDir == DIR_SOUTH && !isLockAttached(level, x, y, z + 1, data))
+ {
+ north = .5f;
+ south = 1;
+ hasInnerPiece = true;
+ }
+ }
+ }
+ else if (dir == DIR_SOUTH)
+ {
+ int frontTile = level->getTile(x, y, z - 1);
+ int frontData = level->getData(x, y, z - 1);
+ if (isStairs(frontTile) && ((data & UPSIDEDOWN_BIT) == (frontData & UPSIDEDOWN_BIT)))
+ {
+ north = 0;
+ south = .5f;
+
+ int frontDir = frontData & 0x3;
+ if (frontDir == DIR_WEST && !isLockAttached(level, x - 1, y, z, data))
+ {
+ hasInnerPiece = true;
+ }
+ else if (frontDir == DIR_EAST && !isLockAttached(level, x + 1, y, z, data))
+ {
+ west = .5f;
+ east = 1.0f;
+ hasInnerPiece = true;
+ }
+ }
+ }
+ else if (dir == DIR_NORTH)
+ {
+ int frontTile = level->getTile(x, y, z + 1);
+ int frontData = level->getData(x, y, z + 1);
+ if (isStairs(frontTile) && ((data & UPSIDEDOWN_BIT) == (frontData & UPSIDEDOWN_BIT)))
+ {
+ int frontDir = frontData & 0x3;
+ if (frontDir == DIR_WEST && !isLockAttached(level, x - 1, y, z, data))
+ {
+ hasInnerPiece = true;
+ }
+ else if (frontDir == DIR_EAST && !isLockAttached(level, x + 1, y, z, data))
+ {
+ west = .5f;
+ east = 1.0f;
+ hasInnerPiece = true;
+ }
+ }
+ }
+
+ if (hasInnerPiece)
+ {
+ setShape(west, bottom, north, east, top, south);
+ }
+ return hasInnerPiece;
+}
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StairTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StairTile_SPU.h
new file mode 100644
index 00000000..eefa36b2
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StairTile_SPU.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include "Tile_SPU.h"
+
+class StairTile_SPU : public Tile_SPU
+{
+public:
+ static const int UPSIDEDOWN_BIT = 4;
+
+ // the direction is the way going up (for normal non-upsidedown stairs)
+ static const int DIR_EAST = 0;
+ static const int DIR_WEST = 1;
+ static const int DIR_SOUTH = 2;
+ static const int DIR_NORTH = 3;
+
+public:
+ StairTile_SPU(int id) : Tile_SPU(id) {}
+ void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL); // 4J added forceData, forceEntity param
+ bool isSolidRender(bool isServerLevel = false);
+ int getRenderShape();
+ void setBaseShape(ChunkRebuildData *level, int x, int y, int z);
+ static bool isStairs(int id);
+
+private:
+ bool isLockAttached(ChunkRebuildData *level, int x, int y, int z, int data);
+
+public:
+ bool setStepShape(ChunkRebuildData *level, int x, int y, int z);
+ bool setInnerPieceShape(ChunkRebuildData *level, int x, int y, int z);
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StemTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StemTile_SPU.h
new file mode 100644
index 00000000..89cd3739
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StemTile_SPU.h
@@ -0,0 +1,62 @@
+#pragma once
+#include "Bush_SPU.h"
+
+class StemTile_SPU : public Bush_SPU
+{
+private:
+public:
+ StemTile_SPU(int id) : Bush_SPU(id) {}
+
+public:
+ int getColor(int data) const
+ {
+ //int r = data * 32;
+ //int g = 255 - data * 8;
+ //int b = data * 4;
+ //return r << 16 | g << 8 | b;
+
+ int colour = 0;
+
+ unsigned int minColour = ms_pTileData->stemTile_minColour;
+ unsigned int maxColour = ms_pTileData->stemTile_maxColour;
+
+ byte redComponent = ((minColour>>16)&0xFF) + (( (maxColour>>16)&0xFF - (minColour>>16)&0xFF)*( data/7.0f));
+ byte greenComponent = ((minColour>>8)&0xFF) + (( (maxColour>>8)&0xFF - (minColour>>8)&0xFF)*( data/7.0f));
+ byte blueComponent = ((minColour)&0xFF) + (( (maxColour)&0xFF - (minColour)&0xFF)*( data/7.0f));
+
+ colour = redComponent<<16 | greenComponent<<8 | blueComponent;
+ return colour;
+ }
+
+ virtual int getColor(ChunkRebuildData *level, int x, int y, int z) { return getColor(level->getData(x, y, z)); }
+ virtual void updateDefaultShape()
+ {
+ float ss = 0.125f;
+ this->setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, 0.25f, 0.5f + ss);
+ }
+
+ virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param
+ {
+ ms_pTileData->yy1[id] = (level->getData(x, y, z) * 2 + 2) / 16.0f;
+ float ss = 0.125f;
+ this->setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, (float) ms_pTileData->yy1[id], 0.5f + ss);
+ }
+
+ int getConnectDir(ChunkRebuildData *level, int x, int y, int z)
+ {
+ int fruitID = pumpkin_Id;
+ if(id == melonStem_Id)
+ fruitID = melon_Id;
+
+ int d = level->getData(x, y, z);
+ if (d < 7) return -1;
+ if (level->getTile(x - 1, y, z) == fruitID) return 0;
+ if (level->getTile(x + 1, y, z) == fruitID) return 1;
+ if (level->getTile(x, y, z - 1) == fruitID) return 2;
+ if (level->getTile(x, y, z + 1) == fruitID) return 3;
+ return -1;
+ }
+
+ virtual int getRenderShape() { return Tile_SPU::SHAPE_STEM; }
+ Icon_SPU *getAngledTexture() { return &ms_pTileData->stemTile_iconAngled; }
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StoneMonsterTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StoneMonsterTile_SPU.h
new file mode 100644
index 00000000..75675eda
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StoneMonsterTile_SPU.h
@@ -0,0 +1,32 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class Random;
+
+class StoneMonsterTile_SPU : public Tile_SPU
+{
+public:
+ static const int HOST_ROCK = 0;
+ static const int HOST_COBBLE = 1;
+ static const int HOST_STONEBRICK = 2;
+
+ static const int STONE_MONSTER_NAMES_LENGTH = 3;
+
+ // 4J Stu - I don't know why this is protected in Java
+//protected:
+public:
+ StoneMonsterTile_SPU(int id) : Tile_SPU(id) {}
+public:
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ if (data == HOST_COBBLE)
+ {
+ return TileRef_SPU(stoneBrick_Id)->getTexture(face);
+ }
+ if (data == HOST_STONEBRICK)
+ {
+ return TileRef_SPU(stoneBrickSmooth_Id)->getTexture(face);
+ }
+ return TileRef_SPU(rock_Id)->getTexture(face);
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StoneSlabTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StoneSlabTile_SPU.h
new file mode 100644
index 00000000..1c0b2799
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/StoneSlabTile_SPU.h
@@ -0,0 +1,60 @@
+#pragma once
+
+#include "HalfSlabTile_SPU.h"
+#include "Facing_SPU.h"
+
+class StoneSlabTile_SPU : public HalfSlabTile_SPU
+{
+public:
+ static const int STONE_SLAB = 0;
+ static const int SAND_SLAB = 1;
+ static const int WOOD_SLAB = 2;
+ static const int COBBLESTONE_SLAB = 3;
+ static const int BRICK_SLAB = 4;
+ static const int SMOOTHBRICK_SLAB = 5;
+ static const int NETHERBRICK_SLAB = 6;
+ static const int QUARTZ_SLAB = 7;
+
+ static const int SLAB_NAMES_LENGTH = 8;
+
+
+
+public:
+ StoneSlabTile_SPU(int id) : HalfSlabTile_SPU(id) {}
+
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ int type = data & TYPE_MASK;
+ if (fullSize() && (data & TOP_SLOT_BIT) != 0)
+ {
+ face = Facing::UP;
+ }
+ switch(type)
+ {
+ case STONE_SLAB:
+ if (face == Facing::UP || face == Facing::DOWN)
+ return icon();
+ return &ms_pTileData->stoneSlab_iconSide;
+ break;
+ case SAND_SLAB:
+ return TileRef_SPU(sandStone_Id)->getTexture(face); //Tile::sandStone->getTexture(face);
+ case WOOD_SLAB:
+ return TileRef_SPU(wood_Id)->getTexture(face); //Tile::wood->getTexture(face);
+ case COBBLESTONE_SLAB:
+ return TileRef_SPU(stoneBrick_Id)->getTexture(face); //Tile::stoneBrick->getTexture(face);
+ case BRICK_SLAB:
+ return TileRef_SPU(redBrick_Id)->getTexture(face); //Tile::redBrick->getTexture(face);
+ case SMOOTHBRICK_SLAB:
+ return TileRef_SPU(stoneBrickSmooth_Id)->getTexture(face); //Tile::stoneBrickSmooth->getTexture(face, SmoothStoneBrickTile::TYPE_DEFAULT);
+ case NETHERBRICK_SLAB:
+ return TileRef_SPU(netherBrick_Id)->getTexture(Facing::UP); //Tile::netherBrick->getTexture(Facing::UP);
+ case QUARTZ_SLAB:
+ return TileRef_SPU(quartzBlock_Id)->getTexture(face); //Tile::quartzBlock->getTexture(face);
+
+ }
+
+ return icon();
+ }
+
+
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TallGrass_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TallGrass_SPU.cpp
new file mode 100644
index 00000000..cf849e99
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TallGrass_SPU.cpp
@@ -0,0 +1,35 @@
+#include "stdafx.h"
+#include "TallGrass_SPU.h"
+#include "ChunkRebuildData.h"
+
+// const unsigned int TallGrass_SPU::TALL_GRASS_TILE_NAMES[TALL_GRASS_TILE_NAMES_LENGTH] = { IDS_TILE_SHRUB,
+// IDS_TILE_GRASS,
+// IDS_TILE_FERN,
+// };
+
+const int TallGrass_SPU::DEAD_SHRUB = 0;
+const int TallGrass_SPU::TALL_GRASS = 1;
+const int TallGrass_SPU::FERN = 2;
+
+// const wstring TallGrass::TEXTURE_NAMES[] = {L"deadbush", L"tallgrass", L"fern"};
+
+
+Icon_SPU *TallGrass_SPU::getTexture(int face, int data)
+{
+ if (data >= TALL_GRASS_TILE_NAMES_LENGTH) data = 0;
+ return &ms_pTileData->tallGrass_Icons[data];
+}
+
+int TallGrass_SPU::getColor(ChunkRebuildData *level, int x, int y, int z )
+{
+ return getColor( level, x, y, z, level->getData(x, y, z) );
+}
+
+// 4J - changed interface to have data passed in, and put existing interface as wrapper above
+int TallGrass_SPU::getColor(ChunkRebuildData *level, int x, int y, int z, int data)
+{
+ int d = data;
+ if (d == DEAD_SHRUB) return 0xffffff;
+
+ return level->getGrassColor(x, z);
+}
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TallGrass_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TallGrass_SPU.h
new file mode 100644
index 00000000..14bbf357
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TallGrass_SPU.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "Bush_SPU.h"
+
+class TallGrass_SPU : public Bush_SPU
+{
+public:
+ static const int DEAD_SHRUB;
+ static const int TALL_GRASS;
+ static const int FERN;
+
+ static const int TALL_GRASS_TILE_NAMES_LENGTH = 3;
+
+// static const unsigned int TALL_GRASS_TILE_NAMES[TALL_GRASS_TILE_NAMES_LENGTH];
+
+
+ TallGrass_SPU(int id) : Bush_SPU(id) {}
+
+ virtual Icon_SPU *getTexture(int face, int data);
+ virtual int getColor(ChunkRebuildData *level, int x, int y, int z);
+ virtual int getColor(ChunkRebuildData *level, int x, int y, int z, int data); // 4J added
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp
new file mode 100644
index 00000000..3d1007af
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.cpp
@@ -0,0 +1,796 @@
+#include "stdafx.h"
+
+
+#ifdef SN_TARGET_PS3_SPU
+#include <stdint.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <spu_intrinsics.h>
+#include <cell/spurs.h>
+#include <cell/dma.h>
+#include <math.h>
+#include "..\Common\spu_assert.h"
+#endif // SN_TARGET_PS3_SPU
+
+#include "Tesselator_SPU.h"
+
+static const bool sc_verbose = false;
+// #include "..\Minecraft.World\BasicTypeContainers.h"
+// #include "..\Minecraft.World\FloatBuffer.h"
+// #include "..\Minecraft.World\IntBuffer.h"
+// #include "..\Minecraft.World\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;
+
+#endif
+
+bool Tesselator_SPU::TRIANGLE_MODE = false;
+// bool Tesselator_SPU::USE_VBO = false;
+
+/* Things to check we are intialising in the constructor...
+
+
+
+double u, v;
+int col;
+int mode;
+double xo, yo, zo;
+int normal;
+
+
+
+
+
+
+*/
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// 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;
+// 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;
+
+// 255 is the max exponent biased value
+const unsigned int FLOAT_MAX_BIASED_EXP = (0xFF << 23);
+
+const unsigned int HALF_FLOAT_MAX_BIASED_EXP = (0x1F << 10);
+
+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;
+
+ // 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);
+
+ 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;
+}
+
+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;
+ }
+
+ 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);
+}
+
+// void Tesselator_SPU::CreateNewThreadStorage(int bytes)
+// {
+// Tesselator_SPU *instance = new Tesselator_SPU(bytes/4);
+// 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::clear()
+{
+ vertices = 0;
+
+ p = 0;
+ count = 0;
+}
+
+void Tesselator_SPU::begin()
+{
+ begin(GL_QUADS);
+ bounds.reset();
+}
+
+void Tesselator_SPU::useProjectedTexture(bool enable)
+{
+ useProjectedTexturePixelShader = enable;
+}
+
+void Tesselator_SPU::useCompactVertices(bool enable)
+{
+ useCompactFormat360 = enable;
+}
+
+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();
+ this->mode = mode;
+ hasNormal = false;
+ hasColor = false;
+ hasTexture = false;
+ hasTexture2 = false;
+ _noColor = false;
+}
+
+void Tesselator_SPU::tex(float u, float v)
+{
+ hasTexture = true;
+ this->u = u;
+ this->v = v;
+}
+
+void Tesselator_SPU::tex2(int tex2)
+{
+ hasTexture2 = true;
+ 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, 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, int a)
+{
+ if (_noColor) return;
+
+ if (r > 255) r = 255;
+ if (g > 255) g = 255;
+ if (b > 255) b = 255;
+ if (a > 255) a = 255;
+ if (r < 0) r = 0;
+ if (g < 0) g = 0;
+ if (b < 0) b = 0;
+ if (a < 0) a = 0;
+
+ hasColor = true;
+ // 4J - removed little-endian option
+ col = (r << 24) | (g << 16) | (b << 8) | (a);
+}
+
+void Tesselator_SPU::color(byte r, byte g, byte b)
+{
+ color(r & 0xff, g & 0xff, b & 0xff);
+}
+
+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):
+//
+// 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
+// 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
+//
+// 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)
+// 0000 0000 uuuu vvvv (vertex 2)
+// 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 );
+
+ // 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 = 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;
+ }
+ }
+
+ 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 );
+
+ 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
+
+ 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++;
+
+ // 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;
+
+#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
+
+ 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
+
+ ipackedcol -= 32768; // -32768 to 32767 range
+ ipackedcol &= 0xffff;
+
+ 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;
+
+ // 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);
+#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);
+#endif
+
+#endif
+
+ 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
+#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
+#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];
+ }
+
+ _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);
+ }
+ }
+
+ 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 );
+#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;
+#else
+ _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;
+ }
+
+ 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;
+ }
+ }
+}
+
+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)
+{
+ 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::normal(float x, float y, float z)
+{
+ hasNormal = true;
+ byte xx = (byte) (x * 127);
+ byte yy = (byte) (y * 127);
+ byte zz = (byte) (z * 127);
+
+ _normal = (xx & 0xff) | ((yy & 0xff) << 8) | ((zz & 0xff) << 16);
+}
+
+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)
+{
+ xo += x;
+ yo += y;
+ zo += z;
+}
+
+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);
+
+// int copySize = (p-4096);
+// for(int i=0;i<copySize;i++)
+// _array->data[i] = _array->data[4096+i];
+ //p -= 4096;
+ p=0;
+ m_PPUOffset += dmaSize;//16384;
+ }
+#endif // SN_TARGET_PS3_SPU
+}
+
+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;
+#endif
+}
+
+void Tesselator_SPU::beginData()
+{
+ p = 0;
+}
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.h
new file mode 100644
index 00000000..66e8424e
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tesselator_SPU.h
@@ -0,0 +1,167 @@
+#pragma once
+
+#ifdef __PS3__
+#ifdef SN_TARGET_PS3_SPU
+typedef unsigned int DWORD;
+typedef unsigned char byte;
+#include <float.h>
+#else
+#include "..\..\..\stdafx.h"
+class ChunkRebuildData;
+#endif
+#endif
+class intArray_SPU
+{
+public:
+ unsigned int* data;
+
+ intArray_SPU(unsigned int* preAllocData) { data = preAllocData; }
+ ~intArray_SPU(){ }
+};
+
+class ChunkRebuildData;
+
+class Tesselator_SPU
+{
+#ifndef SN_TARGET_PS3_SPU
+ friend ChunkRebuildData;
+#endif
+ // private static boolean TRIANGLE_MODE = false;
+public:
+ static bool TRIANGLE_MODE;
+ static bool USE_VBO;
+
+ static const int MAX_MEMORY_USE = 16 * 1024 * 1024;
+ static const int MAX_FLOATS = MAX_MEMORY_USE / 4 / 2;
+
+ void* m_PPUArray;
+ int m_PPUOffset;
+public:
+ intArray_SPU* _array;
+private:
+ int vertices;
+ float u, v;
+ int _tex2;
+ int col;
+ bool hasColor;
+ bool hasTexture;
+ bool hasTexture2;
+ bool hasNormal;
+ int p ;
+ bool useCompactFormat360; // 4J - added
+ bool useProjectedTexturePixelShader; // 4J - added
+public:
+ int count;
+private:
+ bool _noColor;
+ int mode;
+ float xo, yo, zo;
+ int _normal;
+
+ // 4J - added for thread local storage
+public:
+// static void CreateNewThreadStorage(int bytes);
+private:
+// static DWORD tlsIdx;
+public:
+ static Tesselator_SPU *getInstance();
+
+private:
+ bool tesselating;
+ bool mipmapEnable; // 4J added
+
+ bool vboMode;
+// IntBuffer *vboIds;
+ int vboId;
+ int vboCounts;
+ int size;
+
+public:
+ Tesselator_SPU() {}
+ void end();
+private:
+ void clear();
+
+ // 4J - added to handle compact quad vertex format, which need packaged up as quads
+ unsigned int m_ix[4],m_iy[4],m_iz[4];
+ unsigned int m_clr[4];
+ unsigned int m_u[4], m_v[4];
+ unsigned int m_t2[4];
+ void packCompactQuad();
+ void incData(int numInts);
+public:
+
+ class Bounds
+ {
+ public:
+ void reset()
+ {
+ boundingBox[0] = FLT_MAX;
+ boundingBox[1] = FLT_MAX;
+ boundingBox[2] = FLT_MAX;
+ boundingBox[3] = -FLT_MAX;
+ boundingBox[4] = -FLT_MAX;
+ boundingBox[5] = -FLT_MAX;
+ }
+ void addVert(float x, float y, float z)
+ {
+ if(x < boundingBox[0])
+ boundingBox[0] = x;
+ if(y < boundingBox[1])
+ boundingBox[1] = y;
+ if(z < boundingBox[2])
+ boundingBox[2] = z;
+
+ if(x > boundingBox[3])
+ boundingBox[3] = x;
+ if(y > boundingBox[4])
+ boundingBox[4] = y;
+ if(z > boundingBox[5])
+ boundingBox[5] = z;
+ }
+ void addBounds(Bounds& ob)
+ {
+ if(ob.boundingBox[0] < boundingBox[0])
+ boundingBox[0] = ob.boundingBox[0];
+ if(ob.boundingBox[1] < boundingBox[1])
+ boundingBox[1] = ob.boundingBox[1];
+ if(ob.boundingBox[2] < boundingBox[2])
+ boundingBox[2] = ob.boundingBox[2];
+
+ if(ob.boundingBox[3] > boundingBox[3])
+ boundingBox[3] = ob.boundingBox[3];
+ if(ob.boundingBox[4] > boundingBox[4])
+ boundingBox[4] = ob.boundingBox[4];
+ if(ob.boundingBox[5] > boundingBox[5])
+ boundingBox[5] = ob.boundingBox[5];
+ }
+ float boundingBox[6]; // 4J MGH added
+
+ } bounds;
+
+
+
+ void beginData();
+ void endData();
+
+ void begin();
+ void begin(int mode);
+ void useCompactVertices(bool enable); // 4J added
+ void useProjectedTexture(bool enable); // 4J added
+ void tex(float u, float v);
+ void tex2(int tex2); // 4J - change brought forward from 1.8.2
+ void color(float r, float g, float b);
+ void color(float r, float g, float b, float a);
+ void color(int r, int g, int b);
+ void color(int r, int g, int b, int a);
+ void color(byte r, byte g, byte b);
+ void vertexUV(float x, float y, float z, float u, float v);
+ void vertex(float x, float y, float z);
+ void color(int c);
+ void color(int c, int alpha);
+ void noColor();
+ void normal(float x, float y, float z);
+ void offset(float xo, float yo, float zo);
+ void addOffset(float x, float y, float z);
+ bool setMipmapEnable(bool enable); // 4J added
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TheEndPortalFrameTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TheEndPortalFrameTile_SPU.h
new file mode 100644
index 00000000..8aab31a3
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TheEndPortalFrameTile_SPU.h
@@ -0,0 +1,12 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class TheEndPortalFrameTile_SPU : public Tile_SPU
+{
+public:
+ TheEndPortalFrameTile_SPU(int id) : Tile_SPU(id) {}
+ virtual Icon_SPU *getTexture(int face, int data) { return NULL; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual int getRenderShape() { return SHAPE_PORTAL_FRAME; }
+// virtual void updateDefaultShape();
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TheEndPortal_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TheEndPortal_SPU.h
new file mode 100644
index 00000000..f6e3b3e7
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TheEndPortal_SPU.h
@@ -0,0 +1,17 @@
+#pragma once
+#include "EntityTile_SPU.h"
+
+class TheEndPortal_SPU : public EntityTile_SPU
+{
+public:
+ TheEndPortal_SPU(int id) : EntityTile_SPU(id) {}
+
+// virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, shared_ptr<TileEntity> forceEntity = shared_ptr<TileEntity>()); // 4J added forceData, forceEntity param
+ virtual bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face)
+ {
+ if (face != 0) return false;
+ return EntityTile_SPU::shouldRenderFace(level, x, y, z, face);
+ }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual int getRenderShape() { return SHAPE_INVISIBLE; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.cpp
new file mode 100644
index 00000000..20393f6e
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.cpp
@@ -0,0 +1,83 @@
+#include "stdafx.h"
+#include "ThinFenceTile_SPU.h"
+#include "ChunkRebuildData.h"
+
+bool ThinFenceTile_SPU::isSolidRender(bool isServerLevel)
+{
+ return false;
+}
+
+int ThinFenceTile_SPU::getRenderShape()
+{
+ return Tile_SPU::SHAPE_IRON_FENCE;
+}
+
+bool ThinFenceTile_SPU::shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face)
+{
+ int id = level->getTile(x, y, z);
+ if (id == this->id) return false;
+ return Tile_SPU::shouldRenderFace(level, x, y, z, face);
+}
+
+void ThinFenceTile_SPU::updateDefaultShape()
+{
+ setShape(0, 0, 0, 1, 1, 1);
+}
+
+void ThinFenceTile_SPU::updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData, TileEntity* forceEntity) // 4J added forceData, forceEntity param
+{
+ float minX = 7.0f / 16.0f;
+ float maxX = 9.0f / 16.0f;
+ float minZ = 7.0f / 16.0f;
+ float maxZ = 9.0f / 16.0f;
+
+ bool n = attachsTo(level->getTile(x, y, z - 1));
+ bool s = attachsTo(level->getTile(x, y, z + 1));
+ bool w = attachsTo(level->getTile(x - 1, y, z));
+ bool e = attachsTo(level->getTile(x + 1, y, z));
+
+ if ((w && e) || (!w && !e && !n && !s))
+ {
+ minX = 0;
+ maxX = 1;
+ }
+ else if (w && !e)
+ {
+ minX = 0;
+ }
+ else if (!w && e)
+ {
+ maxX = 1;
+ }
+ if ((n && s) || (!w && !e && !n && !s))
+ {
+ minZ = 0;
+ maxZ = 1;
+ }
+ else if (n && !s)
+ {
+ minZ = 0;
+ }
+ else if (!n && s)
+ {
+ maxZ = 1;
+ }
+ setShape(minX, 0, minZ, maxX, 1, maxZ);
+}
+
+Icon_SPU *ThinFenceTile_SPU::getEdgeTexture()
+{
+ if(id == Tile_SPU::ironFence_Id)
+ return &ms_pTileData->ironFence_EdgeTexture;
+ if(id == Tile_SPU::thinGlass_Id)
+ return &ms_pTileData->thinGlass_EdgeTexture;
+#ifndef SN_TARGET_PS3_SPU
+ assert(0);
+#endif
+ return NULL;
+}
+
+bool ThinFenceTile_SPU::attachsTo(int tile)
+{
+ return ms_pTileData->solid[tile] || tile == id || tile == Tile_SPU::glass_Id;
+}
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.h
new file mode 100644
index 00000000..61c39201
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.h
@@ -0,0 +1,17 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class ThinFenceTile_SPU : public Tile_SPU
+{
+
+public:
+ ThinFenceTile_SPU(int id) : Tile_SPU(id) {}
+
+ virtual bool isSolidRender(bool isServerLevel = false);
+ virtual int getRenderShape();
+ virtual bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face);
+ virtual void updateDefaultShape();
+ virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL); // 4J added forceData, forceEntity param
+ virtual Icon_SPU *getEdgeTexture();
+ bool attachsTo(int tile);
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.cpp
new file mode 100644
index 00000000..ab9b2c94
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.cpp
@@ -0,0 +1,7635 @@
+#include "stdafx.h"
+
+#include "TileRenderer_SPU.h"
+#include "LiquidTile_SPU.h"
+#include "FireTile_SPU.h"
+#include "RailTile_SPU.h"
+#include "StemTile_SPU.h"
+#include "VineTile_SPU.h"
+#include "WaterLilyTile_SPU.h"
+#include "BrewingStandTile_SPU.h"
+#include "RedStoneDustTile_SPU.h"
+#include "DiodeTile_SPU.h"
+#include "FenceGateTile_SPU.h"
+#include "StairTile_SPU.h"
+#include "EggTile_SPU.h"
+#include "DoorTile_SPU.h"
+#include "FenceTile_SPU.h"
+#include "GrassTile_SPU.h"
+#include "TreeTile_SPU.h"
+#include "WallTile_SPU.h"
+#include "QuartzBlockTile_SPU.h"
+
+// #include <string>
+#include <math.h>
+#include <assert.h>
+
+#ifdef SN_TARGET_PS3_SPU
+#include "..\Common\spu_assert.h"
+#endif
+
+static const float MATH_PI = 3.141592654f;
+
+// #include "GameRenderer.h"
+// #include "Minecraft.h"
+// #include "Textures.h"
+// #include "..\Minecraft.World\net.minecraft.world.level.h"
+// #include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.h"
+// #include "..\Minecraft.World\net.minecraft.world.level.material.h"
+// #include "..\Minecraft.World\net.minecraft.h"
+// #include "..\Minecraft.World\net.minecraft.world.h"
+// #include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.h"
+
+#include "Tesselator_SPU.h"
+
+#ifdef SN_TARGET_PS3_SPU
+#include "Stubs_SPU.h"
+#endif // SN_TARGET_PS3_SPU
+
+// #include "..\..\Minecraft.World\SharedConstants.h"
+#include "Facing_SPU.h"
+
+// #include "EntityTileRenderer.h"
+// #include "Options.h"
+
+// #define DISABLE_TESS_FUNCS
+#ifdef SN_TARGET_PS3_SPU
+class SharedConstants
+{
+public:
+ 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 );
+
+
+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();
+}
+
+TileRenderer_SPU::TileRenderer_SPU( ChunkRebuildData* level )
+{
+ this->level = level;
+ _init();
+}
+
+TileRenderer_SPU::TileRenderer_SPU()
+{
+ this->level = NULL;
+ _init();
+}
+
+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::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);
+ }
+}
+
+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::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::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
+{
+ this->setFixedTexture(fixedTexture);
+ tesselateInWorld( tile, x, y, z );
+ this->clearFixedTexture();
+}
+
+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)
+{
+#ifdef DISABLE_TESS_FUNCS
+ int data = level->getData(x, y, z);
+
+ int direction = data & 3;
+ if (direction == Direction::SOUTH)
+ {
+ upFlip = FLIP_180;
+ }
+ else if (direction == Direction::EAST)
+ {
+ upFlip = FLIP_CW;
+ }
+ else if (direction == Direction::WEST)
+ {
+ upFlip = FLIP_CCW;
+ }
+
+ 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 );
+
+ upFlip = FLIP_NONE;
+ return 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);
+ tesselateBlockInWorld(tt, x, y, z);
+ noCulling = false;
+ clearFixedTexture();
+// LeaveCriticalSection( &Tile_SPU::m_csShape );
+
+ upFlip = FLIP_NONE;
+#endif // DISABLE_TESS_FUNCS
+ return true;
+}
+
+bool TileRenderer_SPU::tesselateBedInWorld( Tile_SPU* tt, int x, int y, int z )
+{
+#ifdef DISABLE_TESS_FUNCS
+ Tesselator_SPU* t = getTesselator();
+
+ 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 r11 = c11;
+ float g11 = c11;
+ float b11 = c11;
+
+ float r10 = c10;
+ float r2 = c2;
+ float r3 = c3;
+
+ float g10 = c10;
+ float g2 = c2;
+ float g3 = 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 );
+ }
+
+ // 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 );
+
+ 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;
+
+ 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 );
+ }
+
+ 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 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;
+ }
+
+ 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 );
+
+ // 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::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 ) );
+ }
+
+ 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;
+
+}
+
+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);
+ 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);
+ 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);
+ 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);
+ tesselateBlockInWorld(tt, x, y, z);
+
+ clearFixedTexture();
+
+ 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;
+
+ t->color(br * r, br * g, br * b);
+
+ Icon_SPU *tex = getTexture(tt, 0, 0);
+
+ 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++)
+ {
+
+ 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)
+ {
+ 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;
+
+ t->vertexUV(x0, y + 1.0f, z0, u0, v0);
+ t->vertexUV(x0, y + 0.0f, z0, u0, v1);
+ t->vertexUV(x1, y + 0.0f, z1, u1, v1);
+ t->vertexUV(x1, y + 1.0f, z1, u1, v0);
+
+ t->vertexUV(x1, y + 1.0f, z1, u1, v0);
+ t->vertexUV(x1, y + 0.0f, z1, u1, v1);
+ t->vertexUV(x0, y + 0.0f, z0, u0, v1);
+ t->vertexUV(x0, y + 1.0f, z0, u0, v0);
+ }
+
+ tt->updateDefaultShape();
+
+// LeaveCriticalSection( &Tile_SPU::m_csShape );
+
+ return true;
+}
+
+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();
+
+ 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;
+
+ 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
+ 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);
+ 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 > 3)
+ {
+ waterLevel = 3;
+ }
+
+ renderFaceUp(tt, x, y - 1.0f + (6.0f + waterLevel * 3.0f) / 16.0f, z, liquidTex);
+ }
+#endif // DISABLE_TESS_FUNCS
+
+ return true;
+
+}
+
+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);
+
+ 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;
+
+ 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);
+
+ // 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);
+
+ renderFaceUp(tt, x, y - 0.5f + halfWidth + 3.0f / 16.0f, z, getTexture(Tile::dirt));
+
+ int type = level->getData(x, y, z);
+
+ 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;
+ }
+
+ 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)
+ {
+
+ // 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);
+
+ 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);
+ }
+ }
+
+ t->addOffset(-xOff / 16.0f, -yOff / 16.0f, -zOff / 16.0f);
+ }
+#endif //DISABLE_TESS_FUNCS
+
+ 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, int data)
+{
+#ifdef DISABLE_TESS_FUNCS
+ 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;
+
+ 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
+
+
+ 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)
+{
+#ifdef DISABLE_TESS_FUNCS
+
+ 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;
+ }
+
+ 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
+
+ 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)
+{
+#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
+ 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;
+ }
+
+// LeaveCriticalSection( &Tile_SPU::m_csShape );
+#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 )
+{
+#ifdef DISABLE_TESS_FUNCS
+ Icon_SPU *armTex = PistonBaseTile::getTexture(PistonBaseTile::EDGE_TEX);
+ if (hasFixedTexture()) armTex = fixedTexture;
+
+ 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);
+
+ 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 )
+{
+#ifdef DISABLE_TESS_FUNCS
+ Icon_SPU *armTex = PistonBaseTile::getTexture(PistonBaseTile::EDGE_TEX);
+ if (hasFixedTexture()) armTex = fixedTexture;
+
+ 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);
+
+ 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
+}
+
+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;
+
+ 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);
+
+ 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
+}
+
+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
+}
+
+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 );
+
+ 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();
+
+ 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 );
+
+ 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
+ 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 ) );
+ 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 );
+
+// LeaveCriticalSection( &Tile_SPU::m_csShape );
+#endif // DISABLE_TESS_FUNCS
+
+ return true;
+
+}
+
+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 dir = data & 7;
+ bool flipped = ( data & 8 ) > 0;
+
+ 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();
+
+ 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();
+
+ 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 );
+ }
+
+ 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 );
+
+ 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)
+{
+#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);
+
+ 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 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();
+
+ 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();
+
+ 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;
+
+ 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);
+
+ 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;
+ }
+
+ 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);
+ }
+
+
+ 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;
+
+ 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);
+
+ 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;
+
+ 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;
+
+ 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);
+
+ 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 + 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
+
+ return true;
+}
+
+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;
+
+ 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);
+
+ 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);
+
+ 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)
+ {
+ 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 + 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.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);
+
+ 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.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
+
+ 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;
+
+ if (hasFixedTexture()) tex = fixedTexture;
+
+ 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 ( 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;
+
+ 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 )( 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 ) );
+
+ 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 ) );
+
+ tex = secondTex;
+ u0 = tex->getU0();
+ v0 = tex->getV0();
+ u1 = tex->getU1();
+ v1 = tex->getV1();
+
+ 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 ) );
+
+ 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.5f;
+ x1 = x + 0.5f + 0.5f;
+ z0 = z + 0.5f - 0.5f;
+ z1 = z + 0.5f + 0.5f;
+
+ 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 )( 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 ) );
+
+ 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 ) );
+
+ tex = firstTex;
+ u0 = tex->getU0();
+ v0 = tex->getV0();
+ u1 = tex->getU1();
+ v1 = tex->getV1();
+
+ 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 + 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 + 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 - 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 + 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 + 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;
+
+ 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();
+
+ y += 1;
+ h = -0.2f;
+
+ 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 ) );
+
+ 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;
+}
+
+bool TileRenderer_SPU::tesselateDustInWorld( Tile_SPU* tt, int x, int y, int z )
+{
+#ifdef DISABLE_TESS_FUNCS
+
+ 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);
+
+ 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;
+
+ 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 );
+
+ 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;
+
+ 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 + 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() );
+ }
+
+ 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() );
+
+ 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 ), ( 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
+
+ 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 );
+
+ Icon_SPU *tex = getTexture(tt, 0, data);
+ if (hasFixedTexture()) tex = fixedTexture;
+
+ 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 );
+ }
+
+ float u0 = tex->getU0();
+ float v0 = tex->getV0();
+ float u1 = tex->getU1();
+ float v1 = tex->getV1();
+
+ 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 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 );
+
+ 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;
+ }
+
+ 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;
+
+}
+
+bool TileRenderer_SPU::tesselateLadderInWorld( Tile_SPU* tt, int x, int y, int z )
+{
+ Tesselator_SPU* t = getTesselator();
+
+ Icon_SPU *tex = getTexture(tt, 0);
+
+ 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();
+
+ 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;
+}
+
+bool TileRenderer_SPU::tesselateVineInWorld( Tile_SPU* tt, int x, int y, int z )
+{
+ Tesselator_SPU* t = getTesselator();
+
+ Icon_SPU *tex = getTexture(tt, 0);
+
+ 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;
+
+ 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 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 );
+
+ 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 + 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;
+}
+
+bool TileRenderer_SPU::tesselateThinFenceInWorld( ThinFenceTile* tt, int x, int y, int z )
+{
+#ifdef DISABLE_TESS_FUNCS
+ 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;
+
+ 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 );
+
+ 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();
+ }
+
+ 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();
+
+ 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;
+
+ 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 );
+
+ 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 );
+
+ 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 );
+
+ 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( 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( 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( 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 );
+
+ 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 );
+
+ 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 );
+ }
+
+ }
+ 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 );
+
+ // 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 );
+ }
+
+ 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 - 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 );
+
+ 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 );
+
+ 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, 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( 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 );
+ }
+ }
+
+ }
+ 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 );
+
+ // 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 );
+ }
+
+ 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 );
+ }
+
+ 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 );
+ }
+
+ }
+ 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 );
+
+ // 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 );
+ }
+
+ 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 - 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;
+}
+
+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 );
+ }
+
+ 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 );
+
+ 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;
+
+ 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;
+ }
+
+ 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();
+
+ 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 );
+
+ 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;
+}
+
+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 );
+ }
+
+ 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();
+
+ 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();
+
+ 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);
+
+ 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 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 ), ( 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 )( 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 ) );
+}
+
+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);
+
+ 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;
+
+ 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 )( 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 ) );
+}
+
+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);
+
+ 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;
+
+ 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( 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
+}
+
+bool TileRenderer_SPU::tesselateLilypadInWorld(WaterlilyTile_SPU *tt, int x, int y, int z)
+{
+ Tesselator_SPU* t = getTesselator();
+
+ Icon_SPU *tex = getTexture(tt, Facing::UP);
+
+ 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();
+
+ int64_t seed = (x * 3129871) ^ (z * 116129781l) ^ (y);
+ seed = seed * seed * 42317861 + seed * 11;
+
+ int dir = (int) ((seed >> 16) & 0x3);
+
+
+
+ t->tex2(tt->getLightColor(level, x, y, z));
+
+ float xx = x + 0.5f;
+ float zz = z + 0.5f;
+ float c = ((dir & 1) * 0.5f) * (1 - dir / 2 % 2 * 2);
+ float s = (((dir + 1) & 1) * 0.5f) * (1 - (dir + 1) / 2 % 2 * 2);
+
+ t->color(tt->getColor());
+ t->vertexUV(xx + c - s, y + h, zz + c + s, u0, v0);
+ t->vertexUV(xx + c + s, y + h, zz - c + s, u1, v0);
+ t->vertexUV(xx - c + s, y + h, zz - c - s, u1, v1);
+ t->vertexUV(xx - c - s, y + h, zz + c - s, u0, v1);
+
+ t->color((tt->getColor() & 0xfefefe) >> 1);
+ t->vertexUV(xx - c - s, y + h, zz + c - s, u0, v1);
+ t->vertexUV(xx - c + s, y + h, zz - c - s, u1, v1);
+ t->vertexUV(xx + c + s, y + h, zz - c + s, u1, v0);
+ t->vertexUV(xx + c - s, y + h, zz + c + s, u0, v0);
+
+ 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();
+
+ 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();
+
+ 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;
+
+ 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 );
+
+ 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 );
+ }
+}
+
+
+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);
+
+ 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;
+
+ 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 )( 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 ) );
+
+ 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 )( 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 ) );
+
+}
+
+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 );
+
+ 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;
+
+ float yo0 = 0;
+ float yo1 = 1;
+
+ 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 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;
+ }
+ }
+
+ 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 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;
+ }
+
+ 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++;
+
+ 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 );
+ }
+
+
+ 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);
+
+ 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 ) );
+
+ }
+
+ }
+
+ tileShapeY0 = yo0;
+ tileShapeY1 = yo1;
+
+ 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;
+}
+
+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;
+
+ 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 ) );
+
+ 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 );
+ 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();
+
+}
+
+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 );
+
+ 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 );
+ }
+}
+
+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;
+ }
+
+ bool result = tesselateBlockInWorld(tt, x, y, z);
+
+ eastFlip = 0;
+ northFlip = 0;
+ southFlip = 0;
+ westFlip = 0;
+ upFlip = 0;
+ downFlip = 0;
+
+ return result;
+}
+
+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;
+ }
+
+ bool result = tesselateBlockInWorld(tt, x, y, z);
+
+ eastFlip = 0;
+ northFlip = 0;
+ southFlip = 0;
+ westFlip = 0;
+ upFlip = 0;
+ downFlip = 0;
+
+ return result;
+}
+
+bool TileRenderer_SPU::tesselateCocoaInWorld(CocoaTile_SPU *tt, int x, int y, int z)
+{
+#ifdef DISABLE_TESS_FUNCS
+ 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);
+ }
+
+ 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;
+
+ 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;
+
+ 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;
+
+ // 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--;
+ }
+
+ 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);
+ }
+
+ // stalk
+ u0 = tex->getU(12, true);
+ u1 = tex->getU1(true);
+ v0 = tex->getV0(true);
+ v1 = tex->getV(4, true);
+
+ 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;
+ }
+
+ 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;
+}
+
+// 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<StairTile *>(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;
+
+ }
+#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;
+ }
+
+ 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;
+
+
+ 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 )];
+
+ 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
+
+ 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 );
+
+ 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 ( 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;
+
+ 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;
+
+ 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 );
+ 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 );
+ 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
+
+#ifdef _XBOX
+ #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));
+
+ 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;
+
+
+ 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
+
+ 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 );
+
+ 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;
+
+ 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 );
+
+ 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);
+
+ 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 );
+
+ 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 );
+
+ 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;
+
+ 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;
+
+ 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;
+
+}
+
+// 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 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;
+
+ Tesselator_SPU* t = getTesselator();
+
+ 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 r10 = c10;
+ float r2 = c2;
+ float r3 = c3;
+
+ float g10 = c10;
+ float g2 = c2;
+ float g3 = c3;
+
+ float b10 = c10;
+ float b2 = c2;
+ float b3 = c3;
+
+ if ( tt->id != Tile_SPU::grass_Id )
+ {
+ r10 *= r;
+ r2 *= r;
+ r3 *= r;
+
+ g10 *= g;
+ g2 *= g;
+ g3 *= g;
+
+ 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 );
+ }
+
+ 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, 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 );
+
+ 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 ( 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 ( 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 ( 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;
+
+ 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 );
+}
+
+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;
+
+ 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 b10 = c10 * b;
+ float b11 = c11 * b;
+ float b2 = c2 * b;
+ float b3 = c3 * b;
+
+ 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 );
+ }
+
+ 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, 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 );
+ }
+
+ 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, 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;
+}
+
+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;
+
+ 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;
+
+ 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;
+
+ 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;
+ }
+
+ 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;
+}
+
+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);
+
+ 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);
+ }
+
+ 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 );
+
+ int y0 = 0;
+ 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)
+ {
+ ww = 5;
+ hh = 2;
+ }
+ if (i == 4)
+ {
+ ww = 6;
+ hh = 3;
+ }
+ if (i == 5)
+ {
+ ww = 7;
+ hh = 5;
+ }
+ if (i == 6)
+ {
+ ww = 6;
+ hh = 2;
+ }
+ if (i == 7) ww = 3;
+ float w = ww / 16.0f;
+ float yy1 = 1 - (y0 / 16.0f);
+ float yy0 = 1 - ((y0 + hh) / 16.0f);
+ y0 += hh;
+ setShape(0.5f - w, yy0, 0.5f - w, 0.5f + w, yy1, 0.5f + w);
+ tesselateBlockInWorld(tt, x, y, z);
+ }
+ changed = true;
+
+ setShape(0, 0, 0, 1, 1, 1);
+// LeaveCriticalSection( &Tile_SPU::m_csShape );
+ return changed;
+}
+
+bool TileRenderer_SPU::tesselateFenceGateInWorld(FenceGateTile_SPU *tt, int x, int y, int z)
+{
+ bool changed = true;
+#ifdef DISABLE_TESS_FUNCS
+
+ int data = level->getData(x, y, z);
+ bool isOpen = FenceGateTile_SPU::isOpen(data);
+ int direction = FenceGateTile_SPU::getDirection(data);
+
+ float h00 = 6 / 16.0f;
+ float h01 = 9 / 16.0f;
+ float h10 = 12 / 16.0f;
+ float h11 = 15 / 16.0f;
+ 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;
+ //}
+
+ noCulling = true;
+
+// EnterCriticalSection( &Tile_SPU::m_csShape );
+
+ // edge sticks
+ 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;
+ float z1 = 2 / 16.0f;
+ setShape(x0, h20, z0, x1, h21, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+
+ z0 = 14 / 16.0f;
+ z1 = 16 / 16.0f;
+ setShape(x0, h20, z0, x1, h21, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+ upFlip = FLIP_NONE;
+ }
+ else
+ {
+ float x0 = 0 / 16.0f;
+ float x1 = 2 / 16.0f;
+ float z0 = 7 / 16.0f;
+ float z1 = 9 / 16.0f;
+ setShape(x0, h20, z0, x1, h21, z1);
+ tesselateBlockInWorld(tt, x, y, z);
+
+ x0 = 14 / 16.0f;
+ x1 = 16 / 16.0f;
+ 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)
+ {
+
+ 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;
+
+ 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, 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;
+
+ 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, 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;
+
+ const float z0 = 9 / 16.0f;
+ const float z1 = 13 / 16.0f;
+ const float z2 = 15 / 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);
+
+ 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, 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;
+
+ const float z0 = 1 / 16.0f;
+ const float z1 = 3 / 16.0f;
+ const float z2 = 7 / 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);
+
+ 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(0, 0, 0, 1, 1, 1);
+
+// LeaveCriticalSection( &Tile_SPU::m_csShape );
+#endif // #ifdef DISABLE_TESS_FUNCS
+
+ return changed;
+}
+
+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);
+
+ 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);
+ }
+ }
+// LeaveCriticalSection( &Tile_SPU::m_csShape );
+#endif // #ifdef DISABLE_TESS_FUNCS
+ return true;
+}
+
+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;
+ }
+ }
+
+ 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;
+
+ 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( 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;
+}
+
+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 ( 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);
+
+ 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);
+
+ 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;
+
+ 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();
+
+ 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();
+ }
+
+ 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);
+
+ 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);
+
+ 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;
+
+ 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();
+
+ 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();
+ }
+
+ 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);
+
+ 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);
+
+ 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;
+
+ 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();
+
+ 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();
+ }
+
+ 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);
+
+ 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);
+
+ 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;
+
+ 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();
+
+ 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();
+ }
+
+ 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);
+
+ 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);
+
+
+ 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 ) );
+ }
+
+}
+
+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 ( 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;
+
+ 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);
+
+ // 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;
+ }
+
+ 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;
+}
+
+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)
+{
+ return getTextureOrMissing(tile->getTexture(face));
+}
+
+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
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.h
new file mode 100644
index 00000000..2c484faa
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TileRenderer_SPU.h
@@ -0,0 +1,205 @@
+#pragma once
+
+#include <stddef.h>
+//#include <string>
+#include "Tile_SPU.h"
+#include "Icon_SPU.h"
+#include "ChunkRebuildData.h"
+
+class Level;
+class LevelSource;
+class Tile_SPU;
+class RailTile_SPU;
+class Material;
+class TileEntity;
+class ThinFenceTile;
+class FenceTile_SPU;
+class FenceGateTile_SPU;
+class BrewingStandTile_SPU;
+class CauldronTile_SPU;
+class EggTile_SPU;
+class TheEndPortalFrameTile;
+class DiodeTile_SPU;
+class FireTile_SPU;
+class StemTile_SPU;
+class WaterlilyTile_SPU;
+class StairTile_SPU;
+class CocoaTile_SPU;
+class AnvilTile_SPU;
+class FlowerPotTile_SPU;
+class WallTile_SPU;
+
+class Icon;
+class Minecraft;
+
+class TileRenderer_SPU
+{
+ friend class FallingTileRenderer_SPU;
+ private:
+ ChunkRebuildData* level;
+ Icon_SPU *fixedTexture;
+ bool xFlipTexture;
+ bool noCulling;
+ public :
+ static bool fancy;
+ bool setColor;
+
+ float tileShapeX0;
+ float tileShapeX1;
+ float tileShapeY0;
+ float tileShapeY1;
+ float tileShapeZ0;
+ float tileShapeZ1;
+ bool fixedShape;
+ bool smoothShapeLighting;
+// Minecraft *minecraft;
+
+ void _init();
+
+public:
+ TileRenderer_SPU( ChunkRebuildData* level );
+ TileRenderer_SPU();
+ Tesselator_SPU* getTesselator();
+
+ bool hasRenderer(Tile_SPU* tt);
+ void setFixedTexture( Icon_SPU *fixedTexture );
+ void clearFixedTexture();
+ bool hasFixedTexture();
+ void setShape(float x0, float y0, float z0, float x1, float y1, float z1);
+ void setShape(Tile_SPU *tt);
+ void setFixedShape(float x0, float y0, float z0, float x1, float y1, float z1);
+ void clearFixedShape();
+
+ void tesselateInWorldFixedTexture( Tile_SPU* tile, int x, int y, int z, Icon_SPU *fixedTexture ); // 4J renamed to differentiate from tesselateInWorld
+ void tesselateInWorldNoCulling( Tile_SPU* tile, int x, int y, int z, int forceData = -1,
+ TileEntity* forceEntity = NULL ); // 4J added forceData, forceEntity param
+ bool tesselateInWorld( Tile_SPU* tt, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL ); // 4J added forceData, forceEntity param
+
+ private:
+ bool tesselateAirPortalFrameInWorld(TheEndPortalFrameTile *tt, int x, int y, int z);
+ bool tesselateBedInWorld( Tile_SPU* tt, int x, int y, int z );
+ bool tesselateBrewingStandInWorld(BrewingStandTile_SPU *tt, int x, int y, int z);
+ bool tesselateCauldronInWorld(CauldronTile_SPU *tt, int x, int y, int z);
+ bool tesselateFlowerPotInWorld(FlowerPotTile_SPU *tt, int x, int y, int z);
+ bool tesselateAnvilInWorld(AnvilTile_SPU *tt, int x, int y, int z);
+
+public:
+ bool tesselateAnvilInWorld(AnvilTile_SPU *tt, int x, int y, int z, int data);
+
+private:
+ bool tesselateAnvilInWorld(AnvilTile_SPU *tt, int x, int y, int z, int data, bool render);
+ float 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);
+
+
+ public:
+ bool tesselateTorchInWorld( Tile_SPU* tt, int x, int y, int z );
+ private:
+ bool tesselateDiodeInWorld(DiodeTile_SPU *tt, int x, int y, int z);
+ void tesselateDiodeInWorld( DiodeTile_SPU* tt, int x, int y, int z, int dir );
+ static const int FLIP_NONE = 0, FLIP_CW = 1, FLIP_CCW = 2, FLIP_180 = 3;
+
+ int northFlip;
+ int southFlip;
+ int eastFlip;
+ int westFlip;
+ int upFlip;
+ int downFlip;
+ public:
+ void tesselatePistonBaseForceExtended( Tile_SPU* tile, int x, int y, int z, int forceData = -1 ); // 4J added data param
+ private:
+ bool tesselatePistonBaseInWorld( Tile_SPU* tt, int x, int y, int z, bool forceExtended, int forceData = -1 ); // 4J added data param
+ void renderPistonArmUpDown( float x0, float x1, float y0, float y1, float z0, float z1, float br, float armLengthPixels );
+ void renderPistonArmNorthSouth( float x0, float x1, float y0, float y1, float z0, float z1, float br, float armLengthPixels );
+ void renderPistonArmEastWest( float x0, float x1, float y0, float y1, float z0, float z1, float br, float armLengthPixels );
+ public:
+ void tesselatePistonArmNoCulling( Tile_SPU* tile, int x, int y, int z, bool fullArm, int forceData = -1 ); // 4J added data param
+ private:
+ bool tesselatePistonExtensionInWorld( Tile_SPU* tt, int x, int y, int z, bool fullArm, int forceData = -1 ); // 4J added data param
+ public:
+ bool tesselateLeverInWorld( Tile_SPU* tt, int x, int y, int z );
+ bool tesselateTripwireSourceInWorld(Tile_SPU *tt, int x, int y, int z);
+ bool tesselateTripwireInWorld(Tile_SPU *tt, int x, int y, int z);
+ bool tesselateFireInWorld( FireTile_SPU* tt, int x, int y, int z );
+ bool tesselateDustInWorld( Tile_SPU* tt, int x, int y, int z );
+ bool tesselateRailInWorld( RailTile_SPU* tt, int x, int y, int z );
+ bool tesselateLadderInWorld( Tile_SPU* tt, int x, int y, int z );
+ bool tesselateVineInWorld( Tile_SPU* tt, int x, int y, int z );
+ bool tesselateThinFenceInWorld( ThinFenceTile* tt, int x, int y, int z );
+ bool tesselateCrossInWorld( Tile_SPU* tt, int x, int y, int z );
+ bool tesselateStemInWorld( Tile_SPU* _tt, int x, int y, int z );
+ bool tesselateRowInWorld( Tile_SPU* tt, int x, int y, int z );
+ void tesselateTorch( Tile_SPU* tt, float x, float y, float z, float xxa, float zza, int data );
+ void tesselateCrossTexture( Tile_SPU* tt, int data, float x, float y, float z, float scale );
+ void tesselateStemTexture( Tile_SPU* tt, int data, float h, float x, float y, float z );
+ bool tesselateLilypadInWorld(WaterlilyTile_SPU *tt, int x, int y, int z);
+ void tesselateStemDirTexture( StemTile_SPU* tt, int data, int dir, float h, float x, float y, float z );
+
+ void tesselateRowTexture( Tile_SPU* tt, int data, float x, float y, float z );
+ bool tesselateWaterInWorld( Tile_SPU* tt, int x, int y, int z );
+ private:
+ float getWaterHeight( int x, int y, int z, Material_SPU* m );
+ public:
+ void renderBlock( Tile_SPU* tt, ChunkRebuildData* level, int x, int y, int z );
+ void renderBlock(Tile_SPU *tt, ChunkRebuildData *level, int x, int y, int z, int data);
+ bool tesselateBlockInWorld( Tile_SPU* tt, int x, int y, int z );
+ bool tesselateTreeInWorld(Tile_SPU *tt, int x, int y, int z);
+ bool tesselateQuartzInWorld(Tile_SPU *tt, int x, int y, int z);
+ bool tesselateCocoaInWorld(CocoaTile_SPU *tt, int x, int y, int z);
+
+ private:
+ bool applyAmbienceOcclusion;
+ float ll000, llx00, ll0y0, ll00z, llX00, ll0Y0, ll00Z;
+ float llxyz, llxy0, llxyZ, ll0yz, ll0yZ, llXyz, llXy0;
+ float llXyZ, llxYz, llxY0, llxYZ, ll0Yz, llXYz, llXY0;
+ float ll0YZ, llXYZ, llx0z, llX0z, llx0Z, llX0Z;
+ // 4J - brought forward changes from 1.8.2
+ int ccx00, cc00z, cc0Y0, cc00Z;
+ int ccxyz, ccxy0, ccxyZ, cc0yz, cc0yZ, ccXyz, ccXy0;
+ int ccXyZ, ccxYz, ccxY0, ccxYZ, cc0Yz, ccXYz, ccXY0;
+ int cc0YZ, ccXYZ, ccx0z, ccX0z, ccx0Z, ccX0Z;
+ int blsmooth;
+ int tc1, tc2, tc3, tc4; // 4J - brought forward changes from 1.8.2
+ float c1r, c2r, c3r, c4r;
+ float c1g, c2g, c3g, c4g;
+ float c1b, c2b, c3b, c4b;
+ bool llTrans0Yz, llTransXY0, llTransxY0, llTrans0YZ;
+ bool llTransx0z, llTransX0Z, llTransx0Z, llTransX0z;
+ bool llTrans0yz, llTransXy0, llTransxy0, llTrans0yZ;
+
+ public:
+ // 4J - brought forward changes from 1.8.2
+ bool tesselateBlockInWorldWithAmbienceOcclusionTexLighting( Tile_SPU* tt, int pX, int pY, int pZ, float pBaseRed,
+ float pBaseGreen, float pBaseBlue );
+ bool tesselateBlockInWorldWithAmbienceOcclusionOldLighting( Tile_SPU* tt, int pX, int pY, int pZ, float pBaseRed,
+ float pBaseGreen, float pBaseBlue );
+ private:
+ int blend( int a, int b, int c, int def );
+ int blend(int a, int b, int c, int d, float fa, float fb, float fc, float fd);
+ public:
+ bool tesselateBlockInWorld( Tile_SPU* tt, int x, int y, int z, float r, float g, float b );
+ bool tesselateCactusInWorld( Tile_SPU* tt, int x, int y, int z );
+ bool tesselateCactusInWorld( Tile_SPU* tt, int x, int y, int z, float r, float g, float b );
+ bool tesselateFenceInWorld( FenceTile_SPU* tt, int x, int y, int z );
+ bool tesselateWallInWorld(WallTile_SPU *tt, int x, int y, int z);
+ bool tesselateEggInWorld(EggTile_SPU *tt, int x, int y, int z);
+ bool tesselateFenceGateInWorld(FenceGateTile_SPU *tt, int x, int y, int z);
+ bool tesselateStairsInWorld( StairTile_SPU* tt, int x, int y, int z );
+ bool tesselateDoorInWorld( Tile_SPU* tt, int x, int y, int z );
+ void renderFaceUp( Tile_SPU* tt, float x, float y, float z, Icon_SPU *tex );
+ void renderFaceDown( Tile_SPU* tt, float x, float y, float z, Icon_SPU *tex );
+ void renderNorth( Tile_SPU* tt, float x, float y, float z, Icon_SPU *tex );
+ void renderSouth( Tile_SPU* tt, float x, float y, float z, Icon_SPU *tex );
+ void renderWest( Tile_SPU* tt, float x, float y, float z, Icon_SPU *tex );
+ void renderEast( Tile_SPU* tt, float x, float y, float z, Icon_SPU *tex );
+// void renderCube( Tile_SPU* tile, float alpha );
+// void renderTile( Tile_SPU* tile, int data, float brightness, float fAlpha = 1.0f );
+ static bool canRender( int renderShape );
+ Icon_SPU *getTexture(Tile_SPU *tile, ChunkRebuildData *level, int x, int y, int z, int face);
+
+ Icon_SPU *getTexture(Tile_SPU *tile, int face, int data);
+ Icon_SPU *getTexture(Tile_SPU *tile, int face);
+ Icon_SPU *getTexture(Tile_SPU *tile);
+ Icon_SPU *getTextureOrMissing(Icon_SPU *icon);
+
+ bool isAnaglyph3d() { return false; } //GameRenderer::anaglyph3d
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.cpp
new file mode 100644
index 00000000..f2dfeaac
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.cpp
@@ -0,0 +1,899 @@
+#include "stdafx.h"
+#include "Tile_SPU.h"
+#include "ChunkRebuildData.h"
+#include "GrassTile_SPU.h"
+#include "HalfSlabTile_SPU.h"
+#include "WoodSlabTile_SPU.h"
+#include "StoneSlabTile_SPU.h"
+#include "ChestTile_SPU.h"
+#include "ThinFenceTile_SPU.h"
+#include "FenceTile_SPU.h"
+#include "StairTile_SPU.h"
+#include "DirtTile_SPU.h"
+#include "DoorTile_SPU.h"
+#include "PressurePlateTile_SPU.h"
+#include "FarmTile_SPU.h"
+#include "Bush_SPU.h"
+#include "TallGrass_SPU.h"
+#include "SandStoneTile_SPU.h"
+#include "WoodTile_SPU.h"
+#include "TreeTile_SPU.h"
+#include "LeafTile_SPU.h"
+#include "CropTile_SPU.h"
+#include "ReedTile_SPU.h"
+#include "TorchTile_SPU.h"
+#include "Mushroom_SPU.h"
+#include "FurnaceTile_SPU.h"
+#include "WebTile_SPU.h"
+#include "LiquidTile_SPU.h"
+#include "FireTile_SPU.h"
+#include "Sapling_SPU.h"
+#include "GlassTile_SPU.h"
+#include "IceTile_SPU.h"
+#include "PortalTile_SPU.h"
+#include "DispenserTile_SPU.h"
+#include "RailTile_SPU.h"
+#include "DetectorRailTile_SPU.h"
+#include "TntTile_SPU.h"
+#include "BookshelfTile_SPU.h"
+#include "WorkbenchTile_SPU.h"
+#include "SignTile_SPU.h"
+#include "LadderTile_SPU.h"
+#include "ButtonTile_SPU.h"
+#include "TopSnowTile_SPU.h"
+#include "CactusTile_SPU.h"
+#include "RecordPlayerTile_SPU.h"
+#include "PumpkinTile_SPU.h"
+#include "CakeTile_SPU.h"
+#include "TrapDoorTile_SPU.h"
+#include "StoneMonsterTile_SPU.h"
+#include "SmoothStoneBrickTile_SPU.h"
+#include "HugeMushroomTile_SPU.h"
+#include "MelonTile_SPU.h"
+#include "StemTile_SPU.h"
+#include "VineTile_SPU.h"
+#include "MycelTile_SPU.h"
+#include "WaterlilyTile_SPU.h"
+#include "NetherStalkTile_SPU.h"
+#include "EnchantmentTableTile_SPU.h"
+#include "BrewingStandTile_SPU.h"
+#include "DiodeTile_SPU.h"
+#include "RedStoneDustTile_SPU.h"
+#include "FenceGateTile_SPU.h"
+#include "BedTile_SPU.h"
+#include "PistonBaseTile_SPU.h"
+#include "PistonExtensionTile_SPU.h"
+#include "PistonMovingPiece_SPU.h"
+#include "LeverTile_SPU.h"
+#include "CauldronTile_SPU.h"
+#include "TheEndPortal_SPU.h"
+#include "TheEndPortalFrameTile_SPU.h"
+#include "EggTile_SPU.h"
+#include "CocoaTile_SPU.h"
+#include "RedlightTile_SPU.h"
+#include "ClothTile_SPU.h"
+#include "SkullTile_SPU.h"
+#include "MobSpawnerTile_SPU.h"
+#include "EnderChestTile_SPU.h"
+#include "TripWireSourceTile_SPU.h"
+#include "TripWireTile_SPU.h"
+#include "WallTile_SPU.h"
+#include "FlowerPotTile_SPU.h"
+#include "CarrotTile_SPU.h"
+#include "PotatoTile_SPU.h"
+#include "QuartzBlockTile_SPU.h"
+#include "WoolCarpetTile_SPU.h"
+
+#ifdef SN_TARGET_PS3_SPU
+#include "..\Common\spu_assert.h"
+#endif
+
+#include <assert.h>
+#include <new>
+#include "AnvilTile_SPU.h"
+
+TileData_SPU* Tile_SPU::ms_pTileData = NULL;
+
+Tile_SPU Tile_SPU::m_tiles[256];
+
+
+
+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;
+}
+
+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]);
+}
+//
+// bool Tile_SPU::isFaceVisible(Level *level, int x, int y, int z, int f)
+// {
+// if (f == 0) y--;
+// if (f == 1) y++;
+// if (f == 2) z--;
+// if (f == 3) z++;
+// if (f == 4) x--;
+// 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::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
+
+ 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;
+ }
+ }
+
+
+ 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)
+{
+ 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);
+// }
+//
+// 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)
+// {
+// 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);
+// }
+//
+ 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(shared_ptr<Player> 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)
+// {
+// 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)
+// {
+// if (level->isClientSide) return;
+// 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, shared_ptr<ItemInstance>( new ItemInstance(type, 1, getSpawnResourcesAuxValue(data) ) ) );
+// }
+// }
+//
+// void Tile_SPU::popResource(Level *level, int x, int y, int z, shared_ptr<ItemInstance> 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;
+// shared_ptr<ItemEntity> item = shared_ptr<ItemEntity>( 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)
+// {
+// if (!level->isClientSide)
+// {
+// while (amount > 0)
+// {
+// int newCount = ExperienceOrb::getExperienceValue(amount);
+// amount -= newCount;
+// level->addEntity(shared_ptr<ExperienceOrb>( new ExperienceOrb(level, x + .5, y + .5, z + .5, newCount)));
+// }
+// }
+// }
+//
+// int Tile_SPU::getSpawnResourcesAuxValue(int data)
+// {
+// return 0;
+// }
+//
+// float Tile_SPU::getExplosionResistance(shared_ptr<Entity> source)
+// {
+// return explosionResistance / 5.0f;
+// }
+//
+// 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;
+//
+// 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;
+}
+//
+// 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, shared_ptr<Player> player)
+// {
+// return false;
+// }
+//
+// bool Tile_SPU::use(Level *level, int x, int y, int z, shared_ptr<Player> 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, shared_ptr<Entity> 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, shared_ptr<Player> player)
+// {
+// }
+//
+// void Tile_SPU::handleEntityInside(Level *level, int x, int y, int z, shared_ptr<Entity> e, Vec3 *current)
+// {
+// }
+//
+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(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, shared_ptr<Entity> 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, shared_ptr<Player> 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)
+// {
+// if( Tile_SPU::crops->getResource(data, NULL, 0) > 0 )
+// player->awardStat(Stats::blocksMined[id], 1);
+// }
+// else
+// {
+// player->awardStat(Stats::blocksMined[id], 1);
+// }
+// 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))
+// {
+// shared_ptr<ItemInstance> item = getSilkTouchItemInstance(data);
+// if (item != NULL)
+// {
+// popResource(level, x, y, z, item);
+// }
+// }
+// else
+// {
+// int playerBonusLevel = EnchantmentHelper::getDiggingLootBonus(player->inventory);
+// spawnResources(level, x, y, z, data, playerBonusLevel);
+// }
+// }
+//
+// shared_ptr<ItemInstance> Tile_SPU::getSilkTouchItemInstance(int data)
+// {
+// int popData = 0;
+// if (id >= 0 && id < Item::items.length && Item::items[id]->isStackedByData())
+// {
+// popData = data;
+// }
+// return shared_ptr<ItemInstance>(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, shared_ptr<Mob> by)
+// {
+// }
+//
+// Tile *Tile_SPU::setDescriptionId(unsigned int id)
+// {
+// this->descriptionId = id;
+// return this;
+// }
+//
+// 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)
+// {
+// }
+//
+// 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;
+}
+
+Tile_SPU* Tile_SPU::createFromID( int tileID )
+{
+ if(tileID == 0)
+ return NULL;
+
+ if(m_tiles[tileID].id != -1)
+ return &m_tiles[tileID];
+
+#ifndef SN_TARGET_PS3_SPU
+ app.DebugPrintf("missing tile ID %d\n", tileID);
+#else
+ 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];
+}
+
+//
+// void Tile_SPU::fallOn(Level *level, int x, int y, int z, shared_ptr<Entity> entity, float fallDistance)
+// {
+// }
+//
+// void Tile_SPU::registerIcons(IconRegister *iconRegister)
+// {
+// icon = iconRegister->registerIcon(m_textureName);
+// }
+//
+// wstring Tile_SPU::getTileItemIconName()
+// {
+// return L"";
+// }
+//
+// Tile *Tile_SPU::setTextureName(const 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);
+
+ CREATE_TILE_TYPE(chest_Id, ChestTile_SPU);
+
+ 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(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(dirt_Id, DirtTile_SPU);
+
+ CREATE_TILE_TYPE(door_iron_Id, DoorTile_SPU);
+ CREATE_TILE_TYPE(door_wood_Id, DoorTile_SPU);
+
+ CREATE_TILE_TYPE(pressurePlate_stone_Id, PressurePlateTile_SPU);
+ CREATE_TILE_TYPE(pressurePlate_wood_Id, PressurePlateTile_SPU);
+
+ CREATE_TILE_TYPE(farmland_Id, FarmTile_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(tallgrass_Id, TallGrass_SPU);
+
+ CREATE_TILE_TYPE(sandStone_Id, SandStoneTile_SPU);
+
+ CREATE_TILE_TYPE(wood_Id, WoodTile_SPU);
+
+ CREATE_TILE_TYPE(treeTrunk_Id, TreeTile_SPU);
+
+ CREATE_TILE_TYPE(leaves_Id, LeafTile_SPU);
+
+ CREATE_TILE_TYPE(crops_Id, CropTile_SPU);
+
+ CREATE_TILE_TYPE(reeds_Id, ReedTile_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(mushroom1_Id, Mushroom_SPU);
+ CREATE_TILE_TYPE(mushroom2_Id, Mushroom_SPU);
+
+ CREATE_TILE_TYPE(mobSpawner_Id, MobSpawnerTile_SPU);
+ CREATE_TILE_TYPE(musicBlock_Id, EntityTile_SPU); // MusicTile->EntityTile
+
+ CREATE_TILE_TYPE(furnace_Id, FurnaceTile_SPU);
+ CREATE_TILE_TYPE(furnace_lit_Id, FurnaceTile_SPU);
+
+ CREATE_TILE_TYPE(web_Id, WebTile_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(fire_Id, FireTile_SPU);
+
+ CREATE_TILE_TYPE(sapling_Id, Sapling_SPU);
+
+ CREATE_TILE_TYPE(glass_Id, GlassTile_SPU);
+
+ CREATE_TILE_TYPE(ice_Id, IceTile_SPU);
+
+ CREATE_TILE_TYPE(portalTile_Id, PortalTile_SPU);
+
+ CREATE_TILE_TYPE(dispenser_Id, DispenserTile_SPU);
+
+ CREATE_TILE_TYPE(rail_Id, RailTile_SPU);
+ CREATE_TILE_TYPE(goldenRail_Id, RailTile_SPU);
+
+ CREATE_TILE_TYPE(detectorRail_Id, DetectorRailTile_SPU);
+
+ CREATE_TILE_TYPE(tnt_Id, TntTile_SPU);
+
+ CREATE_TILE_TYPE(bookshelf_Id, BookshelfTile_SPU);
+
+ CREATE_TILE_TYPE(workBench_Id, WorkbenchTile_SPU);
+
+ CREATE_TILE_TYPE(sign_Id, SignTile_SPU);
+ CREATE_TILE_TYPE(wallSign_Id, SignTile_SPU);
+
+ CREATE_TILE_TYPE(ladder_Id, LadderTile_SPU);
+
+ CREATE_TILE_TYPE(button_stone_Id, ButtonTile_SPU);
+ CREATE_TILE_TYPE(button_wood_Id, ButtonTile_SPU);
+
+ CREATE_TILE_TYPE(topSnow_Id, TopSnowTile_SPU);
+
+ CREATE_TILE_TYPE(cactus_Id, CactusTile_SPU);
+
+ CREATE_TILE_TYPE(recordPlayer_Id, RecordPlayerTile_SPU);
+
+ CREATE_TILE_TYPE(pumpkin_Id, PumpkinTile_SPU);
+ CREATE_TILE_TYPE(litPumpkin_Id, PumpkinTile_SPU);
+
+ CREATE_TILE_TYPE(cake_Id, CakeTile_SPU);
+
+ CREATE_TILE_TYPE(trapdoor_Id, TrapDoorTile_SPU);
+
+ CREATE_TILE_TYPE(monsterStoneEgg_Id, StoneMonsterTile_SPU);
+
+ CREATE_TILE_TYPE(stoneBrickSmooth_Id, SmoothStoneBrickTile_SPU);
+
+ CREATE_TILE_TYPE(hugeMushroom1_Id, HugeMushroomTile_SPU);
+ CREATE_TILE_TYPE(hugeMushroom2_Id, HugeMushroomTile_SPU);
+
+ CREATE_TILE_TYPE(melon_Id, MelonTile_SPU);
+
+ CREATE_TILE_TYPE(melonStem_Id, StemTile_SPU);
+ CREATE_TILE_TYPE(pumpkinStem_Id, StemTile_SPU);
+
+ CREATE_TILE_TYPE(vine_Id, VineTile_SPU);
+
+ CREATE_TILE_TYPE(mycel_Id, MycelTile_SPU);
+
+ CREATE_TILE_TYPE(waterLily_Id, WaterlilyTile_SPU);
+
+ CREATE_TILE_TYPE(netherStalk_Id, NetherStalkTile_SPU);
+
+ CREATE_TILE_TYPE(enchantTable_Id, EnchantmentTableTile_SPU);
+
+ CREATE_TILE_TYPE(brewingStand_Id, BrewingStandTile_SPU);
+
+ CREATE_TILE_TYPE(diode_on_Id, DiodeTile_SPU);
+ CREATE_TILE_TYPE(diode_off_Id, DiodeTile_SPU);
+
+ CREATE_TILE_TYPE(redStoneDust_Id, RedStoneDustTile_SPU);
+
+ CREATE_TILE_TYPE(fenceGate_Id, FenceGateTile_SPU);
+
+ CREATE_TILE_TYPE(bed_Id, BedTile_SPU);
+
+ CREATE_TILE_TYPE(pistonBase_Id, PistonBaseTile_SPU);
+ CREATE_TILE_TYPE(pistonStickyBase_Id, PistonBaseTile_SPU);
+
+ CREATE_TILE_TYPE(pistonExtensionPiece_Id, PistonExtensionTile_SPU);
+
+ CREATE_TILE_TYPE(pistonMovingPiece_Id, PistonMovingPiece_SPU);
+
+ CREATE_TILE_TYPE(lever_Id, LeverTile_SPU);
+
+ CREATE_TILE_TYPE(cauldron_Id, CauldronTile_SPU);
+
+ CREATE_TILE_TYPE(endPortalTile_Id, TheEndPortal_SPU);
+
+ CREATE_TILE_TYPE(endPortalFrameTile_Id, TheEndPortalFrameTile_SPU);
+
+ CREATE_TILE_TYPE(dragonEgg_Id, EggTile_SPU);
+
+ CREATE_TILE_TYPE(cocoa_Id, CocoaTile_SPU);
+
+ 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
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.h
new file mode 100644
index 00000000..484823ef
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.h
@@ -0,0 +1,510 @@
+#pragma once
+// #include "Material.h"
+// #include "Vec3.h"
+// #include "Definitions.h"
+// #include "SoundTypes.h"
+// using namespace std;
+#include "Icon_SPU.h"
+#include "Material_SPU.h"
+#include <stddef.h>
+
+class ChunkRebuildData;
+class GrassTile_SPU;
+class LeafTile;
+class TallGrass;
+class DeadBushTile;
+class FireTile;
+class PortalTile;
+class MycelTile;
+class PistonExtensionTile;
+class PistonMovingPiece;
+class StoneTile;
+class stoneBrick;
+class Bush;
+class StairTile;
+class LiquidTile;
+class PistonBaseTile;
+class ChestTile;
+class RedStoneDustTile;
+class RepeaterTile;
+class CauldronTile;
+class TripWireSourceTile;
+class Random;
+class HitResult;
+class Level;
+
+class Player;
+class LevelSource;
+class Mob;
+class TileEntity;
+class HalfSlabTile;
+class IconRegister;
+
+class TileData_SPU
+{
+public:
+
+ class Bitfield256
+ {
+ unsigned int m_data[8];
+
+ void setBit(unsigned char i){ m_data[i>>5] |= (1<<(i%32)); }
+ void clearBit(unsigned char i) { m_data[i>>5] &= ~(1<<(i%32)); }
+ public:
+ bool operator[](unsigned char i) { return (m_data[i>>5] & 1<<(i%32)) != 0; }
+ void set(unsigned char i, bool val){ (val) ? setBit(i) : clearBit(i); }
+ };
+ Bitfield256 mipmapEnable;
+ Bitfield256 solid;
+ Bitfield256 transculent;
+ Bitfield256 _sendTileData;
+ Bitfield256 propagate;
+ Bitfield256 signalSource;
+ Bitfield256 cubeShaped;
+
+
+ char lightBlock[256];
+ char lightEmission[256];
+ char materialIDs[256];
+ Material_SPU materials[Material_SPU::num_Ids];
+
+ float xx0[256];
+ float yy0[256];
+ float zz0[256];
+ float xx1[256];
+ float yy1[256];
+ float zz1[256];
+
+ int iconTexWidth;
+ int iconTexHeight;
+ Icon_SPU iconData[256];
+
+
+ Icon_SPU grass_iconTop;
+ Icon_SPU grass_iconSnowSide;
+ Icon_SPU grass_iconSideOverlay;
+
+ Icon_SPU ironFence_EdgeTexture;
+ Icon_SPU thinGlass_EdgeTexture;
+
+ Icon_SPU farmTile_Wet;
+ Icon_SPU farmTile_Dry;
+
+ Icon_SPU doorTile_Icons[8];
+
+ Icon_SPU tallGrass_Icons[3];
+
+ Icon_SPU sandStone_icons[3];
+ Icon_SPU sandStone_iconTop;
+ Icon_SPU sandStone_iconBottom;
+
+ Icon_SPU woodTile_icons[4];
+
+ Icon_SPU treeTile_icons[4];
+ Icon_SPU treeTile_iconTop;
+
+ Icon_SPU leafTile_icons[2][4];
+ bool leafTile_allowSame;
+ int leafTile_fancyTextureSet;
+
+ Icon_SPU cropTile_icons[8];
+
+ Icon_SPU furnaceTile_iconTop;
+ Icon_SPU furnaceTile_iconFront;
+ Icon_SPU furnaceTile_iconFront_lit;
+
+ Icon_SPU liquidTile_iconWaterStill;
+ Icon_SPU liquidTile_iconWaterFlow;
+ Icon_SPU liquidTile_iconLavaStill;
+ Icon_SPU liquidTile_iconLavaFlow;
+
+ Icon_SPU fireTile_icons[2];
+ Icon_SPU sapling_icons[4];
+
+ bool glassTile_allowSame;
+ bool iceTile_allowSame;
+
+ Icon_SPU dispenserTile_iconTop;
+ Icon_SPU dispenserTile_iconFront;
+ Icon_SPU dispenserTile_iconFrontVertical;
+
+ Icon_SPU railTile_iconTurn;
+ Icon_SPU railTile_iconTurnGolden;
+
+ Icon_SPU detectorRailTile_icons[2];
+
+ Icon_SPU tntTile_iconBottom;
+ Icon_SPU tntTile_iconTop;
+
+ Icon_SPU workBench_iconTop;
+ Icon_SPU workBench_iconFront;
+
+ Icon_SPU cactusTile_iconTop;
+ Icon_SPU cactusTile_iconBottom;
+
+ Icon_SPU recordPlayer_iconTop;
+
+ Icon_SPU pumpkinTile_iconTop;
+ Icon_SPU pumpkinTile_iconFace;
+ Icon_SPU pumpkinTile_iconFaceLit;
+
+ Icon_SPU cakeTile_iconTop;
+ Icon_SPU cakeTile_iconBottom;
+ Icon_SPU cakeTile_iconInner;
+
+ Icon_SPU smoothStoneBrick_icons[4];
+
+ Icon_SPU hugeMushroom_icons[2];
+ Icon_SPU hugeMushroom_iconStem;
+ Icon_SPU hugeMushroom_iconInside;
+
+ Icon_SPU melonTile_iconTop;
+
+ Icon_SPU stemTile_iconAngled;
+
+ Icon_SPU mycelTile_iconTop;
+ Icon_SPU mycelTile_iconSnowSide;
+
+ Icon_SPU netherStalk_icons[3];
+
+ Icon_SPU enchantmentTable_iconTop;
+ Icon_SPU enchantmentTable_iconBottom;
+
+ Icon_SPU brewingStand_iconBase;
+
+ Icon_SPU redStoneDust_iconCross;
+ Icon_SPU redStoneDust_iconLine;
+ Icon_SPU redStoneDust_iconCrossOver;
+ Icon_SPU redStoneDust_iconLineOver;
+
+ Icon_SPU clothTile_icons[16];
+
+ Icon_SPU stoneSlab_iconSide;
+
+ Icon_SPU carrot_icons[4];
+ Icon_SPU potato_icons[4];
+ Icon_SPU anvil_icons[3];
+
+
+ Icon_SPU quartzBlock_icons[5];
+ Icon_SPU quartzBlock_iconChiseledTop;
+ Icon_SPU quartzBlock_iconLinesTop;
+ Icon_SPU quartzBlock_iconTop;
+ Icon_SPU quartzBlock_iconBottom;
+
+
+ int anvilPart; // normally part of the AnvilTile class
+
+ unsigned int stemTile_minColour;
+ unsigned int stemTile_maxColour;
+ unsigned int waterLily_colour;
+
+ unsigned int foliageColor_evergreenColor;
+ unsigned int foliageColor_birchColor;
+
+
+protected:
+// float destroySpeed;
+// float explosionResistance;
+// bool isInventoryItem;
+// bool collectStatistics;
+// int m_iMaterial;
+// int m_iBaseItemType;
+
+
+public:
+// const SoundType *soundType;
+//
+// float gravity;
+// Material *material;
+// float friction;
+
+private:
+// unsigned int descriptionId;
+// unsigned int useDescriptionId; // 4J Added
+//
+// wstring m_textureName;
+
+protected:
+// Icon *icon;
+
+public:
+
+ int getRenderShape();
+
+ void setShape(float x0, float y0, float z0, float x1, float y1, float z1);
+ float getBrightness(ChunkRebuildData *level, int x, int y, int z);
+ int getLightColor(ChunkRebuildData *level, int x, int y, int z); // 4J - brought forward from 1.8.2
+ bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face);
+
+public:
+ Icon_SPU *getTexture(ChunkRebuildData *level, int x, int y, int z, int face);
+ Icon_SPU *getTexture(int face, int data);
+ Icon_SPU *getTexture(int face);
+ public:
+ void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL); // 4J added forceData, forceEntity param
+ double getShapeX0();
+ double getShapeX1();
+ double getShapeY0();
+ double getShapeY1();
+ double getShapeZ0();
+ double getShapeZ1();
+// int getColor(int auxData);
+ int getColor(ChunkRebuildData *level, int x, int y, int z);
+ float getShadeBrightness(ChunkRebuildData *level, int x, int y, int z); // 4J - brought forward from 1.8.2
+ bool hasMaterialLiquid() { return false; } // material->isLiquid()
+};
+
+class Tile_SPU
+{
+public:
+ static const int SHAPE_INVISIBLE = -1;
+ static const int SHAPE_BLOCK = 0;
+ static const int SHAPE_CROSS_TEXTURE = 1;
+ static const int SHAPE_TORCH = 2;
+ static const int SHAPE_FIRE = 3;
+ static const int SHAPE_WATER = 4;
+ static const int SHAPE_RED_DUST = 5;
+ static const int SHAPE_ROWS = 6;
+ static const int SHAPE_DOOR = 7;
+ static const int SHAPE_LADDER = 8;
+ static const int SHAPE_RAIL = 9;
+ static const int SHAPE_STAIRS = 10;
+ static const int SHAPE_FENCE = 11;
+ static const int SHAPE_LEVER = 12;
+ static const int SHAPE_CACTUS = 13;
+ static const int SHAPE_BED = 14;
+ static const int SHAPE_DIODE = 15;
+ static const int SHAPE_PISTON_BASE = 16;
+ static const int SHAPE_PISTON_EXTENSION = 17;
+ static const int SHAPE_IRON_FENCE = 18;
+ static const int SHAPE_STEM = 19;
+ static const int SHAPE_VINE = 20;
+ static const int SHAPE_FENCE_GATE = 21;
+ static const int SHAPE_ENTITYTILE_ANIMATED = 22;
+ static const int SHAPE_LILYPAD = 23;
+ static const int SHAPE_CAULDRON = 24;
+ static const int SHAPE_BREWING_STAND = 25;
+ static const int SHAPE_PORTAL_FRAME = 26;
+ static const int SHAPE_EGG = 27;
+ static const int SHAPE_COCOA = 28;
+ static const int SHAPE_TRIPWIRE_SOURCE = 29;
+ static const int SHAPE_TRIPWIRE = 30;
+ static const int SHAPE_TREE = 31;
+ static const int SHAPE_WALL = 32;
+ static const int SHAPE_FLOWER_POT = 33;
+ static const int SHAPE_BEACON = 34;
+ static const int SHAPE_ANVIL = 35;
+ static const int SHAPE_QUARTZ = 39;
+
+ // 4J - this array of simple constants made so the compiler can optimise references to Ids that were previous of the form Tile_SPU::<whatever>->id, and are now simply Tile_SPU::whatever_Id
+ static const int rock_Id = 1;
+ static const int grass_Id = 2;
+ static const int dirt_Id = 3;
+ static const int stoneBrick_Id = 4;
+ static const int wood_Id = 5;
+ static const int sapling_Id = 6;
+ static const int unbreakable_Id = 7;
+ static const int water_Id = 8;
+ static const int calmWater_Id = 9;
+ static const int lava_Id = 10;
+ static const int calmLava_Id = 11;
+ static const int sand_Id = 12;
+ static const int gravel_Id = 13;
+ static const int goldOre_Id = 14;
+ static const int ironOre_Id = 15;
+ static const int coalOre_Id = 16;
+ static const int treeTrunk_Id = 17;
+ static const int leaves_Id = 18;
+ static const int sponge_Id = 19;
+ static const int glass_Id = 20;
+ static const int lapisOre_Id = 21;
+ static const int lapisBlock_Id = 22;
+ static const int dispenser_Id = 23;
+ static const int sandStone_Id = 24;
+ static const int musicBlock_Id = 25;
+ static const int bed_Id = 26;
+ static const int goldenRail_Id = 27;
+ static const int detectorRail_Id = 28;
+ static const int pistonStickyBase_Id = 29;
+ static const int web_Id = 30;
+ static const int tallgrass_Id = 31;
+ static const int deadBush_Id = 32;
+ static const int pistonBase_Id = 33;
+ static const int pistonExtensionPiece_Id = 34;
+ static const int cloth_Id = 35;
+ static const int pistonMovingPiece_Id = 36;
+ static const int flower_Id = 37;
+ static const int rose_Id = 38;
+ static const int mushroom1_Id = 39;
+ static const int mushroom2_Id = 40;
+ static const int goldBlock_Id = 41;
+ static const int ironBlock_Id = 42;
+ static const int stoneSlab_Id = 43;
+ static const int stoneSlabHalf_Id = 44;
+ static const int redBrick_Id = 45;
+ static const int tnt_Id = 46;
+ static const int bookshelf_Id = 47;
+ static const int mossStone_Id = 48;
+ static const int obsidian_Id = 49;
+ static const int torch_Id = 50;
+ static const int fire_Id = 51;
+ static const int mobSpawner_Id = 52;
+ static const int stairs_wood_Id = 53;
+ static const int chest_Id = 54;
+ static const int redStoneDust_Id = 55;
+ static const int diamondOre_Id = 56;
+ static const int diamondBlock_Id = 57;
+ static const int workBench_Id = 58;
+ static const int crops_Id = 59;
+ static const int farmland_Id = 60;
+ static const int furnace_Id = 61;
+ static const int furnace_lit_Id = 62;
+ static const int sign_Id = 63;
+ static const int door_wood_Id = 64;
+ static const int ladder_Id = 65;
+ static const int rail_Id = 66;
+ static const int stairs_stone_Id = 67;
+ static const int wallSign_Id = 68;
+ static const int lever_Id = 69;
+ static const int pressurePlate_stone_Id = 70;
+ static const int door_iron_Id = 71;
+ static const int pressurePlate_wood_Id = 72;
+ static const int redStoneOre_Id = 73;
+ static const int redStoneOre_lit_Id = 74;
+ static const int notGate_off_Id = 75;
+ static const int notGate_on_Id = 76;
+ static const int button_stone_Id = 77;
+ static const int topSnow_Id = 78;
+ static const int ice_Id = 79;
+ static const int snow_Id = 80;
+ static const int cactus_Id = 81;
+ static const int clay_Id = 82;
+ static const int reeds_Id = 83;
+ static const int recordPlayer_Id = 84;
+ static const int fence_Id = 85;
+ static const int pumpkin_Id = 86;
+ static const int hellRock_Id = 87;
+ static const int hellSand_Id = 88;
+ static const int lightGem_Id = 89;
+ static const int portalTile_Id = 90;
+ static const int litPumpkin_Id = 91;
+ static const int cake_Id = 92;
+ static const int diode_off_Id = 93;
+ static const int diode_on_Id = 94;
+ static const int aprilFoolsJoke_Id = 95;
+ static const int trapdoor_Id = 96;
+
+ static const int monsterStoneEgg_Id = 97;
+ static const int stoneBrickSmooth_Id = 98;
+ static const int hugeMushroom1_Id = 99;
+ static const int hugeMushroom2_Id = 100;
+ static const int ironFence_Id = 101;
+ static const int thinGlass_Id = 102;
+ static const int melon_Id = 103;
+ static const int pumpkinStem_Id = 104;
+ static const int melonStem_Id = 105;
+ static const int vine_Id = 106;
+ static const int fenceGate_Id = 107;
+ static const int stairs_bricks_Id = 108;
+ static const int stairs_stoneBrickSmooth_Id = 109;
+
+ static const int mycel_Id = 110;
+ static const int waterLily_Id = 111;
+ static const int netherBrick_Id = 112;
+ static const int netherFence_Id = 113;
+ static const int stairs_netherBricks_Id = 114;
+ static const int netherStalk_Id = 115;
+ static const int enchantTable_Id = 116;
+ static const int brewingStand_Id = 117;
+ static const int cauldron_Id = 118;
+ static const int endPortalTile_Id = 119;
+ static const int endPortalFrameTile_Id = 120;
+ static const int whiteStone_Id = 121;
+ static const int dragonEgg_Id = 122;
+ static const int redstoneLight_Id = 123;
+ static const int redstoneLight_lit_Id = 124;
+
+
+ static const int woodSlab_Id = 125;
+ static const int woodSlabHalf_Id = 126;
+ static const int cocoa_Id = 127;
+ static const int stairs_sandstone_Id = 128;
+ static const int stairs_sprucewood_Id = 134;
+ static const int stairs_birchwood_Id = 135;
+ static const int stairs_junglewood_Id = 136;
+ static const int emeraldOre_Id = 129;
+ static const int enderChest_Id = 130;
+ static const int tripWireSource_Id = 131;
+ static const int tripWire_Id = 132;
+ static const int emeraldBlock_Id = 133;
+
+ static const int cobbleWall_Id = 139;
+ static const int flowerPot_Id = 140;
+ static const int carrots_Id = 141;
+ static const int potatoes_Id = 142;
+ static const int anvil_Id = 145;
+ static const int button_wood_Id = 143;
+ static const int skull_Id = 144;
+ static const int netherQuartz_Id = 153;
+ static const int quartzBlock_Id = 155;
+ static const int stairs_quartz_Id = 156;
+ static const int woolCarpet_Id = 171;
+
+ static Tile_SPU m_tiles[256];
+
+ Tile_SPU() { id = -1;}
+ Tile_SPU(int tileID) { id = tileID; }
+ virtual ~Tile_SPU() {}
+
+ double getShapeX0() { return ms_pTileData->xx0[id]; }
+ double getShapeX1() { return ms_pTileData->xx1[id]; }
+ double getShapeY0() { return ms_pTileData->yy0[id]; }
+ double getShapeY1() { return ms_pTileData->yy1[id]; }
+ double getShapeZ0() { return ms_pTileData->zz0[id]; }
+ double getShapeZ1() { return ms_pTileData->zz1[id]; }
+ Material_SPU* getMaterial();
+
+ virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL); // 4J added forceData, forceEntity param
+ virtual void updateDefaultShape();
+ virtual void setShape(float x0, float y0, float z0, float x1, float y1, float z1);
+ virtual float getBrightness(ChunkRebuildData *level, int x, int y, int z);
+ virtual int getLightColor(ChunkRebuildData *level, int x, int y, int z); // 4J - brought forward from 1.8.2
+ virtual bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face);
+ virtual int getRenderShape();
+ virtual int getColor(ChunkRebuildData *level, int x, int y, int z);
+ virtual float getShadeBrightness(ChunkRebuildData *level, int x, int y, int z); // 4J - brought forward from 1.8.2
+ virtual bool isSolidRender(bool isServerLevel = false);
+ virtual bool isSolidFace(ChunkRebuildData *level, int x, int y, int z, int face);
+ virtual int getRenderLayer();
+ virtual Icon_SPU *getTexture(ChunkRebuildData *level, int x, int y, int z, int face);
+ virtual Icon_SPU *getTexture(int face, int data);
+ virtual Icon_SPU *getTexture(int face);
+
+ bool isSignalSource() { return ms_pTileData->signalSource[id]; }
+ bool isCubeShaped() { return ms_pTileData->cubeShaped[id]; }
+
+ Icon_SPU* icon() { return &ms_pTileData->iconData[id]; }
+
+
+ int id;
+ static TileData_SPU* ms_pTileData;
+
+ static void initTilePointers();
+ static Tile_SPU* createFromID(int tileID);
+
+};
+
+class TileRef_SPU
+{
+ // because of the way this ref stuff works, we need all the tile classes to be of the same size,
+ // so make sure no data is added to child classes.
+ Tile_SPU* m_pTile;
+public:
+ TileRef_SPU(int tileID) { m_pTile = Tile_SPU::createFromID(tileID); }
+ virtual ~TileRef_SPU() { }
+ Tile_SPU* operator->() const { return m_pTile; }
+ Tile_SPU* getPtr() { return m_pTile; }
+};
+
+//class stoneBrick : public Tile {}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TntTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TntTile_SPU.h
new file mode 100644
index 00000000..5e469ff5
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TntTile_SPU.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "Tile_SPU.h"
+
+class TntTile_SPU : public Tile_SPU
+{
+public:
+ static const int EXPLODE_BIT = 1;
+ TntTile_SPU(int id) : Tile_SPU(id) {}
+
+ Icon_SPU *getTexture(int face, int data)
+ {
+ if (face == Facing::DOWN) return &ms_pTileData->tntTile_iconBottom;
+ if (face == Facing::UP) return &ms_pTileData->tntTile_iconTop;
+ return icon();
+
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TopSnowTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TopSnowTile_SPU.h
new file mode 100644
index 00000000..2b5f86a5
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TopSnowTile_SPU.h
@@ -0,0 +1,61 @@
+#pragma once
+
+#include "Tile_SPU.h"
+#include "ChunkRebuildData.h"
+
+class TopSnowTile_SPU : public Tile_SPU
+{
+public:
+ static const int MAX_HEIGHT = 6;
+ static const int HEIGHT_MASK = 7;
+
+ TopSnowTile_SPU(int id) : Tile_SPU(id) {}
+
+ bool blocksLight() { return false; }
+ bool isSolidRender(bool isServerLevel = false) { return false; }
+ bool isCubeShaped() { return false; }
+ void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param
+ {
+ int height = level->getData(x, y, z) & HEIGHT_MASK;
+ float o = 2 * (1 + height) / 16.0f;
+ setShape(0, 0, 0, 1, o, 1);
+ }
+ bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face)
+ {
+ // Material m = level.getMaterial(x, y, z);
+ if (face == 1) return true;
+ // 4J - don't render faces if neighbouring tiles are also TopSnowTile with at least the same height as this one
+ // Otherwise we get horrible artifacts from the non-manifold geometry created. Fixes bug #8506
+ if ( ( level->getTile(x,y,z) == Tile_SPU::topSnow_Id ) && ( face >= 2 ) )
+ {
+ int h0 = level->getData(x,y,z) & HEIGHT_MASK;
+ int xx = x;
+ int yy = y;
+ int zz = z;
+ // Work out coords of tile who's face we're considering (rather than it's neighbour which is passed in here as x,y,z already
+ // offsetting by the face direction)
+ switch(face)
+ {
+ case 2:
+ zz += 1;
+ break;
+ case 3:
+ zz -= 1;
+ break;
+ case 4:
+ xx += 1;
+ break;
+ case 5:
+ xx -= 1;
+ break;
+ default:
+ break;
+ }
+ int h1 = level->getData(xx,yy,zz) & HEIGHT_MASK;
+ if( h0 >= h1 ) return false;
+ }
+ // if (m == this.material) return false;
+ return Tile_SPU::shouldRenderFace(level, x, y, z, face);
+
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TorchTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TorchTile_SPU.h
new file mode 100644
index 00000000..e2181d00
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TorchTile_SPU.h
@@ -0,0 +1,12 @@
+#pragma once
+#include "Tile_SPU.h"
+
+
+class TorchTile_SPU : public Tile_SPU
+{
+public:
+ TorchTile_SPU(int id) : Tile_SPU(id) {}
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual bool isCubeShaped() { return false; }
+ virtual int getRenderShape() { return Tile_SPU::SHAPE_TORCH;}
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TrapDoorTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TrapDoorTile_SPU.h
new file mode 100644
index 00000000..6f096a17
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TrapDoorTile_SPU.h
@@ -0,0 +1,51 @@
+#pragma once
+
+#include "Tile_SPU.h"
+
+
+class TrapDoorTile_SPU : public Tile_SPU
+{
+public:
+ TrapDoorTile_SPU(int id) : Tile_SPU(id) {}
+
+/*
+ * public int getTexture(int face, int data) { if (face == 0 || face == 1)
+ * return tex; int dir = getDir(data); if ((dir == 0 || dir == 2) ^ (face <= 3))
+ * { return tex; } int tt = (dir / 2 + ((face & 1) ^ dir)); tt += ((data & 4) /
+ * 4); int texture = tex - (data & 8) * 2; if ((tt & 1) != 0) { texture =
+ * -texture; } // if (getDir(data)==0 // tt-=((face+data&3)&1)^((data&4)>>2);
+ * return texture; }
+ */
+
+ bool blocksLight() { return false; }
+ bool isSolidRender(bool isServerLevel = false) { return false; }
+ bool isCubeShaped() { return false; }
+ int getRenderShape() { return Tile_SPU::SHAPE_BLOCK;}
+ void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param
+ {
+ setShape(level->getData(x, y, z));
+ }
+
+ void updateDefaultShape()
+ {
+ float r = 3 / 16.0f;
+ setShape(0, 0.5f - r / 2, 0, 1, 0.5f + r / 2, 1);
+ }
+
+ bool isOpen(int data){ return (data & 4) != 0; }
+
+ using Tile_SPU::setShape;
+ void setShape(int data)
+ {
+ float r = 3 / 16.0f;
+ Tile_SPU::setShape(0, 0, 0, 1, r, 1);
+ if (isOpen(data))
+ {
+ if ((data & 3) == 0) setShape(0, 0, 1 - r, 1, 1, 1);
+ if ((data & 3) == 1) setShape(0, 0, 0, 1, 1, r);
+ if ((data & 3) == 2) setShape(1 - r, 0, 0, 1, 1, 1);
+ if ((data & 3) == 3) setShape(0, 0, 0, r, 1, 1);
+ }
+ }
+
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TreeTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TreeTile_SPU.h
new file mode 100644
index 00000000..dec9f6ac
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TreeTile_SPU.h
@@ -0,0 +1,40 @@
+#pragma once
+
+#include "Tile_SPU.h"
+
+class Player;
+
+class TreeTile_SPU : public Tile_SPU
+{
+public:
+ static const int DARK_TRUNK = 1;
+ static const int BIRCH_TRUNK = 2;
+ static const int JUNGLE_TRUNK = 3;
+
+ static const int MASK_TYPE = 0x3;
+ static const int MASK_FACING = 0xC;
+ static const int FACING_Y = 0 << 2;
+ static const int FACING_X = 1 << 2;
+ static const int FACING_Z = 2 << 2;
+
+ static const int TREE_NAMES_LENGTH = 4;
+
+ TreeTile_SPU(int id) : Tile_SPU(id) {}
+ int getRenderShape() { return Tile_SPU::SHAPE_TREE; }
+
+
+public:
+ Icon_SPU *getTexture(int face, int data)
+ {
+ int dir = data & MASK_FACING;
+ int type = data & MASK_TYPE;
+ if (dir == FACING_Y && (face == Facing::UP || face == Facing::DOWN))
+ return &ms_pTileData->treeTile_iconTop;
+ else if (dir == FACING_X && (face == Facing::EAST || face == Facing::WEST))
+ return &ms_pTileData->treeTile_iconTop;
+ else if (dir == FACING_Z && (face == Facing::NORTH || face == Facing::SOUTH))
+ return &ms_pTileData->treeTile_iconTop;
+
+ return &ms_pTileData->treeTile_icons[data];
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TripWireSourceTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TripWireSourceTile_SPU.h
new file mode 100644
index 00000000..d0abb16e
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TripWireSourceTile_SPU.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "Tile_SPU.h"
+
+class TripWireSourceTile_SPU : public Tile_SPU
+{
+public:
+ static const int MASK_DIR = 0x3;
+ static const int MASK_ATTACHED = 0x4;
+ static const int MASK_POWERED = 0x8;
+ static const int WIRE_DIST_MIN = 1;
+ static const int WIRE_DIST_MAX = 2 + 40; // 2 hooks + x string
+
+ TripWireSourceTile_SPU(int id) : Tile_SPU(id) {}
+
+ bool blocksLight() { return false; }
+ bool isSolidRender(bool isServerLevel = false) { return false; }
+ bool isCubeShaped() { return false; }
+ int getRenderShape() { return Tile_SPU::SHAPE_TRIPWIRE_SOURCE; }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TripWireTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TripWireTile_SPU.h
new file mode 100644
index 00000000..fbb84fb5
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/TripWireTile_SPU.h
@@ -0,0 +1,70 @@
+#pragma once
+
+#include "Tile_SPU.h"
+#include "TripWireSourceTile_SPU.h"
+#include "Direction_SPU.h"
+
+class TripWireTile_SPU : public Tile_SPU
+{
+public:
+ static const int MASK_POWERED = 0x1;
+ static const int MASK_SUSPENDED = 0x2;
+ static const int MASK_ATTACHED = 0x4;
+ static const int MASK_DISARMED = 0x8;
+
+ TripWireTile_SPU(int id) : Tile_SPU(id) {}
+
+ bool blocksLight() { return false; }
+ bool isSolidRender(bool isServerLevel = false) { return false; }
+ bool isCubeShaped() { return false;}
+ int getRenderLayer() { return 1; }
+ int getRenderShape() { return Tile_SPU::SHAPE_TRIPWIRE; }
+
+ void updateShape(ChunkRebuildData *level, int x, int y, int z)
+ {
+ int data = level->getData(x, y, z);
+ bool attached = (data & MASK_ATTACHED) == MASK_ATTACHED;
+ bool suspended = (data & MASK_SUSPENDED) == MASK_SUSPENDED;
+
+ if (!suspended)
+ {
+ setShape(0, 0, 0, 1, 1.5f / 16.0f, 1);
+ }
+ else if (!attached)
+ {
+ setShape(0, 0, 0, 1, 8.0f / 16.0f, 1);
+ }
+ else
+ {
+ setShape(0, 1.0f / 16.0f, 0, 1, 2.5f / 16.0f, 1);
+ }
+
+ }
+ static bool shouldConnectTo(ChunkRebuildData *level, int x, int y, int z, int data, int dir)
+ {
+ {
+ int tx = x + Direction::STEP_X[dir];
+ int ty = y;
+ int tz = z + Direction::STEP_Z[dir];
+ int t = level->getTile(tx, ty, tz);
+ bool suspended = (data & MASK_SUSPENDED) == MASK_SUSPENDED;
+
+ if (t == Tile_SPU::tripWireSource_Id)
+ {
+ int otherData = level->getData(tx, ty, tz);
+ int facing = otherData & TripWireSourceTile_SPU::MASK_DIR;
+
+ return facing == Direction::DIRECTION_OPPOSITE[dir];
+ }
+
+ if (t == Tile_SPU::tripWire_Id)
+ {
+ int otherData = level->getData(tx, ty, tz);
+ bool otherSuspended = (otherData & MASK_SUSPENDED) == MASK_SUSPENDED;
+ return suspended == otherSuspended;
+ }
+
+ return false;
+ }
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/VineTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/VineTile_SPU.h
new file mode 100644
index 00000000..e2f4a4ad
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/VineTile_SPU.h
@@ -0,0 +1,99 @@
+#pragma once
+#include "Tile_SPU.h"
+#include "Direction_SPU.h"
+
+class VineTile_SPU : public Tile_SPU
+{
+public:
+ static const int VINE_SOUTH = 1 << Direction::SOUTH;
+ static const int VINE_NORTH = 1 << Direction::NORTH;
+ static const int VINE_EAST = 1 << Direction::EAST;
+ static const int VINE_WEST = 1 << Direction::WEST;
+
+public:
+ VineTile_SPU(int id) : Tile_SPU(id) {}
+ virtual void updateDefaultShape() { setShape(0, 0, 0, 1, 1, 1); }
+ virtual int getRenderShape() { return SHAPE_VINE; }
+ virtual bool isSolidRender(bool isServerLevel = false) { return false; }
+ virtual bool isCubeShaped() { return false; }
+
+ float _max(float a, float b) { return a > b ? a : b; }
+ float _min(float a, float b) { return a < b ? a : b; }
+ bool isAcceptableNeighbor(int id)
+ {
+ if (id == 0) return false;
+ TileRef_SPU tile(id);
+ if (tile->isCubeShaped() && tile->getMaterial()->blocksMotion()) return true;
+ return false;
+ }
+
+ virtual void updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData = -1, TileEntity* forceEntity = NULL) // 4J added forceData, forceEntity param
+ {
+ const float thickness = 1.0f / 16.0f;
+
+ int facings = level->getData(x, y, z);
+
+ float minX = 1;
+ float minY = 1;
+ float minZ = 1;
+ float maxX = 0;
+ float maxY = 0;
+ float maxZ = 0;
+ bool hasWall = facings > 0;
+
+ if ((facings & VINE_WEST) != 0)
+ {
+ maxX = _max(maxX, thickness);
+ minX = 0;
+ minY = 0;
+ maxY = 1;
+ minZ = 0;
+ maxZ = 1;
+ hasWall = true;
+ }
+ if ((facings & VINE_EAST) != 0)
+ {
+ minX = _min(minX, 1 - thickness);
+ maxX = 1;
+ minY = 0;
+ maxY = 1;
+ minZ = 0;
+ maxZ = 1;
+ hasWall = true;
+ }
+ if ((facings & VINE_NORTH) != 0)
+ {
+ maxZ = _max(maxZ, thickness);
+ minZ = 0;
+ minX = 0;
+ maxX = 1;
+ minY = 0;
+ maxY = 1;
+ hasWall = true;
+ }
+ if ((facings & VINE_SOUTH) != 0)
+ {
+ minZ = _min(minZ, 1 - thickness);
+ maxZ = 1;
+ minX = 0;
+ maxX = 1;
+ minY = 0;
+ maxY = 1;
+ hasWall = true;
+ }
+ if (!hasWall && isAcceptableNeighbor(level->getTile(x, y + 1, z)))
+ {
+ minY = _min(minY, 1 - thickness);
+ maxY = 1;
+ minX = 0;
+ maxX = 1;
+ minZ = 0;
+ maxZ = 1;
+ }
+ setShape(minX, minY, minZ, maxX, maxY, maxZ);
+ }
+
+public:
+ virtual int getColor(ChunkRebuildData *level, int x, int y, int z, int data) { return getColor(level, x, y, z); } // 4J added
+ virtual int getColor(ChunkRebuildData *level, int x, int y, int z){ return level->getFoliageColor(x, z); }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WallTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WallTile_SPU.h
new file mode 100644
index 00000000..98e215d2
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WallTile_SPU.h
@@ -0,0 +1,105 @@
+#pragma once
+
+#include "Tile_SPU.h"
+
+class WallTile_SPU : public Tile_SPU
+{
+public:
+ static const float WALL_WIDTH = 3.0f / 16.0f;
+ static const float WALL_HEIGHT = 13.0f / 16.0f;
+ static const float POST_WIDTH = 4.0f / 16.0f;
+ static const float POST_HEIGHT = 16.0f / 16.0f;
+
+
+ static const int TYPE_NORMAL = 0;
+ static const int TYPE_MOSSY = 1;
+
+ static const unsigned int COBBLE_NAMES[2];
+
+ WallTile_SPU(int id) : Tile_SPU(id) {}
+
+ Icon_SPU *getTexture(int face, int data)
+ {
+ if (data == TYPE_MOSSY)
+ {
+ return TileRef_SPU(mossStone_Id)->getTexture(face);
+ }
+ return TileRef_SPU(stoneBrick_Id)->getTexture(face);
+
+ }
+ int getRenderShape() { return SHAPE_WALL; }
+ bool isCubeShaped() { return false; }
+ bool isSolidRender(bool isServerLevel = false) { return false; }
+ void updateShape(ChunkRebuildData *level, int x, int y, int z)
+ {
+ bool n = connectsTo(level, x, y, z - 1);
+ bool s = connectsTo(level, x, y, z + 1);
+ bool w = connectsTo(level, x - 1, y, z);
+ bool e = connectsTo(level, x + 1, y, z);
+
+ float west = .5f - POST_WIDTH;
+ float east = .5f + POST_WIDTH;
+ float north = .5f - POST_WIDTH;
+ float south = .5f + POST_WIDTH;
+ float up = POST_HEIGHT;
+
+ if (n)
+ {
+ north = 0;
+ }
+ if (s)
+ {
+ south = 1;
+ }
+ if (w)
+ {
+ west = 0;
+ }
+ if (e)
+ {
+ east = 1;
+ }
+
+ if (n && s && !w && !e)
+ {
+ up = WALL_HEIGHT;
+ west = .5f - WALL_WIDTH;
+ east = .5f + WALL_WIDTH;
+ }
+ else if (!n && !s && w && e)
+ {
+ up = WALL_HEIGHT;
+ north = .5f - WALL_WIDTH;
+ south = .5f + WALL_WIDTH;
+ }
+
+ setShape(west, 0, north, east, up, south);
+ }
+ bool connectsTo(ChunkRebuildData *level, int x, int y, int z)
+ {
+ int tile = level->getTile(x, y, z);
+ if (tile == id || tile == Tile_SPU::fenceGate_Id)
+ {
+ return true;
+ }
+ TileRef_SPU tileInstance(tile);
+ if (tileInstance.getPtr() != NULL)
+ {
+ if (tileInstance->getMaterial()->isSolidBlocking() && tileInstance->isCubeShaped())
+ {
+ return tileInstance->getMaterial()->getID() != Material_SPU::vegetable_Id;
+ }
+ }
+ return false;
+
+ }
+ bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face)
+ {
+ if (face == Facing::DOWN)
+ {
+ return Tile_SPU::shouldRenderFace(level, x, y, z, face);
+ }
+ return true;
+
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WaterLilyTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WaterLilyTile_SPU.h
new file mode 100644
index 00000000..4812deea
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WaterLilyTile_SPU.h
@@ -0,0 +1,15 @@
+#pragma once
+#include "Bush_SPU.h"
+
+class WaterlilyTile_SPU : public Bush_SPU
+{
+private:
+ static const int col = 0x208030;
+
+public:
+ WaterlilyTile_SPU(int id) : Bush_SPU(id) {}
+
+ virtual int getRenderShape() { return Tile_SPU::SHAPE_LILYPAD; }
+ virtual int getColor(LevelSource *level, int x, int y, int z) { return ms_pTileData->waterLily_colour;/*return col;*/ }
+ virtual int getColor() { return ms_pTileData->waterLily_colour; /*return col;*/ }
+};
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WebTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WebTile_SPU.h
new file mode 100644
index 00000000..26eeb406
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WebTile_SPU.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include "Tile_SPU.h"
+
+class WebTile_SPU : public Tile_SPU
+{
+
+public:
+ WebTile_SPU(int id) : Tile_SPU(id) {}
+ bool isSolidRender(bool isServerLevel = false) { return false;}
+ int getRenderShape() { return Tile_SPU::SHAPE_CROSS_TEXTURE; }
+ bool blocksLight() { return false;}
+ bool isCubeShaped() { return false;}
+
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WoodSlabTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WoodSlabTile_SPU.h
new file mode 100644
index 00000000..1ed1d839
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WoodSlabTile_SPU.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include "HalfSlabTile_SPU.h"
+
+class WoodSlabTile_SPU : HalfSlabTile_SPU
+{
+public:
+ static const int TYPE_MASK = 7;
+
+ WoodSlabTile_SPU(int id) : HalfSlabTile_SPU(id) {}
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ return TileRef_SPU(wood_Id)->getTexture(face, data & TYPE_MASK);
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WoodTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WoodTile_SPU.h
new file mode 100644
index 00000000..0c1cc3c9
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WoodTile_SPU.h
@@ -0,0 +1,19 @@
+#pragma once
+#include "Tile_SPU.h"
+
+class WoodTile_SPU : public Tile_SPU
+{
+
+public:
+
+ static const int WOOD_NAMES_LENGTH = 4;
+
+public:
+ WoodTile_SPU(int id) : Tile_SPU(id) {}
+ virtual Icon_SPU *getTexture(int face, int data)
+ {
+ if (data < 0 || data >= WOOD_NAMES_LENGTH)
+ data = 0;
+ return &ms_pTileData->woodTile_icons[data];
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WoolCarpetTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WoolCarpetTile_SPU.h
new file mode 100644
index 00000000..4d49e8c4
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WoolCarpetTile_SPU.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include "Tile_SPU.h"
+
+class WoolCarpetTile_SPU : public Tile_SPU
+{
+public:
+ WoolCarpetTile_SPU(int id) : Tile_SPU(id) {}
+
+ Icon_SPU *getTexture(int face, int data) { return TileRef_SPU(cloth_Id)->getTexture(face, data); }
+ bool isSolidRender(bool isServerLevel = false) { return false; }
+ void updateDefaultShape() { updateShape(0); }
+ void updateShape(ChunkRebuildData *level, int x, int y, int z) { updateShape(level->getData(x, y, z)); }
+
+protected:
+ void updateShape(int data)
+ {
+ int height = 0;
+ float o = 1 * (1 + height) / 16.0f;
+ setShape(0, 0, 0, 1, o, 1);
+ }
+
+public:
+ bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face)
+ {
+ if (face == 1) return true;
+ return Tile_SPU::shouldRenderFace(level, x, y, z, face);
+
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WorkbenchTile_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WorkbenchTile_SPU.h
new file mode 100644
index 00000000..5087abd5
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/WorkbenchTile_SPU.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "Tile_SPU.h"
+
+class Player;
+
+class WorkbenchTile_SPU : public Tile_SPU
+{
+public:
+ WorkbenchTile_SPU(int id) : Tile_SPU(id) {}
+ Icon_SPU *getTexture(int face, int data)
+ {
+ if (face == Facing::UP) return &ms_pTileData->workBench_iconTop;
+ if (face == Facing::DOWN) return TileRef_SPU(wood_Id)->getTexture(face);
+ if (face == Facing::NORTH || face == Facing::WEST) return &ms_pTileData->workBench_iconFront;
+ return icon();
+ }
+}; \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/stdafx.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/stdafx.h
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/stdafx.h
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/stubs_SPU.h b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/stubs_SPU.h
new file mode 100644
index 00000000..e298ae2d
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/stubs_SPU.h
@@ -0,0 +1,263 @@
+#pragma once
+
+
+
+const int GL_BYTE = 0;
+const int GL_FLOAT = 0;
+const int GL_UNSIGNED_BYTE = 0;
+
+const int GL_COLOR_ARRAY = 0;
+const int GL_VERTEX_ARRAY = 0;
+const int GL_NORMAL_ARRAY = 0;
+const int GL_TEXTURE_COORD_ARRAY = 0;
+
+const int GL_COMPILE = 0;
+
+const int GL_NORMALIZE = 0;
+
+const int GL_RESCALE_NORMAL = 0;
+
+
+
+const int GL_SMOOTH = 0;
+const int GL_FLAT = 0;
+
+
+
+const int GL_RGBA = 0;
+const int GL_BGRA = 1;
+const int GL_BGR = 0;
+
+const int GL_SAMPLES_PASSED_ARB = 0;
+const int GL_QUERY_RESULT_AVAILABLE_ARB = 0;
+const int GL_QUERY_RESULT_ARB = 0;
+
+const int GL_POLYGON_OFFSET_FILL = 0;
+
+const int GL_FRONT = 0;
+const int GL_BACK = 1;
+const int GL_FRONT_AND_BACK = 2;
+
+const int GL_COLOR_MATERIAL = 0;
+
+const int GL_AMBIENT_AND_DIFFUSE = 0;
+
+const int GL_TEXTURE1 = 0;
+const int GL_TEXTURE0 = 1;
+
+void glFlush();
+void glTexGeni(int,int,int);
+// void glTexGen(int,int,FloatBuffer *);
+//void glReadPixels(int,int, int, int, int, int, ByteBuffer *);
+void glClearDepth(double);
+void glCullFace(int);
+void glDeleteLists(int,int);
+//void glGenTextures(IntBuffer *);
+int glGenTextures();
+int glGenLists(int);
+// void glLight(int, int,FloatBuffer *);
+// void glLightModel(int, FloatBuffer *);
+// void glGetFloat(int a, FloatBuffer *b);
+void glTexCoordPointer(int, int, int, int);
+// void glTexCoordPointer(int, int, FloatBuffer *);
+void glNormalPointer(int, int, int);
+// void glNormalPointer(int, ByteBuffer *);
+void glEnableClientState(int);
+void glDisableClientState(int);
+// void glColorPointer(int, bool, int, ByteBuffer *);
+void glColorPointer(int, int, int, int);
+void glVertexPointer(int, int, int, int);
+// void glVertexPointer(int, int, FloatBuffer *);
+void glDrawArrays(int,int,int);
+void glTranslatef(float,float,float);
+void glRotatef(float,float,float,float);
+void glNewList(int,int);
+void glEndList(int vertexCount = 0);
+void glCallList(int);
+void glPopMatrix();
+void glPushMatrix();
+void glColor3f(float,float,float);
+void glScalef(float,float,float);
+void glMultMatrixf(float *);
+void glColor4f(float,float,float,float);
+void glDisable(int);
+void glEnable(int);
+void glBlendFunc(int,int);
+void glDepthMask(bool);
+void glNormal3f(float,float,float);
+void glDepthFunc(int);
+void glMatrixMode(int);
+void glLoadIdentity();
+void glBindTexture(int,int);
+void glTexParameteri(int,int,int);
+// void glTexImage2D(int,int,int,int,int,int,int,int,ByteBuffer *);
+// void glTexSubImage2D(int,int,int,int,int,int,int,int, ByteBuffer *);
+// void glTexSubImage2D(int,int,int,int,int,int,int,int, IntBuffer *);
+// void glDeleteTextures(IntBuffer *);
+// void glDeleteTextures(int);
+// void glCallLists(IntBuffer *);
+// void glGenQueriesARB(IntBuffer *);
+void glColorMask(bool,bool,bool,bool);
+void glBeginQueryARB(int,int);
+void glEndQueryARB(int);
+// void glGetQueryObjectuARB(int,int,IntBuffer *);
+void glShadeModel(int);
+void glPolygonOffset(float,float);
+void glLineWidth(float);
+void glScaled(double,double,double);
+void gluPerspective(float,float,float,float);
+void glClear(int);
+void glViewport(int,int,int,int);
+void glAlphaFunc(int,float);
+void glOrtho(float,float,float,float,float,float);
+void glClearColor(float,float,float,float);
+void glFogi(int,int);
+void glFogf(int,float);
+// void glFog(int,FloatBuffer *);
+void glColorMaterial(int,int);
+void glMultiTexCoord2f(int, float, float);
+
+//1.8.2
+void glClientActiveTexture(int);
+void glActiveTexture(int);
+
+class GL11
+{
+public:
+ static const int GL_SMOOTH = 0;
+ static const int GL_FLAT = 0;
+ static void glShadeModel(int) {};
+};
+
+// class ARBVertexBufferObject
+// {
+// public:
+// static const int GL_ARRAY_BUFFER_ARB = 0;
+// static const int GL_STREAM_DRAW_ARB = 0;
+// static void glBindBufferARB(int, int) {}
+// static void glBufferDataARB(int, ByteBuffer *, int) {}
+// static void glGenBuffersARB(IntBuffer *) {}
+// };
+//
+//
+// class Level;
+// class Player;
+// class Textures;
+// class Font;
+// class MapItemSavedData;
+// class Mob;
+// class Particles
+// {
+// public:
+// void render(float) {}
+// void tick() {}
+// };
+//
+// class BufferedImage;
+//
+// class Graphics
+// {
+// public:
+// void drawImage(BufferedImage *, int, int, void *) {}
+// void dispose() {}
+// };
+//
+// class ZipEntry
+// {
+// };
+// class InputStream;
+//
+// class File;
+// class ZipFile
+// {
+// public:
+// ZipFile(File *file) {}
+// InputStream *getInputStream(ZipEntry *entry) { return NULL; }
+// ZipEntry *getEntry(const wstring& name) {return NULL;}
+// void close() {}
+// };
+//
+// class ImageIO
+// {
+// public:
+// static BufferedImage *read(InputStream *in) { return NULL; }
+// };
+//
+// class Keyboard
+// {
+// public:
+// static void create() {}
+// static void destroy() {}
+// static bool isKeyDown(int) {return false;}
+// static wstring getKeyName(int) { return L"KEYNAME"; }
+// static void enableRepeatEvents(bool) {}
+// static const int KEY_A = 0;
+// static const int KEY_B = 1;
+// static const int KEY_C = 2;
+// static const int KEY_D = 3;
+// static const int KEY_E = 4;
+// static const int KEY_F = 5;
+// static const int KEY_G = 6;
+// static const int KEY_H = 7;
+// static const int KEY_I = 8;
+// static const int KEY_J = 9;
+// static const int KEY_K = 10;
+// static const int KEY_L = 11;
+// static const int KEY_M = 12;
+// static const int KEY_N = 13;
+// static const int KEY_O = 14;
+// static const int KEY_P = 15;
+// static const int KEY_Q = 16;
+// static const int KEY_R = 17;
+// static const int KEY_S = 18;
+// static const int KEY_T = 19;
+// static const int KEY_U = 20;
+// static const int KEY_V = 21;
+// static const int KEY_W = 22;
+// static const int KEY_X = 23;
+// static const int KEY_Y = 24;
+// static const int KEY_Z = 25;
+// static const int KEY_SPACE = 26;
+// static const int KEY_LSHIFT = 27;
+// static const int KEY_ESCAPE = 28;
+// static const int KEY_BACK = 29;
+// static const int KEY_RETURN = 30;
+// static const int KEY_RSHIFT = 31;
+// static const int KEY_UP = 32;
+// static const int KEY_DOWN = 33;
+// static const int KEY_TAB = 34;
+// };
+//
+// class Mouse
+// {
+// public:
+// static void create() {}
+// static void destroy() {}
+// static int getX() { return 0; }
+// static int getY() { return 0; }
+// static bool isButtonDown(int) { return false; }
+// };
+//
+// class Display
+// {
+// public:
+// static bool isActive() {return true;}
+// static void update();
+// static void swapBuffers();
+// static void destroy() {}
+// };
+//
+// class BackgroundDownloader
+// {
+// public:
+// BackgroundDownloader(File workDir, Minecraft* minecraft) {}
+// void start() {}
+// void halt() {}
+// void forceReload() {}
+// };
+//
+// class Color
+// {
+// public:
+// static int HSBtoRGB(float,float,float) {return 0;}
+// };
diff --git a/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/task.cpp b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/task.cpp
new file mode 100644
index 00000000..24dd069a
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/task.cpp
@@ -0,0 +1,80 @@
+/* SCE CONFIDENTIAL
+PlayStation(R)3 Programmer Tool Runtime Library 430.001
+* Copyright (C) 2007 Sony Computer Entertainment Inc.
+* All Rights Reserved.
+*/
+
+/* common headers */
+#include <stdint.h>
+#include <stdlib.h>
+#include <spu_intrinsics.h>
+#include <cell/spurs.h>
+#include <cell/dma.h>
+
+#include "ChunkRebuildData.h"
+#include "TileRenderer_SPU.h"
+#include "..\Common\DmaData.h"
+
+// #define SPU_HEAPSIZE (0*1024)
+// #define SPU_STACKSIZE (64*1024)
+//
+// CELL_SPU_LS_PARAM(0*1024, 64*1024); // can't use #defines here as it seems to create an asm instruction
+
+
+static const bool sc_verbose = false;
+
+int g_lastHitBlockX = 0;
+int g_lastHitBlockY = 0;
+int g_lastHitBlockZ = 0;
+
+CellSpursJobContext2* g_pSpursJobContext;
+
+void cellSpursJobQueueMain(CellSpursJobContext2 *pContext, CellSpursJob256 *pJob)
+{
+ CellSpursTaskId idTask = cellSpursGetTaskId();
+ unsigned int idSpu = cellSpursGetCurrentSpuId();
+
+ if(sc_verbose)
+ spu_print("ChunkUpdate [SPU#%u] start\n", idSpu);
+
+ g_pSpursJobContext = pContext;
+
+// void* pVolatileMem = NULL;
+// uint32_t volatileSize = 0;
+// ret = cellSpursGetTaskVolatileArea(&pVolatileMem, &volatileSize);
+// spu_print( "----------------- ChunkUpdate ------------------\n"
+// "Stack : %dKb\n"
+// "Heap : %dKb\n"
+// "Prog : %dKb\n"
+// "Free : %dKb\n"
+// "-------------------------------------------------------------\n",
+// SPU_STACKSIZE/1024,
+// SPU_HEAPSIZE/1024,
+// 256 - ((SPU_HEAPSIZE+SPU_STACKSIZE+volatileSize)/1024),
+// volatileSize/1024);
+
+// uint32_t eaEventFlag = spu_extract((vec_uint4)argTask, 0);
+ uint32_t eaDataIn = pJob->workArea.userData[0];
+ uint32_t eaDataOut =pJob->workArea.userData[1];
+
+
+ ChunkRebuildData rebuildData;
+ TileRenderer_SPU tileRenderer(&rebuildData);
+ unsigned int arrayData[4096+32];
+ intArray_SPU tesselatorArray(arrayData);
+ Tile_SPU::initTilePointers();
+
+ DmaData_SPU::getAndWait(&rebuildData, eaDataIn, sizeof(ChunkRebuildData));
+ g_lastHitBlockX = rebuildData.m_lastHitBlockX;
+ g_lastHitBlockY = rebuildData.m_lastHitBlockY;
+ g_lastHitBlockZ = rebuildData.m_lastHitBlockZ;
+
+ rebuildData.m_tesselator._array = &tesselatorArray;
+ rebuildData.disableUnseenTiles();
+ rebuildData.tesselateAllTiles(&tileRenderer);
+ DmaData_SPU::putAndWait(&rebuildData, eaDataOut, sizeof(ChunkRebuildData));
+
+ if(sc_verbose)
+ spu_print("ChunkUpdate [SPU#%u] exit\n", idTask, idSpu);
+}
+