Merge pull request #44651 from lawnjelly/bvh_world_aabb
Fix BVH to world_aabb, and call update
This commit is contained in:
commit
4d9b95f3a8
2 changed files with 16 additions and 3 deletions
|
@ -354,10 +354,17 @@ void DynamicBVH::_update(Node *leaf, int lookahead) {
|
||||||
void DynamicBVH::update(const ID &p_id, const AABB &p_box) {
|
void DynamicBVH::update(const ID &p_id, const AABB &p_box) {
|
||||||
ERR_FAIL_COND(!p_id.is_valid());
|
ERR_FAIL_COND(!p_id.is_valid());
|
||||||
Node *leaf = p_id.node;
|
Node *leaf = p_id.node;
|
||||||
Node *base = _remove_leaf(leaf);
|
|
||||||
Volume volume;
|
Volume volume;
|
||||||
volume.min = p_box.position;
|
volume.min = p_box.position;
|
||||||
volume.max = p_box.position + p_box.size;
|
volume.max = p_box.position + p_box.size;
|
||||||
|
|
||||||
|
if ((leaf->volume.min == volume.min) && (leaf->volume.max == volume.max)) {
|
||||||
|
// noop
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Node *base = _remove_leaf(leaf);
|
||||||
if (base) {
|
if (base) {
|
||||||
if (lkhd >= 0) {
|
if (lkhd >= 0) {
|
||||||
for (int i = 0; (i < lkhd) && base->parent; ++i) {
|
for (int i = 0; (i < lkhd) && base->parent; ++i) {
|
||||||
|
|
|
@ -1070,9 +1070,15 @@ void RendererSceneCull::_update_instance(Instance *p_instance) {
|
||||||
|
|
||||||
if (!p_instance->indexer_id.is_valid()) {
|
if (!p_instance->indexer_id.is_valid()) {
|
||||||
if ((1 << p_instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) {
|
if ((1 << p_instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) {
|
||||||
p_instance->indexer_id = p_instance->scenario->indexers[Scenario::INDEXER_GEOMETRY].insert(p_instance->aabb, p_instance);
|
p_instance->indexer_id = p_instance->scenario->indexers[Scenario::INDEXER_GEOMETRY].insert(p_instance->transformed_aabb, p_instance);
|
||||||
} else {
|
} else {
|
||||||
p_instance->indexer_id = p_instance->scenario->indexers[Scenario::INDEXER_VOLUMES].insert(p_instance->aabb, p_instance);
|
p_instance->indexer_id = p_instance->scenario->indexers[Scenario::INDEXER_VOLUMES].insert(p_instance->transformed_aabb, p_instance);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((1 << p_instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) {
|
||||||
|
p_instance->scenario->indexers[Scenario::INDEXER_GEOMETRY].update(p_instance->indexer_id, p_instance->transformed_aabb);
|
||||||
|
} else {
|
||||||
|
p_instance->scenario->indexers[Scenario::INDEXER_VOLUMES].update(p_instance->indexer_id, p_instance->transformed_aabb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue