Переглянути джерело

Fix not refitting upward from leaf nodes.

Previously, the wrong node id (root node id) was used. Dirty leaf nodes
do not actually recalculate aabb.

Additionally, when requesting a new leaf, mark `dirty` as `false` in `clear()`.

Make sure to only mark the leaf as **dirty** when shrinking the border of
the leaf when removing items.

In other cases, the leaf node's aabb will get the correct result immediately.
1. When adding an item, the leaf nodes will be calculated immediately.
2. Removing the item within the border of the leaf node has no effect on the
original aabb.
风青山 1 рік тому
батько
коміт
e705aa4550
2 змінених файлів з 2 додано та 2 видалено
  1. 1 1
      core/math/bvh_refit.inc
  2. 1 1
      core/math/bvh_structs.inc

+ 1 - 1
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

+ 1 - 1
core/math/bvh_structs.inc

@@ -83,7 +83,7 @@ public:
 
 	void clear() {
 		num_items = 0;
-		set_dirty(true);
+		set_dirty(false);
 	}
 	bool is_full() const { return num_items >= MAX_ITEMS; }