diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-05-31 11:33:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-31 11:33:24 +0200 |
commit | 6ebe3bebaef99130fbded4af9754b317dc95e445 (patch) | |
tree | 6551559dd5e294f9cdce4dbd2540e536a3101644 /core/math/bvh_tree.h | |
parent | 0e678a2bad3c13e1ed690b5a202cf3cf28476f9c (diff) | |
parent | bd42de5fea718ed6bf680dddbb8d823dd6760b68 (diff) |
Merge pull request #49192 from lawnjelly/bvh_current_tree4
BVH - fix stale current_tree in deactivate function [4.x]
Diffstat (limited to 'core/math/bvh_tree.h')
-rw-r--r-- | core/math/bvh_tree.h | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/core/math/bvh_tree.h b/core/math/bvh_tree.h index 64c5f6e254..3169d31ec7 100644 --- a/core/math/bvh_tree.h +++ b/core/math/bvh_tree.h @@ -196,7 +196,7 @@ private: new_child.parent_id = p_parent_id; } - void node_remove_child(uint32_t p_parent_id, uint32_t p_child_id, bool p_prevent_sibling = false) { + void node_remove_child(uint32_t p_parent_id, uint32_t p_child_id, uint32_t p_tree_id, bool p_prevent_sibling = false) { TNode &parent = _nodes[p_parent_id]; BVH_ASSERT(!parent.is_leaf()); @@ -231,7 +231,7 @@ private: if (grandparent_id == BVHCommon::INVALID) { if (sibling_present) { // change the root node - change_root_node(sibling_id); + change_root_node(sibling_id, p_tree_id); // delete the old root node as no longer needed _nodes.free(p_parent_id); @@ -243,16 +243,15 @@ private: if (sibling_present) { node_replace_child(grandparent_id, p_parent_id, sibling_id); } else { - node_remove_child(grandparent_id, p_parent_id, true); + node_remove_child(grandparent_id, p_parent_id, p_tree_id, true); } // put the node on the free list to recycle _nodes.free(p_parent_id); } - // this relies on _current_tree being accurate - void change_root_node(uint32_t p_new_root_id) { - _root_node_id[_current_tree] = p_new_root_id; + void change_root_node(uint32_t p_new_root_id, uint32_t p_tree_id) { + _root_node_id[p_tree_id] = p_new_root_id; TNode &root = _nodes[p_new_root_id]; // mark no parent @@ -272,7 +271,7 @@ private: node.neg_leaf_id = -(int)child_leaf_id; } - void node_remove_item(uint32_t p_ref_id, BVHABB_CLASS *r_old_aabb = nullptr) { + void node_remove_item(uint32_t p_ref_id, uint32_t p_tree_id, BVHABB_CLASS *r_old_aabb = nullptr) { // get the reference ItemRef &ref = _refs[p_ref_id]; uint32_t owner_node_id = ref.tnode_id; @@ -336,7 +335,7 @@ private: uint32_t parent_id = tnode.parent_id; - node_remove_child(parent_id, owner_node_id); + node_remove_child(parent_id, owner_node_id, p_tree_id); refit_upward(parent_id); // put the node on the free list to recycle |