diff options
| author | aura <nw@moneybot.cc> | 2026-03-04 18:58:21 +0100 |
|---|---|---|
| committer | aura <nw@moneybot.cc> | 2026-03-04 18:58:21 +0100 |
| commit | 73045b6642348c8d2fd8b45cae305bbf0344d444 (patch) | |
| tree | 9898f64cc14f4e95b147e0fab4b9004e41109780 /src/game/world/bsp.cpp | |
| parent | fc12cd41c56bc123f01bc073b703fb151dfde814 (diff) | |
more collision improv
Diffstat (limited to 'src/game/world/bsp.cpp')
| -rw-r--r-- | src/game/world/bsp.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/game/world/bsp.cpp b/src/game/world/bsp.cpp index 7f72e52..c33cac1 100644 --- a/src/game/world/bsp.cpp +++ b/src/game/world/bsp.cpp @@ -417,6 +417,10 @@ I32 bsp_build_nodes( } U8 bsp_edge_is_shared( BSP* bsp, VEC3 edge1a, VEC3 edge1b, VEC3 center, VEC3 ecross, U32 facei ) { + BSP_FACE* face = &bsp->faces[facei]; + VEC3 n = bsp_face_get_normal( face ); + U8 aligned = bsp_face_is_axis_aligned( face ); + for( U32 i = 0; i < bsp->faces.size; ++i ) { if( facei == i ) continue; @@ -425,6 +429,12 @@ U8 bsp_edge_is_shared( BSP* bsp, VEC3 edge1a, VEC3 edge1b, VEC3 center, VEC3 ecr if( other->verts.size < 3 ) continue; + VEC3 othern = bsp_face_get_normal( face ); + F32 d = vec_dot( n, othern ); + // dont create edge planes for planes that are axis-aligned and directly perpendicular + if( aligned && (d < BSP_NORM_EPSILON || d > 1.f - BSP_NORM_EPSILON) ) + continue; + VEC3 otherc{}; for( U32 vi = 0; vi < other->verts.size; ++vi ) otherc += other->verts[vi].pos; @@ -487,9 +497,6 @@ void bsp_gen_leaf_edges( BSP* bsp, I32 leaf_idx ) { if( fabsf( vec_dot( cross, facen ) ) > 0.995f ) continue; - if( !bsp_edge_is_shared( bsp, a, b, center, cross, faceidx ) ) - continue; - F32 d = vec_dot( cross, a ); BSP_PLANE plane = { cross, d }; U8 dupe = 0; @@ -500,6 +507,9 @@ void bsp_gen_leaf_edges( BSP* bsp, I32 leaf_idx ) { if( dupe ) continue; + if( !bsp_edge_is_shared( bsp, a, b, center, cross, faceidx ) ) + continue; + BSP_EDGE e; e.plane = plane; e.face = faceidx; |
