summaryrefslogtreecommitdiff
path: root/core/math/bvh_tree.h
diff options
context:
space:
mode:
authorlawnjelly <lawnjelly@gmail.com>2022-03-23 08:06:29 +0000
committerlawnjelly <lawnjelly@gmail.com>2022-03-23 09:19:26 +0000
commit109d08c84ae72c74b48471efd8581ab740b27888 (patch)
tree24c001c9c927a0c2d6d1b796661e30696228b3c2 /core/math/bvh_tree.h
parentcd2e7fbc57345370d03854d225208ff480ba6969 (diff)
Add protective checks for invalid handle use in BVH
Adds DEV_ASSERTS that will halt at runtime if the BVH is misused with invalid IDs, and adds ERR_FAIL macros to prevent calling with invalid IDs. Any such misuse is a bug in the physics, but this should flag any errors quickly.
Diffstat (limited to 'core/math/bvh_tree.h')
-rw-r--r--core/math/bvh_tree.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/core/math/bvh_tree.h b/core/math/bvh_tree.h
index da9b307778..cdb2bb4413 100644
--- a/core/math/bvh_tree.h
+++ b/core/math/bvh_tree.h
@@ -54,7 +54,7 @@
#define BVH_EXPAND_LEAF_AABBS
// never do these checks in release
-#if defined(TOOLS_ENABLED) && defined(DEBUG_ENABLED)
+#ifdef DEV_ENABLED
//#define BVH_VERBOSE
//#define BVH_VERBOSE_TREE
//#define BVH_VERBOSE_PAIRING
@@ -217,7 +217,7 @@ private:
BVH_ASSERT(!parent.is_leaf());
int child_num = parent.find_child(p_old_child_id);
- BVH_ASSERT(child_num != BVHCommon::INVALID);
+ BVH_ASSERT(child_num != -1);
parent.children[child_num] = p_new_child_id;
TNode &new_child = _nodes[p_new_child_id];
@@ -229,7 +229,7 @@ private:
BVH_ASSERT(!parent.is_leaf());
int child_num = parent.find_child(p_child_id);
- BVH_ASSERT(child_num != BVHCommon::INVALID);
+ BVH_ASSERT(child_num != -1);
parent.remove_child_internal(child_num);