diff options
Diffstat (limited to 'src/world.c')
| -rw-r--r-- | src/world.c | 21 |
1 files changed, 15 insertions, 6 deletions
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; } |
