]> git.mxchange.org Git - flightgear.git/blobdiff - src/Model/modelmgr.cxx
Mathias Fröhlich:
[flightgear.git] / src / Model / modelmgr.cxx
index f178b26e9c29f2bdf371c7ab7c4ea1314b250df8..50f5e60cc64e48ffa41b39a118686555a3e21a84 100644 (file)
@@ -3,6 +3,10 @@
 //
 // This file is in the Public Domain, and comes with no warranty.
 
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
 #include <simgear/compiler.h>
 
 #include <vector>
 #include <plib/ssg.h>
 
 #include <simgear/scene/model/placement.hxx>
+#include <simgear/scene/model/model.hxx>
 
 #include <Main/fg_props.hxx>
 #include <Scenery/scenery.hxx>
 
-#include "model.hxx"
 
 #include "modelmgr.hxx"
 
@@ -45,10 +49,10 @@ FGModelMgr::init ()
     SG_LOG(SG_GENERAL, SG_INFO,
           "Adding model " << node->getStringValue("name", "[unnamed]"));
     Instance * instance = new Instance;
-    FGModelPlacement *model = new FGModelPlacement;
+    SGModelPlacement *model = new SGModelPlacement;
     instance->model = model;
     ssgBranch *object
-        = fgLoad3DModel( globals->get_fg_root(),
+        = sgLoad3DModel( globals->get_fg_root(),
                          node->getStringValue("path",
                                               "Models/Geometry/glider.ac"),
                          globals->get_props(),
@@ -97,6 +101,10 @@ FGModelMgr::init ()
                                // Add this model to the global scene graph
     globals->get_scenery()->get_scene_graph()->addKid(model->getSceneGraph());
 
+    // Register that one at the scenery manager
+    globals->get_scenery()->register_placement_transform(model->getTransform());
+
+
                                // Save this instance for updating
     add_instance(instance);
   }
@@ -117,7 +125,7 @@ FGModelMgr::update (double dt)
 {
   for (unsigned int i = 0; i < _instances.size(); i++) {
     Instance * instance = _instances[i];
-    FGModelPlacement * model = instance->model;
+    SGModelPlacement * model = instance->model;
 
                                // Optionally set position from properties
     if (instance->lon_deg_node != 0)
@@ -135,7 +143,7 @@ FGModelMgr::update (double dt)
     if (instance->heading_deg_node != 0)
       model->setHeadingDeg(instance->heading_deg_node->getDoubleValue());
 
-    instance->model->update( globals->get_scenery()->get_center() );
+    instance->model->update();
   }
 }
 
@@ -184,6 +192,9 @@ FGModelMgr::Instance::Instance ()
 
 FGModelMgr::Instance::~Instance ()
 {
+  // Unregister that one at the scenery manager
+  globals->get_scenery()->unregister_placement_transform(model->getTransform());
+
   delete model;
 }