diff options
Diffstat (limited to 'src/world.c')
-rw-r--r-- | src/world.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/src/world.c b/src/world.c index 5719c3c..14f7ed7 100644 --- a/src/world.c +++ b/src/world.c @@ -1,23 +1,20 @@ #include "world.h" #include "game.h" -// Very messy right now. Mostly been playing around. -void buildWorldBVH(World* world) +size_t buildWorldBVHLeafs(BVHNode leafs[WORLD_ENTITY_MAX], const World* world) { - Entity* entities = world->entities; + size_t leafsSize = 0; + const Entity* entities = world->entities; bool grouped[WORLD_ENTITY_MAX]; WorldUID groupedList[WORLD_ENTITY_MAX]; int ungroupedCount = WORLD_ENTITY_MAX; - + for (int index = 0; index < WORLD_ENTITY_MAX; ++index) { grouped[index] = false; groupedList[index] = index; } - world->bvhTestSize = 0; - - // This is going to be slow. Optimizjl;dsfz lajtklers (: while (ungroupedCount > 0) { BVHNode leaf; @@ -138,11 +135,11 @@ void buildWorldBVH(World* world) world->entities[leaf.entities[index]].position); } - world->bvhTest[world->bvhTestSize] = leaf; - ++world->bvhTestSize; + leafs[leafsSize] = leaf; + ++leafsSize; } - // test + // test for (int index = 0; index < WORLD_ENTITY_MAX; ++index) { if (!grouped[index]) @@ -151,7 +148,19 @@ void buildWorldBVH(World* world) } } - printf("size: %d\n", world->bvhTestSize); + printf("size: %ld\n", leafsSize); + + return leafsSize; +} + +// Very messy right now. Mostly been playing around. +void buildWorldBVH(World* world) +{ + Entity* entities = world->entities; + + // Get leafs + BVHNode leafs[WORLD_ENTITY_MAX]; + size_t leafsSize = buildWorldBVHLeafs(leafs, world); } World createWorld(int seed) @@ -204,11 +213,11 @@ void updateWorld(World* world, Game* game) } // Draw BVH leafs. - for (int index = 0; index < world->bvhTestSize; ++index) - { - Color colors[] = {RED, GREEN, BLUE, ORANGE, YELLOW, PINK}; - DrawBoundingBox(world->bvhTest[index].box, colors[index % 6]); - } + /* for (int index = 0; index < world->bvhTestSize; ++index) */ + /* { */ + /* Color colors[] = {RED, GREEN, BLUE, ORANGE, YELLOW, PINK}; */ + /* DrawBoundingBox(world->bvhTest[index].box, colors[index % 6]); */ + /* } */ } void freeWorld(World world) |