X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2Fmodelmgr.cxx;h=139cf2d4f2441eb00e5c7fff7a1694d5c0abd32c;hb=9ab41ea15809c02ba46bf9e6911fbb1aa808b8b1;hp=41eaa6cd2fe0afde590bd68ce2d6e163e0d99536;hpb=2710564c7d3c3e95361a366441d3b96a6049ee05;p=flightgear.git diff --git a/src/Model/modelmgr.cxx b/src/Model/modelmgr.cxx index 41eaa6cd2..139cf2d4f 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,6 +16,7 @@ #include #include #include +#include #include @@ -65,21 +70,22 @@ FGModelMgr::add_model (SGPropertyNode * node) { SG_LOG(SG_GENERAL, 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 " << t.getFormattedMessage() << t.getOrigin()); return; } + + Instance * instance = new Instance; + SGModelPlacement *model = new SGModelPlacement; + instance->model = model; + instance->node = node; model->init( object ); @@ -156,23 +162,23 @@ struct UpdateFunctor : public std::unary_function SGModelPlacement* model = instance->model; double lon, lat, elev, roll, pitch, heading; - // Optionally set position from properties - if (instance->lon_deg_node != 0) - lon =instance->lon_deg_node->getDoubleValue(); - if (instance->lat_deg_node != 0) - lat = instance->lat_deg_node->getDoubleValue(); - if (instance->elev_ft_node != 0) - elev = instance->elev_ft_node->getDoubleValue(); - - // Optionally set orientation from properties - if (instance->roll_deg_node != 0) - roll = instance->roll_deg_node->getDoubleValue(); - if (instance->pitch_deg_node != 0) - pitch = instance->pitch_deg_node->getDoubleValue(); - if (instance->heading_deg_node != 0) - heading = instance->heading_deg_node->getDoubleValue(); - if ( osg::isNaN(lon) || osg::isNaN(lat) || osg::isNaN(elev) || - osg::isNaN(roll) || osg::isNaN(pitch) || osg::isNaN(heading) ) { + try { + // Optionally set position from properties + if (instance->lon_deg_node != 0) + lon = testNan(instance->lon_deg_node->getDoubleValue()); + if (instance->lat_deg_node != 0) + lat = testNan(instance->lat_deg_node->getDoubleValue()); + if (instance->elev_ft_node != 0) + elev = testNan(instance->elev_ft_node->getDoubleValue()); + + // Optionally set orientation from properties + if (instance->roll_deg_node != 0) + roll = testNan(instance->roll_deg_node->getDoubleValue()); + if (instance->pitch_deg_node != 0) + 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&) { const char *path = instance->node->getStringValue("path", "unknown"); SG_LOG(SG_GENERAL, SG_INFO, "Instance of model " << path