]> git.mxchange.org Git - flightgear.git/commitdiff
Autopilot: save loads of CPU cycles
authorTorsten Dreyer <Torsten@t3r.de>
Thu, 5 Apr 2012 18:40:07 +0000 (20:40 +0200)
committerTorsten Dreyer <Torsten@t3r.de>
Thu, 5 Apr 2012 18:40:07 +0000 (20:40 +0200)
Not every xml-autopilot filter needs to run at the update rate
of the FDM. This only makes sense for the autpilot filters. Those,
who update instrument needles or environment properties for example
may run at frame rate.
This patch (thanks to ThorstenB, who is the author) forces those
filters defined in /sim/systems/autopilot into the FDM loop and those
defined in /sim/systems/property-rule into the default loop. They
show up as xml-autopilot and xml-proprules in the performance monitor

src/Autopilot/autopilotgroup.cxx
src/Autopilot/autopilotgroup.hxx
src/Main/fg_init.cxx

index 8cf389f8e2d85fb4e6da3d4a8d0a7ba23cc0a353..c9df860d220a58da2a65b0442eae59204c5e94ad 100644 (file)
@@ -44,6 +44,8 @@ using simgear::PropertyList;
 class FGXMLAutopilotGroupImplementation : public FGXMLAutopilotGroup
 {
 public:
+    FGXMLAutopilotGroupImplementation(const std::string& nodeName) :
+        FGXMLAutopilotGroup(), _nodeName(nodeName) {}
     virtual void addAutopilot( const std::string & name, SGPropertyNode_ptr apNode, SGPropertyNode_ptr config );
     virtual void removeAutopilot( const std::string & name );
     void init();
@@ -52,6 +54,7 @@ public:
 private:
     void initFrom( SGPropertyNode_ptr rootNode, const char * childName );
     vector<string> _autopilotNames;
+    std::string _nodeName;
 
 };
 
@@ -100,12 +103,7 @@ void FGXMLAutopilotGroupImplementation::reinit()
 
 void FGXMLAutopilotGroupImplementation::init()
 {
-    static const char * nodeNames[] = {
-        "autopilot",
-        "property-rule"
-    };
-    for( unsigned i = 0; i < sizeof(nodeNames)/sizeof(nodeNames[0]); i++ )
-        initFrom( fgGetNode( "/sim/systems" ), nodeNames[i] );
+    initFrom( fgGetNode( "/sim/systems" ), _nodeName.c_str() );
 
     SGSubsystemGroup::bind();
     SGSubsystemGroup::init();
@@ -173,7 +171,7 @@ void FGXMLAutopilotGroup::addAutopilotFromFile( const std::string & name, SGProp
     }
 }
 
-FGXMLAutopilotGroup * FGXMLAutopilotGroup::createInstance()
+FGXMLAutopilotGroup * FGXMLAutopilotGroup::createInstance(const std::string& nodeName)
 {
-    return new FGXMLAutopilotGroupImplementation();
+    return new FGXMLAutopilotGroupImplementation(nodeName);
 }
index 6e6c1f1968f3a713912be0b08dcb5380c84bad37..5390f8c43186c2880e7630d613f16790a18b760e 100644 (file)
@@ -31,7 +31,7 @@
 class FGXMLAutopilotGroup : public SGSubsystemGroup
 {
 public:
-    static FGXMLAutopilotGroup * createInstance();
+    static FGXMLAutopilotGroup * createInstance(const std::string& nodeName);
     void addAutopilotFromFile( const std::string & name, SGPropertyNode_ptr apNode, const char * path );
     virtual void addAutopilot( const std::string & name, SGPropertyNode_ptr apNode, SGPropertyNode_ptr config ) = 0;
     virtual void removeAutopilot( const std::string & name ) = 0;
index d26a93bce7ddbec784d10098e68f0ce5f685d3fb..8f1141c26ea485944befed2d295aa605500057a1 100644 (file)
@@ -1251,7 +1251,8 @@ bool fgInitSubsystems() {
     // Initialize the XML Autopilot subsystem.
     ////////////////////////////////////////////////////////////////////
 
-    globals->add_subsystem( "xml-autopilot", FGXMLAutopilotGroup::createInstance(), SGSubsystemMgr::FDM );
+    globals->add_subsystem( "xml-autopilot", FGXMLAutopilotGroup::createInstance("autopilot"), SGSubsystemMgr::FDM );
+    globals->add_subsystem( "xml-proprules", FGXMLAutopilotGroup::createInstance("property-rule"), SGSubsystemMgr::GENERAL );
     globals->add_subsystem( "route-manager", new FGRouteMgr );
 
     ////////////////////////////////////////////////////////////////////