Combine plane facing and initial radius checks
This commit is contained in:
parent
df8cb6f1ca
commit
4b3016d895
|
@ -699,20 +699,11 @@ public class LightMapper
|
||||||
|
|
||||||
var light = _lights[lightIdx - 1];
|
var light = _lights[lightIdx - 1];
|
||||||
|
|
||||||
// Check if plane normal is facing towards the light
|
// If the light is behind the plane we'll never be directly lit by this light.
|
||||||
// If it's not then we're never going to be (directly) lit by this
|
// Additionally, if the distance from the plane is more than the light's radius
|
||||||
// light.
|
// we know no points on the plane will be lit.
|
||||||
var centerDirection = renderPoly.Center - light.Position;
|
var planeDist = MathUtils.DistanceFromPlane(plane, light.Position);
|
||||||
if (Vector3.Dot(plane.Normal, centerDirection) >= 0)
|
if (planeDist <= MathUtils.Epsilon || planeDist > light.Radius)
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If there aren't *any* points on the plane that are in range of the light
|
|
||||||
// then none of the lightmap points will be so we can discard.
|
|
||||||
// The more compact a map is the less effective this is
|
|
||||||
var planeDist = Math.Abs(MathUtils.DistanceFromPlane(plane, light.Position));
|
|
||||||
if (planeDist > light.Radius)
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue