]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - bih.h
BIH building and recursion no longer directly links leaf nodes into the
[xonotic/darkplaces.git] / bih.h
diff --git a/bih.h b/bih.h
index 56632b366fc4b0f6e31b3742f84cbce64df85aee..43b659e97f6753aa5fd8e9fb7756aca0035741bc 100644 (file)
--- a/bih.h
+++ b/bih.h
@@ -6,10 +6,12 @@
 #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,10 +20,18 @@ typedef enum bih_nodetype_e
        BIH_SPLITX = 0,
        BIH_SPLITY = 1,
        BIH_SPLITZ = 2,
-       BIH_LEAF = 3,
+       BIH_UNORDERED = 3,
 }
 bih_nodetype_t;
 
+typedef enum bih_leaftype_e
+{
+       BIH_BRUSH = 4,
+       BIH_COLLISIONTRIANGLE = 5,
+       BIH_RENDERTRIANGLE = 6
+}
+bih_leaftype_t;
+
 typedef struct bih_node_s
 {
        bih_nodetype_t type; // = BIH_SPLITX and similar values
@@ -29,22 +39,25 @@ 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;
 
 typedef struct bih_leaf_s
 {
-       bih_nodetype_t type; // = BIH_LEAF
+       bih_leaftype_t type; // = BIH_BRUSH And similar values
        float mins[3];
        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;
@@ -73,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