[Libreoffice-commits] core.git: Branch 'libreoffice-4-3-0' - avmedia/source

Zolnai Tamás tamas.zolnai at collabora.com
Thu Jul 10 03:01:15 PDT 2014


 avmedia/source/opengl/oglwindow.cxx |   18 ++++++++++++++++++
 avmedia/source/opengl/oglwindow.hxx |    2 ++
 2 files changed, 20 insertions(+)

New commits:
commit 1fd83db78cc08aca927682f71dde6294087dfc7c
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Thu Jul 3 16:26:44 2014 +0200

    glTF: constraine camera move in orbit mode
    
    Not to get too close to / too far from the model.
    Too close means move into the model.
    
    Change-Id: Ie25d87c88093d4baaf98f13ab8239263b5e1bf66
    (cherry picked from commit 9a670eb493f3760eb398c3f9d2296d979b608f95)
    
    glTF: improve camera movement constraint
    
    Stop moving only on the wrong direction.
    
    Change-Id: Ic9e7f2e7814d9adcbcf707e7fb786bf17fac3125
    (cherry picked from commit 09fe9db46615265c6c7119f2524d19335d0e0283)
    
    glTF: camera movement constraint: use distance from the boundary box
    
    ... instead of distance from model center position.
    
    Change-Id: I379ab5e32cc5009d0eb751c4808fecf0109d1e5a
    (cherry picked from commit 2946c7c62718cb74feab554b5939ec340e6c4280)
    Reviewed-on: https://gerrit.libreoffice.org/10084
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/avmedia/source/opengl/oglwindow.cxx b/avmedia/source/opengl/oglwindow.cxx
index ffb0855..c748ca1 100644
--- a/avmedia/source/opengl/oglwindow.cxx
+++ b/avmedia/source/opengl/oglwindow.cxx
@@ -22,6 +22,7 @@ OGLWindow::OGLWindow( glTFHandle& rHandle, OpenGLContext& rContext, Window& rEve
     , meZoomLevel( media::ZoomLevel_ORIGINAL )
     , m_aLastMousePos(Point())
     , m_bIsOrbitMode( false )
+    , m_fCameraDistance(0.0)
 {
 }
 
@@ -274,6 +275,17 @@ IMPL_LINK(OGLWindow, CameraHandler, VclWindowEvent*, pEvent)
                         if(nCode == KEY_A)vMoveBy -= vStrafe*(0.0005f*fModelSize);
                         if(nCode == KEY_D)vMoveBy += vStrafe*(0.0005f*fModelSize);
                     }
+                    else
+                    {
+                        // Limit zooming in orbit mode
+                        m_fCameraDistance += vMoveBy.z;
+                        if ((m_fCameraDistance < 0.5 * fModelSize && vMoveBy.z < 0.0 ) ||
+                            (m_fCameraDistance > 2 * fModelSize && vMoveBy.z > 0.0 ))
+                        {
+                            m_fCameraDistance -= vMoveBy.z;
+                            vMoveBy = glm::vec3(0.0);
+                        }
+                    }
                 }
                 gltf_renderer_move_camera(&m_rHandle, vMoveBy.x, vMoveBy.y, vMoveBy.z, 0.0);
             }
@@ -288,6 +300,12 @@ IMPL_LINK(OGLWindow, CameraHandler, VclWindowEvent*, pEvent)
                 {
                     gltf_orbit_mode_start(&m_rHandle);
                     m_bIsOrbitMode = true;
+                    // Set default camera distance
+                    glm::vec3 vEye;
+                    glm::vec3 vView;
+                    glm::vec3 vUp;
+                    gltf_get_camera_pos(&m_rHandle, &vEye,&vView,&vUp);
+                    m_fCameraDistance = vEye.z - gltf_get_model_center_pos(&m_rHandle)->z - (gltf_get_model_size(&m_rHandle)/2.0);
                 }
             }
             else if(nCode == KEY_F)
diff --git a/avmedia/source/opengl/oglwindow.hxx b/avmedia/source/opengl/oglwindow.hxx
index 5a52cca..35c54c8 100644
--- a/avmedia/source/opengl/oglwindow.hxx
+++ b/avmedia/source/opengl/oglwindow.hxx
@@ -68,10 +68,12 @@ private:
     glTFHandle& m_rHandle;
     OpenGLContext& m_rContext;
     Window& m_rEventHandler;
+
     bool m_bVisible;
     com::sun::star::media::ZoomLevel meZoomLevel;
     Point m_aLastMousePos;
     bool m_bIsOrbitMode;
+    double m_fCameraDistance;
 };
 
 } // namespace ogl


More information about the Libreoffice-commits mailing list