Skip to content

Commit

Permalink
Merge pull request #801 from dlyr/fix-rotate-cam
Browse files Browse the repository at this point in the history
Fix rotate cam
  • Loading branch information
dlyr authored Jul 19, 2021
2 parents cc64b4e + 6801a3f commit e22754d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 4 additions & 7 deletions src/Gui/Viewer/RotateAroundCameraManipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ bool RotateAroundCameraManipulator::handleMouseMoveEvent(
Scalar dx = ( event->pos().x() - m_lastMouseX ) / m_camera->getWidth();
Scalar dy = ( event->pos().y() - m_lastMouseY ) / m_camera->getHeight();

m_lastMouseX = event->pos().x();
m_lastMouseY = event->pos().y();

if ( m_currentAction == TRACKBALLCAMERA_ROTATE )
handleCameraRotate( event->pos().x(), event->pos().y() );
else if ( m_currentAction == TRACKBALLCAMERA_PAN )
Expand All @@ -74,8 +71,8 @@ bool RotateAroundCameraManipulator::handleMouseMoveEvent(
else if ( m_currentAction == TRACKBALLCAMERA_MOVE_FORWARD )
handleCameraMoveForward( dx, dy );

m_prevMouseX = m_lastMouseX;
m_prevMouseY = m_lastMouseY;
m_lastMouseX = event->pos().x();
m_lastMouseY = event->pos().y();

if ( m_light != nullptr )
{
Expand Down Expand Up @@ -184,8 +181,8 @@ Scalar RotateAroundCameraManipulator::projectOnBall( Scalar x, Scalar y ) {
Ra::Core::Quaternion
RotateAroundCameraManipulator::deformedBallQuaternion( Scalar x, Scalar y, Scalar cx, Scalar cy ) {
// Points on the deformed ball
Scalar px = m_cameraSensitivity * ( m_prevMouseX - cx ) / m_camera->getWidth();
Scalar py = m_cameraSensitivity * ( cy - m_prevMouseY ) / m_camera->getHeight();
Scalar px = m_cameraSensitivity * ( m_lastMouseX - cx ) / m_camera->getWidth();
Scalar py = m_cameraSensitivity * ( cy - m_lastMouseY ) / m_camera->getHeight();
Scalar dx = m_cameraSensitivity * ( x - cx ) / m_camera->getWidth();
Scalar dy = m_cameraSensitivity * ( cy - y ) / m_camera->getHeight();

Expand Down
2 changes: 0 additions & 2 deletions src/Gui/Viewer/RotateAroundCameraManipulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ class RA_GUI_API RotateAroundCameraManipulator
Scalar projectOnBall( Scalar x, Scalar y );

private:
Scalar m_prevMouseX {0.0_ra};
Scalar m_prevMouseY {0.0_ra};
Ra::Core::Vector3 m_pivot {0.0_ra, 0.0_ra, 0.0_ra};

Ra::Gui::Viewer* m_viewer;
Expand Down

0 comments on commit e22754d

Please sign in to comment.