62 for (
int j = 0; j < brush->
numsides && w; j++) {
93 for (
int i = 0;
i < 3;
i++) {
124 for (i = 0; i < brush->
numsides; i++) {
157 for (; brushes; brushes = brushes->
next)
197 for (; brushes; brushes = next) {
198 next = brushes->
next;
212 memcpy(newbrush, brush, size);
225 int* numsplits,
bool* hintsplit,
int* epsilonbrush)
230 vec_t d_front, d_back;
238 for (i = 0; i < brush->
numsides; i++) {
242 if (num == (planenum ^ 1))
259 d_front = d_back = 0;
261 for (i = 0; i < brush->
numsides; i++) {
291 if ((d_front > 0.0 && d_front < 1.0) || (d_back < 0.0 && d_back > -1.0))
305 for (b = brushlist; b; b = b->
next) {
352 #define TESTING_MOCK_SPLIT 1
353 #if TESTING_MOCK_SPLIT
360 int front_cnt = 0, back_cnt = 0;
377 return front_cnt && back_cnt ;
381 #if TESTING_MOCK_SPLIT
401 good = (front && back);
421 int front, back, both, facing, splits;
422 int bsplits, epsilonbrush;
428 side_t* bestside =
nullptr;
429 int bestvalue = -99999;
438 for (pass = 0; pass < numpasses; pass++) {
439 for (brush = brushes; brush; brush = brush->
next) {
444 for (i = 0; i < brush->
numsides; i++) {
457 if (side->
visible ^ (pass < 2))
474 for (test = brushes; test; test = test->
next) {
484 if (s & PSIDE_FACING) {
486 for (
int j = 0; j < test->
numsides; j++) {
501 value = 5 * facing - 5 * splits - abs(front - back);
504 value -= epsilonbrush * 1000;
513 if (value > bestvalue) {
516 for (test = brushes; test; test = test->
next)
533 for (brush = brushes; brush; brush = brush->
next) {
534 for (i = 0; i < brush->
numsides; i++)
550 float d_front, d_back;
552 *front = *back =
nullptr;
556 d_front = d_back = 0;
557 for (i = 0; i < brush->
numsides; i++) {
563 if (d > 0 && d > d_front)
565 else if (d < 0 && d < d_back)
582 for (i = 0; i < brush->
numsides && w; i++) {
606 for (i = 0; i < 2; i++) {
612 for (i = 0; i < brush->
numsides; i++) {
619 for (j = 0; j < 2; j++) {
635 for (i = 0; i < 2; i++) {
637 for (j = 0; j < 3; j++) {
646 if (b[i]->numsides < 3 || j < 3) {
652 if (!(b[0] && b[1])) {
671 for (i = 0; i < 2; i++) {
685 for (i = 0; i < 2; i++) {
704 *front = *back =
nullptr;
706 for (brush = brushes; brush; brush = brush->
next) {
707 const int sides = brush->
side;
712 SplitBrush(brush, planenum, &newbrush, &newbrush2);
714 newbrush->
next = *front;
719 newbrush2->
next = *back;
734 if ((side->
planenum & ~1) == planenum)
740 newbrush->
next = *front;
746 newbrush->
next = *back;
762 int c_faces = 0, c_nonvisfaces = 0, c_brushes = 0;
764 for (b = brushlist; b; b = b->
next) {
768 if (volume <
config.microvolume) {
769 Com_Printf(
"\nWARNING: entity %i, brush %i: microbrush, volume %.3g\n",
#define VectorCopy(src, dest)
static void BoundBrush(bspbrush_t *brush)
Sets the mins/maxs based on the windings.
void setNegativeVolume()
Sets mins and maxs to their starting points before using addPoint.
void Sys_Error(const char *error,...)
winding_t * CopyWinding(const winding_t *w)
Copy a winding with all its points allocated.
void SplitBrushList(bspbrush_t *brushes, uint16_t planenum, bspbrush_t **front, bspbrush_t **back)
#define CONTENTS_PASSABLE
uint16_t FindOrCreateFloatPlane(vec3_t normal, vec_t dist)
bspbrush_t * BrushFromBounds(const vec3_t mins, const vec3_t maxs)
Creates a new axial brush.
bool FixWinding(winding_t *w)
removes degenerate edges from a winding
static vec_t BrushVolume(const bspbrush_t *brush)
Returns the volume of the given brush.
void FreeBrushList(bspbrush_t *brushes)
void ChopWindingInPlace(winding_t **inout, const vec3_t normal, const vec_t dist, const vec_t epsilon)
void Com_Printf(const char *const fmt,...)
void BrushlistCalcStats(bspbrush_t *brushlist, AABB &blBox)
Counts the faces and calculate the aabb.
uint32_t BrushListCalcContents(bspbrush_t *brushlist)
Collects the contentsflags of the brushes in the given list.
bspbrush_t * AllocBrush(int numsides)
side_t * SelectSplitSide(bspbrush_t *brushes, bspbrush_t *volume)
Using a heuristic, choses one of the sides out of the brushlist to partition the brushes with...
void add(const vec3_t point)
If the point is outside the box, expand the box to accommodate it.
#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.
static int c_active_brushes
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 FreeBrush(bspbrush_t *brushes)
static bool DoesPlaneSplitBrush(const bspbrush_t *brush, int planenum)
Checks if the plane splits the brush.
#define STANDARD_NUMBER_OF_BRUSHSIDES
static void CreateBrushWindings(bspbrush_t *brush)
makes basewindigs for sides and mins/maxs for the brush
for storing the vertices of the side of a brush or other polygon
static bool CheckPlaneAgainstVolume(int pnum, const bspbrush_t *volume)
bool WindingIsTiny(winding_t *w)
Returns true if the winding would be crunched out of existance by the vertex snapping.
plane_t mapplanes[MAX_MAP_PLANES]
bspbrush_t * CopyBrush(const bspbrush_t *brush)
Duplicates the brush, the sides, and the windings.
side_t sides[STANDARD_NUMBER_OF_BRUSHSIDES]
vec_t WindingArea(const winding_t *w)
int CountBrushList(bspbrush_t *brushes)
Returns the amount of brushes in the given brushlist.
void SplitBrush(const bspbrush_t *brush, uint16_t planenum, bspbrush_t **front, bspbrush_t **back)
Generates two new brushes, leaving the original unchanged.
struct mapbrush_s * original
struct bspbrush_s bspbrush_t
winding_t * BaseWindingForPlane(const vec3_t normal, const vec_t dist)
static int BrushMostlyOnSide(const bspbrush_t *brush, const plane_t *plane)
Checks on which side a of plane the brush is.
#define MAX_WORLD_WIDTH
-MAX_WORLD_WIDTH up tp +MAX_WORLD_WIDTH
void FreeWinding(winding_t *w)
static int TestBrushToPlanenum(bspbrush_t *brush, uint16_t planenum, int *numsplits, bool *hintsplit, int *epsilonbrush)
int TR_BoxOnPlaneSide(const vec3_t mins, const vec3_t maxs, const TR_PLANE_TYPE *plane)
Returns PSIDE_FRONT, PSIDE_BACK, or PSIDE_BOTH.