csg.c File Reference

Constructive Solids Geometry. More...

#include "bsp.h"
Include dependency graph for csg.c:

Go to the source code of this file.

Functions

static bspbrush_tSubtractBrush (bspbrush_t *a, const bspbrush_t *b)
static qboolean BrushesDisjoint (bspbrush_t *a, bspbrush_t *b)
static bspbrush_tClipBrushToBox (bspbrush_t *brush, vec3_t clipmins, vec3_t clipmaxs)
 Any planes shared with the box edge will be set to no texinfo.
static qboolean IsInLevel (const int contents, const int level)
 checks if the level# matches the contentsmask. The level# is mapped to the appropriate levelflags.
static bspbrush_tAddBrushListToTail (bspbrush_t *list, bspbrush_t *tail)
static bspbrush_tCullList (bspbrush_t *list, bspbrush_t *skip)
 Builds a new list that doesn't hold the given brush.
static qboolean BrushGE (bspbrush_t *b1, bspbrush_t *b2)
 Returns true if b1 is allowed to bite b2.
int MapBrushesBounds (const int startbrush, const int endbrush, const int level, const vec3_t clipmins, const vec3_t clipmaxs, vec3_t mins, vec3_t maxs)
 sets mins and maxs to the smallest sizes that can contain all brushes from startbrush to endbrush that are in a given level.
bspbrush_tMakeBspBrushList (int startbrush, int endbrush, int level, vec3_t clipmins, vec3_t clipmaxs)
bspbrush_tChopBrushes (bspbrush_t *head)
 Carves any intersecting solid brushes into the minimum number of non-intersecting brushes.

Variables

static int minplanenums [2]
static int maxplanenums [2]

Detailed Description

Constructive Solids Geometry.

Note:
tag all brushes with original contents brushes may contain multiple contents there will be no brush overlap after csg phase

each side has a count of the other sides it splits

the best split will be the one that minimizes the total split counts of all remaining sides

precalc side on plane table

evaluate split side

 {
 cost = 0
 for all sides
   for all sides
     get
       if side splits side and splitside is on same child
         cost++;
 }

Definition in file csg.c.


Function Documentation

static bspbrush_t* AddBrushListToTail ( bspbrush_t list,
bspbrush_t tail 
) [static]

Definition at line 199 of file csg.c.

References bspbrush_s::next, and next.

Referenced by ChopBrushes().

static qboolean BrushesDisjoint ( bspbrush_t a,
bspbrush_t b 
) [static]
Returns:
true if the two brushes definately do not intersect.
Note:
There will be false negatives for some non-axial combinations.

Definition at line 87 of file csg.c.

References i, bspbrush_s::maxs, bspbrush_s::mins, bspbrush_s::numsides, side_s::planenum, qfalse, qtrue, and bspbrush_s::sides.

Referenced by ChopBrushes().

static qboolean BrushGE ( bspbrush_t b1,
bspbrush_t b2 
) [inline, static]

Returns true if b1 is allowed to bite b2.

Definition at line 242 of file csg.c.

References mapbrush_s::contentFlags, CONTENTS_DETAIL, CONTENTS_SOLID, bspbrush_s::original, qfalse, and qtrue.

Referenced by ChopBrushes().

bspbrush_t* ChopBrushes ( bspbrush_t head  ) 

Carves any intersecting solid brushes into the minimum number of non-intersecting brushes.

Definition at line 391 of file csg.c.

References AddBrushListToTail(), BrushesDisjoint(), BrushGE(), CountBrushList(), CullList(), FreeBrushList(), bspbrush_s::next, next, SubtractBrush(), VERB_EXTRA, and Verb_Printf().

Referenced by ConstructLevelNodes_r(), and ProcessSubModel().

static bspbrush_t* ClipBrushToBox ( bspbrush_t brush,
vec3_t  clipmins,
vec3_t  clipmaxs 
) [static]

Any planes shared with the box edge will be set to no texinfo.

Definition at line 113 of file csg.c.

References FreeBrush(), i, maxplanenums, bspbrush_s::maxs, minplanenums, bspbrush_s::mins, bspbrush_s::numsides, side_s::planenum, qfalse, bspbrush_s::sides, SplitBrush(), side_s::texinfo, TEXINFO_NODE, and side_s::visible.

Referenced by MakeBspBrushList().

static bspbrush_t* CullList ( bspbrush_t list,
bspbrush_t skip 
) [static]

Builds a new list that doesn't hold the given brush.

Parameters:
[in] list The brush list to copy
[in] skip The brush to skip
Returns:
a bspbrush_t that is the old list without the skip entry

Definition at line 220 of file csg.c.

References FreeBrush(), bspbrush_s::next, and next.

Referenced by ChopBrushes().

static qboolean IsInLevel ( const int  contents,
const int  level 
) [static]

checks if the level# matches the contentsmask. The level# is mapped to the appropriate levelflags.

Parameters:
[in] contents The contentsmask (of the brush, surface, etc.) to check
[in] level -1 for skipping the levelflag check
Returns:
boolean value

Definition at line 158 of file csg.c.

References CONTENTS_ACTORCLIP, CONTENTS_LIGHTCLIP, CONTENTS_WEAPONCLIP, LEVEL_ACTORCLIP, LEVEL_LIGHTCLIP, LEVEL_WEAPONCLIP, MASK_CLIP, qfalse, and qtrue.

Referenced by MakeBspBrushList(), and MapBrushesBounds().

bspbrush_t* MakeBspBrushList ( int  startbrush,
int  endbrush,
int  level,
vec3_t  clipmins,
vec3_t  clipmaxs 
)
int MapBrushesBounds ( const int  startbrush,
const int  endbrush,
const int  level,
const vec3_t  clipmins,
const vec3_t  clipmaxs,
vec3_t  mins,
vec3_t  maxs 
)

sets mins and maxs to the smallest sizes that can contain all brushes from startbrush to endbrush that are in a given level.

Parameters:
[in] startbrush the index of the first brush to check.
[in] endbrush the index after the last brush to check.
[in] level the level that we are searching for brushes in. -1 for skipping the levelflag check.
[in] clipmins the absolute lowest boundary to allow for brushes.
[in] clipmaxs the absolute highest boundary to allow for brushes.
[out] mins the lowest boundary for all accepted brushes within the clipped bounds.
[out] maxs the highest boundary for all accepted brushes within the clipped bounds.
See also:
ProcessSubModel
IsInLevel

Definition at line 266 of file csg.c.

References AddPointToBounds(), ClearBounds(), mapbrush_s::contentFlags, mapbrush_s::finished, i, IsInLevel(), mapbrushes, mapbrush_s::maxs, and mapbrush_s::mins.

Referenced by ConstructLevelNodes_r().

static bspbrush_t* SubtractBrush ( bspbrush_t a,
const bspbrush_t b 
) [static]
Returns:
a list of brushes that remain after B is subtracted from A.
Note:
Return may by empty if A is contained inside B.
The originals are undisturbed.

Definition at line 55 of file csg.c.

References FreeBrush(), FreeBrushList(), i, bspbrush_s::next, bspbrush_s::numsides, side_s::planenum, bspbrush_s::sides, and SplitBrush().

Referenced by ChopBrushes().


Variable Documentation

int maxplanenums[2] [static]

Definition at line 108 of file csg.c.

Referenced by ClipBrushToBox(), and MakeBspBrushList().

int minplanenums[2] [static]

Definition at line 107 of file csg.c.

Referenced by ClipBrushToBox(), and MakeBspBrushList().


Generated by  doxygen 1.6.2