From c43f99f6c2c30cab31d82146221bc1015ec775c4 Mon Sep 17 00:00:00 2001 From: Terry Hearst Date: Sun, 22 Jun 2025 21:39:23 -0400 Subject: [PATCH] Use fixed vertical FOV for wide aspect ratios --- engine/source/gui/core/guiTSControl.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/engine/source/gui/core/guiTSControl.cpp b/engine/source/gui/core/guiTSControl.cpp index e5c0c9d1..c6b97f99 100644 --- a/engine/source/gui/core/guiTSControl.cpp +++ b/engine/source/gui/core/guiTSControl.cpp @@ -105,8 +105,19 @@ void GuiTSCtrl::onRender(Point2I offset, const RectI& updateRect) } // set up the camera and viewport stuff: - F32 wwidth = mLastCameraQuery.nearPlane * mTan(mLastCameraQuery.fov / 2); - F32 wheight = F32(mBounds.extent.y) / F32(mBounds.extent.x) * wwidth; + F32 wwidth, wheight; + const float referenceAspectRatio = 16.0f / 9.0f; + + if (F32(mBounds.extent.x) / F32(mBounds.extent.y) > referenceAspectRatio) + { + wheight = mLastCameraQuery.nearPlane * mTan(mLastCameraQuery.fov / 2) / referenceAspectRatio; + wwidth = F32(mBounds.extent.x) / F32(mBounds.extent.y) * wheight; + } + else + { + wwidth = mLastCameraQuery.nearPlane * mTan(mLastCameraQuery.fov / 2); + wheight = F32(mBounds.extent.y) / F32(mBounds.extent.x) * wwidth; + } F32 hscale = wwidth * 2 / F32(mBounds.extent.x); F32 vscale = wheight * 2 / F32(mBounds.extent.y);