From 7df3da668c7a2c7425fe79f9a2a6efe8673bcf0d Mon Sep 17 00:00:00 2001 From: curt Date: Thu, 17 Oct 2002 15:54:31 +0000 Subject: [PATCH] Fix a bug in ground elevation measuring for the first frame after we cross a tile boundary. (Potentially imposes a slight performance penalty, but getting the correct answer needs to be higher priority than getting the wrong answer really quickly.) --- src/Scenery/tilemgr.cxx | 50 +++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx index d95ded203..5793595f1 100644 --- a/src/Scenery/tilemgr.cxx +++ b/src/Scenery/tilemgr.cxx @@ -402,17 +402,18 @@ int FGTileMgr::update( double lon, double lat, double visibility_meters, // no reason to update this if we haven't moved... if ( longitude != last_longitude || latitude != last_latitude ) { - // update current elevation... - if (updateCurrentElevAtPos(abs_pos_vector, center)) { - last_longitude = longitude; - last_latitude = latitude; - } + // update current elevation... + if ( updateCurrentElevAtPos( abs_pos_vector, center ) + ) + /*if ( updateCurrentElevAtPos( abs_pos_vector, + globals->get_scenery()->get_next_center() ) + )*/ + { + last_longitude = longitude; + last_latitude = latitude; + } } -#if 0 - } -#endif - return 1; } @@ -457,25 +458,26 @@ int FGTileMgr::updateCurrentElevAtPos(sgdVec3 abs_pos_vector, Point3D center) { bool hit = false; if ( fabs(sc[0]) > 1.0 || fabs(sc[1]) > 1.0 || fabs(sc[2]) > 1.0 ) { - // scenery center has been properly defined so any hit - // should be valid (and not just luck) - hit = fgCurrentElev(abs_pos_vector, - sc, - current_tile->get_terra_transform(), - &hit_list, - &hit_elev, - &hit_radius, - hit_normal); + // scenery center has been properly defined so any hit should + // be valid (and not just luck) + hit = fgCurrentElev(abs_pos_vector, + sc, + // current_tile->get_terra_transform(), + &hit_list, + &hit_elev, + &hit_radius, + hit_normal); } if ( hit ) { - globals->get_scenery()->set_cur_elev( hit_elev ); - globals->get_scenery()->set_cur_radius( hit_radius ); - globals->get_scenery()->set_cur_normal( hit_normal ); + // cout << "elev = " << hit_elev << " " << hit_radius << endl; + globals->get_scenery()->set_cur_elev( hit_elev ); + globals->get_scenery()->set_cur_radius( hit_radius ); + globals->get_scenery()->set_cur_normal( hit_normal ); } else { - globals->get_scenery()->set_cur_elev( -9999.0 ); - globals->get_scenery()->set_cur_radius( 0.0 ); - globals->get_scenery()->set_cur_normal( hit_normal ); + globals->get_scenery()->set_cur_elev( -9999.0 ); + globals->get_scenery()->set_cur_radius( 0.0 ); + globals->get_scenery()->set_cur_normal( hit_normal ); } return hit; }