diff options
author | nathan <nathan@disroot.org> | 2025-07-09 10:29:22 +0000 |
---|---|---|
committer | nathan <nathan@disroot.org> | 2025-07-09 10:29:22 +0000 |
commit | 524bb54a09e02a45839dcd8c13b66bcdbfce4670 (patch) | |
tree | 46035b7c52af3bacfec94ba20ae90ecde5b1724c | |
parent | 204ad4a59f782ce7faf2f0418b33538cf15a84cb (diff) | |
download | FindThings-524bb54a09e02a45839dcd8c13b66bcdbfce4670.tar.gz FindThings-524bb54a09e02a45839dcd8c13b66bcdbfce4670.tar.bz2 FindThings-524bb54a09e02a45839dcd8c13b66bcdbfce4670.zip |
yippeeee
-rw-r--r-- | src/world.c | 29 |
1 files changed, 23 insertions, 6 deletions
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) { |