X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2Fmodelmgr.cxx;h=449c3bedc8ff0ce5598391ea68c186c8d60a90fb;hb=cff6b2034de866df70a2b29feb3383ee8ccbbef6;hp=600086d29e9d77ece1819bc319f6e8f6fac1fa87;hpb=3b024e3dab4b09122a4b71deac4889ecda4355dc;p=flightgear.git diff --git a/src/Model/modelmgr.cxx b/src/Model/modelmgr.cxx index 600086d29..449c3bedc 100644 --- a/src/Model/modelmgr.cxx +++ b/src/Model/modelmgr.cxx @@ -16,8 +16,7 @@ #include #include #include - -#include +#include #include #include @@ -67,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 @@ -148,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; } @@ -159,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 @@ -179,7 +180,7 @@ struct UpdateFunctor : public std::unary_function } 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; }