]> git.mxchange.org Git - flightgear.git/blobdiff - src/Model/modelmgr.cxx
Make sure that all elapsed time gets passed to update when a subsystem
[flightgear.git] / src / Model / modelmgr.cxx
index 5d7f2afd44e18de53812bce3a278c63ef3509a1c..29693ecf1e11ef2218fa28c2966cbcf99242733e 100644 (file)
@@ -36,7 +36,7 @@ FGModelMgr::init ()
     SG_LOG(SG_GENERAL, SG_INFO,
           "Adding model " << node->getStringValue("name", "[unnamed]"));
     Instance * instance = new Instance;
-    FG3DModel * model = new FG3DModel;
+    FGModelPlacement * model = new FGModelPlacement;
     instance->model = model;
     model->init(node->getStringValue("path", "Models/Geometry/glider.ac"));
 
@@ -83,7 +83,7 @@ FGModelMgr::init ()
     globals->get_scenery()->get_scene_graph()->addKid(model->getSceneGraph());
 
                                // Save this instance for updating
-    _instances.push_back(instance);
+    add_instance(instance);
   }
 }
 
@@ -102,7 +102,7 @@ FGModelMgr::update (double dt)
 {
   for (unsigned int i = 0; i < _instances.size(); i++) {
     Instance * instance = _instances[i];
-    FG3DModel * model = instance->model;
+    FGModelPlacement * model = instance->model;
 
                                // Optionally set position from properties
     if (instance->lon_deg_node != 0)
@@ -120,10 +120,29 @@ FGModelMgr::update (double dt)
     if (instance->heading_deg_node != 0)
       model->setHeadingDeg(instance->heading_deg_node->getDoubleValue());
 
-    instance->model->update(dt);
+    instance->model->update();
   }
 }
 
+void
+FGModelMgr::add_instance (Instance * instance)
+{
+    _instances.push_back(instance);
+}
+
+void
+FGModelMgr::remove_instance (Instance * instance)
+{
+    vector<Instance *>::iterator it;
+    for (it = _instances.begin(); it != _instances.end(); it++) {
+        if (*it == instance) {
+            _instances.erase(it);
+            delete instance;
+            return;
+        }
+    }
+}
+
 void
 FGModelMgr::draw ()
 {