From 6e42edd1cb0c5fcda9b8da6c5e738faa2b717058 Mon Sep 17 00:00:00 2001 From: Garux Date: Sat, 31 Aug 2019 11:30:29 +0300 Subject: [PATCH] * calculate fov against max of 3D viewport width, height for consistency --- radiant/camwindow.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index 92677209..b4dd3ae0 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -215,8 +215,13 @@ const float camera_t::near_z = 1.f; camera_draw_mode camera_t::draw_mode = cd_texture; inline Matrix4 projection_for_camera( float near_z, float far_z, float fieldOfView, int width, int height ){ - const float half_width = static_cast( near_z * tan( degrees_to_radians( fieldOfView * 0.5 ) ) ); - const float half_height = half_width * ( static_cast( height ) / static_cast( width ) ); + float half_width = static_cast( near_z * tan( degrees_to_radians( fieldOfView * 0.5 ) ) ); + const bool swap = height > width; + if( swap ) + std::swap( width, height ); + float half_height = half_width * ( static_cast( height ) / static_cast( width ) ); + if( swap ) + std::swap( half_width, half_height ); return matrix4_frustum( -half_width,