the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2
3class ChunkRebuildData;
4
5class Tesselator {
6 // private static boolean TRIANGLE_MODE = false;
7 friend ChunkRebuildData;
8private:
9 static bool TRIANGLE_MODE;
10 static bool USE_VBO;
11
12 static const int MAX_MEMORY_USE = 16 * 1024 * 1024;
13 static const int MAX_FLOATS = MAX_MEMORY_USE / 4 / 2;
14
15 intArray *_array;
16
17 int vertices;
18 float u, v;
19 int _tex2;
20 int col;
21 bool hasColor;
22 bool hasTexture;
23 bool hasTexture2;
24 bool hasNormal;
25 int p ;
26 bool useCompactFormat360; // 4J - added
27 bool useProjectedTexturePixelShader; // 4J - added
28public:
29 int count;
30private:
31 bool _noColor;
32 int mode;
33 float xo, yo, zo;
34 float xoo, yoo, zoo;
35 int _normal;
36
37 // 4J - added for thread local storage
38public:
39 static void CreateNewThreadStorage(int bytes);
40private:
41 static DWORD tlsIdx;
42public:
43 static Tesselator *getInstance();
44
45private:
46 bool tesselating;
47 bool mipmapEnable; // 4J added
48
49 bool vboMode;
50 IntBuffer *vboIds;
51 int vboId;
52 int vboCounts;
53 int size;
54
55 Tesselator(int size);
56public:
57 Tesselator *getUniqueInstance(int size);
58 void end();
59private:
60 void clear();
61
62 // 4J - added to handle compact quad vertex format, which need packaged up as quads
63 unsigned int m_ix[4],m_iy[4],m_iz[4];
64 unsigned int m_clr[4];
65 unsigned int m_u[4], m_v[4];
66 unsigned int m_t2[4];
67 void packCompactQuad();
68
69#ifdef __PSVITA__
70 // AP - alpha cut out is expensive on vita. Use this to defer primitives that use icons with alpha
71 bool alphaCutOutEnabled;
72
73 // this is the cut out enabled vertex array
74 intArray *_array2;
75 int vertices2;
76 int p2;
77#endif
78
79public:
80
81 // 4J MGH - added, to calculate tight bounds
82 class Bounds
83 {
84 public:
85 void reset()
86 {
87 boundingBox[0] = FLT_MAX;
88 boundingBox[1] = FLT_MAX;
89 boundingBox[2] = FLT_MAX;
90 boundingBox[3] = -FLT_MAX;
91 boundingBox[4] = -FLT_MAX;
92 boundingBox[5] = -FLT_MAX;
93 }
94 void addVert(float x, float y, float z)
95 {
96 if(x < boundingBox[0])
97 boundingBox[0] = x;
98 if(y < boundingBox[1])
99 boundingBox[1] = y;
100 if(z < boundingBox[2])
101 boundingBox[2] = z;
102
103 if(x > boundingBox[3])
104 boundingBox[3] = x;
105 if(y > boundingBox[4])
106 boundingBox[4] = y;
107 if(z > boundingBox[5])
108 boundingBox[5] = z;
109 }
110 void addBounds(Bounds& ob)
111 {
112 if(ob.boundingBox[0] < boundingBox[0])
113 boundingBox[0] = ob.boundingBox[0];
114 if(ob.boundingBox[1] < boundingBox[1])
115 boundingBox[1] = ob.boundingBox[1];
116 if(ob.boundingBox[2] < boundingBox[2])
117 boundingBox[2] = ob.boundingBox[2];
118
119 if(ob.boundingBox[3] > boundingBox[3])
120 boundingBox[3] = ob.boundingBox[3];
121 if(ob.boundingBox[4] > boundingBox[4])
122 boundingBox[4] = ob.boundingBox[4];
123 if(ob.boundingBox[5] > boundingBox[5])
124 boundingBox[5] = ob.boundingBox[5];
125 }
126 float boundingBox[6]; // 4J MGH added
127
128 } bounds;
129
130 void begin();
131 void begin(int mode);
132 void useCompactVertices(bool enable); // 4J added
133 bool getCompactVertices(); // AP added
134 void useProjectedTexture(bool enable); // 4J added
135 void tex(float u, float v);
136 void tex2(int tex2); // 4J - change brought forward from 1.8.2
137 void color(float r, float g, float b);
138 void color(float r, float g, float b, float a);
139 void color(int r, int g, int b);
140 void color(int r, int g, int b, int a);
141 void color(byte r, byte g, byte b);
142 void vertexUV(float x, float y, float z, float u, float v);
143 void vertex(float x, float y, float z);
144 void color(int c);
145 void color(int c, int alpha);
146 void noColor();
147 void normal(float x, float y, float z);
148 void offset(float xo, float yo, float zo);
149 void addOffset(float x, float y, float z);
150 bool setMipmapEnable(bool enable); // 4J added
151
152 bool hasMaxVertices(); // 4J Added
153#ifdef __PSVITA__
154 // AP - alpha cut out is expensive on vita. Use this to defer primitives that use icons with alpha
155 void setAlphaCutOut(bool enable);
156 bool getCutOutFound();
157
158 // AP - a faster way of creating a compressed tile quad
159 void tileQuad(float x1, float y1, float z1, float u1, float v1, float r1, float g1, float b1, int tex1,
160 float x2, float y2, float z2, float u2, float v2, float r2, float g2, float b2, int tex2,
161 float x3, float y3, float z3, float u3, float v3, float r3, float g3, float b3, int tex3,
162 float x4, float y4, float z4, float u4, float v4, float r4, float g4, float b4, int tex4);
163 // AP - a faster way of creating rain quads
164 void tileRainQuad(float x1, float y1, float z1, float u1, float v1,
165 float x2, float y2, float z2, float u2, float v2,
166 float x3, float y3, float z3, float u3, float v3,
167 float x4, float y4, float z4, float u4, float v4,
168 float r1, float g1, float b1, float a1,
169 float r2, float g2, float b2, float a2, int tex1);
170 // AP - a faster way of creating particles
171 void tileParticleQuad(float x1, float y1, float z1, float u1, float v1,
172 float x2, float y2, float z2, float u2, float v2,
173 float x3, float y3, float z3, float u3, float v3,
174 float x4, float y4, float z4, float u4, float v4,
175 float r1, float g1, float b1, float a1);
176#endif
177
178};