Initial sauer
[SauerbratenRemote.git] / src / engine / bih.h
blob43a2f41fbee19347d890dc23e10642783a3b9121
1 struct BIHNode
3 short split[2];
4 ushort child[2];
6 int axis() const { return child[0]>>14; }
7 int childindex(int which) const { return child[which]&0x3FFF; }
8 bool isleaf(int which) const { return (child[1]&(1<<(14+which)))!=0; }
9 };
11 struct BIH
13 struct tri : triangle
15 float tc[6];
16 Texture *tex;
19 int maxdepth;
20 int numnodes;
21 BIHNode *nodes;
22 int numtris;
23 tri *tris;
25 vec bbmin, bbmax;
27 BIH(int numtris, tri *tris);
29 ~BIH()
31 DELETEA(nodes);
32 DELETEA(tris);
35 static bool triintersect(tri &tri, const vec &o, const vec &ray, float maxdist, float &dist, int mode);
37 void build(vector<BIHNode> &buildnodes, ushort *indices, int numindices, int depth = 1);
39 bool traverse(const vec &o, const vec &ray, float maxdist, float &dist, int mode);
40 bool collide(const vec &o, const vec &radius, const vec &ray, float cutoff, vec &normal);
43 extern bool mmintersect(const extentity &e, const vec &o, const vec &ray, float maxdist, int mode, float &dist);