Fix zero-interval repeat on pick/knob animation

See:
https://sourceforge.net/p/flightgear/codetickets/2241/

Note did not adjust bug in knob-animation ignoring repeatable flag
(always marked repeatable) since this might break some aircraft.
This commit is contained in:
James Turner 2020-06-15 16:11:11 +01:00
parent 3075b8bcc4
commit 60dcf00f2b

View File

@ -136,11 +136,19 @@ osg::Vec2d eventToWindowCoords(const osgGA::GUIEventAdapter& ea)
virtual void update(double dt, int keyModState) virtual void update(double dt, int keyModState)
{ {
if (!_condition || _condition->test()) {
SG_UNUSED(keyModState); SG_UNUSED(keyModState);
if (_condition && !_condition->test()) {
return;
}
if (!_repeatable) if (!_repeatable)
return; return;
const bool zeroInterval = (_repeatInterval <= 0.0);
if (zeroInterval) {
// fire once per frame
fireBindingList(_bindingsDown);
} else {
_repeatTime += dt; _repeatTime += dt;
while (_repeatInterval < _repeatTime) { while (_repeatInterval < _repeatTime) {
_repeatTime -= _repeatInterval; _repeatTime -= _repeatInterval;
@ -679,12 +687,18 @@ public:
return; return;
} }
const bool zeroInterval = (_repeatInterval <= 0.0);
if (zeroInterval) {
// fire once per frame
fire(keyModState & osgGA::GUIEventAdapter::MODKEY_SHIFT, _direction);
} else {
_repeatTime += dt; _repeatTime += dt;
while (_repeatInterval < _repeatTime) { while (_repeatInterval < _repeatTime) {
_repeatTime -= _repeatInterval; _repeatTime -= _repeatInterval;
fire(keyModState & osgGA::GUIEventAdapter::MODKEY_SHIFT, _direction); fire(keyModState & osgGA::GUIEventAdapter::MODKEY_SHIFT, _direction);
} // of repeat iteration } // of repeat iteration
} }
}
bool hover( const osg::Vec2d& windowPos, const Info& ) override bool hover( const osg::Vec2d& windowPos, const Info& ) override
{ {