mirror of
https://github.com/ZDoom/ZDRay.git
synced 2025-01-24 16:51:08 +00:00
- use the cheaper any hit test when possible
This commit is contained in:
parent
63715b855d
commit
b55a9671e5
4 changed files with 8 additions and 6 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue