doin' some cleanup...
This commit is contained in:
parent
40f5cdcaa5
commit
f6d6efea95
16 changed files with 136 additions and 182 deletions
|
|
@ -11,20 +11,6 @@ typedef struct {
|
|||
bool start_solid;
|
||||
} trace_result;
|
||||
|
||||
static i32 bsp_find_leaf(const demo3d_bsp* bsp, pxl8_vec3 pos) {
|
||||
if (!bsp || bsp->num_nodes == 0) return -1;
|
||||
|
||||
i32 node_id = 0;
|
||||
while (node_id >= 0) {
|
||||
const demo3d_bsp_node* node = &bsp->nodes[node_id];
|
||||
const demo3d_bsp_plane* plane = &bsp->planes[node->plane_id];
|
||||
f32 dist = pxl8_vec3_dot(pos, plane->normal) - plane->dist;
|
||||
node_id = node->children[dist < 0 ? 1 : 0];
|
||||
}
|
||||
|
||||
return -(node_id + 1);
|
||||
}
|
||||
|
||||
static i32 bsp_contents_from(const demo3d_bsp* bsp, i32 node_id, pxl8_vec3 pos) {
|
||||
while (node_id >= 0) {
|
||||
const demo3d_bsp_node* node = &bsp->nodes[node_id];
|
||||
|
|
@ -124,7 +110,7 @@ bool demo3d_bsp_point_solid(const demo3d_bsp* bsp, pxl8_vec3 pos) {
|
|||
(pos.x < bsp->bounds_min_x || pos.x >= bsp->bounds_max_x ||
|
||||
pos.z < bsp->bounds_min_z || pos.z >= bsp->bounds_max_z))
|
||||
return false;
|
||||
i32 leaf = bsp_find_leaf(bsp, pos);
|
||||
i32 leaf = demo3d_bsp_find_leaf(bsp, pos);
|
||||
if (leaf < 0 || (u32)leaf >= bsp->num_leafs) return true;
|
||||
return bsp->leafs[leaf].contents == -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue