MCPcopy Create free account
hub / github.com/demoth/jake2 / SubdividePolygon

Method SubdividePolygon

client/src/main/java/jake2/client/render/fast/Warp.java:117–240  ·  view source on GitHub ↗

SubdividePolygon @param numverts @param verts

(int numverts, float[][] verts)

Source from the content-addressed store, hash-verified

115 * @param verts
116 */
117 void SubdividePolygon(int numverts, float[][] verts)
118 {
119 int i, j, k;
120 float m;
121 float[][] front = new float[64][3];
122 float[][] back = new float[64][3];
123
124 int f, b;
125 float[] dist = new float[64];
126 float frac;
127
128 if (numverts > 60)
129 Com.Error(Defines.ERR_DROP, "numverts = " + numverts);
130
131 float[] mins = Vec3Cache.get();
132 float[] maxs = Vec3Cache.get();
133
134 BoundPoly(numverts, verts, mins, maxs);
135 float[] v;
136 // x,y und z
137 for (i=0 ; i<3 ; i++)
138 {
139 m = (mins[i] + maxs[i]) * 0.5f;
140 m = SUBDIVIDE_SIZE * (float)Math.floor(m / SUBDIVIDE_SIZE + 0.5f);
141 if (maxs[i] - m < 8)
142 continue;
143 if (m - mins[i] < 8)
144 continue;
145
146 // cut it
147 for (j=0 ; j<numverts ; j++) {
148 dist[j] = verts[j][i] - m;
149 }
150
151 // wrap cases
152 dist[j] = dist[0];
153
154 Math3D.VectorCopy(verts[0], verts[numverts]);
155
156 f = b = 0;
157 for (j=0 ; j<numverts ; j++)
158 {
159 v = verts[j];
160 if (dist[j] >= 0)
161 {
162 Math3D.VectorCopy(v, front[f]);
163 f++;
164 }
165 if (dist[j] <= 0)
166 {
167 Math3D.VectorCopy(v, back[b]);
168 b++;
169 }
170 if (dist[j] == 0 || dist[j+1] == 0) continue;
171
172 if ( (dist[j] > 0) != (dist[j+1] > 0) )
173 {
174 // clip point

Callers 1

GL_SubdivideSurfaceMethod · 0.95

Calls 15

ErrorMethod · 0.95
getMethod · 0.95
BoundPolyMethod · 0.95
VectorCopyMethod · 0.95
releaseMethod · 0.95
createMethod · 0.95
VectorClearMethod · 0.95
xMethod · 0.95
yMethod · 0.95
zMethod · 0.95
DotProductMethod · 0.95
VectorAddMethod · 0.95

Tested by

no test coverage detected