X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fstructure%2FSGExpression.hxx;h=420a9045ce001926310942e49e4ffbdaa21b2327;hb=c82df0590dd46347e2f1d0dca4cc3712f67f3654;hp=ffb9dd1ded2408b43797160ab597e6820cb0fa9f;hpb=6d2646239e70d46e993d08492da43c4583c4e519;p=simgear.git diff --git a/simgear/structure/SGExpression.hxx b/simgear/structure/SGExpression.hxx index ffb9dd1d..420a9045 100644 --- a/simgear/structure/SGExpression.hxx +++ b/simgear/structure/SGExpression.hxx @@ -665,24 +665,16 @@ public: private: T apply_mods(T property) const { - T modprop; - if (_step > 0) { - T scrollval = 0; - if(_scroll > 0) { - // calculate scroll amount (for odometer like movement) - T remainder = _step - fmod(fabs(property), _step); - if (remainder < _scroll) { - scrollval = (_scroll - remainder) / _scroll * _step; - } - } - // apply stepping of input value - if(property > 0) - modprop = ((floor(property/_step) * _step) + scrollval); - else - modprop = ((ceil(property/_step) * _step) + scrollval); - } else { - modprop = property; - } + if( _step <= SGLimits::min() ) return property; + + // apply stepping of input value + T modprop = floor(property/_step)*_step; + + // calculate scroll amount (for odometer like movement) + T remainder = property <= SGLimits::min() ? -fmod(property,_step) : (_step - fmod(property,_step)); + if( remainder > SGLimits::min() && remainder < _scroll ) + modprop += (_scroll - remainder) / _scroll * _step; + return modprop; } @@ -1256,7 +1248,7 @@ namespace simgear ConvertExpression() {} ConvertExpression(::SGExpression* expr0) { - addOperand(expr0); + this->addOperand(expr0); } virtual void eval(T& value, const simgear::expression::Binding* b) const {