Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

qbsp.h File Reference

#include "cmdlib.h"
#include "mathlib.h"
#include "scriplib.h"
#include "polylib.h"
#include "imagelib.h"
#include "threads.h"
#include "bspfile.h"
#include "shaders.h"
#include "mesh.h"

Include dependency graph for qbsp.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  bspbrush_s
struct  bspface_s
struct  drawsurf_s
struct  drawSurfRef_s
struct  node_s
struct  parseMesh_s
struct  plane_s
struct  portal_s
struct  side_s
struct  tree_t

Defines

#define BPRIMIT_NEWBRUSHES   2
#define BPRIMIT_OLDBRUSHES   1
#define BPRIMIT_UNDEFINED   0
#define CLIP_EPSILON   0.1
#define HINT_PRIORITY   1000
#define MAX_BRUSH_SIDES   1024
#define MAX_BUILD_SIDES   300
#define MAX_PATCH_SIZE   32
#define PLANENUM_LEAF   -1
#define PSIDE_BACK   2
#define PSIDE_BOTH   (PSIDE_FRONT|PSIDE_BACK)
#define PSIDE_FACING   4
#define PSIDE_FRONT   1

Typedefs

typedef bspbrush_s bspbrush_t
typedef bspface_s bspface_t
typedef drawSurfRef_s drawSurfRef_t
typedef drawsurf_s mapDrawSurface_t
typedef node_s node_t
typedef parseMesh_s parseMesh_t
typedef plane_s plane_t
typedef portal_s portal_t
typedef side_s side_t

Functions

void AddTriangleModels (tree_t *tree)
void AllocateLightmaps (entity_t *e)
bspbrush_tAllocBrush (int numsides)
mapDrawSurface_tAllocDrawSurf (void)
node_tAllocNode (void)
tree_tAllocTree (void)
void BeginBSPFile (void)
void BeginModel (void)
qboolean BoundBrush (bspbrush_t *brush)
int BoxOnPlaneSide (vec3_t mins, vec3_t maxs, plane_t *plane)
tree_tBrushBSP (bspbrush_t *brushlist, vec3_t mins, vec3_t maxs)
bspbrush_tBrushFromBounds (vec3_t mins, vec3_t maxs)
vec_t BrushVolume (bspbrush_t *brush)
bspface_tBspFaceForPortal (portal_t *p)
void ClipSidesIntoTree (entity_t *e, tree_t *tree)
void ComputeAxisBase (vec3_t normal, vec3_t texX, vec3_t texY)
bspbrush_tCopyBrush (bspbrush_t *brush)
int CountBrushList (bspbrush_t *brushes)
qboolean CreateBrushWindings (bspbrush_t *brush)
void Draw_ClearWindow (void)
void DrawBrushList (bspbrush_t *brush)
mapDrawSurface_tDrawSurfaceForMesh (mesh_t *m)
mapDrawSurface_tDrawSurfaceForSide (bspbrush_t *b, side_t *s, winding_t *w)
void DrawWinding (winding_t *w)
int EmitShader (const char *shader)
void EndBSPFile (void)
void EndModel (node_t *headnode)
tree_tFaceBSP (bspface_t *list)
void FillOutside (node_t *headnode)
void FilterDetailBrushesIntoTree (entity_t *e, tree_t *tree)
void FilterDrawsurfsIntoTree (entity_t *e, tree_t *tree)
void FilterStructuralBrushesIntoTree (entity_t *e, tree_t *tree)
int FindFloatPlane (vec3_t normal, vec_t dist)
bspbrush_tFinishBrush (void)
void FixTJunctions (entity_t *e)
void FloodAreas (tree_t *tree)
qboolean FloodEntities (tree_t *tree)
void FogDrawSurfs (void)
void FreeBrush (bspbrush_t *brushes)
void FreeBrushList (bspbrush_t *brushes)
void FreePortal (portal_t *p)
void FreeTree (tree_t *tree)
void FreeTree_r (node_t *node)
void FreeTreePortals_r (node_t *node)
void GLS_BeginScene (void)
void GLS_EndScene (void)
void GLS_Winding (winding_t *w, int code)
void LeakFile (tree_t *tree)
void LoadMapFile (char *filename)
bspbrush_tMakeBspBrushList (bspbrush_t *brushes, vec3_t clipmins, vec3_t clipmaxs)
void MakeDrawSurfaces (bspbrush_t *b)
void MakeHeadnodePortals (tree_t *tree)
void MakeNodePortal (node_t *node)
bspface_tMakeStructuralBspFaceList (bspbrush_t *list)
void MakeTreePortals (tree_t *tree)
bspface_tMakeVisibleBspFaceList (bspbrush_t *list)
void MergeSides (entity_t *e, tree_t *tree)
void NumberClusters (tree_t *tree)
void OutputWinding (winding_t *w, FILE *glview)
void ParsePatch (void)
void PatchMapDrawSurfs (entity_t *e)
int PlaneTypeForNormal (vec3_t normal)
qboolean Portal_Passable (portal_t *p)
void PrintBrush (bspbrush_t *brush)
void PrintTree_r (node_t *node, int depth)
void SetLightStyles (void)
void SetModelNumbers (void)
void SplitBrush (bspbrush_t *brush, int planenum, bspbrush_t **front, bspbrush_t **back)
void SplitNodePortals (node_t *node)
void SubdivideDrawSurfs (entity_t *e, tree_t *tree)
mesh_tSubdivideMesh (mesh_t in, float maxError, float minLength)
bspface_tVisibleFaces (entity_t *e, tree_t *tree)
winding_tWindingFromDrawSurf (mapDrawSurface_t *ds)
qboolean WindingIsTiny (winding_t *w)
void WriteBrushList (char *name, bspbrush_t *brush, qboolean onlyvis)
void WriteBspBrushMap (char *name, bspbrush_t *list)
void WriteGLView (tree_t *tree, char *source)
void WritePortalFile (tree_t *tree)

Variables

bspbrush_tbuildBrush
int c_triangleIndexes
int c_triangleModels
int c_triangleSurfaces
int c_triangleVertexes
qboolean coplanar
vec3_t draw_maxs
vec3_t draw_mins
qboolean drawflag
int entity_num
int entitySourceBrushes
qboolean fakemap
qboolean fulldetail
int g_bBrushPrimit
vec3_t map_maxs
vec3_t map_mins
mapDrawSurface_t mapDrawSurfs [MAX_MAP_DRAW_SURFS]
entity_tmapent
char mapIndexedShaders [MAX_MAP_BRUSHSIDES][MAX_QPATH]
plane_t mapplanes [MAX_MAP_PLANES]
vec_t microvolume
qboolean noCurveBrushes
qboolean nodetail
qboolean nofog
int nogridlighting
qboolean noprune
int novertexlighting
qboolean nowater
int numMapDrawSurfs
int numMapIndexedShaders
int numMapPatches
int nummapplanes
char outbase [32]
int samplesize
qboolean showseams
char source [1024]
qboolean testExpand


Define Documentation

#define BPRIMIT_NEWBRUSHES   2
 

Definition at line 452 of file qbsp.h.

#define BPRIMIT_OLDBRUSHES   1
 

Definition at line 451 of file qbsp.h.

Referenced by ParsePatch().

#define BPRIMIT_UNDEFINED   0
 

Definition at line 450 of file qbsp.h.

#define CLIP_EPSILON   0.1
 

Definition at line 36 of file qbsp.h.

#define HINT_PRIORITY   1000
 

Definition at line 39 of file qbsp.h.

#define MAX_BRUSH_SIDES   1024
 

Definition at line 89 of file qbsp.h.

#define MAX_BUILD_SIDES   300
 

Definition at line 265 of file qbsp.h.

Referenced by LoadMapFile().

#define MAX_PATCH_SIZE   32
 

Definition at line 34 of file qbsp.h.

#define PLANENUM_LEAF   -1
 

Definition at line 37 of file qbsp.h.

#define PSIDE_BACK   2
 

Definition at line 303 of file qbsp.h.

#define PSIDE_BOTH   (PSIDE_FRONT|PSIDE_BACK)
 

Definition at line 304 of file qbsp.h.

#define PSIDE_FACING   4
 

Definition at line 305 of file qbsp.h.

#define PSIDE_FRONT   1
 

Definition at line 302 of file qbsp.h.


Typedef Documentation

typedef struct bspbrush_s bspbrush_t
 

typedef struct bspface_s bspface_t
 

Referenced by AllocBspFace(), BspFaceForPortal(), BuildFaceTree_r(), CountFaceList(), FaceBSP(), FreeBspFace(), MakeStructuralBspFaceList(), MakeVisibleBspFaceList(), ProcessWorldModel(), and SelectSplitPlaneNum().

typedef struct drawSurfRef_s drawSurfRef_t
 

Referenced by EmitLeaf(), FilterMapDrawSurfIntoTree(), FilterMapDrawSurfIntoTree_r(), and FilterSideIntoTree_r().

typedef struct drawsurf_s mapDrawSurface_t
 

Referenced by AddPatchEdges(), AddSurfaceEdges(), AllocateLightmapForPatch(), AllocateLightmapForSurface(), AllocateLightmaps(), AllocDrawSurf(), ChopFaceByBrush(), ChopPatchByBrush(), CreateFlareSurface(), CreateTerrainSurface(), DrawSurfaceForMesh(), DrawSurfaceForSide(), DrawSurfToMesh(), EmitFlareSurf(), EmitModelSurf(), EmitPatchSurf(), EmitPlanarSurf(), FilterDrawsurfsIntoTree(), FilterFaceIntoTree(), FilterFlareSurfIntoTree(), FilterMapDrawSurfIntoTree(), FilterMapDrawSurfIntoTree_r(), FilterMiscModelSurfIntoTree(), FilterPatchSurfIntoTree(), FilterSideIntoTree_r(), FixSurfaceJunctions(), FixTJunctions(), FogDrawSurfs(), InsertASEModel(), InsertMD3Model(), PatchMapDrawSurfs(), SubdivideDrawSurf(), SubdivideDrawSurfs(), and WindingFromDrawSurf().

typedef struct node_s node_t
 

typedef struct parseMesh_s parseMesh_t
 

Referenced by AdjustBrushesForOrigin(), BeginModel(), MoveBrushesToWorld(), ParsePatch(), and PatchMapDrawSurfs().

typedef struct plane_s plane_t
 

typedef struct portal_s portal_t
 

typedef struct side_s side_t
 


Function Documentation

void AddTriangleModels tree_t tree  ) 
 

Definition at line 428 of file misc_model.c.

References _printf(), c_triangleIndexes, c_triangleModels, c_triangleSurfaces, c_triangleVertexes, entities, entity_num, FloatForKey(), GetVectorForKey(), InsertASEModel(), InsertMD3Model(), Q_stricmp(), qprintf(), strstr(), tree(), ValueForKey(), and vec3_t.

Referenced by ProcessWorldModel().

00428                                        {
00429     int         entity_num;
00430     entity_t    *entity;
00431 
00432     qprintf("----- AddTriangleModels -----\n");
00433 
00434     for ( entity_num=1 ; entity_num< num_entities ; entity_num++ ) {
00435         entity = &entities[entity_num];
00436     
00437         // convert misc_models into raw geometry
00438         if ( !Q_stricmp( "misc_model", ValueForKey( entity, "classname" ) ) ) {
00439             const char  *model;
00440             vec3_t  origin;
00441             float   angle;
00442 
00443             // get the angle for rotation  FIXME: support full matrix positioning
00444             angle = FloatForKey( entity, "angle" );
00445 
00446             GetVectorForKey( entity, "origin", origin );
00447 
00448             model = ValueForKey( entity, "model" );
00449             if ( !model[0] ) {
00450                 _printf("WARNING: misc_model at %i %i %i without a model key\n", (int)origin[0],
00451                     (int)origin[1], (int)origin[2] );
00452                 continue;
00453             }
00454             if ( strstr( model, ".md3" ) || strstr( model, ".MD3" ) ) {
00455                 InsertMD3Model( model, origin, angle, tree );
00456                 continue;
00457             }
00458             if ( strstr( model, ".ase" ) || strstr( model, ".ASE" ) ) {
00459                 InsertASEModel( model, origin, angle, tree );
00460                 continue;
00461             }
00462             _printf( "Unknown misc_model type: %s\n", model );
00463             continue;
00464         }
00465     }
00466 
00467     qprintf( "%5i triangle models\n", c_triangleModels );
00468     qprintf( "%5i triangle surfaces\n", c_triangleSurfaces );
00469     qprintf( "%5i triangle vertexes\n", c_triangleVertexes );
00470     qprintf( "%5i triangle indexes\n", c_triangleIndexes );
00471 }

Here is the call graph for this function:

void AllocateLightmaps entity_t e  ) 
 

Definition at line 328 of file lightmaps.c.

References AllocateLightmapForSurface(), c_exactLightmap, e, Error(), entity_t::firstDrawSurf, i, j, LIGHTMAP_HEIGHT, LIGHTMAP_WIDTH, drawsurf_s::lightmapNum, drawsurf_s::lightmapVecs, mapDrawSurface_t, mapDrawSurfs, mapplanes, drawsurf_s::miscModel, drawsurf_s::nextOnShader, numLightmaps, numSortShaders, drawsurf_s::numVerts, drawsurf_s::patch, side_s::planenum, qprintf(), drawsurf_s::shaderInfo, shaderInfo_t, drawsurf_s::side, shaderInfo_s::surfaceFlags, surfsOnShader, and VectorCopy.

Referenced by ProcessSubModel(), and ProcessWorldModel().

00328                                       {
00329     int             i, j;
00330     mapDrawSurface_t    *ds;
00331     shaderInfo_t    *si;
00332 
00333     qprintf ("--- AllocateLightmaps ---\n");
00334 
00335 
00336     // sort all surfaces by shader so common shaders will usually
00337     // be in the same lightmap
00338     numSortShaders = 0;
00339 
00340     for ( i = e->firstDrawSurf ; i < numMapDrawSurfs ; i++ ) {
00341         ds = &mapDrawSurfs[i];
00342         if ( !ds->numVerts ) {
00343             continue;       // leftover from a surface subdivision
00344         }
00345         if ( ds->miscModel ) {
00346             continue;
00347         }
00348         if ( !ds->patch ) {
00349             VectorCopy( mapplanes[ds->side->planenum].normal, ds->lightmapVecs[2] );
00350         }
00351 
00352         // search for this shader
00353         for ( j = 0 ; j < numSortShaders ; j++ ) {
00354             if ( ds->shaderInfo == surfsOnShader[j]->shaderInfo ) {
00355                 ds->nextOnShader = surfsOnShader[j];
00356                 surfsOnShader[j] = ds;
00357                 break;
00358             }
00359         }
00360         if ( j == numSortShaders ) {
00361             if ( numSortShaders >= MAX_MAP_SHADERS ) {
00362                 Error( "MAX_MAP_SHADERS" );
00363             }
00364             surfsOnShader[j] = ds;
00365             numSortShaders++;
00366         }
00367     }
00368     qprintf( "%5i unique shaders\n", numSortShaders );
00369 
00370     // for each shader, allocate lightmaps for each surface
00371 
00372 //  numLightmaps = 0;
00373 //  PrepareNewLightmap();
00374 
00375     for ( i = 0 ; i < numSortShaders ; i++ ) {
00376         si = surfsOnShader[i]->shaderInfo;
00377 
00378         for ( ds = surfsOnShader[i] ; ds ; ds = ds->nextOnShader ) {
00379             // some surfaces don't need lightmaps allocated for them
00380             if ( si->surfaceFlags & SURF_NOLIGHTMAP ) {
00381                 ds->lightmapNum = -1;
00382             } else if ( si->surfaceFlags & SURF_POINTLIGHT ) {
00383                 ds->lightmapNum = -3;
00384             } else {
00385                 AllocateLightmapForSurface( ds );
00386             }
00387         }
00388     }
00389 
00390     qprintf( "%7i exact lightmap texels\n", c_exactLightmap );
00391     qprintf( "%7i block lightmap texels\n", numLightmaps * LIGHTMAP_WIDTH*LIGHTMAP_HEIGHT );
00392 }

Here is the call graph for this function:

bspbrush_t* AllocBrush int  numsides  ) 
 

Definition at line 422 of file brushbsp.c.

References bspbrush_t, c, c_active_brushes, c_brushmemory, c_peak_brushmemory, GetMemory(), malloc(), MemorySize(), memset(), and numthreads.

Referenced by BrushFromBounds(), CopyBrush(), HL_SplitBrush(), LoadMapFile(), MakeBspBrushList(), Q1_SplitBrush(), SplitBrush(), and TryMergeBrushes().

00423 {
00424     bspbrush_t  *bb;
00425     int         c;
00426 
00427     c = (int)&(((bspbrush_t *)0)->sides[numsides]);
00428     bb = GetMemory(c);
00429     memset (bb, 0, c);
00430     if (numthreads == 1)
00431     {
00432         c_active_brushes++;
00433         c_brushmemory += MemorySize(bb);
00434         if (c_brushmemory > c_peak_brushmemory)
00435                 c_peak_brushmemory = c_brushmemory;
00436     } //end if
00437     return bb;
00438 } //end of the function AllocBrush

Here is the call graph for this function:

mapDrawSurface_t * AllocDrawSurf void   ) 
 

Definition at line 42 of file surface.c.

References Error(), mapDrawSurface_t, mapDrawSurfs, and numMapDrawSurfs.

Referenced by CreateFlareSurface(), CreateTerrainSurface(), DrawSurfaceForMesh(), DrawSurfaceForSide(), InsertASEModel(), and InsertMD3Model().

00042                                            {
00043     mapDrawSurface_t    *ds;
00044 
00045     if ( numMapDrawSurfs >= MAX_MAP_DRAW_SURFS ) {
00046         Error( "MAX_MAP_DRAW_SURFS");
00047     }
00048     ds = &mapDrawSurfs[ numMapDrawSurfs ];
00049     numMapDrawSurfs++;
00050 
00051     return ds;
00052 }

Here is the call graph for this function:

node_t* AllocNode void   ) 
 

Definition at line 404 of file brushbsp.c.

References c_nodememory, GetMemory(), malloc(), MemorySize(), memset(), node_t, and numthreads.

00405 {
00406     node_t  *node;
00407 
00408     node = GetMemory(sizeof(*node));
00409     memset (node, 0, sizeof(*node));
00410     if (numthreads == 1)
00411     {
00412         c_nodememory += MemorySize(node);
00413     } //end if
00414     return node;
00415 } //end of the function AllocNode

Here is the call graph for this function:

tree_t* AllocTree void   ) 
 

Definition at line 546 of file brush.c.

References ClearBounds(), malloc(), memset(), and tree().

Referenced by FaceBSP(), and ProcessSubModel().

00547 {
00548     tree_t  *tree;
00549 
00550     tree = malloc(sizeof(*tree));
00551     memset (tree, 0, sizeof(*tree));
00552     ClearBounds (tree->mins, tree->maxs);
00553 
00554     return tree;
00555 }

Here is the call graph for this function:

void BeginBSPFile void   ) 
 

Definition at line 477 of file writebsp.c.

References dleaf_t::contents, dleafs, numbrushsides, numedges, numfaces, numleafbrushes, numleaffaces, numleafs, numleafsurfaces, nummodels, numnodes, numsurfedges, and numvertexes.

00478 {
00479     // these values may actually be initialized
00480     // if the file existed when loaded, so clear them explicitly
00481     nummodels = 0;
00482     numfaces = 0;
00483     numnodes = 0;
00484     numbrushsides = 0;
00485     numvertexes = 0;
00486     numleaffaces = 0;
00487     numleafbrushes = 0;
00488     numsurfedges = 0;
00489 
00490     // edge 0 is not used, because 0 can't be negated
00491     numedges = 1;
00492 
00493     // leave vertex 0 as an error
00494     numvertexes = 1;
00495 
00496     // leave leaf 0 as an error
00497     numleafs = 1;
00498     dleafs[0].contents = CONTENTS_SOLID;
00499 }

void BeginModel void   ) 
 

Definition at line 538 of file writebsp.c.

References AddPointToBounds(), b, entity_t::brushes, bspbrush_t, ClearBounds(), dmodels, e, EmitBrushes(), entities, Error(), dmodel_t::firstBrush, entity_t::firstbrush, dmodel_t::firstface, firstmodeledge, firstmodelface, firstmodleaf, dmodel_t::firstSurface, mesh_t::height, i, j, mapbrush_t, mapbrushes, bspbrush_s::maxs, dmodel_t::maxs, mapbrush_s::maxs, parseMesh_s::mesh, bspbrush_s::mins, dmodel_t::mins, mapbrush_s::mins, bspbrush_s::next, parseMesh_s::next, entity_t::numbrushes, nummodels, bspbrush_s::numsides, mapbrush_s::numsides, p, parseMesh_t, entity_t::patches, vec3_t, VectorCopy, mesh_t::verts, mesh_t::width, and drawVert_t::xyz.

00539 {
00540     dmodel_t    *mod;
00541     int         start, end;
00542     mapbrush_t  *b;
00543     int         j;
00544     entity_t    *e;
00545     vec3_t      mins, maxs;
00546 
00547     if (nummodels == MAX_MAP_MODELS)
00548         Error ("MAX_MAP_MODELS");
00549     mod = &dmodels[nummodels];
00550 
00551     mod->firstface = numfaces;
00552 
00553     firstmodleaf = numleafs;
00554     firstmodeledge = numedges;
00555     firstmodelface = numfaces;
00556 
00557     //
00558     // bound the brushes
00559     //
00560     e = &entities[entity_num];
00561 
00562     start = e->firstbrush;
00563     end = start + e->numbrushes;
00564     ClearBounds (mins, maxs);
00565 
00566     for (j=start ; j<end ; j++)
00567     {
00568         b = &mapbrushes[j];
00569         if (!b->numsides)
00570             continue;   // not a real brush (origin brush)
00571         AddPointToBounds (b->mins, mins, maxs);
00572         AddPointToBounds (b->maxs, mins, maxs);
00573     }
00574 
00575     VectorCopy (mins, mod->mins);
00576     VectorCopy (maxs, mod->maxs);
00577 }

Here is the call graph for this function:

qboolean BoundBrush bspbrush_t brush  ) 
 

Definition at line 237 of file brushbsp.c.

References AddPointToBounds(), bspbrush_t, ClearBounds(), i, j, MAX_WORLD_COORD, bspbrush_s::maxs, MIN_WORLD_COORD, bspbrush_s::mins, winding_t::numpoints, bspbrush_s::numsides, winding_t::p, qboolean, bspbrush_s::sides, w, and side_s::winding.

Referenced by CheckBSPBrush(), CreateBrushWindings(), HL_SplitBrush(), Q1_SplitBrush(), SplitBrush(), and TryMergeBrushes().

00238 {
00239     int         i, j;
00240     winding_t   *w;
00241 
00242     ClearBounds (brush->mins, brush->maxs);
00243     for (i=0 ; i<brush->numsides ; i++)
00244     {
00245         w = brush->sides[i].winding;
00246         if (!w)
00247             continue;
00248         for (j=0 ; j<w->numpoints ; j++)
00249             AddPointToBounds (w->p[j], brush->mins, brush->maxs);
00250     }
00251 } //end of the function BoundBrush

Here is the call graph for this function:

int BoxOnPlaneSide vec3_t  mins,
vec3_t  maxs,
plane_t plane
 

Definition at line 579 of file brushbsp.c.

References plane_t::dist, plane_t::normal, p, and plane_t::type.

Referenced by CM_BoxLeafnums_r(), QuickTestBrushToPlanenum(), R_BoxSurfaces_r(), R_RecursiveWorldNode(), and TestBrushToPlanenum().

00580 {
00581     float   dist1, dist2;
00582     int sides;
00583 
00584     // axial planes are easy
00585     if (p->type < 3)
00586     {
00587         sides = 0;
00588         if (emaxs[p->type] > p->dist+PLANESIDE_EPSILON) sides |= PSIDE_FRONT;
00589         if (emins[p->type] < p->dist-PLANESIDE_EPSILON) sides |= PSIDE_BACK;
00590         return sides;
00591     } //end if
00592     
00593 // general case
00594     switch (p->signbits)
00595     {
00596     case 0:
00597         dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
00598         dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
00599         break;
00600     case 1:
00601         dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
00602         dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
00603         break;
00604     case 2:
00605         dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
00606         dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
00607         break;
00608     case 3:
00609         dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
00610         dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
00611         break;
00612     case 4:
00613         dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
00614         dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
00615         break;
00616     case 5:
00617         dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
00618         dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
00619         break;
00620     case 6:
00621         dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
00622         dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
00623         break;
00624     case 7:
00625         dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
00626         dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
00627         break;
00628     default:
00629         dist1 = dist2 = 0;      // shut up compiler
00630 //      assert( 0 );
00631         break;
00632     }
00633 
00634     sides = 0;
00635     if (dist1 - p->dist >= PLANESIDE_EPSILON) sides = PSIDE_FRONT;
00636     if (dist2 - p->dist < PLANESIDE_EPSILON) sides |= PSIDE_BACK;
00637 
00638 //  assert(sides != 0);
00639 
00640     return sides;
00641 }

tree_t* BrushBSP bspbrush_t brushlist,
vec3_t  mins,
vec3_t  maxs
 

Definition at line 1756 of file brushbsp.c.

References AddPointToBounds(), AllocNode(), b, BrushFromBounds(), mapbrush_s::brushnum, BrushVolume(), bspbrush_t, BuildTree(), c_active_brushes, c_brushmemory, c_faces, c_nodememory, c_nodes, c_nonvis, c_peak_brushmemory, c_peak_totalbspmemory, c_totalsides, mapbrush_s::entitynum, side_s::flags, i, Log_Print(), Log_Write(), bspbrush_s::maxs, bspbrush_s::mins, bspbrush_s::next, node_t, numrecurse, bspbrush_s::numsides, numthreads, bspbrush_s::original, qprintf(), bspbrush_s::sides, side_s::texinfo, tree(), Tree_Alloc(), vec_t, node_s::volume, and side_s::winding.

Referenced by ProcessWorldBrushes().

01757 {
01758     int i, c_faces, c_nonvisfaces, c_brushes;
01759     bspbrush_t *b;
01760     node_t *node;
01761     tree_t *tree;
01762     vec_t volume;
01763 //  vec3_t point;
01764 
01765     Log_Print("-------- Brush BSP ---------\n");
01766 
01767     tree = Tree_Alloc();
01768 
01769     c_faces = 0;
01770     c_nonvisfaces = 0;
01771     c_brushes = 0;
01772     c_totalsides = 0;
01773     for (b = brushlist; b; b = b->next)
01774     {
01775         c_brushes++;
01776 
01777         volume = BrushVolume(b);
01778         if (volume < microvolume)
01779         {
01780             Log_Print("WARNING: entity %i, brush %i: microbrush\n",
01781                 b->original->entitynum, b->original->brushnum);
01782         } //end if