From 6cadc2cf4017d81865181bb0616503553105e0f9 Mon Sep 17 00:00:00 2001 From: Christian Schmitt Date: Wed, 5 Feb 2014 23:04:58 +0100 Subject: [PATCH] Simplify some SGGeod-related calculations --- src/Instrumentation/dme.cxx | 5 ++--- src/Scenery/tilemgr.cxx | 18 +++++++----------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/Instrumentation/dme.cxx b/src/Instrumentation/dme.cxx index 33ea69279..2a3253f16 100644 --- a/src/Instrumentation/dme.cxx +++ b/src/Instrumentation/dme.cxx @@ -177,9 +177,8 @@ DME::update (double delta_time_sec) } // Calculate the distance to the transmitter - SGVec3d location = SGVec3d::fromGeod(globals->get_aircraft_position()); - - double distance_nm = dist(_navrecord->cart(), location) * SG_METER_TO_NM; + double distance_nm = dist(_navrecord->cart(), + globals->get_aircraft_position_cart()) * SG_METER_TO_NM; double range_nm = adjust_range(_navrecord->get_elev_ft(), globals->get_aircraft_position().getElevationFt(), diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx index ce3fd7742..6283b0b33 100644 --- a/src/Scenery/tilemgr.cxx +++ b/src/Scenery/tilemgr.cxx @@ -185,7 +185,7 @@ bool FGTileMgr::sched_tile( const SGBucket& b, double priority, bool current_vie void FGTileMgr::schedule_needed(const SGBucket& curr_bucket, double vis) { // sanity check (unfortunately needed!) - if ( longitude < -180.0 || longitude > 180.0 + if ( longitude < -180.0 || longitude > 180.0 || latitude < -90.0 || latitude > 90.0 ) { SG_LOG( SG_TERRAIN, SG_ALERT, @@ -422,16 +422,12 @@ void FGTileMgr::schedule_tiles_at(const SGGeod& location, double range_m) */ bool FGTileMgr::schedule_scenery(const SGGeod& position, double range_m, double duration) { - const float priority = 0.0; - double current_longitude = position.getLongitudeDeg(); - double current_latitude = position.getLatitudeDeg(); - bool available = true; - // sanity check (unfortunately needed!) - if (current_longitude < -180 || current_longitude > 180 || - current_latitude < -90 || current_latitude > 90) + if (!position.isValid()) return false; - + const float priority = 0.0; + bool available = true; + SGBucket bucket(position); available = sched_tile( bucket, priority, false, duration ); @@ -457,8 +453,8 @@ bool FGTileMgr::schedule_scenery(const SGGeod& position, double range_m, double // We have already checked for the center tile. if ( x != 0 || y != 0 ) { - SGBucket b = sgBucketOffset( current_longitude, - current_latitude, x, y ); + SGBucket b = sgBucketOffset( position.getLongitudeDeg(), + position.getLatitudeDeg(), x, y ); double distance2 = distSqr(cartPos, SGVec3d::fromGeod(b.get_center())); // Do not ask if it is just the next tile but way out of range. if (distance2 <= max_dist2) -- 2.39.5