31 #define BOGUS_RANGE 8192
48 if (*(
unsigned* )w == 0xdeaddead)
49 Sys_Error(
"FreeWinding: freed a freed winding");
50 *(
unsigned* )w = 0xdeaddead;
78 memcpy(w->
p, p, nump *
sizeof(p[0]));
125 for (
int i = 0;
i < 3;
i++) {
133 Sys_Error(
"BaseWindingForPlane: no axis found");
221 else if (dot < -epsilon)
270 if (sides[i + 1] ==
SIDE_ON || sides[i + 1] == sides[i])
276 dot = dists[i] / (dists[i] - dists[i + 1]);
278 for (
int j = 0; j < 3; j++) {
281 else if (normal[j] == -1)
284 mid[j] = p1[j] + dot * (p2[j] - p1[j]);
294 Sys_Error(
"ClipWinding: points exceeded estimate");
296 Sys_Error(
"ClipWinding: MAX_POINTS_ON_WINDING");
316 else if (dot < -epsilon)
355 if (sides[i + 1] ==
SIDE_ON || sides[i + 1] == sides[i])
361 dot = dists[i] / (dists[i] - dists[i + 1]);
364 for (
int j = 0; j < 3; j++) {
367 else if (normal[j] == -1)
370 mid[j] = p1[j] + dot * (p2[j] - p1[j]);
378 Sys_Error(
"ClipWinding: points exceeded estimate");
380 Sys_Error(
"ClipWinding: MAX_POINTS_ON_WINDING");
402 #define EDGE_LENGTH 0.2
411 const int j = ((
i == w->
numpoints - 1) ? 0 :
i) + 1;
430 for (
int j = 0; j < 3; j++)
437 #define SNAP_EPSILON 0.01
446 if (a ==
nullptr || b ==
nullptr || out ==
nullptr)
450 for (
int i = 0;
i < 3;
i++) {
452 const double ai = rint(a[
i]);
453 const double bi = rint(a[i]);
462 else if (fabs(ai - a[i]) < fabs(bi - b[i]))
468 vec_t outi = rint(out[i]);
winding_t * ChopWinding(winding_t *in, vec3_t normal, vec_t dist)
vec_t VectorLength(const vec3_t v)
Calculate the length of a vector.
#define VectorCopy(src, dest)
void Sys_Error(const char *error,...)
winding_t * CopyWinding(const winding_t *w)
Copy a winding with all its points allocated.
void WindingBounds(const winding_t *w, vec3_t mins, vec3_t maxs)
void VectorMA(const vec3_t veca, const float scale, const vec3_t vecb, vec3_t outVector)
Sets vector_out (vc) to vevtor1 (va) + scale * vector2 (vb)
static const vec3_t scale
bool FixWinding(winding_t *w)
removes degenerate edges from a winding
#define MAX_POINTS_ON_WINDING
void CrossProduct(const vec3_t v1, const vec3_t v2, vec3_t cross)
binary operation on vectors in a three-dimensional space
void ChopWindingInPlace(winding_t **inout, const vec3_t normal, const vec_t dist, const vec_t epsilon)
#define VectorScale(in, scale, out)
void RemoveColinearPoints(winding_t *w)
#define DotProduct(x, y)
Returns the distance between two 3-dimensional vectors.
bool WindingIsHuge(const winding_t *w)
Returns true if the winding still has one of the points from basewinding for plane.
void AddPointToBounds(const vec3_t v, vec3_t mins, vec3_t maxs)
If the point is outside the box defined by mins and maxs, expand the box to accommodate it...
winding_t * AllocWinding(int points)
Allocate a new winding (polygon)
void ClipWindingEpsilon(const winding_t *in, const vec3_t normal, const vec_t dist, const vec_t epsilon, winding_t **front, winding_t **back)
void WindingCenter(const winding_t *w, vec3_t center)
for storing the vertices of the side of a brush or other polygon
bool WindingIsTiny(winding_t *w)
Returns true if the winding would be crunched out of existance by the vertex snapping.
winding_t * ReverseWinding(const winding_t *w)
#define VectorAdd(a, b, dest)
vec_t WindingArea(const winding_t *w)
QGL_EXTERN GLuint GLchar GLuint * len
vec_t VectorNormalize(vec3_t v)
Calculate unit vector for a given vec3_t.
winding_t * BaseWindingForPlane(const vec3_t normal, const vec_t dist)
#define MAX_WORLD_WIDTH
-MAX_WORLD_WIDTH up tp +MAX_WORLD_WIDTH
static void SnapWeldVector(const vec3_t a, const vec3_t b, vec3_t out)
welds two vec3_t's into a third, taking into account nearest-to-integer instead of averaging ...
QGL_EXTERN int GLboolean GLfloat * v
void ClearBounds(vec3_t mins, vec3_t maxs)
Sets mins and maxs to their starting points before using AddPointToBounds.
#define VectorSubtract(a, b, dest)
void FreeWinding(winding_t *w)