From e7ef990a0a3b1ddf40a2f0d517e8eb4e261b1f80 Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 24 Oct 2025 23:24:51 -0600 Subject: Lots of little things I should have done already --- src/world.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/world.c') diff --git a/src/world.c b/src/world.c index 42e3488..75fc0ab 100644 --- a/src/world.c +++ b/src/world.c @@ -1,5 +1,6 @@ #include "world.h" #include "game.h" +#include "entity.h" size_t buildWorldBVHLeafs(BVHNode leafs[WORLD_ENTITY_MAX], const World* world) { @@ -935,8 +936,8 @@ float getWorldHeightAtLocation(const World* world, float x, float y) return 0.0; } -void castRayBVH(const World* world, BVHNode node, Ray ray, int* tests, - WorldUID* closest, float* closestDistance) +void castRayBVH(const World* world, BVHNode node, Ray ray, bool includePlaces, + int* tests, WorldUID* closest, float* closestDistance) { if (!GetRayCollisionBox(ray, node.box).hit) { @@ -962,6 +963,13 @@ void castRayBVH(const World* world, BVHNode node, Ray ray, int* tests, world->entities[node.entities[index]].position, ray.position); + // Don't include places. + if (!includePlaces && + entityIsPlace(world->entities[node.entities[index]].id)) + { + continue; + } + if (distance < *closestDistance) { *closest = node.entities[index]; @@ -974,19 +982,20 @@ void castRayBVH(const World* world, BVHNode node, Ray ray, int* tests, { for (int index = 0; index < node.branchCount; ++index) { - castRayBVH(world, *node.branches[index], ray, tests, closest, - closestDistance); + castRayBVH(world, *node.branches[index], ray, includePlaces, tests, + closest, closestDistance); } } return; } -WorldUID castRayAtWorld(const World* world, Ray ray, int* tests) +WorldUID castRayAtWorld(const World* world, Ray ray, bool includePlaces, + int* tests) { WorldUID uid = -1; float distance = Vector3LengthSqr(world->size); - castRayBVH(world, world->bvh, ray, tests, &uid, &distance); + castRayBVH(world, world->bvh, ray, includePlaces, tests, &uid, &distance); return uid; } -- cgit v1.2.3