commit 56fbdc0c594402915c52f3cfb428f5bd656c28ca parent f8c8a82bc9b1cbb4b177ae2e7bc7c2fc00678906 Author: Michael Savage <mikejsavage@gmail.com> Date: Wed Aug 26 22:22:48 +0200 Make BSP tree node children indexable Diffstat:
bsp.cc | | | 2 | +- |
bsp.h | | | 9 | +++++++-- |
diff --git a/bsp.cc b/bsp.cc @@ -234,7 +234,7 @@ BSP_Leaf & BSP::position_to_leaf( const glm::vec3 & pos ) const { const float dist = point_plane_distance( pos, plane.n, plane.d ); - node_idx = dist >= 0 ? node.pos_child : node.neg_child; + node_idx = node.children[ dist < 0 ]; } while( node_idx >= 0 ); return leaves[ -( node_idx + 1 ) ]; diff --git a/bsp.h b/bsp.h @@ -52,8 +52,13 @@ struct BSP_Plane { struct BSP_Node { u32 plane; - s32 pos_child; - s32 neg_child; + union { + s32 children[ 2 ]; + struct { + s32 pos_child; + s32 neg_child; + }; + }; s32 mins[ 3 ]; s32 maxs[ 3 ];