1
0
Fork 0

Simplify some SGGeod-related calculations

This commit is contained in:
Christian Schmitt 2014-02-05 23:04:58 +01:00
parent ae8ddd04d9
commit 6cadc2cf40
2 changed files with 9 additions and 14 deletions

View file

@ -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(),

View file

@ -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)