From 524bb54a09e02a45839dcd8c13b66bcdbfce4670 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 9 Jul 2025 04:29:22 -0600 Subject: yippeeee --- src/world.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'src/world.c') diff --git a/src/world.c b/src/world.c index 3d4682d..776c6b6 100644 --- a/src/world.c +++ b/src/world.c @@ -118,6 +118,7 @@ size_t buildWorldBVHLeafs(BVHNode leafs[WORLD_ENTITY_MAX], const World* world) world->entities[leaf.entities[index]].box.max); } + memset(leaf.branches, 0, BVH_MAX_BRANCH_COUNT * sizeof(BVHNode*)); leafs[leafsSize] = leaf; ++leafsSize; } @@ -137,12 +138,8 @@ size_t buildWorldBVHLeafs(BVHNode leafs[WORLD_ENTITY_MAX], const World* world) { for (int inner = 0; inner < leafsSize; ++inner) { - if (outer == inner) - { - continue; - } - - if (CheckCollisionBoxes(leafs[outer].box, leafs[inner].box)) + if (outer != inner && + CheckCollisionBoxes(leafs[outer].box, leafs[inner].box)) { printf("Leaf collision: %d and %d\n", outer, inner); } @@ -155,6 +152,26 @@ size_t buildWorldBVHLeafs(BVHNode leafs[WORLD_ENTITY_MAX], const World* world) return leafsSize; } +BVHNode buildWorldBVHTree(BVHNode* nodes, size_t nodesSize) +{ + BVHNode node; + BVHNode usedNodes[nodesSize]; + size_t usedNodesSize = 0; + memset(&node, 0, sizeof(BVHNode)); + + // Add first node to branch. + node.branches[0] = (BVHNode*)FT_MALLOC(sizeof(BVHNode)); + memcpy(node.branches[0], &nodes[0], sizeof(BVHNode)); + ++usedNodesSize; + + for (int index = 0; index < nodesSize; ++index) + { + + } + + return node; +} + // Very messy right now. Mostly been playing around. void buildWorldBVH(World* world) { -- cgit v1.2.3