Skip to content
Snippets Groups Projects

Update orthographic projection correctly.

Merged Julius Nehring-Wirxel requested to merge feature/update-orthogonal into develop
1 file
+ 18
4
Compare changes
  • Side-by-side
  • Inline
@@ -70,11 +70,25 @@ tg::mat4 CameraController::computeViewMatrix() const
tg::mat4 CameraController::computeProjMatrix() const
{
if (mOrthographicModeEnabled)
return tg::orthographic_reverse_z(mOrthographicBounds.min.x, mOrthographicBounds.max.x, //
mOrthographicBounds.min.y, mOrthographicBounds.max.y, //
mOrthographicBounds.min.z, mOrthographicBounds.max.z);
{
auto const aspect = float(mWindowWidth) / mWindowHeight;
auto bounds = mOrthographicBounds;
if (aspect < 1.0f)
{
bounds.min.y /= aspect;
bounds.max.y /= aspect;
}
else
{
bounds.min.x *= aspect;
bounds.max.x *= aspect;
}
return tg::orthographic_reverse_z(bounds.min.x, bounds.max.x, bounds.min.y, bounds.max.y, bounds.min.z, bounds.max.z);
}
else
return tg::perspective_reverse_z(s.HorizontalFov, mWindowWidth / float(mWindowHeight), s.NearPlane);
return tg::perspective_reverse_z(s.HorizontalFov, mWindowWidth / float(mWindowHeight), s.NearPlane);
}
CameraController::CameraController() { resetView(); }
Loading