]> git.mxchange.org Git - flightgear.git/blobdiff - src/Model/modelmgr.cxx
Working at unraveling and breaking dependencies inside of src/Model.
[flightgear.git] / src / Model / modelmgr.cxx
index 3507cc4f6e36839709acc9d87fc1dd246e51173b..72d257368421b74b0041f3bd3aeb1ffa985c4bb9 100644 (file)
@@ -8,8 +8,10 @@
 #include <Main/fg_props.hxx>
 #include <Scenery/scenery.hxx>
 
-#include "modelmgr.hxx"
 #include "model.hxx"
+#include "placement.hxx"
+
+#include "modelmgr.hxx"
 
 
 FGModelMgr::FGModelMgr ()
@@ -36,9 +38,15 @@ FGModelMgr::init ()
     SG_LOG(SG_GENERAL, SG_INFO,
           "Adding model " << node->getStringValue("name", "[unnamed]"));
     Instance * instance = new Instance;
-    FGModelPlacement * model = new FGModelPlacement;
+    FGModelPlacement *model = new FGModelPlacement;
     instance->model = model;
-    model->init(node->getStringValue("path", "Models/Geometry/glider.ac"));
+    ssgBranch *object
+        = fgLoad3DModel( globals->get_fg_root(),
+                         node->getStringValue("path",
+                                              "Models/Geometry/glider.ac"),
+                         globals->get_props(),
+                         globals->get_sim_time_sec() );
+    model->init( object );
 
                                // Set position and orientation either
                                // indirectly through property refs
@@ -120,7 +128,7 @@ FGModelMgr::update (double dt)
     if (instance->heading_deg_node != 0)
       model->setHeadingDeg(instance->heading_deg_node->getDoubleValue());
 
-    instance->model->update();
+    instance->model->update( globals->get_scenery()->get_center() );
   }
 }
 
@@ -133,8 +141,14 @@ FGModelMgr::add_instance (Instance * instance)
 void
 FGModelMgr::remove_instance (Instance * instance)
 {
-    _instances.erase(find(_instances.begin(), _instances.end(), instance));
-    delete instance;
+    vector<Instance *>::iterator it;
+    for (it = _instances.begin(); it != _instances.end(); it++) {
+        if (*it == instance) {
+            _instances.erase(it);
+            delete instance;
+            return;
+        }
+    }
 }
 
 void