aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/world.c21
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;
}
}