Added handling of when mouse delta is too high, indicating a inconsitency in the

the events.  These changes prevent irratic high speed spinning when releasing the
mouse point in a different screen from when the mouse event started.
This commit is contained in:
Robert Osfield
2007-06-15 10:12:57 +00:00
parent 10235ad0b4
commit 4979a0ac41
2 changed files with 21 additions and 5 deletions

View File

@@ -213,7 +213,7 @@ bool NodeTrackerManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter&
{
double timeSinceLastRecordEvent = _ga_t0.valid() ? (ea.getTime() - _ga_t0->getTime()) : DBL_MAX;
if (timeSinceLastRecordEvent>0.02) addMouseEvent(ea);
if (timeSinceLastRecordEvent>0.02) flushMouseEventStack();
if (isMouseMoving())
{
@@ -422,9 +422,18 @@ bool NodeTrackerManipulator::calcMovement()
double dy = _ga_t0->getYnormalized()-_ga_t1->getYnormalized();
float distance = sqrtf(dx*dx + dy*dy);
// return if movement is too fast, indicating an error in event values or change in screen.
if (distance>0.5)
{
return false;
}
// return if there is no movement.
if (dx==0 && dy==0) return false;
if (distance==0.0f)
{
return false;
}
osg::Vec3d nodeCenter;
osg::Quat nodeRotation;

View File

@@ -108,7 +108,7 @@ bool TrackballManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us
{
double timeSinceLastRecordEvent = _ga_t0.valid() ? (ea.getTime() - _ga_t0->getTime()) : DBL_MAX;
if (timeSinceLastRecordEvent>0.02) addMouseEvent(ea);
if (timeSinceLastRecordEvent>0.02) flushMouseEventStack();
if (isMouseMoving())
{
@@ -250,9 +250,16 @@ bool TrackballManipulator::calcMovement()
float dx = _ga_t0->getXnormalized()-_ga_t1->getXnormalized();
float dy = _ga_t0->getYnormalized()-_ga_t1->getYnormalized();
float distance = sqrtf(dx*dx + dy*dy);
// return if movement is too fast, indicating an error in event values or change in screen.
if (distance>0.5)
{
return false;
}
// return if there is no movement.
if (dx==0.0f && dy==0.0f)
if (distance==0.0f)
{
return false;
}