diff options
author | nathan <nathansmith@disroot.org> | 2025-07-20 19:04:18 +0000 |
---|---|---|
committer | nathan <nathansmith@disroot.org> | 2025-07-20 19:04:18 +0000 |
commit | 1edd7f510bb901726f4e47c7d132f1abb06c4b10 (patch) | |
tree | d8343a0538eb050506f40ca4b5124db0f397f862 | |
parent | 0d2212978cf0198f02b48d1fe8cbaa3b3706682c (diff) | |
download | FindThings-1edd7f510bb901726f4e47c7d132f1abb06c4b10.tar.gz FindThings-1edd7f510bb901726f4e47c7d132f1abb06c4b10.tar.bz2 FindThings-1edd7f510bb901726f4e47c7d132f1abb06c4b10.zip |
Going to call it good enough even though it sucks
-rw-r--r-- | src/world.c | 46 | ||||
-rw-r--r-- | src/world.h | 1 |
2 files changed, 25 insertions, 22 deletions
diff --git a/src/world.c b/src/world.c index 39b6bcd..7a3559e 100644 --- a/src/world.c +++ b/src/world.c @@ -184,6 +184,7 @@ size_t buildWorldBVHSubtree(BVHNode* subtree, if (branchIndex == 0) { closest = index; + break; } float distance = 0.0; @@ -215,31 +216,25 @@ size_t buildWorldBVHSubtree(BVHNode* subtree, } } - // Will cause overlap. - int overlapCauseCount = 0; - - for (int innerIndex = 0; innerIndex < nodesSize && !overlaps; - ++innerIndex) - { - if (innerIndex == index || grouped[innerIndex]) - { - continue; - } + BoundingBox currentBox = node.branches[0]->box; - if (CheckCollisionBoxes(overlapBox, nodes[innerIndex].box)) - { - ++overlapCauseCount; - } - - if (overlapCauseCount > BVH_MAX_BRANCH_COUNT - node.branchCount) - { - overlaps = true; - break; - } + for (int innerIndex = 1; innerIndex < node.branchCount; ++innerIndex) + { + currentBox.min = Vector3Min(currentBox.min, + node.branches[innerIndex]->box.min); + currentBox.max = Vector3Max(currentBox.max, + node.branches[innerIndex]->box.max); } - + // Update distance. - if (!overlaps && distance < closestDistance) + if (CheckCollisionBoxes(currentBox, nodes[index].box)) + { + closestDistance = Vector3Distance( + nodes[index].position, + Vector3Scale(Vector3Add(currentBox.min, currentBox.max), 0.5)); + closest = index; + } + else if (!overlaps && distance < closestDistance) { closestDistance = distance; closest = index; @@ -494,4 +489,11 @@ float getWorldHeightAtLocation(const World* world, float x, float y) return 0.0; } +WorldUID castRayAtWorld(const World* world, Ray ray) +{ + WorldUID uid = -1; + + return uid; +} + // Abortions are good. Get more abortions. diff --git a/src/world.h b/src/world.h index 39abb38..5482b0b 100644 --- a/src/world.h +++ b/src/world.h @@ -42,5 +42,6 @@ void freeWorld(World world); // Dam, I wanta live in a free world ): float getWorldHeightAtLocation(const World* world, float x, float y); +WorldUID castRayAtWorld(const World* world, Ray ray); #endif |