summaryrefslogtreecommitdiff
path: root/src/engine/bih.h
diff options
context:
space:
mode:
authorxolatile2025-08-06 22:54:55 +0200
committerxolatile2025-08-06 22:54:55 +0200
commit0a1172b75f571685c264a8b9d8ee224bbf11381f (patch)
treed041fdc68a60f0ebb48a3852bbcce6d9432f83d5 /src/engine/bih.h
parentaffde05dc07a94643f1fd2751b2b441f57f73d7d (diff)
downloadxolatile-badassbug-0a1172b75f571685c264a8b9d8ee224bbf11381f.tar.xz
xolatile-badassbug-0a1172b75f571685c264a8b9d8ee224bbf11381f.tar.zst
Please do not hate me, it makes sense...
Diffstat (limited to 'src/engine/bih.h')
-rw-r--r--src/engine/bih.h33
1 files changed, 6 insertions, 27 deletions
diff --git a/src/engine/bih.h b/src/engine/bih.h
index 16da278..ac49c66 100644
--- a/src/engine/bih.h
+++ b/src/engine/bih.h
@@ -1,38 +1,25 @@
-struct BIH
-{
- struct node
- {
+struct BIH {
+ struct node {
short split[2];
ushort child[2];
-
int axis() const { return child[0]>>14; }
int childindex(int which) const { return child[which]&0x3FFF; }
bool isleaf(int which) const { return (child[1]&(1<<(14+which)))!=0; }
};
-
- struct tri
- {
+ struct tri {
ushort vert[3];
};
-
- struct tribb
- {
+ struct tribb {
svec center, radius;
-
- bool outside(const ivec &bo, const ivec &br) const
- {
+ bool outside(const ivec &bo, const ivec &br) const {
return abs(bo.x - center.x) > br.x + radius.x ||
abs(bo.y - center.y) > br.y + radius.y ||
abs(bo.z - center.z) > br.z + radius.z;
}
};
-
enum { MESH_NOCLIP = 1<<0, MESH_ALPHA = 1<<1, MESH_CULLFACE = 1<<2 };
-
- struct mesh
- {
+ struct mesh {
enum { MAXTRIS = 1<<14 };
-
matrix4x3 xform, invxform;
matrix3 xformnorm, invxformnorm;
float scale, invscale;
@@ -46,13 +33,10 @@ struct BIH
Texture *tex;
int flags;
vec bbmin, bbmax;
-
mesh() : numnodes(0), numtris(0), tex(NULL), flags(0) {}
-
vec getpos(int i) const { return *(const vec *)(pos + i*posstride); }
vec2 gettc(int i) const { return *(const vec2 *)(tc + i*tcstride); }
};
-
mesh *meshes;
int nummeshes;
node *nodes;
@@ -61,17 +45,12 @@ struct BIH
int numtris;
vec bbmin, bbmax, center;
float radius, entradius;
-
BIH(vector<mesh> &buildmeshes);
-
~BIH();
-
void build(mesh &m, ushort *indices, int numindices, const ivec &vmin, const ivec &vmax);
-
bool traverse(const vec &o, const vec &ray, float maxdist, float &dist, int mode);
bool traverse(const mesh &m, const vec &o, const vec &ray, const vec &invray, float maxdist, float &dist, int mode, node *curnode, float tmin, float tmax);
bool triintersect(const mesh &m, int tidx, const vec &mo, const vec &mray, float maxdist, float &dist, int mode);
-
void preload();
};