X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=bih.h;h=4be1564fda8bcb7f5f34c368e7872439bd0dc335;hp=48a33d11c7e05e52a62cc1547a9f4632b0a3a2af;hb=2075ae43356d724bae305ce8fd36ea570718b14a;hpb=c47771198ec4b5144616f28a9774038a0767b3da diff --git a/bih.h b/bih.h index 48a33d11..4be1564f 100644 --- a/bih.h +++ b/bih.h @@ -1,15 +1,17 @@ -// This code written in 2010 by Forest Hale (lordhavoc ghdigital com), and placed into public domain. +// This code written in 2010 by Forest Hale (darkplacesengine gmail com), and placed into public domain. // Based on information in http://zach.in.tu-clausthal.de/papers/vrst02.html (in particular vrst02_boxtree.pdf) #ifndef BIH_H #define BIH_H +#define BIH_MAXUNORDEREDCHILDREN 8 + typedef enum biherror_e { BIHERROR_OK, // no error, be happy - BIHERROR_OUT_OF_NODES, // could not produce complete hierarchy, maxnodes too low (should be roughly half of numleafs) + BIHERROR_OUT_OF_NODES // could not produce complete hierarchy, maxnodes too low (should be roughly half of numleafs) } biherror_t; @@ -18,14 +20,15 @@ typedef enum bih_nodetype_e BIH_SPLITX = 0, BIH_SPLITY = 1, BIH_SPLITZ = 2, + BIH_UNORDERED = 3, } bih_nodetype_t; typedef enum bih_leaftype_e { - BIH_BRUSH = 3, - BIH_COLLISIONTRIANGLE = 4, - BIH_RENDERTRIANGLE = 5, + BIH_BRUSH = 4, + BIH_COLLISIONTRIANGLE = 5, + BIH_RENDERTRIANGLE = 6 } bih_leaftype_t; @@ -36,12 +39,14 @@ typedef struct bih_node_s // TODO: move bounds data to parent node and remove it from leafs? float mins[3]; float maxs[3]; - // < 0 is a leaf index (-1-leafindex), >= 0 is another node index (always >= this node's index) + // node indexes of children (always > this node's index) int front; int back; // interval of children float frontmin; // children[0] float backmax; // children[1] + // BIH_UNORDERED uses this for a list of leafindex (all >= 0), -1 = end of list + int children[BIH_MAXUNORDEREDCHILDREN]; } bih_node_t; @@ -52,6 +57,7 @@ typedef struct bih_leaf_s float maxs[3]; // data past this point is generic and entirely up to the caller... int textureindex; + int surfaceindex; int itemindex; // triangle or brush index } bih_leaf_t; @@ -80,4 +86,6 @@ bih_t; 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); + #endif