Ray traces now continue through any water they hit (unless the water surface is the target)
This commit is contained in:
		
							parent
							
								
									e6ca952962
								
							
						
					
					
						commit
						b47a7536c4
					
				| 
						 | 
					@ -612,13 +612,23 @@ public class LightMapper
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    private bool TraceRay(Vector3 origin, Vector3 target)
 | 
					    private bool TraceRay(Vector3 origin, Vector3 target)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        var direction = target - origin;
 | 
					        var hitDistanceFromTarget = float.MinValue;
 | 
				
			||||||
        var hitResult = _scene.Trace(new Ray
 | 
					        var hitSurfaceType = SurfaceType.Water;
 | 
				
			||||||
 | 
					        while (hitDistanceFromTarget < -MathUtils.Epsilon && hitSurfaceType == SurfaceType.Water)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Origin = origin,
 | 
					            var direction = target - origin;
 | 
				
			||||||
            Direction = Vector3.Normalize(direction),
 | 
					            var hitResult = _scene.Trace(new Ray
 | 
				
			||||||
        });
 | 
					            {
 | 
				
			||||||
        return hitResult && Math.Abs(hitResult.Distance - direction.Length()) < MathUtils.Epsilon;
 | 
					                Origin = origin,
 | 
				
			||||||
 | 
					                Direction = Vector3.Normalize(direction),
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            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()
 | 
					    private void SetAnimLightCellMaps()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue