]> git.mxchange.org Git - simgear.git/blobdiff - simgear/structure/SGExpression.hxx
SGPath rename wrapper. Let's see what Win32 makes of it.
[simgear.git] / simgear / structure / SGExpression.hxx
index 6f90061c32e6b97ba1249c088656f4dc5219bdcd..420a9045ce001926310942e49e4ffbdaa21b2327 100644 (file)
@@ -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<T>::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<T>::min() ? -fmod(property,_step) : (_step - fmod(property,_step));
+    if( remainder > SGLimits<T>::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<T>::getNumOperands();
-    for (unsigned i = 0; i < sz; ++i)
+    for (unsigned i = 1; i < sz; ++i)
       value -= getOperand(i)->getValue(b);
   }
   using SGNaryExpression<T>::getValue;
@@ -1256,7 +1248,7 @@ namespace simgear
     ConvertExpression() {}
     ConvertExpression(::SGExpression<OpType>* expr0)
     {
-      addOperand(expr0);
+      this->addOperand(expr0);
     }
     virtual void eval(T& value, const simgear::expression::Binding* b) const
     {