#include "bsp.h"
Go to the source code of this file.
Defines | |
#define | INTEGRAL_EPSILON 0.01 |
#define | POINT_EPSILON 0.5 |
#define | OFF_EPSILON 0.5 |
#define | MAX_SUPERVERTS 512 |
#define | HASH_SIZE 64 |
#define | CONTINUOUS_EPSILON 0.001 |
Functions | |
static unsigned | HashVec (const vec3_t vec) |
static int | GetVertexnum (const vec3_t in) |
Returns the number of an existing vertex or allocates a new one. | |
static face_t * | AllocFace (void) |
static face_t * | NewFaceFromFace (const face_t *f) |
void | FreeFace (face_t *f) |
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 held in a face (MAXEDGES). | |
static void | EmitFaceVertexes (node_t *node, face_t *f) |
static void | EmitVertexes_r (node_t *node) |
static void | FindEdgeVerts (const vec3_t v1, const vec3_t v2) |
Uses the hash tables to cut down to a small number. | |
static void | TestEdge (vec_t start, vec_t end, int p1, int p2, int startvert) |
static void | FixFaceEdges (node_t *node, face_t *f) |
static void | FixEdges_r (node_t *node) |
void | FixTjuncs (node_t *headnode) |
int | GetEdge (int v1, int v2, const face_t *f) |
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 other polygons, merge them. | |
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 other polygons, merge them. | |
static void | MergeNodeFaces (node_t *node) |
static void | SubdivideFace (node_t *node, face_t *f) |
Chop up faces that are larger than we want in the surface cache. | |
static void | SubdivideNodeFaces (node_t *node) |
static face_t * | FaceFromPortal (portal_t *p, int pside) |
static void | MakeFaces_r (node_t *node) |
If a portal will make a visible face, mark the side that originally created it
| |
void | MakeFaces (node_t *node) |
Variables | |
static int | c_merge |
static int | c_subdivide |
static int | c_totalverts |
static int | c_uniqueverts |
static int | c_degenerate |
static int | c_tjunctions |
static int | c_faceoverflows |
static int | c_facecollapse |
static int | c_badstartverts |
static int | c_faces |
static int | superverts [MAX_SUPERVERTS] |
static int | numsuperverts |
static const face_t * | edgefaces [MAX_MAP_EDGES][2] |
int | firstmodeledge = 1 |
static vec3_t | edge_dir |
static vec3_t | edge_start |
static int | num_edge_verts |
static int | edge_verts [MAX_MAP_VERTS] |
static int | vertexchain [MAX_MAP_VERTS] |
static int | hashverts [HASH_SIZE *HASH_SIZE] |
static int | c_nodefaces |
Definition in file faces.c.
#define CONTINUOUS_EPSILON 0.001 |
Definition at line 448 of file faces.c.
Referenced by TryMergeWinding().
#define HASH_SIZE 64 |
Definition at line 49 of file faces.c.
Referenced by FindEdgeVerts(), and HashVec().
#define INTEGRAL_EPSILON 0.01 |
Definition at line 30 of file faces.c.
Referenced by GetVertexnum().
#define MAX_SUPERVERTS 512 |
Definition at line 36 of file faces.c.
Referenced by FixFaceEdges(), and TestEdge().
#define OFF_EPSILON 0.5 |
Definition at line 32 of file faces.c.
Referenced by TestEdge().
#define POINT_EPSILON 0.5 |
Definition at line 31 of file faces.c.
Referenced by GetVertexnum().
static face_t* AllocFace | ( | void | ) | [static] |
Definition at line 115 of file faces.c.
References c_faces, and Mem_Alloc.
Referenced by FaceFromPortal(), and NewFaceFromFace().
Definition at line 187 of file faces.c.
References c_totalverts, c_uniqueverts, config, curTile, FaceFromSuperverts(), GetVertexnum(), i, MAX_MAP_VERTS, face_s::merged, dMapTile_t::numnormals, winding_s::numpoints, numsuperverts, dMapTile_t::numvertexes, winding_s::p, dBspVertex_t::point, face_s::split, superverts, Sys_Error(), VectorCopy, dMapTile_t::vertexes, and face_s::w.
Referenced by EmitVertexes_r().
static void EmitVertexes_r | ( | node_t * | node | ) | [static] |
Definition at line 216 of file faces.c.
References node_s::children, EmitFaceVertexes(), f, node_s::faces, i, face_s::next, node_s::planenum, and PLANENUM_LEAF.
Referenced by FixTjuncs().
Definition at line 685 of file faces.c.
References AllocFace(), side_s::brush, config, face_s::contentFlags, node_s::contentFlags, CONTENTS_WINDOW, CopyWinding(), curTile, entities, mapbrush_s::entitynum, f, mapplanes, portal_s::nodes, plane_s::normal, side_s::planenum, face_s::planenum, face_s::portal, ReverseWinding(), portal_s::side, SURF_LIGHT, SURF_NODRAW, texinfo_s::surfaceFlags, side_s::surfaceFlags, dMapTile_t::texinfo, side_s::texinfo, face_s::texinfo, ValueForKey(), VisibleContents(), face_s::w, and portal_s::winding.
Referenced by MakeFaces_r().
The faces vertexes have been added to the superverts[] array, and there may be more there than can be held in a face (MAXEDGES).
If less, the faces vertexnums[] will be filled in, otherwise face will reference a tree of split[] faces until all of the vertexnums can be added.
Definition at line 153 of file faces.c.
References c_faceoverflows, node_s::faces, i, MAXEDGES, NewFaceFromFace(), face_s::next, face_s::numpoints, numsuperverts, face_s::split, superverts, and face_s::vertexnums.
Referenced by EmitFaceVertexes(), and FixFaceEdges().
Uses the hash tables to cut down to a small number.
Definition at line 235 of file faces.c.
References edge_verts, HASH_SIZE, hashverts, int(), MAX_WORLD_WIDTH, num_edge_verts, and vertexchain.
Referenced by FixFaceEdges().
static void FixEdges_r | ( | node_t * | node | ) | [static] |
Definition at line 364 of file faces.c.
References node_s::children, f, node_s::faces, FixFaceEdges(), i, face_s::next, node_s::planenum, and PLANENUM_LEAF.
Referenced by FixTjuncs().
Definition at line 308 of file faces.c.
References c_badstartverts, c_facecollapse, count, curTile, edge_dir, edge_start, FaceFromSuperverts(), FindEdgeVerts(), i, len, MAX_SUPERVERTS, face_s::merged, face_s::numpoints, numsuperverts, dBspVertex_t::point, face_s::split, TestEdge(), VectorCopy, VectorNormalize(), VectorSubtract, dMapTile_t::vertexes, and face_s::vertexnums.
Referenced by FixEdges_r().
void FixTjuncs | ( | node_t * | headnode | ) |
Definition at line 383 of file faces.c.
References c_badstartverts, c_degenerate, c_facecollapse, c_faceoverflows, c_tjunctions, c_totalverts, c_uniqueverts, config, EmitVertexes_r(), FixEdges_r(), hashverts, VERB_EXTRA, and Verb_Printf().
Referenced by ConstructLevelNodes_r(), and ProcessSubModel().
void FreeFace | ( | face_t * | f | ) |
Definition at line 134 of file faces.c.
References c_faces, FreeWinding(), Mem_Free, and face_s::w.
Referenced by FreeTree_r().
int GetEdge | ( | int | v1, | |
int | v2, | |||
const face_t * | f | |||
) |
Definition at line 412 of file faces.c.
References config, face_s::contentFlags, curTile, dMapTile_t::edges, firstmodeledge, i, MAX_MAP_EDGES, dMapTile_t::numedges, Sys_Error(), and dBspEdge_t::v.
Referenced by EmitFace().
static int GetVertexnum | ( | const vec3_t | in | ) | [static] |
Returns the number of an existing vertex or allocates a new one.
Definition at line 72 of file faces.c.
References c_totalverts, c_uniqueverts, curTile, HashVec(), hashverts, i, INTEGRAL_EPSILON, MAX_MAP_VERTS, dMapTile_t::numnormals, dMapTile_t::numvertexes, dBspVertex_t::point, POINT_EPSILON, Q_rint(), Sys_Error(), vertexchain, and dMapTile_t::vertexes.
Referenced by EmitFaceVertexes().
static unsigned HashVec | ( | const vec3_t | vec | ) | [static] |
Definition at line 57 of file faces.c.
References HASH_SIZE, int(), and Sys_Error().
Referenced by GetVertexnum().
void MakeFaces | ( | node_t * | node | ) |
Definition at line 777 of file faces.c.
References c_merge, c_nodefaces, c_subdivide, MakeFaces_r(), VERB_EXTRA, and Verb_Printf().
Referenced by ConstructLevelNodes_r(), and ProcessSubModel().
static void MakeFaces_r | ( | node_t * | node | ) | [static] |
If a portal will make a visible face, mark the side that originally created it
Definition at line 741 of file faces.c.
References c_nodefaces, node_s::children, config, node_s::contentFlags, CONTENTS_SOLID, portal_s::face, FaceFromPortal(), node_s::faces, MergeNodeFaces(), portal_s::next, face_s::next, portal_s::nodes, portal_s::onnode, node_s::planenum, PLANENUM_LEAF, node_s::portals, and SubdivideNodeFaces().
Referenced by MakeFaces().
static void MergeNodeFaces | ( | node_t * | node | ) | [static] |
Definition at line 578 of file faces.c.
References node_s::faces, mapplanes, face_s::merged, face_s::next, plane_s::normal, node_s::planenum, face_s::split, and TryMerge().
Referenced by MakeFaces_r().
Definition at line 122 of file faces.c.
References AllocFace(), face_s::merged, face_s::split, and face_s::w.
Referenced by FaceFromSuperverts(), SubdivideFace(), and TryMerge().
Chop up faces that are larger than we want in the surface cache.
Definition at line 610 of file faces.c.
References c_subdivide, ClipWindingEpsilon(), config, curTile, DotProduct, node_s::faces, i, face_s::merged, NewFaceFromFace(), face_s::next, winding_s::numpoints, ON_EPSILON, winding_s::p, face_s::split, SURF_WARP, texinfo_s::surfaceFlags, Sys_Error(), face_s::texinfo, dMapTile_t::texinfo, texinfo_s::texture, texinfo_s::vecs, VectorCopy, VectorNormalize(), and face_s::w.
Referenced by SubdivideNodeFaces().
static void SubdivideNodeFaces | ( | node_t * | node | ) | [static] |
Definition at line 675 of file faces.c.
References f, node_s::faces, face_s::next, and SubdivideFace().
Referenced by MakeFaces_r().
Definition at line 265 of file faces.c.
References c_degenerate, c_tjunctions, curTile, DotProduct, edge_dir, edge_start, edge_verts, error(), MAX_SUPERVERTS, num_edge_verts, numsuperverts, OFF_EPSILON, dBspVertex_t::point, superverts, Sys_Error(), VectorCopy, VectorLength(), VectorMA(), VectorSubtract, and dMapTile_t::vertexes.
Referenced by FixFaceEdges().
If two polygons share a common edge and the edges that meet at the common points are both inside the other polygons, merge them.
Definition at line 550 of file faces.c.
References c_merge, face_s::contentFlags, face_s::merged, NewFaceFromFace(), face_s::planenum, face_s::texinfo, TryMergeWinding(), and face_s::w.
Referenced by MergeNodeFaces().
static winding_t* TryMergeWinding | ( | winding_t * | f1, | |
winding_t * | f2, | |||
const vec3_t | planenormal | |||
) | [static] |
If two polygons share a common edge and the edges that meet at the common points are both inside the other polygons, merge them.
Definition at line 456 of file faces.c.
References AllocWinding(), CONTINUOUS_EPSILON, CrossProduct(), DotProduct, EQUAL_EPSILON, i, winding_s::numpoints, winding_s::p, VectorCopy, VectorNormalize(), and VectorSubtract.
Referenced by TryMerge().
int c_badstartverts [static] |
Definition at line 34 of file faces.c.
Referenced by FixFaceEdges(), and FixTjuncs().
int c_degenerate [static] |
Definition at line 34 of file faces.c.
Referenced by FixTjuncs(), and TestEdge().
int c_facecollapse [static] |
Definition at line 34 of file faces.c.
Referenced by FixFaceEdges(), and FixTjuncs().
int c_faceoverflows [static] |
Definition at line 34 of file faces.c.
Referenced by FaceFromSuperverts(), and FixTjuncs().
int c_faces [static] |
Definition at line 34 of file faces.c.
Referenced by AllocFace(), BrushBSP(), FreeFace(), and MakeBspBrushList().
int c_merge [static] |
Definition at line 34 of file faces.c.
Referenced by MakeFaces(), and TryMerge().
int c_nodefaces [static] |
Definition at line 683 of file faces.c.
Referenced by MakeFaces(), and MakeFaces_r().
int c_subdivide [static] |
Definition at line 34 of file faces.c.
Referenced by MakeFaces(), and SubdivideFace().
int c_tjunctions [static] |
Definition at line 34 of file faces.c.
Referenced by FixTjuncs(), and TestEdge().
int c_totalverts [static] |
Definition at line 34 of file faces.c.
Referenced by EmitFaceVertexes(), FixTjuncs(), and GetVertexnum().
int c_uniqueverts [static] |
Definition at line 34 of file faces.c.
Referenced by EmitFaceVertexes(), FixTjuncs(), and GetVertexnum().
Definition at line 43 of file faces.c.
Referenced by FixFaceEdges(), and TestEdge().
vec3_t edge_start [static] |
Definition at line 44 of file faces.c.
Referenced by FixFaceEdges(), and TestEdge().
int edge_verts[MAX_MAP_VERTS] [static] |
Definition at line 47 of file faces.c.
Referenced by FindEdgeVerts(), and TestEdge().
int firstmodeledge = 1 |
Definition at line 41 of file faces.c.
Referenced by BeginModel(), and GetEdge().
int hashverts[HASH_SIZE *HASH_SIZE] [static] |
Definition at line 52 of file faces.c.
Referenced by FindEdgeVerts(), FixTjuncs(), and GetVertexnum().
int num_edge_verts [static] |
Definition at line 46 of file faces.c.
Referenced by FindEdgeVerts(), and TestEdge().
int numsuperverts [static] |
Definition at line 38 of file faces.c.
Referenced by EmitFaceVertexes(), FaceFromSuperverts(), FixFaceEdges(), and TestEdge().
int superverts[MAX_SUPERVERTS] [static] |
Definition at line 37 of file faces.c.
Referenced by EmitFaceVertexes(), FaceFromSuperverts(), and TestEdge().
int vertexchain[MAX_MAP_VERTS] [static] |
Definition at line 51 of file faces.c.
Referenced by FindEdgeVerts(), and GetVertexnum().