From 4c9e17fcc78fe40404119829df5e63177e38fcc3 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 1 Mar 2015 11:08:51 +0000 Subject: [PATCH] From Jannik Heller, "I noticed the rotation in the OrbitManipulator depends on the framerate. To reproduce this issue, start the osganimate example, rotate the model with the left mouse button, then let go of the mouse button while still moving. You will notice that with V-Sync enabled, the model rotates slower. The OrbitManipulator calculates a scale to counteract the framerate dependency, but it turns out this scale wasn't used for the rotation yet." git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14743 16af8721-9629-0410-8352-f15c8da7e697 --- src/osgGA/OrbitManipulator.cpp | 4 ++-- src/osgGA/StandardManipulator.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/osgGA/OrbitManipulator.cpp b/src/osgGA/OrbitManipulator.cpp index 1ee5af221..3d2750c6d 100644 --- a/src/osgGA/OrbitManipulator.cpp +++ b/src/osgGA/OrbitManipulator.cpp @@ -379,12 +379,12 @@ void OrbitManipulator::OrbitAnimationData::start( const osg::Vec3d& movement, co Scale parameter is useful, for example, when manipulator is thrown. It scales the amount of rotation based, for example, on the current frame time.*/ void OrbitManipulator::rotateTrackball( const float px0, const float py0, - const float px1, const float py1, const float /*scale*/ ) + const float px1, const float py1, const float scale ) { osg::Vec3d axis; float angle; - trackball( axis, angle, px1, py1, px0, py0 ); + trackball( axis, angle, px0 + (px1-px0)*scale, py0 + (py1-py0)*scale, px0, py0 ); Quat new_rotate; new_rotate.makeRotate( angle, axis ); diff --git a/src/osgGA/StandardManipulator.cpp b/src/osgGA/StandardManipulator.cpp index 105fb8a04..747dd20fd 100644 --- a/src/osgGA/StandardManipulator.cpp +++ b/src/osgGA/StandardManipulator.cpp @@ -154,6 +154,8 @@ bool StandardManipulator::isAnimating() const /// Finishes the animation by performing a step that moves it to its final position. void StandardManipulator::finishAnimation() { + _thrown = false; + if( !isAnimating() ) return; @@ -586,7 +588,12 @@ void StandardManipulator::setAllowThrow( bool allowThrow ) events that started the animation.*/ float StandardManipulator::getThrowScale( const double eventTimeDelta ) const { - if( _thrown ) return float( _delta_frame_time / eventTimeDelta ); + if( _thrown ) + { + if (eventTimeDelta == 0.f) + return 0.f; + return float( _delta_frame_time / eventTimeDelta ); + } else return 1.f; }