]> git.mxchange.org Git - flightgear.git/commitdiff
support
authortorsten <torsten>
Mon, 18 May 2009 20:27:57 +0000 (20:27 +0000)
committerTim Moore <timoore@redhat.com>
Tue, 19 May 2009 22:00:06 +0000 (00:00 +0200)
 <abs>true</abs>
for input elements.
If set to true, the input value is filtered thru fabs() function.
Defaults to false if absent, so there is no impact for existing configurations

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

index 640664140c3237537a84ed676955396c5154e53c..1da3642765a9f61ccfa03122e9f784303fad48f6 100644 (file)
@@ -74,6 +74,10 @@ void FGXMLAutoInput::parse( SGPropertyNode_ptr node, double aValue, double aOffs
         min = new FGXMLAutoInput( n );
     }
 
+    if( (n = node->getChild( "abs" )) != NULL ) {
+      abs = n->getBoolValue();
+    }
+
     SGPropertyNode *valueNode = node->getChild( "value" );
     if ( valueNode != NULL ) {
         value = valueNode->getDoubleValue();
@@ -144,7 +148,7 @@ double FGXMLAutoInput::get_value()
             value = m;
     }
     
-    return value;
+    return abs ? fabs(value) : value;
 }
 
 FGXMLAutoComponent::FGXMLAutoComponent( SGPropertyNode * node ) :
index 41946fb25244d79fe8111ac1090a73e99ab51aa8..df2f9d95cba2ac5aa81a441a2c415f319bb07e36 100644 (file)
@@ -52,6 +52,7 @@ using std::deque;
 class FGXMLAutoInput : public SGReferenced {
 private:
      double             value;    // The value as a constant or initializer for the property
+     bool               abs;      // return absolute value
      SGPropertyNode_ptr property; // The name of the property containing the value
      SGSharedPtr<FGXMLAutoInput> offset;   // A fixed offset, defaults to zero
      SGSharedPtr<FGXMLAutoInput> scale;    // A constant scaling factor defaults to one
@@ -63,6 +64,7 @@ public:
     FGXMLAutoInput( SGPropertyNode_ptr node = NULL, double value = 0.0, double offset = 0.0, double scale = 1.0 ) :
       property(NULL),
       value(0.0),
+      abs(false),
       offset(NULL),
       scale(NULL),
       min(NULL),