Ray traces now continue through any water they hit (unless the water surface is the target)

This commit is contained in:
Jarrod Doyle 2024-11-04 18:08:54 +00:00
parent e6ca952962
commit b47a7536c4
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 16 additions and 6 deletions

View File

@ -611,6 +611,10 @@ public class LightMapper
}
private bool TraceRay(Vector3 origin, Vector3 target)
{
var hitDistanceFromTarget = float.MinValue;
var hitSurfaceType = SurfaceType.Water;
while (hitDistanceFromTarget < -MathUtils.Epsilon && hitSurfaceType == SurfaceType.Water)
{
var direction = target - origin;
var hitResult = _scene.Trace(new Ray
@ -618,7 +622,13 @@ public class LightMapper
Origin = origin,
Direction = Vector3.Normalize(direction),
});
return hitResult && Math.Abs(hitResult.Distance - direction.Length()) < MathUtils.Epsilon;
hitDistanceFromTarget = hitResult.Distance - direction.Length();
hitSurfaceType = _triangleTypeMap[(int)hitResult.PrimId];
origin = hitResult.Position += direction * MathUtils.Epsilon;
}
return Math.Abs(hitDistanceFromTarget) < MathUtils.Epsilon;
}
private void SetAnimLightCellMaps()