30 #define INTEGRAL_EPSILON 0.01
31 #define POINT_EPSILON 0.0625
32 #define OFF_EPSILON 0.5
36 #define MAX_SUPERVERTS 512
59 const int x = (4096 + (
int)(vec[0] + 0.5)) >> 7;
60 const int y = (4096 + (
int)(vec[1] + 0.5)) >> 7;
63 Sys_Error(
"HashVec: point outside valid range");
78 for (
int i = 0;
i < 3;
i++) {
97 Sys_Error(
"numvertexes == MAX_MAP_VERTS");
174 remaining -= (MAXEDGES - 2);
180 for (i = 0; i < remaining; i++)
218 for (
int i = 0;
i < 2;
i++)
228 int x1, x2, y1, y2, t;
247 for (x = x1; x <= x2; x++)
248 for (y = y1; y <= y2; y++)
260 vec3_t delta, exact, off, p;
269 if (j == p1 || j == p2)
276 if (dist <= start || dist >= end)
287 TestEdge(start, dist, p1, j, k + 1);
362 for (
int i = 0;
i < 2;
i++)
407 if (v1 == edge->
v[1] && v2 == edge->
v[0]
435 #define CONTINUOUS_EPSILON 0.001
445 vec_t* p1, *p2, *back;
460 const vec_t* p3 = f2->
p[j];
462 for (k = 0; k < 3; k++) {
471 if (j < f2->numpoints)
512 if (k == (i + 1) % f1->
numpoints && !keep2)
521 if (l == (j + 1) % f2->
numpoints && !keep1)
542 if (!f1->
w || !f2->
w)
569 for (f1 = node->
faces; f1; f1 = f1->
next) {
573 for (f2 = node->
faces; f2 != f1; f2 = f2->
next) {
589 merged->
next =
nullptr;
611 for (
int axis = 0; axis < 2; axis++) {
616 float maxs = -999999;
630 if (maxs - mins <=
config.subdivideSize)
638 vec_t dist = (mins +
config.subdivideSize - 16) / v;
641 if (!frontw || !backw)
642 Sys_Error(
"SubdivideFace: didn't split the polygon (texture: '%s')",
752 const int pside = (p->
nodes[1] == node);
755 if (p->
face[pside]) {
vec_t VectorLength(const vec3_t v)
Calculate the length of a vector.
static int vertexchain[MAX_MAP_VERTS]
dBspEdge_t edges[MAX_MAP_EDGES]
#define VectorCopy(src, dest)
void Sys_Error(const char *error,...)
static int edge_verts[MAX_MAP_VERTS]
winding_t * CopyWinding(const winding_t *w)
Copy a winding with all its points allocated.
static void TestEdge(vec_t start, vec_t end, int p1, int p2, int startvert)
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)
#define CONTINUOUS_EPSILON
struct portal_s * next[2]
static unsigned HashVec(const vec3_t vec)
void CrossProduct(const vec3_t v1, const vec3_t v2, vec3_t cross)
binary operation on vectors in a three-dimensional space
static int hashverts[HASH_SIZE *HASH_SIZE]
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
int GetEdge(int v1, int v2, const face_t *f)
entity_t entities[MAX_MAP_ENTITIES]
static face_t * AllocFace(void)
static int GetVertexnum(const vec3_t in)
Returns the number of an existing vertex or allocates a new one.
static void EmitFaceVertexes(node_t *node, face_t *f)
static void FixEdges_r(node_t *node)
dBspTexinfo_t texinfo[MAX_MAP_TEXINFO]
static void EmitVertexes_r(node_t *node)
void MakeFaces(node_t *node)
static int num_edge_verts
#define DotProduct(x, y)
Returns the distance between two 3-dimensional vectors.
struct node_s * children[2]
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)
static void FindEdgeVerts(const vec3_t v1, const vec3_t v2)
Uses the hash tables to cut down to a small number.
static face_t * FaceFromPortal(portal_t *p, bool pside)
struct mapbrush_s * brush
for storing the vertices of the side of a brush or other polygon
plane_t mapplanes[MAX_MAP_PLANES]
static face_t * TryMerge(face_t *f1, face_t *f2, const vec3_t planenormal)
If two polygons share a common edge and the edges that meet at the common points are both inside the ...
struct portal_s * portals
winding_t * ReverseWinding(const winding_t *w)
static int superverts[MAX_SUPERVERTS]
static face_t * NewFaceFromFace(const face_t *f)
static void SubdivideNodeFaces(node_t *node)
static void FixFaceEdges(node_t *node, face_t *f)
QGL_EXTERN GLuint GLchar GLuint * len
void FixTjuncs(node_t *headnode)
static int c_badstartverts
vec_t VectorNormalize(vec3_t v)
Calculate unit vector for a given vec3_t.
static const face_t * edgefaces[MAX_MAP_EDGES][2]
uint32_t VisibleContents(uint32_t contents)
Returns the single content bit of the strongest visible content present.
static void FaceFromSuperverts(node_t *node, face_t *f, int base)
The faces vertexes have been added to the superverts[] array, and there may be more there than can be...
#define MAX_WORLD_WIDTH
-MAX_WORLD_WIDTH up tp +MAX_WORLD_WIDTH
static int c_facecollapse
vec_t Q_rint(const vec_t in)
Round to nearest integer.
#define Mem_AllocType(type)
dBspVertex_t vertexes[MAX_MAP_VERTS]
const char * ValueForKey(const entity_t *ent, const char *key)
static void MakeFaces_r(node_t *node)
If a portal will make a visible face, mark the side that originally created it.
static int c_faceoverflows
QGL_EXTERN int GLboolean GLfloat * v
static winding_t * TryMergeWinding(winding_t *f1, winding_t *f2, const vec3_t planenormal)
If two polygons share a common edge and the edges that meet at the common points are both inside the ...
static void SubdivideFace(node_t *node, face_t *f)
Chop up faces that are larger than we want in the surface cache.
static void MergeNodeFaces(node_t *node)
#define VectorSubtract(a, b, dest)
void FreeWinding(winding_t *w)