From e57cac01b0a4eb764185e8eca9396a25b83f34d3 Mon Sep 17 00:00:00 2001 From: aura Date: Tue, 3 Mar 2026 16:16:06 +0100 Subject: edge planes ))) --- src/game/world/bsp.h | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'src/game/world/bsp.h') diff --git a/src/game/world/bsp.h b/src/game/world/bsp.h index 50e8764..8892108 100644 --- a/src/game/world/bsp.h +++ b/src/game/world/bsp.h @@ -30,6 +30,8 @@ struct BSP_FACE { I32 id; LIST verts{}; LIST render_verts{}; + VEC3 mins; + VEC3 maxs; }; struct BSP_NODE { @@ -41,7 +43,6 @@ struct BSP_NODE { struct BSP_EDGE { BSP_PLANE plane; U32 face; - U8 avgc; VEC3 v1, v2; }; @@ -117,9 +118,26 @@ inline SURF_PROPS* bsp_face_get_props( WORLD_MAP* w, BSP_FACE* s ) { &w->props[s->propid]; } -inline VEC3 bsp_face_get_normal( const BSP_FACE* f ){ - const VEC3 v0 = f->verts.data[0].pos; - const VEC3 v1 = f->verts.data[1].pos; - const VEC3 v2 = f->verts.data[2].pos; +inline VEC3 bsp_face_get_normal( BSP_FACE* f ){ + VEC3 v0 = f->verts.data[0].pos; + VEC3 v1 = f->verts.data[1].pos; + VEC3 v2 = f->verts.data[2].pos; return vec_normalize( vec_cross( v1 - v0, v2 - v0 ) ); } + +inline void bsp_face_calc_extents( BSP_FACE* f ) { + VEC3 mins{ +INFINITY, +INFINITY, +INFINITY }, maxs{ -INFINITY, -INFINITY, -INFINITY }; + for( U32 i = 0; i < f->verts.size; ++i ) { + VEC3 v = f->verts.data[i].pos; + mins.x = min( mins.x, v.x ); + mins.y = min( mins.y, v.y ); + mins.z = min( mins.z, v.z ); + + maxs.x = max( maxs.x, v.x ); + maxs.y = max( maxs.y, v.y ); + maxs.z = max( maxs.z, v.z ); + } + + f->mins = mins; + f->maxs = maxs; +} -- cgit v1.2.3