From 321750d72def379fa6b448b83b7d65dc67bb1410 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 1 Mar 2015 11:08:58 +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/trunk@14744 16af8721-9629-0410-8352-f15c8da7e697 --- src/osgGA/OrbitManipulator.cpp | 4 ++-- src/osgGA/StandardManipulator.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/osgGA/OrbitManipulator.cpp b/src/osgGA/OrbitManipulator.cpp index 59a5a9039..4ac666e83 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 dcbc5dcfb..d0c73c71e 100644 --- a/src/osgGA/StandardManipulator.cpp +++ b/src/osgGA/StandardManipulator.cpp @@ -588,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; }