]> git.mxchange.org Git - flightgear.git/commitdiff
More rationalization of methods, and other clean-ups
authorVivian Meazza <vivian.meazza@lineone.net>
Thu, 28 Oct 2010 16:29:41 +0000 (17:29 +0100)
committerVivian Meazza <vivian.meazza@lineone.net>
Thu, 28 Oct 2010 16:29:41 +0000 (17:29 +0100)
Signed-off-by: Vivian Meazza <vivian.meazza@lineone.net>
src/AIModel/AIBallistic.cxx
src/AIModel/AIBallistic.hxx
src/AIModel/AIBase.cxx
src/AIModel/AIWingman.cxx
src/AIModel/AIWingman.hxx

index fa06b291e36de16f8a32f20e4708ccb6908c4a79..0f7aeb7be12b91a50e52fde772dcbb2c96df2d60 100644 (file)
@@ -152,11 +152,11 @@ bool FGAIBallistic::init(bool search_in_AI_path) {
         props->setStringValue("contents/path", _contents_path.c_str());
     }
 
-    if(_parent != ""){
-        setParentNode();
-    }
+    //if(_parent != ""){
+    //    setParentNode();
+    //}
 
-    setParentNodes(_selected_ac);
+    //setParentNodes(_selected_ac);
 
     //props->setStringValue("vector/path", _vector_path.c_str());
 
@@ -168,7 +168,11 @@ bool FGAIBallistic::init(bool search_in_AI_path) {
 
     Transform();
 
-    //cout << _name << " speed init: " << speed << endl;
+    if(_parent != ""){
+        setParentNode();
+    }
+
+    setParentNodes(_selected_ac);
 
     return true;
 }
index b2b140c1727480d4be62e41b1623a2831a81dde4..739f766714b699254eab76f2cfb3a03f5ae1ad82 100644 (file)
@@ -44,6 +44,7 @@ public:
     void readFromScenario(SGPropertyNode* scFileNode);
 
     bool init(bool search_in_AI_path=false);
+
     virtual void bind();
     virtual void unbind();
 
index 8a073eb6d3b4c8448471d522122d810c5acd6232..514c6abb0498ad77eb133497fd2838e8c521948b 100644 (file)
@@ -194,18 +194,27 @@ void FGAIBase::Transform() {
 }
 
 bool FGAIBase::init(bool search_in_AI_path) {
-    osg::ref_ptr<osgDB::ReaderWriter::Options> opt=
-        new osgDB::ReaderWriter::Options(*osgDB::Registry::instance()->getOptions());
-
+    
+    string f;
     if(search_in_AI_path)
     {
-        SGPath ai_path(globals->get_fg_root());
-        ai_path.append("AI");
-        opt->getDatabasePathList().push_front(ai_path.str());
+    // setup a modified Options strucutre, with only the $fg-root/AI defined;
+    // we'll check that first, then give the normal search logic a chance.
+    // this ensures that models in AI/ are preferred to normal models, where
+    // both exist.
+        osg::ref_ptr<osgDB::ReaderWriter::Options> 
+          opt(osg::clone(osgDB::Registry::instance()->getOptions(), osg::CopyOp::SHALLOW_COPY));
+
+        SGPath ai_path(globals->get_fg_root(), "AI");
+        opt->setDatabasePath(ai_path.str());
+        
+        f = osgDB::findDataFile(model_path, opt.get());
     }
 
-    string f = osgDB::findDataFile(model_path, opt.get());
-
+    if (f.empty()) {
+      f = simgear::SGModelLib::findDataFile(model_path);
+    }
+    
     if(f.empty())
         f = fgGetString("/sim/multiplay/default-model", default_model);
 
index 6c93f395568124ef1e658ff57974d5f9565fc19d..59617b097460dd66a81afc7308eeca1f93004cf3 100644 (file)
@@ -215,13 +215,14 @@ bool FGAIWingman::init(bool search_in_AI_path) {
     roll = _rotation;
     _ht_agl_ft = 1e10;
 
-    props->setStringValue("submodels/path", _path.c_str());
-
     if(_parent != ""){
         setParentNode();
     }
 
     setParentNodes(_selected_ac);
+
+    props->setStringValue("submodels/path", _path.c_str());
+    user_WoW_node      = fgGetNode("gear/gear[1]/wow", true);
     return true;
 }
 
@@ -277,7 +278,7 @@ double FGAIWingman::calcAngle(double range, SGGeod pos1, SGGeod pos2){
 
 void FGAIWingman::formateToAC(double dt){
 
-    double p_hdg, p_pch, p_rll, p_agl, p_ht = 0;
+    double p_hdg, p_pch, p_rll, p_agl, p_ht, p_wow = 0;
 
     setTgtOffsets(dt, 25);
 
@@ -312,8 +313,9 @@ void FGAIWingman::formateToAC(double dt){
     double h_feet  = 3 * factor;
 
     p_agl = manager->get_user_agl();
+    p_wow = user_WoW_node->getDoubleValue();
 
-    if(p_agl <= 10) {
+    if(p_agl <= 10 || p_wow == 1) {
         _height = p_ht;
         //cout << "ht case1 " ;
     } else if (p_agl > 10 && p_agl <= 150 ) {
@@ -332,7 +334,8 @@ void FGAIWingman::formateToAC(double dt){
     pos.setLongitudeDeg(_offsetpos.getLongitudeDeg());
 
     // these calculations are unreliable at slow speeds
-    if(speed >= 10) {
+    // and we don't want random movement on the ground
+    if(speed >= 10 && p_wow != 1) {
         setHdg(p_hdg + h_angle, dt, 0.9);
         setPch(p_pch + p_angle + _pitch_offset, dt, 0.9);
 
index 038df5d0827c9292a834f2d06acbc45c69f290ed..42c51094c333303120aa0660931478cf0b4afa42 100644 (file)
@@ -67,7 +67,7 @@ private:
     double _coeff_bnk; //dimensionless coefficient
     double _coeff_spd; //dimensionless coefficient
 
-
+    SGPropertyNode_ptr user_WoW_node;
 
     inline void setFormate(bool f);
     inline void setTgtHdg(double hdg);