This fixes a race condition when teleporting somewhere outside of the
currently loaded scenery. Before, if there was no valid scenery, an
aircraft might end up at the center of the earth...
double rad)
{
// Empty cache.
- ground_radius = 0.0;
found_ground = false;
+ 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.getLatitudeDeg(),
+ geodPt.getLongitudeDeg(),
+ rad))
+ return false;
+ ground_radius = 0.0;
triangles.resize(0);
catapults.resize(0);
wires.resize(0);
cache_ref_time = ref_time;
// Get a normalized down vector valid for the whole cache
- SGQuatd hlToEc = SGQuatd::fromLonLat(SGGeod::fromCart(pt));
+ SGQuatd hlToEc = SGQuatd::fromLonLat(geodPt);
down = hlToEc.rotate(SGVec3d(0, 0, 1));
// Prepare sphere around the aircraft.