aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/PS3/SPU_Tasks/LevelRenderer_FindNearestChunk/LevelRenderer_FindNearestChunk.h
blob: a6c3ef2a826a4cac606fee18849362a568a5b6d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#pragma once



class LevelRenderer_FindNearestChunk_DataIn
{
public:
	class PlayerData
	{
	public:
		bool bValid;
		double x,y,z;
	};

	class Chunk;
	class ClipChunk
	{
	public:
		Chunk *chunk;
		int globalIdx;
		bool visible;
		float aabb[6];
		int xm, ym, zm;
	};

	class AABB
	{
		double x0, y0, z0;
		double x1, y1, z1;
	};
	class MultiplayerChunkCache
	{
	public:
		int XZSIZE;
		int XZOFFSET;
 		void** cache;

		bool getChunkEmpty(int lowerOffset, int upperOffset, int x, int y, int z);
	};

	class CompressedTileStorage
	{
	public:
		unsigned char	*indicesAndData;
		int				allocatedSize;

		bool isRenderChunkEmpty(int y);				// Determine if 16x16x16 render-sized chunk is actually empty
	private:
		static void getBlock(int *block, int x, int y, int z) {	*block = ( ( x  & 0x0c ) << 5 ) | ( ( z & 0x0c ) << 3 ) | ( y >> 2 );	}

	};

	class Chunk
	{
	public:
		void *level;
		int x, y, z;
		int xRender, yRender, zRender;
		int xRenderOffs, yRenderOffs, zRenderOffs;
		int xm, ym, zm;
		AABB *bb;
		ClipChunk *clipChunk;

		int id;
		int padding[1];
		//public:
		//	vector<std::shared_ptr<TileEntity> > renderableTileEntities;		// 4J - removed

	private:
		void	*globalRenderableTileEntities;
		void	*globalRenderableTileEntities_cs;
		bool	assigned;
	};


	static const int CHUNK_SIZE = 16;
	static const int CHUNK_Y_COUNT = 256 / CHUNK_SIZE;

	int numGlobalChunks;
	unsigned char* pGlobalChunkFlags;

	bool onlyRebuild;
	LevelRenderer_FindNearestChunk_DataIn::ClipChunk*	chunks[4];
	int				chunkLengths[4];
	void* level[4];
	MultiplayerChunkCache multiplayerChunkCache[4];

	int lowerOffset;		// offsets into the level class, we don't want to compile the entire class
	int upperOffset;

	int xChunks, yChunks, zChunks;

	PlayerData playerData[4];
	LevelRenderer_FindNearestChunk_DataIn::ClipChunk* nearChunk;
	int veryNearCount;
	int padding[2];

#ifdef SN_TARGET_PS3_SPU
	void findNearestChunk();
#endif
};