From 109d08c84ae72c74b48471efd8581ab740b27888 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Wed, 23 Mar 2022 08:06:29 +0000 Subject: 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. --- core/math/bvh_tree.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'core/math/bvh_tree.h') 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); -- cgit v1.2.3