diff --git a/src/level/doomdata.h b/src/level/doomdata.h index 2c776a0..c548edb 100644 --- a/src/level/doomdata.h +++ b/src/level/doomdata.h @@ -374,6 +374,7 @@ struct FLevel void CreateLights(); LevelTraceHit Trace(const kexVec3 &startVec, const kexVec3 &endVec); + bool TraceAnyHit(const kexVec3 &startVec, const kexVec3 &endVec); const kexVec3 &GetSunColor() const; const kexVec3 &GetSunDirection() const; diff --git a/src/level/level_light.cpp b/src/level/level_light.cpp index 0168601..e17f3c1 100644 --- a/src/level/level_light.cpp +++ b/src/level/level_light.cpp @@ -379,3 +379,8 @@ LevelTraceHit FLevel::Trace(const kexVec3 &startVec, const kexVec3 &endVec) } return trace; } + +bool FLevel::TraceAnyHit(const kexVec3 &startVec, const kexVec3 &endVec) +{ + return TriangleMeshShape::find_any_hit(CollisionMesh.get(), startVec, endVec); +} diff --git a/src/lightmap/lightmap.cpp b/src/lightmap/lightmap.cpp index ac79d7b..25182a2 100644 --- a/src/lightmap/lightmap.cpp +++ b/src/lightmap/lightmap.cpp @@ -265,9 +265,7 @@ kexVec3 kexLightmapBuilder::LightTexelSample(const kexVec3 &origin, surface_t *s } } - LevelTraceHit trace = map->Trace(lightOrigin, origin); - - if (trace.fraction != 1) + if (map->TraceAnyHit(lightOrigin, origin)) { // this light is occluded by something continue; diff --git a/src/lightmap/lightsurface.cpp b/src/lightmap/lightsurface.cpp index 2952925..356ffcd 100644 --- a/src/lightmap/lightsurface.cpp +++ b/src/lightmap/lightsurface.cpp @@ -286,9 +286,7 @@ float kexLightSurface::TraceSurface(FLevel *map, const surface_t *fragmentSurfac // trace the origin to the center of the light surface. nudge by the normals in // case the start/end points are directly on or inside the surface - LevelTraceHit trace = map->Trace(lightPos + lightSurfaceNormal, fragmentPos + fragmentNormal); - - if (trace.fraction < 1.0f) + if (map->TraceAnyHit(lightPos + lightSurfaceNormal, fragmentPos + fragmentNormal)) continue; // something is obstructing it if (d < closestDistance)