Partially revert change to BVH render tree update method

Leaves in the bug fixes, but reverts the change to the update method.

Turns out the new update method of getting the scenarios was causing problems, I will need to consult with reduz on the best way of getting access to the scenarios for a single update per frame.

Doing multiple updates isn't terrible but it should be nicer to get a single update working, as it should be more efficient, and give a single point for pairing callbacks.
This commit is contained in:
lawnjelly
2021-01-20 19:15:07 +00:00
parent 6d5daac3e4
commit 2527067c4d
3 changed files with 1 additions and 26 deletions

View File

@@ -3578,47 +3578,24 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
p_instance->update_materials = false;
}
void VisualServerScene::update_scenarios() {
// go through all scenarios and update BVH in each
if (!_use_bvh) {
return;
}
List<RID> owned;
scenario_owner.get_owned_list(&owned);
for (List<RID>::Element *E = owned.front(); E; E = E->next()) {
RID rid = E->get();
Scenario *scenario = scenario_owner.get(rid);
scenario->sps->update();
}
}
void VisualServerScene::update_dirty_instances() {
VSG::storage->update_dirty_resources();
// only define this if you run into problems with missed pairing collisions for debugging
//#define GODOT_RENDER_SPS_EXTRA_COLLISION_CHECKS
#ifdef GODOT_RENDER_SPS_EXTRA_COLLISION_CHECKS
// this is just to get access to scenario so we can update the spatial partitioning scheme
Scenario *scenario = nullptr;
if (_instance_update_list.first()) {
scenario = _instance_update_list.first()->self()->scenario;
}
#endif
while (_instance_update_list.first()) {
_update_dirty_instance(_instance_update_list.first()->self());
}
#ifdef GODOT_RENDER_SPS_EXTRA_COLLISION_CHECKS
if (scenario) {
scenario->sps->update_collisions();
scenario->sps->update();
}
#endif
}
bool VisualServerScene::free(RID p_rid) {