DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
bih.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  bih_leaf_t
 
struct  bih_node_t
 
struct  bih_t
 

Macros

#define BIH_MAXUNORDEREDCHILDREN   8
 

Enumerations

enum  bih_leaftype_t { BIH_BRUSH = 4 , BIH_COLLISIONTRIANGLE = 5 , BIH_RENDERTRIANGLE = 6 }
 
enum  bih_nodetype_t { BIH_SPLITX = 0 , BIH_SPLITY = 1 , BIH_SPLITZ = 2 , BIH_UNORDERED = 3 }
 
enum  biherror_t { BIHERROR_OK , BIHERROR_OUT_OF_NODES }
 

Functions

int BIH_Build (bih_t *bih, int numleafs, bih_leaf_t *leafs, int maxnodes, bih_node_t *nodes, int *temp_leafsort, int *temp_leafsortscratch)
 
int BIH_GetTriangleListForBox (const bih_t *bih, int maxtriangles, int *trianglelist_idx, int *trianglelist_surf, const float *mins, const float *maxs)
 

Macro Definition Documentation

◆ BIH_MAXUNORDEREDCHILDREN

Enumeration Type Documentation

◆ bih_leaftype_t

Enumerator
BIH_BRUSH 
BIH_COLLISIONTRIANGLE 
BIH_RENDERTRIANGLE 

Definition at line 27 of file bih.h.

28{
29 BIH_BRUSH = 4,
32}
@ BIH_COLLISIONTRIANGLE
Definition bih.h:30
@ BIH_RENDERTRIANGLE
Definition bih.h:31
@ BIH_BRUSH
Definition bih.h:29

◆ bih_nodetype_t

Enumerator
BIH_SPLITX 
BIH_SPLITY 
BIH_SPLITZ 
BIH_UNORDERED 

Definition at line 18 of file bih.h.

19{
20 BIH_SPLITX = 0,
21 BIH_SPLITY = 1,
22 BIH_SPLITZ = 2,
23 BIH_UNORDERED = 3,
24}
@ BIH_SPLITZ
Definition bih.h:22
@ BIH_UNORDERED
Definition bih.h:23
@ BIH_SPLITY
Definition bih.h:21
@ BIH_SPLITX
Definition bih.h:20

◆ biherror_t

enum biherror_t
Enumerator
BIHERROR_OK 
BIHERROR_OUT_OF_NODES 

Definition at line 11 of file bih.h.

12{
13 BIHERROR_OK, // no error, be happy
14 BIHERROR_OUT_OF_NODES // could not produce complete hierarchy, maxnodes too low (should be roughly half of numleafs)
15}
@ BIHERROR_OUT_OF_NODES
Definition bih.h:14
@ BIHERROR_OK
Definition bih.h:13

Function Documentation

◆ BIH_Build()

int BIH_Build ( bih_t * bih,
int numleafs,
bih_leaf_t * leafs,
int maxnodes,
bih_node_t * nodes,
int * temp_leafsort,
int * temp_leafsortscratch )

Definition at line 133 of file bih.c.

134{
135 int i;
136
137 memset(bih, 0, sizeof(*bih));
138 bih->numleafs = numleafs;
139 bih->leafs = leafs;
140 bih->leafsort = temp_leafsort;
141 bih->leafsortscratch = temp_leafsortscratch;
142 bih->numnodes = 0;
143 bih->maxnodes = maxnodes;
144 bih->nodes = nodes;
145
146 // clear things we intend to rebuild
147 memset(bih->nodes, 0, sizeof(bih->nodes[0]) * bih->maxnodes);
148 for (i = 0;i < bih->numleafs;i++)
149 bih->leafsort[i] = i;
150
151 bih->rootnode = BIH_BuildNode(bih, bih->numleafs, bih->leafsort, bih->mins, bih->maxs);
152 return bih->error;
153}
static int BIH_BuildNode(bih_t *bih, int numchildren, int *leaflist, float *totalmins, float *totalmaxs)
Definition bih.c:8
int i
bih_node_t * nodes
Definition bih.h:77
int maxnodes
Definition bih.h:84
bih_leaf_t * leafs
Definition bih.h:74
int error
Definition bih.h:85
int numnodes
Definition bih.h:76
float maxs[3]
Definition bih.h:81
int * leafsortscratch
Definition bih.h:87
int rootnode
Definition bih.h:78
int numleafs
Definition bih.h:73
int * leafsort
Definition bih.h:86
float mins[3]
Definition bih.h:80

References BIH_BuildNode(), bih_t::error, i, bih_t::leafs, bih_t::leafsort, bih_t::leafsortscratch, bih_t::maxnodes, bih_t::maxs, bih_t::mins, bih_t::nodes, bih_t::numleafs, bih_t::numnodes, and bih_t::rootnode.

Referenced by Mod_MakeCollisionBIH().

◆ BIH_GetTriangleListForBox()

int BIH_GetTriangleListForBox ( const bih_t * bih,
int maxtriangles,
int * trianglelist_idx,
int * trianglelist_surf,
const float * mins,
const float * maxs )

Definition at line 211 of file bih.c.

212{
213 int numtriangles = 0;
214 BIH_GetTriangleListForBox_Node(bih, bih->rootnode, maxtriangles, trianglelist_idx, trianglelist_surf, &numtriangles, mins, maxs);
215 return numtriangles;
216}
static void BIH_GetTriangleListForBox_Node(const bih_t *bih, int nodenum, int maxtriangles, int *trianglelist_idx, int *trianglelist_surf, int *numtrianglespointer, const float *mins, const float *maxs)
Definition bih.c:155
vector mins
vector maxs

References BIH_GetTriangleListForBox_Node(), maxs, mins, and bih_t::rootnode.

Referenced by R_DecalSystem_SplatEntity().