#include "map.h"
#include "bsp.h"
Go to the source code of this file.
Defines | |
#define | SNAP_EPSILON 0.01 |
#define | EDGE_LENGTH 0.2 |
Functions | |
static void | BoundBrush (bspbrush_t *brush) |
Sets the mins/maxs based on the windings. | |
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 | |
static qboolean | FixWinding (winding_t *w) |
removes degenerate edges from a winding | |
static void | CreateBrushWindings (bspbrush_t *brush) |
makes basewindigs for sides and mins/maxs for the brush | |
static bspbrush_t * | BrushFromBounds (vec3_t mins, vec3_t maxs) |
Creates a new axial brush. | |
static vec_t | BrushVolume (bspbrush_t *brush) |
Returns the volume of the given brush. | |
int | CountBrushList (bspbrush_t *brushes) |
Returns the amount of brushes in the given brushlist. | |
static tree_t * | AllocTree (void) |
static node_t * | AllocNode (void) |
bspbrush_t * | AllocBrush (int numsides) |
void | FreeBrush (bspbrush_t *brushes) |
void | FreeBrushList (bspbrush_t *brushes) |
bspbrush_t * | CopyBrush (const bspbrush_t *brush) |
Duplicates the brush, the sides, and the windings. | |
static int | TestBrushToPlanenum (bspbrush_t *brush, int planenum, int *numsplits, qboolean *hintsplit, int *epsilonbrush) |
qboolean | WindingIsTiny (winding_t *w) |
Returns true if the winding would be crunched out of existance by the vertex snapping. | |
static qboolean | WindingIsHuge (const winding_t *w) |
Returns true if the winding still has one of the points from basewinding for plane. | |
static void | LeafNode (node_t *node, bspbrush_t *brushes) |
static void | CheckPlaneAgainstParents (int pnum, const node_t *node) |
static qboolean | CheckPlaneAgainstVolume (int pnum, node_t *node) |
static side_t * | SelectSplitSide (bspbrush_t *brushes, node_t *node) |
Using a heuristic, choses one of the sides out of the brushlist to partition the brushes with. | |
static int | BrushMostlyOnSide (const bspbrush_t *brush, const plane_t *plane) |
Checks on which side a of plane the brush is. | |
void | SplitBrush (const bspbrush_t *brush, int planenum, bspbrush_t **front, bspbrush_t **back) |
Generates two new brushes, leaving the original unchanged. | |
static void | SplitBrushList (bspbrush_t *brushes, node_t *node, bspbrush_t **front, bspbrush_t **back) |
static node_t * | BuildTree_r (node_t *node, bspbrush_t *brushes) |
tree_t * | BrushBSP (bspbrush_t *brushlist, vec3_t mins, vec3_t maxs) |
The incoming list will be freed before exiting. | |
void | WriteBSPBrushMap (const char *name, const bspbrush_t *list) |
writes a map with the split bsp brushes | |
Variables | |
int | c_nodes |
static int | c_nonvis |
static int | c_active_brushes |
Definition in file brushbsp.c.
#define EDGE_LENGTH 0.2 |
Definition at line 421 of file brushbsp.c.
Referenced by WindingIsTiny().
#define SNAP_EPSILON 0.01 |
Definition at line 51 of file brushbsp.c.
Referenced by SnapWeldVector().
bspbrush_t* AllocBrush | ( | int | numsides | ) |
Definition at line 287 of file brushbsp.c.
References c_active_brushes, Mem_Alloc, and threadstate.
Referenced by BrushFromBounds(), CopyBrush(), MakeBspBrushList(), and SplitBrush().
static node_t* AllocNode | ( | void | ) | [static] |
Definition at line 278 of file brushbsp.c.
References Mem_Alloc.
Referenced by BrushBSP(), and BuildTree_r().
static tree_t* AllocTree | ( | void | ) | [static] |
Definition at line 265 of file brushbsp.c.
References ClearBounds(), tree_t::maxs, Mem_Alloc, and tree_t::mins.
Referenced by BrushBSP().
static void BoundBrush | ( | bspbrush_t * | brush | ) | [static] |
Sets the mins/maxs based on the windings.
Definition at line 36 of file brushbsp.c.
References AddPointToBounds(), ClearBounds(), i, bspbrush_s::maxs, bspbrush_s::mins, winding_s::numpoints, bspbrush_s::numsides, winding_s::p, bspbrush_s::sides, and side_s::winding.
Referenced by CreateBrushWindings(), and SplitBrush().
tree_t* BrushBSP | ( | bspbrush_t * | brushlist, | |
vec3_t | mins, | |||
vec3_t | maxs | |||
) |
The incoming list will be freed before exiting.
Definition at line 945 of file brushbsp.c.
References AddPointToBounds(), AllocNode(), AllocTree(), side_s::bevel, BrushFromBounds(), mapbrush_s::brushnum, BrushVolume(), BuildTree_r(), c_faces, c_nodes, c_nonvis, Com_Printf(), config, mapbrush_s::entitynum, tree_t::headnode, i, bspbrush_s::maxs, tree_t::maxs, tree_t::mins, bspbrush_s::mins, bspbrush_s::next, bspbrush_s::numsides, bspbrush_s::original, bspbrush_s::sides, side_s::texinfo, TEXINFO_NODE, VERB_EXTRA, Verb_Printf(), side_s::visible, node_s::volume, and side_s::winding.
Referenced by ConstructLevelNodes_r(), and ProcessSubModel().
static bspbrush_t* BrushFromBounds | ( | vec3_t | mins, | |
vec3_t | maxs | |||
) | [static] |
Creates a new axial brush.
Definition at line 183 of file brushbsp.c.
References AllocBrush(), CreateBrushWindings(), FindOrCreateFloatPlane(), i, bspbrush_s::numsides, side_s::planenum, bspbrush_s::sides, and VectorClear.
Referenced by BrushBSP().
static int BrushMostlyOnSide | ( | const bspbrush_t * | brush, | |
const plane_t * | plane | |||
) | [static] |
Checks on which side a of plane the brush is.
Definition at line 653 of file brushbsp.c.
References plane_s::dist, DotProduct, i, plane_s::normal, winding_s::numpoints, bspbrush_s::numsides, winding_s::p, PSIDE_BACK, PSIDE_FRONT, bspbrush_s::sides, and side_s::winding.
Referenced by SplitBrush().
static vec_t BrushVolume | ( | bspbrush_t * | brush | ) | [static] |
Returns the volume of the given brush.
Definition at line 211 of file brushbsp.c.
References plane_s::dist, DotProduct, i, mapplanes, plane_s::normal, bspbrush_s::numsides, winding_s::p, side_s::planenum, bspbrush_s::sides, VectorCopy, side_s::winding, and WindingArea().
Referenced by BrushBSP(), and SplitBrush().
static node_t* BuildTree_r | ( | node_t * | node, | |
bspbrush_t * | brushes | |||
) | [static] |
Definition at line 893 of file brushbsp.c.
References AllocNode(), c_nodes, node_s::children, FreeBrushList(), i, LeafNode(), MAX_MAP_PLANES, node_s::parent, side_s::planenum, node_s::planenum, PLANENUM_LEAF, SelectSplitSide(), node_s::side, SplitBrush(), SplitBrushList(), threadstate, VERB_DUMP, Verb_Printf(), and node_s::volume.
Referenced by BrushBSP().
static void CheckPlaneAgainstParents | ( | int | pnum, | |
const node_t * | node | |||
) | [static] |
Definition at line 491 of file brushbsp.c.
References node_s::parent, node_s::planenum, and Sys_Error().
Referenced by SelectSplitSide().
Definition at line 501 of file brushbsp.c.
References FreeBrush(), SplitBrush(), and node_s::volume.
Referenced by SelectSplitSide().
bspbrush_t* CopyBrush | ( | const bspbrush_t * | brush | ) |
Duplicates the brush, the sides, and the windings.
Definition at line 328 of file brushbsp.c.
References AllocBrush(), CopyWinding(), i, bspbrush_s::numsides, bspbrush_s::sides, and side_s::winding.
Referenced by SplitBrush(), and SplitBrushList().
int CountBrushList | ( | bspbrush_t * | brushes | ) |
Returns the amount of brushes in the given brushlist.
Definition at line 251 of file brushbsp.c.
References bspbrush_s::next.
Referenced by ChopBrushes().
static void CreateBrushWindings | ( | bspbrush_t * | brush | ) | [static] |
makes basewindigs for sides and mins/maxs for the brush
Definition at line 146 of file brushbsp.c.
References BaseWindingForPlane(), side_s::bevel, BoundBrush(), ChopWindingInPlace(), plane_s::dist, FixWinding(), i, mapplanes, plane_s::normal, bspbrush_s::numsides, side_s::planenum, bspbrush_s::sides, VERB_EXTRA, Verb_Printf(), and side_s::winding.
Referenced by BrushFromBounds().
removes degenerate edges from a winding
Definition at line 95 of file brushbsp.c.
References i, winding_s::numpoints, ON_EPSILON, winding_s::p, qfalse, qtrue, SnapWeldVector(), VectorCopy, VectorLength(), and VectorSubtract.
Referenced by CreateBrushWindings().
void FreeBrush | ( | bspbrush_t * | brushes | ) |
Definition at line 298 of file brushbsp.c.
References c_active_brushes, FreeWinding(), i, Mem_Free, bspbrush_s::numsides, bspbrush_s::sides, threadstate, and side_s::winding.
Referenced by CheckPlaneAgainstVolume(), ClipBrushToBox(), CullList(), FreeBrushList(), FreeTree_r(), SplitBrush(), and SubtractBrush().
void FreeBrushList | ( | bspbrush_t * | brushes | ) |
Definition at line 314 of file brushbsp.c.
References FreeBrush(), bspbrush_s::next, and next.
Referenced by BuildTree_r(), ChopBrushes(), FreeTree_r(), and SubtractBrush().
static void LeafNode | ( | node_t * | node, | |
bspbrush_t * | brushes | |||
) | [static] |
Definition at line 461 of file brushbsp.c.
References node_s::brushlist, mapbrush_s::brushnum, mapbrush_s::contentFlags, node_s::contentFlags, CONTENTS_PASSABLE, CONTENTS_SOLID, i, bspbrush_s::next, bspbrush_s::numsides, bspbrush_s::original, node_s::planenum, PLANENUM_LEAF, bspbrush_s::sides, side_s::texinfo, TEXINFO_NODE, VERB_DUMP, and Verb_Printf().
Referenced by BuildTree_r().
static side_t* SelectSplitSide | ( | bspbrush_t * | brushes, | |
node_t * | node | |||
) | [static] |
Using a heuristic, choses one of the sides out of the brushlist to partition the brushes with.
the search order goes: visible-structural, visible-detail, nonvisible-structural, nonvisible-detail. If any valid plane is available in a pass, no further passes will be tried.
Definition at line 523 of file brushbsp.c.
References AXIAL, side_s::bevel, c_nonvis, CheckPlaneAgainstParents(), CheckPlaneAgainstVolume(), mapbrush_s::contentFlags, CONTENTS_DETAIL, i, mapplanes, bspbrush_s::next, bspbrush_s::numsides, bspbrush_s::original, side_s::planenum, PSIDE_BACK, PSIDE_BOTH, PSIDE_FACING, PSIDE_FRONT, qfalse, qtrue, bspbrush_s::side, bspbrush_s::sides, SURF_HINT, SURF_SKIP, side_s::surfaceFlags, Sys_Error(), TestBrushToPlanenum(), side_s::tested, bspbrush_s::testside, side_s::texinfo, TEXINFO_NODE, threadstate, side_s::visible, and side_s::winding.
Referenced by BuildTree_r().
welds two vec3_t's into a third, taking into account nearest-to-integer instead of averaging
Definition at line 57 of file brushbsp.c.
References i, and SNAP_EPSILON.
Referenced by FixWinding().
void SplitBrush | ( | const bspbrush_t * | brush, | |
int | planenum, | |||
bspbrush_t ** | front, | |||
bspbrush_t ** | back | |||
) |
Generates two new brushes, leaving the original unchanged.
Definition at line 682 of file brushbsp.c.
References AllocBrush(), BaseWindingForPlane(), BoundBrush(), BrushMostlyOnSide(), BrushVolume(), ChopWindingInPlace(), ClipWindingEpsilon(), Com_Printf(), CopyBrush(), CopyWinding(), plane_s::dist, DotProduct, FreeBrush(), i, mapplanes, MAX_WORLD_WIDTH, plane_s::normal, winding_s::numpoints, bspbrush_s::numsides, bspbrush_s::original, winding_s::p, side_s::planenum, PSIDE_BACK, PSIDE_FRONT, qfalse, bspbrush_s::sides, side_s::tested, side_s::texinfo, TEXINFO_NODE, VERB_EXTRA, Verb_Printf(), side_s::visible, side_s::winding, WindingIsHuge(), and WindingIsTiny().
Referenced by BuildTree_r(), CheckPlaneAgainstVolume(), ClipBrushToBox(), SplitBrushList(), and SubtractBrush().
static void SplitBrushList | ( | bspbrush_t * | brushes, | |
node_t * | node, | |||
bspbrush_t ** | front, | |||
bspbrush_t ** | back | |||
) | [static] |
Definition at line 837 of file brushbsp.c.
References mapbrush_s::brushnum, CopyBrush(), i, bspbrush_s::next, bspbrush_s::numsides, bspbrush_s::original, side_s::planenum, node_s::planenum, PSIDE_BACK, PSIDE_BOTH, PSIDE_FACING, PSIDE_FRONT, bspbrush_s::side, bspbrush_s::sides, SplitBrush(), side_s::texinfo, TEXINFO_NODE, VERB_DUMP, and Verb_Printf().
Referenced by BuildTree_r().
static int TestBrushToPlanenum | ( | bspbrush_t * | brush, | |
int | planenum, | |||
int * | numsplits, | |||
qboolean * | hintsplit, | |||
int * | epsilonbrush | |||
) | [static] |
Definition at line 346 of file brushbsp.c.
References plane_s::dist, dBspPlane_t::dist, DotProduct, i, mapplanes, bspbrush_s::maxs, bspbrush_s::mins, dBspPlane_t::normal, plane_s::normal, winding_s::numpoints, bspbrush_s::numsides, winding_s::p, side_s::planenum, PSIDE_BACK, PSIDE_BOTH, PSIDE_FACING, PSIDE_FRONT, qfalse, qtrue, bspbrush_s::sides, SURF_HINT, side_s::surfaceFlags, Sys_Error(), side_s::texinfo, TEXINFO_NODE, TR_BoxOnPlaneSide(), plane_s::type, dBspPlane_t::type, VectorCopy, side_s::visible, and side_s::winding.
Referenced by SelectSplitSide().
Returns true if the winding still has one of the points from basewinding for plane.
Definition at line 449 of file brushbsp.c.
References i, MAX_WORLD_WIDTH, winding_s::numpoints, winding_s::p, qfalse, and qtrue.
Referenced by SplitBrush().
Returns true if the winding would be crunched out of existance by the vertex snapping.
Definition at line 426 of file brushbsp.c.
References EDGE_LENGTH, i, len, winding_s::numpoints, winding_s::p, qfalse, qtrue, VectorLength(), and VectorSubtract.
Referenced by MakeNodePortal(), SplitBrush(), and SplitNodePortals().
void WriteBSPBrushMap | ( | const char * | name, | |
const bspbrush_t * | list | |||
) |
writes a map with the split bsp brushes
Definition at line 1010 of file brushbsp.c.
References BaseWindingForPlane(), curTile, plane_s::dist, qFILE_s::f, f, FILE_WRITE, FreeWinding(), FS_CloseFile(), FS_OpenFile(), FS_Printf(), i, mapplanes, bspbrush_s::next, plane_s::normal, winding_s::p, side_s::planenum, bspbrush_s::sides, texinfo_s::surfaceFlags, Sys_Error(), side_s::texinfo, dMapTile_t::texinfo, texinfo_s::texture, texinfo_s::value, VERB_LESS, and Verb_Printf().
int c_active_brushes [static] |
Definition at line 30 of file brushbsp.c.
Referenced by AllocBrush(), and FreeBrush().
int c_nodes |
Definition at line 28 of file brushbsp.c.
Referenced by BrushBSP(), BuildTree_r(), and FreeTree_r().
int c_nonvis [static] |
Definition at line 29 of file brushbsp.c.
Referenced by BrushBSP(), and SelectSplitSide().