public override void Execute( IRaySceneQueryListener listener )
{
Vector3 dir = ray.Direction;
Vector3 origin = ray.Origin;
// Straight up / down?
if ( dir == Vector3.UnitY || dir == Vector3.NegativeUnitY )
{
float height = ( (TerrainSceneManager)creator ).GetHeightAt( origin, -1 );
if ( height != -1 && ( height <= origin.y && dir.y < 0 ) || ( height >= origin.y && dir.y > 0 ) )
{
this.WorldFragment.SingleIntersection.x = origin.x;
this.WorldFragment.SingleIntersection.z = origin.z;
this.WorldFragment.SingleIntersection.y = height;
if ( !listener.OnQueryResult( this.WorldFragment, ( this.WorldFragment.SingleIntersection - origin ).Length ) )
return;
}
}
else
{
TerrainSceneManager tsm = (TerrainSceneManager)creator;
this.WorldFragment.SingleIntersection = tsm.IntersectSegment( origin, origin + ( dir * 100000 ) );
if ( !listener.OnQueryResult( this.WorldFragment, ( this.WorldFragment.SingleIntersection - origin ).Length ) )
return;
}
}
}