aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Chunk.h
blob: e0ae016ef128dc5d43561c2f5329b8d69994ef5a (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
#pragma once
#include "AllowAllCuller.h"
#include "Tesselator.h"
#include "..\Minecraft.World\ArrayWithLength.h"
#include "LevelRenderer.h"

class Level;
class TileEntity;
class Entity;
using namespace std;

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

class Chunk
{
private:
	static const int XZSIZE = LevelRenderer::CHUNK_XZSIZE;
	static const int SIZE = LevelRenderer::CHUNK_SIZE;

public:
	Level *level;
	static LevelRenderer *levelRenderer;
private:
#ifndef _LARGE_WORLDS
    static Tesselator *t;
#else
	static DWORD tlsIdx;
public:
	static void CreateNewThreadStorage();
	static void ReleaseThreadStorage();
	static unsigned char *GetTileIdsStorage();
#endif
	
public:
	static int updates;

    int x, y, z;
    int xRender, yRender, zRender;
    int xRenderOffs, yRenderOffs, zRenderOffs;
 
	int xm, ym, zm;
	shared_ptr<AABB> bb;
	ClipChunk *clipChunk;

	int id;
//public:
//	vector<shared_ptr<TileEntity> > renderableTileEntities;		// 4J - removed
    
private:
	LevelRenderer::rteMap			*globalRenderableTileEntities;
	CRITICAL_SECTION				*globalRenderableTileEntities_cs;
	bool							assigned;
public:
	Chunk(Level *level, LevelRenderer::rteMap &globalRenderableTileEntities, CRITICAL_SECTION &globalRenderableTileEntities_cs, int x, int y, int z, ClipChunk *clipChunk);
	Chunk();

    void setPos(int x, int y, int z);
private:
	void translateToPos();
public:
	void makeCopyForRebuild(Chunk *source);
	void rebuild();
#ifdef __PS3__
	void rebuild_SPU();
#endif // __PS3__
	float distanceToSqr(shared_ptr<Entity> player) const;
    float squishedDistanceToSqr(shared_ptr<Entity> player);
    void reset();
    void _delete();

    int getList(int layer);
    void cull(Culler *culler);
    void renderBB() ;
    bool isEmpty();
    void setDirty();
	void clearDirty();	// 4J added
	bool emptyFlagSet(int layer);
	~Chunk();
};