]> git.mxchange.org Git - flightgear.git/commitdiff
More robust behaviour when the tilemanager reports 'no scenery'.
authorfrohlich <frohlich>
Thu, 12 Mar 2009 06:18:53 +0000 (06:18 +0000)
committerTim Moore <timoore@redhat.com>
Wed, 18 Mar 2009 07:00:07 +0000 (08:00 +0100)
Insert log if this happens.

Modified Files:
flight.cxx groundcache.cxx

src/FDM/flight.cxx
src/FDM/groundcache.cxx

index e749b76fd637a1967911077e2fee21cd90848597..37cb97689f5d6d6641a183b071a6d80d5be35998 100644 (file)
@@ -731,9 +731,8 @@ FGInterface::get_agl_m(double t, const double pt[3], double max_altoff,
   SGVec3d pt_m = SGVec3d(pt) - max_altoff*ground_cache.get_down();
   SGVec3d _contact, _normal, _linearVel, _angularVel;
   material = 0;
-  if (!ground_cache.get_agl(t, pt_m, _contact, _normal, _linearVel,
-                            _angularVel, id, material))
-      return false;
+  bool ret = ground_cache.get_agl(t, pt_m, _contact, _normal, _linearVel,
+                                  _angularVel, id, material);
   // correct the linear velocity, since the line intersector delivers
   // values for the start point and the get_agl function should
   // traditionally deliver for the contact point
@@ -743,7 +742,7 @@ FGInterface::get_agl_m(double t, const double pt[3], double max_altoff,
   assign(normal, _normal);
   assign(linearVel, _linearVel);
   assign(angularVel, _angularVel);
-  return true;
+  return ret;
 }
 
 bool
@@ -757,9 +756,8 @@ FGInterface::get_agl_ft(double t, const double pt[3], double max_altoff,
   pt_m *= SG_FEET_TO_METER;
   SGVec3d _contact, _normal, _linearVel, _angularVel;
   material = 0;
-  if (!ground_cache.get_agl(t, pt_m, _contact, _normal, _linearVel,
-                            _angularVel, id, material))
-      return false;
+  bool ret = ground_cache.get_agl(t, pt_m, _contact, _normal, _linearVel,
+                                  _angularVel, id, material);
   // correct the linear velocity, since the line intersector delivers
   // values for the start point and the get_agl function should
   // traditionally deliver for the contact point
@@ -770,7 +768,7 @@ FGInterface::get_agl_ft(double t, const double pt[3], double max_altoff,
   assign( normal, _normal );
   assign( linearVel, SG_METER_TO_FEET*_linearVel );
   assign( angularVel, _angularVel );
-  return true;
+  return ret;
 }
 
 bool
index 0d5f4e09274b8c3bf77ce4ec527a3a6c85ba8091..9b17eef531d2dc25666ece7cae345e1e45141c6c 100644 (file)
@@ -245,9 +245,12 @@ FGGroundCache::prepare_ground_cache(double ref_time, const SGVec3d& pt,
     SGGeod geodPt = SGGeod::fromCart(pt);
     // Don't blow away the cache ground_radius and stuff if there's no
     // scenery
-    if (!globals->get_tile_mgr()->scenery_available(geodPt, rad))
+    if (!globals->get_tile_mgr()->scenery_available(geodPt, rad)) {
+        SG_LOG(SG_FLIGHT, SG_WARN, "prepare_ground_cache(): scenery_available "
+               "returns false at " << geodPt << " " << pt << " " << rad);
         return false;
-    _altitude = 0;
+    }
+    _material = 0;
 
     // If we have an active wire, get some more area into the groundcache
     if (_wire)
@@ -283,8 +286,11 @@ FGGroundCache::prepare_ground_cache(double ref_time, const SGVec3d& pt,
         found_ground = true;
     } else {
         // Else do a crude scene query for the current point
+        double alt = 0;
         found_ground = globals->get_scenery()->
-            get_cart_elevation_m(pt, rad, _altitude, &_material);
+            get_cart_elevation_m(pt, rad, alt, &_material);
+        if (found_ground)
+            _altitude = alt;
     }
     
     // Still not sucessful??