This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository colobot.

commit 2751db324536a8f1bca8519a628ac1d39d7f1911
Author: immibis <immi...@gmail.com>
Date:   Sat Aug 5 19:45:08 2017 +1200

    Add horizontal FoV to CEngine
---
 src/graphics/engine/engine.cpp | 14 ++++++++++++++
 src/graphics/engine/engine.h   | 12 +++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp
index a145838..a6d21cd 100644
--- a/src/graphics/engine/engine.cpp
+++ b/src/graphics/engine/engine.cpp
@@ -2631,6 +2631,10 @@ void CEngine::SetFocus(float focus)
     float farPlane = m_deepView[0] * m_clippingDistance;
 
     float aspect = static_cast<float>(m_size.x) / static_cast<float>(m_size.y);
+
+    // Compute H-FoV from V-FoV and aspect ratio.
+    m_hfov = 2.0f * atan(aspect * tan(focus / 2.0f));
+
     Math::LoadProjectionMatrix(m_matProj, m_focus, aspect, 0.5f, farPlane);
 }
 
@@ -2639,6 +2643,16 @@ float CEngine::GetFocus()
     return m_focus;
 }
 
+float CEngine::GetVFovAngle()
+{
+    return m_focus;
+}
+
+float CEngine::GetHFovAngle()
+{
+    return m_hfov;
+}
+
 void CEngine::SetShadowColor(float value)
 {
     m_shadowColor = value;
diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h
index 429bca1..655bc02 100644
--- a/src/graphics/engine/engine.h
+++ b/src/graphics/engine/engine.h
@@ -921,12 +921,16 @@ public:
     void            SetTerrainVision(float vision);
 
     //@{
-    //! Management of camera angle
-    /**
+    //! Management of camera vertical field-of-view angle.
+    /** This is specified in radians.
+    Horizontal FoV is calculated based on vertical FoV and aspect ratio.
     0.75 = normal
     1.50 = wide-angle */
     void            SetFocus(float focus);
+    //! Deprecated alias for GetVFovAngle
     float           GetFocus();
+    float           GetVFovAngle();
+    float           GetHFovAngle();
     //@}
 
     //@{
@@ -1318,8 +1322,10 @@ protected:
     Math::Matrix    m_matProj;
     //! View matrix for 3D scene
     Math::Matrix    m_matView;
-    //! Camera angle for 3D scene
+    //! Camera vertical field-of-view angle for 3D scene. A.k.a. m_vfov
     float           m_focus;
+    //! Horizontal field-of-view angle, calculated from vertical FOV and 
aspect ratio
+    float           m_hfov;
 
     //! Projection matrix for rendering shadow maps
     Math::Matrix    m_shadowProjMat;

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-games/colobot.git

_______________________________________________
Pkg-games-commits mailing list
Pkg-games-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to