X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fstructure%2FSGExpression.hxx;h=420a9045ce001926310942e49e4ffbdaa21b2327;hb=c82df0590dd46347e2f1d0dca4cc3712f67f3654;hp=6f90061c32e6b97ba1249c088656f4dc5219bdcd;hpb=1670f88e54fcb7842913f874f0f308f551df102f;p=simgear.git diff --git a/simgear/structure/SGExpression.hxx b/simgear/structure/SGExpression.hxx index 6f90061c..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; } @@ -807,9 +799,9 @@ public: { } virtual void eval(T& value, const simgear::expression::Binding* b) const { - value = T(0); + value = getOperand(0)->getValue(b); unsigned sz = SGNaryExpression::getNumOperands(); - for (unsigned i = 0; i < sz; ++i) + for (unsigned i = 1; i < sz; ++i) value -= getOperand(i)->getValue(b); } using SGNaryExpression::getValue; @@ -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 {