Skip to content

Commit 5d23965

Browse files
authored
Merge pull request #959 from Fred-si/master
Nothing new from author in the last few weeks, merging to tidy things up.
2 parents edbd2bb + 2452cb0 commit 5d23965

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Source/Contrib/TrackViewer/Drawing/DrawTerrain.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,14 @@ void UpdateCamera(DrawArea drawArea)
486486
float camHeight = width / device.Viewport.AspectRatio / 2;
487487
Vector3 cameraPosition = cameraTarget;
488488
cameraPosition.Y = -camHeight;
489+
float nearPlaneDistance = camHeight / 2;
490+
if (nearPlaneDistance <= 0)
491+
{
492+
// distance is too close for CreatePerspectiveFieldOfView
493+
return;
494+
}
489495
basicEffect.View = Matrix.CreateLookAt(cameraPosition, cameraTarget, new Vector3(0, 0, 1));
490-
basicEffect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver2, device.Viewport.AspectRatio, camHeight / 2, camHeight * 2);
496+
basicEffect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver2, device.Viewport.AspectRatio, nearPlaneDistance, camHeight * 2);
491497

492498
}
493499
#endregion

0 commit comments

Comments
 (0)