]> git.mxchange.org Git - flightgear.git/commitdiff
Use simgear functions for clip and wrap around.
authorThomas Geymayer <tomgey@gmail.com>
Tue, 14 Feb 2012 13:41:53 +0000 (14:41 +0100)
committerThorstenB <brehmt@gmail.com>
Sun, 19 Feb 2012 13:53:04 +0000 (14:53 +0100)
docs-mini/README.protocol
src/Network/generic.hxx

index e106f5f80aec743d00bfc56467cd0bc71422dcc9..80a7163c68f6119bc43c53885f75224b85a881c8 100644 (file)
@@ -144,7 +144,7 @@ For input chunks there exist some more options:
   <max>         an optional upper limit for the input value to be clamped to. If
                 <min> equals <max> no limit is applied. (default: 0)
   <wrap>        instead of clamping to minimum and maximum limits, wrap values
-                around. (default: false)
+                around. Values will be in [min, max[ (default: false)
                 (Usefull for eg. heading selector to start again with 1 for
                 values higher than 360)
 
index 0b27248f5882a9b11ee071c59d0d1430ed598cb4..55f0ca8a5675df995d5c57cab9b67297bab167c8 100644 (file)
@@ -113,18 +113,9 @@ private:
       if( prot.max > prot.min )
       {
         if( prot.wrap )
-        {
-          T range = prot.max - prot.min + 1;
-          if( range > 0 )
-          {
-            while( new_val < prot.min )
-              new_val += range;
-            while( new_val > prot.max )
-              new_val -= range;
-          }
-        }
+          new_val = SGMisc<double>::normalizePeriodic(prot.min, prot.max, new_val);
         else
-          new_val = std::min<T>(prot.max, std::max<T>(prot.min, new_val));
+          new_val = SGMisc<T>::clip(new_val, prot.min, prot.max);
       }
 
       setValue(prot.prop, new_val);