]> git.mxchange.org Git - flightgear.git/commitdiff
Roy Vegard Ovesen:
authorehofman <ehofman>
Thu, 20 Jan 2005 09:55:47 +0000 (09:55 +0000)
committerehofman <ehofman>
Thu, 20 Jan 2005 09:55:47 +0000 (09:55 +0000)
I guess it is much more efficient to compare integers than comparing long strings like "double-exponential" every frame.

src/Autopilot/xmlauto.cxx
src/Autopilot/xmlauto.hxx

index 61171a08ec02a39c259961834a966ebc6c462d40..c8b7b9c61d5a5f1e2e312d7a71e4f0c986411d38 100644 (file)
@@ -607,7 +607,15 @@ FGDigitalFilter::FGDigitalFilter(SGPropertyNode *node)
         } else if ( cname == "debug" ) {
             debug = child->getBoolValue();
         } else if ( cname == "type" ) {
-            filterType = cval;
+            if ( cval == "exponential" ) {
+                filterType = exponential;
+            } else if (cval == "double-exponential") {
+                filterType = doubleExponential;
+            } else if (cval == "moving-average") {
+                filterType = movingAverage;
+            } else if (cval == "noise-spike") {
+                filterType = noiseSpike;
+            }
         } else if ( cname == "input" ) {
             input_prop = fgGetNode( child->getStringValue(), true );
         } else if ( cname == "filter-time" ) {
@@ -645,7 +653,7 @@ void FGDigitalFilter::update(double dt)
          *
          */
 
-        if (filterType == "exponential")
+        if (filterType == exponential)
         {
             double alpha = 1 / ((Tf/dt) + 1);
             output.push_front(alpha * input[0] + 
@@ -656,7 +664,7 @@ void FGDigitalFilter::update(double dt)
             }
             output.resize(1);
         } 
-        else if (filterType == "double-exponential")
+        else if (filterType == doubleExponential)
         {
             double alpha = 1 / ((Tf/dt) + 1);
             output.push_front(alpha * alpha * input[0] + 
@@ -668,7 +676,7 @@ void FGDigitalFilter::update(double dt)
             }
             output.resize(2);
         }
-        else if (filterType == "moving-average")
+        else if (filterType == movingAverage)
         {
             output.push_front(output[0] + 
                               (input[0] - input.back()) / samples);
@@ -678,7 +686,7 @@ void FGDigitalFilter::update(double dt)
             }
             output.resize(1);
         }
-        else if (filterType == "noise-spike")
+        else if (filterType == noiseSpike)
         {
             double maxChange = rateOfChange * dt;
 
index 8ff6db71d19db6035d5e72be553f99fa7f02f1fc..7d87dc7cf7a150c5bbbdca0f5689d39386f4305e 100644 (file)
@@ -230,7 +230,8 @@ private:
     double rateOfChange;  // The maximum allowable rate of change [1/s]
     deque <double> output;
     deque <double> input;
-    string filterType;
+    enum filterTypes { exponential, doubleExponential, movingAverage, noiseSpike };
+    filterTypes filterType;
 
     bool debug;