]> git.mxchange.org Git - flightgear.git/blobdiff - src/Model/modelmgr.cxx
Merge branch 'maint' (early part) into next
[flightgear.git] / src / Model / modelmgr.cxx
index 41eaa6cd2fe0afde590bd68ce2d6e163e0d99536..2b547cf027486a0cfcefbad6f69f98329ada551c 100644 (file)
@@ -156,23 +156,23 @@ struct UpdateFunctor : public std::unary_function<FGModelMgr::Instance*, void>
         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& e) {
             const char *path = instance->node->getStringValue("path",
                                                               "unknown");
             SG_LOG(SG_GENERAL, SG_INFO, "Instance of model " << path