From 74adf0bf2e171353c33cd47ed67ec5ee040a284a Mon Sep 17 00:00:00 2001 From: reduz Date: Sat, 5 Feb 2022 11:59:34 +0100 Subject: Remove RID_Owner.get_rid_by_index * Implementing this function efficiently is not really possible. * Replaced by an option to get all RIDs into a buffer for performance. --- servers/rendering/renderer_scene_cull.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'servers') diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp index 8ded180633..5b2be8e174 100644 --- a/servers/rendering/renderer_scene_cull.cpp +++ b/servers/rendering/renderer_scene_cull.cpp @@ -3871,8 +3871,12 @@ void RendererSceneCull::update_dirty_instances() { void RendererSceneCull::update() { //optimize bvhs - for (uint32_t i = 0; i < scenario_owner.get_rid_count(); i++) { - Scenario *s = scenario_owner.get_ptr_by_index(i); + + uint32_t rid_count = scenario_owner.get_rid_count(); + RID *rids = (RID *)alloca(sizeof(RID) * rid_count); + scenario_owner.fill_owned_buffer(rids); + for (uint32_t i = 0; i < rid_count; i++) { + Scenario *s = scenario_owner.get_or_null(rids[i]); s->indexers[Scenario::INDEXER_GEOMETRY].optimize_incremental(indexer_update_iterations); s->indexers[Scenario::INDEXER_VOLUMES].optimize_incremental(indexer_update_iterations); } -- cgit v1.2.3