From 43998d6a383f6d6a8ae31ed8533235c226deda3f Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 18 Apr 2013 23:34:32 +0000 Subject: [PATCH] BGE: Extend Framing Mode + Camera sensor If the "Framing" mode is set to extend, the camera frustrum changes when you resizes the blenderplayer window. Before this patch, there were no way to control which part of the framing you want to extend (vertical, horizontal or arbritary). Now: If the camera sensor fit is set to HORIZONTAL, the horizontal field of view doesn't change. If set to VERTICAL, the vertical fov doesn't change. If set to AUTO the old behaviour takes place, arbitrarly showing more of the horizontal or vertical field of view depending on the aspect ratio of the window. Test file: https://svn.blender.org/svnroot/bf-blender/trunk/lib/tests/gameengine/framing_extend.blend Bugfix supported by NF-UBC Nereus Program as part of the development of OceanViz/NereusViz --- .../Rasterizer/RAS_FramingManager.cpp | 84 ++++++++++++++----- 1 file changed, 62 insertions(+), 22 deletions(-) diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.cpp b/source/gameengine/Rasterizer/RAS_FramingManager.cpp index 53d9b64ab0e..d1a801c52f8 100644 --- a/source/gameengine/Rasterizer/RAS_FramingManager.cpp +++ b/source/gameengine/Rasterizer/RAS_FramingManager.cpp @@ -257,19 +257,39 @@ ComputeFrustum( case RAS_FrameSettings::e_frame_extend: { - RAS_Rect vt; - ComputeBestFitViewRect( - availableViewport, - design_aspect_ratio, - vt - ); + float x_scale, y_scale; + switch (sensor_fit) { + case RAS_SENSORFIT_HOR: + { + x_scale = 1.0; + y_scale = float(viewport.GetHeight()) / float(viewport.GetWidth()); + break; + } + case RAS_SENSORFIT_VERT: + { + x_scale = float(viewport.GetWidth()) / float(viewport.GetHeight()); + y_scale = 1.0; + break; + } + case RAS_SENSORFIT_AUTO: + default: + { + RAS_Rect vt; + ComputeBestFitViewRect( + availableViewport, + design_aspect_ratio, + vt + ); - // now scale the calculated frustum by the difference - // between vt and the viewport in each axis. - // These are always > 1 + // now scale the calculated frustum by the difference + // between vt and the viewport in each axis. + // These are always > 1 - float x_scale = float(viewport.GetWidth())/float(vt.GetWidth()); - float y_scale = float(viewport.GetHeight())/float(vt.GetHeight()); + x_scale = float(viewport.GetWidth())/float(vt.GetWidth()); + y_scale = float(viewport.GetHeight())/float(vt.GetHeight()); + break; + } + } frustum.x1 *= x_scale; frustum.x2 *= x_scale; @@ -327,19 +347,39 @@ RAS_FramingManager:: case RAS_FrameSettings::e_frame_extend: { - RAS_Rect vt; - ComputeBestFitViewRect( - availableViewport, - design_aspect_ratio, - vt - ); + float x_scale, y_scale; + switch (sensor_fit) { + case RAS_SENSORFIT_HOR: + { + x_scale = 1.0; + y_scale = float(viewport.GetHeight()) / float(viewport.GetWidth()); + break; + } + case RAS_SENSORFIT_VERT: + { + x_scale = float(viewport.GetWidth()) / float(viewport.GetHeight()); + y_scale = 1.0; + break; + } + case RAS_SENSORFIT_AUTO: + default: + { + RAS_Rect vt; + ComputeBestFitViewRect( + availableViewport, + design_aspect_ratio, + vt + ); - // now scale the calculated frustum by the difference - // between vt and the viewport in each axis. - // These are always > 1 + // now scale the calculated frustum by the difference + // between vt and the viewport in each axis. + // These are always > 1 - float x_scale = float(viewport.GetWidth())/float(vt.GetWidth()); - float y_scale = float(viewport.GetHeight())/float(vt.GetHeight()); + x_scale = float(viewport.GetWidth())/float(vt.GetWidth()); + y_scale = float(viewport.GetHeight())/float(vt.GetHeight()); + break; + } + } frustum.x1 *= x_scale; frustum.x2 *= x_scale;