@@ -226,10 +226,48 @@ void W3DView::setWidth(Int width)
226226 m_3DCamera->Get_Viewport (vMin,vMax);
227227 vMax.X =(Real)(m_originX+width)/(Real)TheDisplay->getWidth ();
228228 m_3DCamera->Set_Viewport (vMin,vMax);
229+ }
230+
231+ // TheSuperHackers @tweak valeronm 25/03/2025 Adjusting FOV to look similar to what we have in in 4:3 (hFOV: 50, vFOV 38.55)
232+ void W3DView::adjustFovToAspectRatio (const Int width, const Int height)
233+ {
234+ static const Real fixedHFOV = 50 .00f ;
235+ static const Real fixedVFOV = 38 .55f ;
229236
230- // we want to maintain the same scale, so we'll need to adjust the fov.
231- // default W3D fov for full-screen is 50 degrees.
232- m_3DCamera->Set_View_Plane ((Real)width/(Real)TheDisplay->getWidth ()*DEG_TO_RADF (50 .0f ),-1 );
237+ const Real aspectRatio = static_cast <Real>(width)/ static_cast <Real>(height);
238+ Real vFOVRad, hFOVRad;
239+ Bool drawEntireTerrain = false ;
240+ if (aspectRatio >= 4 .0f / 3 .0f )
241+ {
242+ // Wider than 4:3 resolutions get fixed vFOV 38.55
243+ vFOVRad = DEG_TO_RADF (fixedVFOV);
244+ hFOVRad = 2 .0f * atan (tan (vFOVRad / 2 .0f ) * aspectRatio);
245+ drawEntireTerrain = true ;
246+ }
247+ else if (aspectRatio >= 1.0 )
248+ {
249+ // Narrower than 4:3 but not yet portrait resolutions get fixed hFOV 50.0
250+ hFOVRad = DEG_TO_RADF (fixedHFOV);
251+ vFOVRad = 2 .0f * atan (tan (hFOVRad / 2 .0f ) / aspectRatio);
252+ }
253+ else
254+ {
255+ // Portrait resolutions get fixed vFOV adjusted to aspect ratio
256+ // vFOV increases from 50.0 for 1:1 to 60.0 for 9:21 and then fixed 60.0
257+ static const Real adjMinRatio = 9 .0f / 21 .0f ;
258+ static const Real adjValue = 10 .0f ;
259+
260+ Real adjustment;
261+ if (aspectRatio < adjMinRatio)
262+ adjustment = adjValue;
263+ else
264+ adjustment = (1 - aspectRatio) * adjValue / (1 - adjMinRatio);
265+ vFOVRad = DEG_TO_RADF (50 + adjustment);
266+ hFOVRad = 2 .0f * atan (tan (vFOVRad / 2 .0f ) * aspectRatio);
267+ drawEntireTerrain = true ;
268+ }
269+ TheWritableGlobalData->m_drawEntireTerrain = drawEntireTerrain;
270+ m_3DCamera->Set_View_Plane (hFOVRad, vFOVRad);
233271}
234272
235273// -------------------------------------------------------------------------------------------------
0 commit comments