MCPcopy Create free account
hub / github.com/JACoders/OpenJK / CM_NeedsSubdivision

Function CM_NeedsSubdivision

code/qcommon/cm_patch.cpp:184–206  ·  view source on GitHub ↗

================= CM_NeedsSubdivision Returns true if the given quadratic curve is not flat enough for our collision detection purposes ================= */

Source from the content-addressed store, hash-verified

182=================
183*/
184static qboolean CM_NeedsSubdivision( vec3_t a, vec3_t b, vec3_t c ) {
185 vec3_t cmid;
186 vec3_t lmid;
187 vec3_t delta;
188 float dist;
189 int i;
190
191 // calculate the linear midpoint
192 for ( i = 0 ; i < 3 ; i++ ) {
193 lmid[i] = 0.5*(a[i] + c[i]);
194 }
195
196 // calculate the exact curve midpoint
197 for ( i = 0 ; i < 3 ; i++ ) {
198 cmid[i] = 0.5 * ( 0.5*(a[i] + b[i]) + 0.5*(b[i] + c[i]) );
199 }
200
201 // see if the curve is far enough away from the linear mid
202 VectorSubtract( cmid, lmid, delta );
203 dist = VectorLengthSquared( delta );
204
205 return (qboolean)(dist >= (SUBDIVIDE_DISTANCE * SUBDIVIDE_DISTANCE));
206}
207
208/*
209===============

Callers 1

CM_SubdivideGridColumnsFunction · 0.70

Calls 2

VectorSubtractFunction · 0.85
VectorLengthSquaredFunction · 0.85

Tested by

no test coverage detected