From 01c60dc9eea6cc975f2f7d8c4980d68e94ae7577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E9=9D=92=E5=B1=B1?= Date: Fri, 29 Sep 2023 05:54:40 +0800 Subject: [PATCH] [3.x] BVH - fix not refitting upward from leaf nodes Fix leaf node possibly not updating aabb due to wrong node id. Additionally, when requesting a new leaf, mark `dirty` as `false` in `clear()`. --- core/math/bvh_refit.inc | 2 +- core/math/bvh_structs.inc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/math/bvh_refit.inc b/core/math/bvh_refit.inc index 717a3438c7c..b20b805bb0d 100644 --- a/core/math/bvh_refit.inc +++ b/core/math/bvh_refit.inc @@ -134,7 +134,7 @@ void refit_branch(uint32_t p_node_id) { TLeaf &leaf = _node_get_leaf(tnode); if (leaf.is_dirty()) { leaf.set_dirty(false); - refit_upward(p_node_id); + refit_upward(rp.node_id); } } } // while more nodes to pop diff --git a/core/math/bvh_structs.inc b/core/math/bvh_structs.inc index 7b5cc2c3508..41a895c0d20 100644 --- a/core/math/bvh_structs.inc +++ b/core/math/bvh_structs.inc @@ -71,7 +71,7 @@ public: void clear() { num_items = 0; - set_dirty(true); + set_dirty(false); } bool is_full() const { return num_items >= MAX_ITEMS; }