[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56155] trunk/blender/source/gameengine/ Rasterizer/RAS_FramingManager.cpp: BGE: Extend Framing Mode + Camera sensor
Dalai Felinto
dfelinto at gmail.com
Fri Apr 19 01:34:32 CEST 2013
Revision: 56155
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56155
Author: dfelinto
Date: 2013-04-18 23:34:32 +0000 (Thu, 18 Apr 2013)
Log Message:
-----------
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
Modified Paths:
--------------
trunk/blender/source/gameengine/Rasterizer/RAS_FramingManager.cpp
Modified: trunk/blender/source/gameengine/Rasterizer/RAS_FramingManager.cpp
===================================================================
--- trunk/blender/source/gameengine/Rasterizer/RAS_FramingManager.cpp 2013-04-18 23:29:05 UTC (rev 56154)
+++ trunk/blender/source/gameengine/Rasterizer/RAS_FramingManager.cpp 2013-04-18 23:34:32 UTC (rev 56155)
@@ -257,19 +257,39 @@
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 @@
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;
More information about the Bf-blender-cvs
mailing list