1void _integrity_check_all() {
2#ifdef BVH_INTEGRITY_CHECKS
3 for (int n = 0; n < NUM_TREES; n++) {
4 uint32_t root = _root_node_id[n];
5 if (root != BVHCommon::INVALID) {
6 _integrity_check_down(root);
7 }
8 }
9#endif
10}
11
12void _integrity_check_up(uint32_t p_node_id) {
13 TNode &node = _nodes[p_node_id];
14
15 BVHABB_CLASS abb = node.aabb;
16 node_update_aabb(node);
17
18 BVHABB_CLASS abb2 = node.aabb;
19 abb2.expand(-_node_expansion);
20
21 CRASH_COND(!abb.is_other_within(abb2));
22}
23
24void _integrity_check_down(uint32_t p_node_id) {
25 const TNode &node = _nodes[p_node_id];
26
27 if (node.is_leaf()) {
28 _integrity_check_up(p_node_id);
29 } else {
30 CRASH_COND(node.num_children != 2);
31
32 for (int n = 0; n < node.num_children; n++) {
33 uint32_t child_id = node.children[n];
34
35 // check the children parent pointers are correct
36 TNode &child = _nodes[child_id];
37 CRASH_COND(child.parent_id != p_node_id);
38
39 _integrity_check_down(child_id);
40 }
41 }
42}
43