diff --git a/src/lib/viewport/glc_camera.cpp b/src/lib/viewport/glc_camera.cpp index ed38fc04..d579b5f6 100644 --- a/src/lib/viewport/glc_camera.cpp +++ b/src/lib/viewport/glc_camera.cpp @@ -82,25 +82,20 @@ bool GLC_Camera::operator==(const GLC_Camera& other) const ///////////////////////////////////////////////////////////////////// // Set Functions ///////////////////////////////////////////////////////////////////// -void GLC_Camera::orbit(GLC_Vector3d VectOldPoss, GLC_Vector3d VectCurPoss) +void GLC_Camera::orbit(GLC_Vector3d vectOldPoss, GLC_Vector3d vectCurPoss) { - // Map Vectors - GLC_Matrix4x4 invMat(m_ModelViewMatrix); - invMat.invert(); - VectOldPoss= invMat * VectOldPoss; - VectCurPoss= invMat * VectCurPoss; - // Compute rotation matrix - const GLC_Vector3d VectAxeRot(VectCurPoss ^ VectOldPoss); - // Check if rotation vector is not null - if (!VectAxeRot.isNull()) - { // Ok, is not null - const double Angle= acos(VectCurPoss * VectOldPoss); - const GLC_Matrix4x4 MatOrbit(VectAxeRot, Angle); + const GLC_Vector3d rotationAxis(vectCurPoss ^ vectOldPoss); + // Check if rotation axis is not null + if (!rotationAxis.isNull()) + { + const double angle= acos(vectCurPoss * vectOldPoss); + const GLC_Matrix4x4 invMat(m_ModelViewMatrix.inverted()); + const GLC_Matrix4x4 orbitMatrix(invMat * rotationAxis, angle); // Camera transformation - m_Eye= (MatOrbit * (m_Eye - m_Target)) + m_Target; - m_VectUp= MatOrbit * m_VectUp; + m_Eye= (orbitMatrix * (m_Eye - m_Target)) + m_Target; + m_VectUp= orbitMatrix * m_VectUp; createMatComp(); } diff --git a/src/lib/viewport/glc_camera.h b/src/lib/viewport/glc_camera.h index 6ec6dde8..c727c2c3 100644 --- a/src/lib/viewport/glc_camera.h +++ b/src/lib/viewport/glc_camera.h @@ -154,7 +154,7 @@ class GLC_LIB_EXPORT GLC_Camera : public QObject ////////////////////////////////////////////////////////////////////// public: //! Camera orbiting - void orbit(GLC_Vector3d VectOldPoss, GLC_Vector3d VectCurPoss); + void orbit(GLC_Vector3d vectOldPoss, GLC_Vector3d vectCurPoss); //! panoramic movement void pan(GLC_Vector3d VectDep); diff --git a/src/lib/viewport/glc_trackballmover.cpp b/src/lib/viewport/glc_trackballmover.cpp index 766e3238..edc6aa0e 100644 --- a/src/lib/viewport/glc_trackballmover.cpp +++ b/src/lib/viewport/glc_trackballmover.cpp @@ -80,19 +80,21 @@ void GLC_TrackBallMover::init(const GLC_UserInput& userInput) // Move the camera bool GLC_TrackBallMover::move(const GLC_UserInput& userInput) { - const GLC_Vector3d VectCurOrbit(mapForTracking(static_cast(userInput.x()), static_cast(userInput.y()))); + const double x= static_cast(userInput.x()); + const double y= static_cast(userInput.y()); + + const GLC_Vector3d vectCurOrbit(mapForTracking(x, y)); // Update camera position (orbit) - GLC_Mover::m_pViewport->cameraHandle()->orbit(GLC_Mover::m_PreviousVector, VectCurOrbit); + GLC_Mover::m_pViewport->cameraHandle()->orbit(GLC_Mover::m_PreviousVector, vectCurOrbit); // Update arcs of circle's positionning matrix - const GLC_Matrix4x4 MatRot(GLC_Mover::m_PreviousVector, VectCurOrbit); - - GLC_Mover::m_MoverInfo.m_MatrixInfo.first()= MatRot; + const GLC_Matrix4x4 matRot(GLC_Mover::m_PreviousVector, vectCurOrbit); + GLC_Mover::m_MoverInfo.m_MatrixInfo.first()= matRot; updateRepresentation(); // Previous vector become current vector - GLC_Mover::m_PreviousVector = VectCurOrbit; + GLC_Mover::m_PreviousVector = vectCurOrbit; return true; }