X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2Fmodelmgr.cxx;h=449c3bedc8ff0ce5598391ea68c186c8d60a90fb;hb=cff6b2034de866df70a2b29feb3383ee8ccbbef6;hp=a7f543f1ebada0c253283faca328533b254153f0;hpb=fd492a297aee6d40c58f71b1889847b6668af3fd;p=flightgear.git diff --git a/src/Model/modelmgr.cxx b/src/Model/modelmgr.cxx index a7f543f1e..449c3bedc 100644 --- a/src/Model/modelmgr.cxx +++ b/src/Model/modelmgr.cxx @@ -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 #endif @@ -12,8 +16,7 @@ #include #include #include - -#include +#include #include #include @@ -25,7 +28,7 @@ #include "modelmgr.hxx" -SG_USING_STD(vector); +using std::vector; using namespace simgear; @@ -63,24 +66,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; const char *path = node->getStringValue("path", "Models/Geometry/glider.ac"); osg::Node *object; try { - object = SGModelLib::loadPagedModel(path, globals->get_props()); + 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 @@ -144,7 +148,7 @@ namespace { double testNan(double val) throw (sg_range_exception) { - if (osg::isNaN(val)) + if (SGMisc::isNaN(val)) throw sg_range_exception("value is nan"); return val; } @@ -155,6 +159,7 @@ struct UpdateFunctor : public std::unary_function { 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 @@ -172,10 +177,10 @@ struct UpdateFunctor : public std::unary_function 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; }