diff options
author | nathan <nathansmith@disroot.org> | 2025-07-09 03:23:05 +0000 |
---|---|---|
committer | nathan <nathansmith@disroot.org> | 2025-07-09 03:23:05 +0000 |
commit | 4819292821b51083538d4d4880e90d0d3314f839 (patch) | |
tree | 68ccfb84a0b44411e2c390567c5532ad5cef98a8 | |
parent | aaf4dd3efe219391c83ce07aa4d24a34bc0c6608 (diff) | |
download | FindThings-4819292821b51083538d4d4880e90d0d3314f839.tar.gz FindThings-4819292821b51083538d4d4880e90d0d3314f839.tar.bz2 FindThings-4819292821b51083538d4d4880e90d0d3314f839.zip |
Making BVN faster
-rw-r--r-- | src/world.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/world.c b/src/world.c index e670d6f..c633e44 100644 --- a/src/world.c +++ b/src/world.c @@ -6,13 +6,10 @@ void buildWorldBVH(World* world) { Entity* entities = world->entities; bool grouped[WORLD_ENTITY_MAX]; + WorldUID groupedList[WORLD_ENTITY_MAX]; + int groupedListSize = 0; int ungroupedCount = WORLD_ENTITY_MAX; - - // This is a mess thats not going to work. - for (int index = 0; index < WORLD_ENTITY_MAX; ++index) - { - grouped[index] = false; - } + memset(grouped, 0, sizeof(grouped)); world->bvhTestSize = 0; @@ -62,14 +59,10 @@ void buildWorldBVH(World* world) bool overlaps = false; // Check if overlap will be caused. - for (int overlapIndex = 0; overlapIndex < WORLD_ENTITY_MAX; - ++overlapIndex) + for (int groupedIndex = 0; groupedIndex < groupedListSize; + ++groupedIndex) { - if (!grouped[overlapIndex]) - { - continue; - } - + int overlapIndex = groupedList[groupedIndex]; bool isPartOf = false; for (int partOfIndex = 0; partOfIndex < leafIndex + 1; ++partOfIndex) @@ -111,6 +104,8 @@ void buildWorldBVH(World* world) { leaf.entities[leafIndex] = closest; grouped[closest] = true; + groupedList[groupedListSize] = closest; + ++groupedListSize; --ungroupedCount; } } |