diff --git a/configure.ac b/configure.ac index 6e021f9ef..c89d87aa2 100644 --- a/configure.ac +++ b/configure.ac @@ -193,7 +193,8 @@ network_LIBS="$LIBS" LIBS="" dnl check for some default libraries -AC_SEARCH_LIBS(cos, [fastm m]) +AC_SEARCH_LIBS(sqrt, [am ffm fm fastm m]) +AC_SEARCH_LIBS(ceil, m) AC_SEARCH_LIBS(dlclose, dl) base_LIBS="$LIBS" diff --git a/src/FDM/MagicCarpet.cxx b/src/FDM/MagicCarpet.cxx index 0402c28a5..2dc4008fd 100644 --- a/src/FDM/MagicCarpet.cxx +++ b/src/FDM/MagicCarpet.cxx @@ -111,6 +111,7 @@ void FGMagicCarpet::update( double dt ) { sl_radius + get_Altitude() + climb ); // cout << "sea level radius (ft) = " << sl_radius << endl; // cout << "(setto) sea level radius (ft) = " << get_Sea_level_radius() << endl; + _update_ground_elev_at_pos(); _set_Sea_level_radius( sl_radius * SG_METER_TO_FEET); _set_Altitude( get_Altitude() + climb ); } diff --git a/src/FDM/SP/ACMS.cxx b/src/FDM/SP/ACMS.cxx index c5b7eefdd..5b75f8520 100644 --- a/src/FDM/SP/ACMS.cxx +++ b/src/FDM/SP/ACMS.cxx @@ -103,6 +103,7 @@ void FGACMS::update( double dt ) { _set_Euler_Rates(0,0,0); _set_Geocentric_Position( lat_geoc, get_Longitude(), sl_radius); + _update_ground_elev_at_pos(); _set_Sea_level_radius( sl_radius * SG_METER_TO_FEET); } diff --git a/src/FDM/UFO.cxx b/src/FDM/UFO.cxx index e8df63e42..357c26258 100644 --- a/src/FDM/UFO.cxx +++ b/src/FDM/UFO.cxx @@ -191,6 +191,7 @@ void FGUFO::update( double dt ) { sl_radius + get_Altitude() + climb ); // cout << "sea level radius (ft) = " << sl_radius << endl; // cout << "(setto) sea level radius (ft) = " << get_Sea_level_radius() << endl; + _update_ground_elev_at_pos(); _set_Sea_level_radius( sl_radius * SG_METER_TO_FEET); _set_Altitude( get_Altitude() + climb ); } diff --git a/src/FDM/YASim/YASim.cxx b/src/FDM/YASim/YASim.cxx index 742101917..d374a3e5e 100644 --- a/src/FDM/YASim/YASim.cxx +++ b/src/FDM/YASim/YASim.cxx @@ -366,6 +366,7 @@ void YASim::copyFromYASim() double lat, lon, alt; sgCartToGeod(s->pos, &lat, &lon, &alt); _set_Geodetic_Position(lat, lon, alt*M2FT); + _update_ground_elev_at_pos(); // UNUSED //_set_Geocentric_Position(Glue::geod2geocLat(lat), lon, alt*M2FT); diff --git a/src/FDM/flight.cxx b/src/FDM/flight.cxx index 9bda7929a..43b5aa03b 100644 --- a/src/FDM/flight.cxx +++ b/src/FDM/flight.cxx @@ -515,9 +515,7 @@ void FGInterface::_updateGeodeticPosition( double lat, double lon, double alt ) _set_Geodetic_Position( lat, lon, alt ); _set_Sea_level_radius( sl_radius * SG_METER_TO_FEET ); - double alt_m = alt*SG_FEET_TO_METER; - double groundlevel_m = get_groundlevel_m(lat, lon, alt_m); - _set_Runway_altitude( groundlevel_m * SG_METER_TO_FEET ); + _update_ground_elev_at_pos(); _set_sin_lat_geocentric( lat_geoc ); _set_cos_lat_geocentric( lat_geoc ); @@ -554,9 +552,7 @@ void FGInterface::_updateGeocentricPosition( double lat_geoc, double lon, _set_Geodetic_Position( lat_geod, lon, alt ); _set_Sea_level_radius( sl_radius2 * SG_METER_TO_FEET ); - double alt_m = alt*SG_FEET_TO_METER; - double groundlevel_m = get_groundlevel_m(lat_geod, lon, alt_m); - _set_Runway_altitude( groundlevel_m * SG_METER_TO_FEET ); + _update_ground_elev_at_pos(); _set_sin_lat_geocentric( lat_geoc ); _set_cos_lat_geocentric( lat_geoc ); @@ -566,6 +562,13 @@ void FGInterface::_updateGeocentricPosition( double lat_geoc, double lon, _set_sin_cos_latitude( lat_geod ); } +void FGInterface::_update_ground_elev_at_pos( void ) { + double lat = get_Latitude(); + double lon = get_Longitude(); + double alt_m = get_Altitude()*SG_FEET_TO_METER; + double groundlevel_m = get_groundlevel_m(lat, lon, alt_m); + _set_Runway_altitude( groundlevel_m * SG_METER_TO_FEET ); +} // Extrapolate fdm based on time_offset (in usec) void FGInterface::extrapolate( int time_offset ) { diff --git a/src/FDM/flight.hxx b/src/FDM/flight.hxx index 5b01cff0a..dd32bde2c 100644 --- a/src/FDM/flight.hxx +++ b/src/FDM/flight.hxx @@ -238,6 +238,7 @@ public: void _busdump(void); void _updateGeodeticPosition( double lat, double lon, double alt ); void _updateGeocentricPosition( double lat_geoc, double lon, double alt ); + void _update_ground_elev_at_pos( void ); void _updateWeather( void ); inline void _set_Inertias( double m, double xx, double yy, diff --git a/src/Main/renderer.cxx b/src/Main/renderer.cxx index 06ef1bcd9..b5566b0c2 100644 --- a/src/Main/renderer.cxx +++ b/src/Main/renderer.cxx @@ -494,11 +494,10 @@ FGRenderer::update( bool refresh_camera_settings ) { glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) ; glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ) ; - double agl = - current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER - - cur_fdm_state->get_Runway_altitude_m(); + double agl = current__view->getAltitudeASL_ft()*SG_FEET_TO_METER + - current__view->getSGLocation()->get_cur_elev_m(); - if ( agl > 50.0 ) { + if ( agl > 10.0 ) { scene_nearplane = 10.0f; scene_farplane = 120000.0f; } else {