- if ( !needTrim ) {
- fgic->SetLatitudeRadIC(get_Lat_geocentric() );
- fgic->SetLongitudeRadIC( get_Longitude() );
- fgic->SetAltitudeASLFtIC( get_Altitude() );
- fgic->SetVcalibratedKtsIC( get_V_calibrated_kts() );
- fgic->SetThetaRadIC( get_Theta() );
- fgic->SetPhiRadIC( get_Phi() );
- fgic->SetPsiRadIC( get_Psi() );
- fgic->SetClimbRateFpsIC( get_Climb_Rate() );
- }
+ // Compute the radius of the aircraft. That is the radius of a ball
+ // where all gear units are in. At the moment it is at least 10ft ...
+ double acrad = 10.0;
+ int n_gears = GroundReactions->GetNumGearUnits();
+ for (int i=0; i<n_gears; ++i) {
+ FGColumnVector3 bl = GroundReactions->GetGearUnit(i)->GetBodyLocation();
+ double r = bl.Magnitude();
+ if (acrad < r)
+ acrad = r;
+ }
+
+ // Compute the potential movement of this aircraft and query for the
+ // ground in this area.
+ double groundCacheRadius = acrad + 2*dt*Propagate->GetUVW().Magnitude();
+ cart_pos[0] = cart(1);
+ cart_pos[1] = cart(2);
+ cart_pos[2] = cart(3);
+ double t0 = fdmex->GetSimTime();
+ bool cache_ok = prepare_ground_cache_ft( t0, t0 + dt, cart_pos,
+ groundCacheRadius );
+ if (!cache_ok) {
+ SG_LOG(SG_FLIGHT, SG_WARN,
+ "FGInterface is being called without scenery below the aircraft!");
+
+ SG_LOG(SG_FLIGHT, SG_WARN, "altitude = "
+ << fgic->GetAltitudeASLFtIC());
+
+ SG_LOG(SG_FLIGHT, SG_WARN, "sea level radius = "
+ << get_Sea_level_radius());
+
+ SG_LOG(SG_FLIGHT, SG_WARN, "latitude = "
+ << fgic->GetLatitudeRadIC());
+
+ SG_LOG(SG_FLIGHT, SG_WARN, "longitude = "
+ << fgic->GetLongitudeRadIC());
+ }
+
+ return cache_ok;