]> git.mxchange.org Git - flightgear.git/blobdiff - src/Model/modelmgr.cxx
Canvas: Add new element type map for geo mapping.
[flightgear.git] / src / Model / modelmgr.cxx
index 4d19b7be16ca61bd4d9bf2b5c49e2b755ae9723b..0310274bd612c38cf55dbb38ff08a17e0dd9ac26 100644 (file)
@@ -3,6 +3,10 @@
 //
 // This file is in the Public Domain, and comes with no warranty.
 
+#ifdef _MSC_VER
+#  pragma warning( disable: 4355 )
+#endif
+
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
@@ -12,6 +16,7 @@
 #include <algorithm>
 #include <functional>
 #include <vector>
+#include <cstring>
 
 #include <osg/Math>
 
 
 #include "modelmgr.hxx"
 
-SG_USING_STD(vector);
+using std::vector;
+
+using namespace simgear;
 
 // OSGFIXME
 // extern SGShadowVolume *shadows;
 
-
 FGModelMgr::FGModelMgr ()
   : _models(fgGetNode("/models", true)),
     _listener(new Listener(this))
@@ -62,29 +68,25 @@ FGModelMgr::init ()
 void
 FGModelMgr::add_model (SGPropertyNode * node)
 {
-  SG_LOG(SG_GENERAL, SG_INFO,
+  SG_LOG(SG_AIRCRAFT, SG_INFO,
          "Adding model " << node->getStringValue("name", "[unnamed]"));
-  Instance * instance = new Instance;
-  SGModelPlacement *model = new SGModelPlacement;
-  instance->model = model;
-  instance->node = node;
-  SGModelLib *model_lib = globals->get_model_lib();
 
   const char *path = node->getStringValue("path", "Models/Geometry/glider.ac");
   osg::Node *object;
 
   try {
-    object = model_lib->load_model(
-        globals->get_fg_root(),
-        path,
-        globals->get_props(),
-        globals->get_sim_time_sec(), /*cache_object=*/false);
+      object = SGModelLib::loadDeferredModel(path, globals->get_props());
   } catch (const sg_throwable& t) {
-    SG_LOG(SG_GENERAL, SG_ALERT, "Error loading " << path << ":\n  "
+    SG_LOG(SG_AIRCRAFT, SG_ALERT, "Error loading " << path << ":\n  "
         << t.getFormattedMessage() << t.getOrigin());
     return;
   }
 
+  Instance * instance = new Instance;
+  SGModelPlacement *model = new SGModelPlacement;
+  instance->model = model;
+  instance->node = node;
+
   model->init( object );
 
                                // Set position and orientation either
@@ -159,6 +161,7 @@ struct UpdateFunctor : public std::unary_function<FGModelMgr::Instance*, void>
     {
         SGModelPlacement* model = instance->model;
         double lon, lat, elev, roll, pitch, heading;
+        lon = lat = elev = roll = pitch = heading = 0.0;
 
         try {
             // Optionally set position from properties
@@ -176,10 +179,10 @@ struct UpdateFunctor : public std::unary_function<FGModelMgr::Instance*, void>
                 pitch = testNan(instance->pitch_deg_node->getDoubleValue());
             if (instance->heading_deg_node != 0)
                 heading = testNan(instance->heading_deg_node->getDoubleValue());
-        } catch (const sg_range_exception& e) {
+        } catch (const sg_range_exception&) {
             const char *path = instance->node->getStringValue("path",
                                                               "unknown");
-            SG_LOG(SG_GENERAL, SG_INFO, "Instance of model " << path
+            SG_LOG(SG_AIRCRAFT, SG_INFO, "Instance of model " << path
                    << " has invalid values");
             return;
         }