Skip to content

Commit

Permalink
Merge pull request #959 from Fred-si/master
Browse files Browse the repository at this point in the history
Nothing new from author in the last few weeks, merging to tidy things up.
  • Loading branch information
SteelFill authored Sep 9, 2024
2 parents edbd2bb + 2452cb0 commit 5d23965
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Source/Contrib/TrackViewer/Drawing/DrawTerrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,14 @@ void UpdateCamera(DrawArea drawArea)
float camHeight = width / device.Viewport.AspectRatio / 2;
Vector3 cameraPosition = cameraTarget;
cameraPosition.Y = -camHeight;
float nearPlaneDistance = camHeight / 2;
if (nearPlaneDistance <= 0)
{
// distance is too close for CreatePerspectiveFieldOfView
return;
}
basicEffect.View = Matrix.CreateLookAt(cameraPosition, cameraTarget, new Vector3(0, 0, 1));
basicEffect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver2, device.Viewport.AspectRatio, camHeight / 2, camHeight * 2);
basicEffect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver2, device.Viewport.AspectRatio, nearPlaneDistance, camHeight * 2);

}
#endregion
Expand Down

0 comments on commit 5d23965

Please sign in to comment.