With this patch, you can fly under bridges, then turn around and land on
them lengthwise.
This commit is contained in:
parent
0f1c24bbed
commit
ca6067cbc0
4 changed files with 28 additions and 9 deletions
|
@ -511,7 +511,8 @@ static void ssgGetCurrentBSphere( ssgEntity *entity, sgVec3 center, float *radiu
|
||||||
// ======================
|
// ======================
|
||||||
// Determine scenery altitude via ssg.
|
// Determine scenery altitude via ssg.
|
||||||
// returned results are in meters
|
// returned results are in meters
|
||||||
bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center,
|
bool fgCurrentElev( sgdVec3 abs_view_pos, double max_alt_m,
|
||||||
|
sgdVec3 scenery_center,
|
||||||
FGHitList *hit_list,
|
FGHitList *hit_list,
|
||||||
double *terrain_elev, double *radius, double *normal)
|
double *terrain_elev, double *radius, double *normal)
|
||||||
{
|
{
|
||||||
|
@ -539,7 +540,8 @@ bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center,
|
||||||
&alt, &sea_level_r);
|
&alt, &sea_level_r);
|
||||||
// cout << "hit " << i << " lon = " << geoc.lon() << " lat = "
|
// cout << "hit " << i << " lon = " << geoc.lon() << " lat = "
|
||||||
// << lat_geod << " alt = " << alt << endl;
|
// << lat_geod << " alt = " << alt << endl;
|
||||||
if ( alt > result && alt < 10000 ) {
|
if ( alt > result && alt < max_alt_m ) {
|
||||||
|
// cout << " it's a keeper" << endl;
|
||||||
result = alt;
|
result = alt;
|
||||||
this_hit = i;
|
this_hit = i;
|
||||||
}
|
}
|
||||||
|
@ -571,7 +573,8 @@ bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center,
|
||||||
// ======================
|
// ======================
|
||||||
// Determine scenery altitude via ssg.
|
// Determine scenery altitude via ssg.
|
||||||
// returned results are in meters
|
// returned results are in meters
|
||||||
bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center,
|
bool fgCurrentElev( sgdVec3 abs_view_pos, double max_alt_m,
|
||||||
|
sgdVec3 scenery_center,
|
||||||
ssgTransform *terra_transform,
|
ssgTransform *terra_transform,
|
||||||
FGHitList *hit_list,
|
FGHitList *hit_list,
|
||||||
double *terrain_elev, double *radius, double *normal)
|
double *terrain_elev, double *radius, double *normal)
|
||||||
|
@ -604,7 +607,7 @@ bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center,
|
||||||
double lat_geod, alt, sea_level_r;
|
double lat_geod, alt, sea_level_r;
|
||||||
sgGeocToGeod(geoc.lat(), geoc.radius(), &lat_geod,
|
sgGeocToGeod(geoc.lat(), geoc.radius(), &lat_geod,
|
||||||
&alt, &sea_level_r);
|
&alt, &sea_level_r);
|
||||||
if ( alt > result && alt < 20000 ) {
|
if ( alt > result && alt < max_alt_m ) {
|
||||||
result = alt;
|
result = alt;
|
||||||
this_hit = i;
|
this_hit = i;
|
||||||
}
|
}
|
||||||
|
@ -624,7 +627,7 @@ bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center,
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
SG_LOG( SG_TERRAIN, SG_DEBUG, "DOING FULL TERRAIN INTERSECTION" );
|
SG_LOG( SG_TERRAIN, SG_DEBUG, "DOING FULL TERRAIN INTERSECTION" );
|
||||||
return fgCurrentElev( abs_view_pos, scenery_center, hit_list,
|
return fgCurrentElev( abs_view_pos, max_alt_m, scenery_center, hit_list,
|
||||||
terrain_elev,radius,normal);
|
terrain_elev,radius,normal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,7 @@ public:
|
||||||
// center, find the current terrain intersection elevation for the
|
// center, find the current terrain intersection elevation for the
|
||||||
// point specified.
|
// point specified.
|
||||||
bool fgCurrentElev( sgdVec3 abs_view_pos,
|
bool fgCurrentElev( sgdVec3 abs_view_pos,
|
||||||
|
double max_alt_m,
|
||||||
sgdVec3 scenery_center,
|
sgdVec3 scenery_center,
|
||||||
ssgTransform *terra_transform,
|
ssgTransform *terra_transform,
|
||||||
FGHitList *hit_list,
|
FGHitList *hit_list,
|
||||||
|
@ -93,6 +94,7 @@ bool fgCurrentElev( sgdVec3 abs_view_pos,
|
||||||
double *normal );
|
double *normal );
|
||||||
|
|
||||||
bool fgCurrentElev( sgdVec3 abs_view_pos,
|
bool fgCurrentElev( sgdVec3 abs_view_pos,
|
||||||
|
double max_alt_m,
|
||||||
sgdVec3 scenery_center,
|
sgdVec3 scenery_center,
|
||||||
FGHitList *hit_list,
|
FGHitList *hit_list,
|
||||||
double *terrain_elev,
|
double *terrain_elev,
|
||||||
|
|
|
@ -367,6 +367,15 @@ int FGTileMgr::update( SGLocation *location, double visibility_meters,
|
||||||
{
|
{
|
||||||
longitude = location->getLongitude_deg();
|
longitude = location->getLongitude_deg();
|
||||||
latitude = location->getLatitude_deg();
|
latitude = location->getLatitude_deg();
|
||||||
|
// add 2.0m to the max altitude to give a little leeway to the
|
||||||
|
// ground reaction code.
|
||||||
|
altitude_m = location->getAltitudeASL_ft() * SG_FEET_TO_METER + 2.0;
|
||||||
|
|
||||||
|
// if current altitude is apparently not initialized, set max
|
||||||
|
// altitude to something big.
|
||||||
|
if ( altitude_m < -1000 ) {
|
||||||
|
altitude_m = 10000;
|
||||||
|
}
|
||||||
// SG_LOG( SG_TERRAIN, SG_DEBUG, "FGTileMgr::update() for "
|
// SG_LOG( SG_TERRAIN, SG_DEBUG, "FGTileMgr::update() for "
|
||||||
// << longitude << " " << latatitude );
|
// << longitude << " " << latatitude );
|
||||||
|
|
||||||
|
@ -411,7 +420,7 @@ int FGTileMgr::update( SGLocation *location, double visibility_meters,
|
||||||
// no reason to update this if we haven't moved...
|
// no reason to update this if we haven't moved...
|
||||||
if ( longitude != last_longitude || latitude != last_latitude ) {
|
if ( longitude != last_longitude || latitude != last_latitude ) {
|
||||||
// update current elevation...
|
// update current elevation...
|
||||||
if ( updateCurrentElevAtPos( abs_pos_vector,
|
if ( updateCurrentElevAtPos( abs_pos_vector, altitude_m,
|
||||||
location->get_tile_center() ) )
|
location->get_tile_center() ) )
|
||||||
{
|
{
|
||||||
last_longitude = longitude;
|
last_longitude = longitude;
|
||||||
|
@ -432,8 +441,10 @@ void FGTileMgr::refresh_view_timestamps() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int FGTileMgr::updateCurrentElevAtPos(sgdVec3 abs_pos_vector, Point3D center) {
|
int FGTileMgr::updateCurrentElevAtPos( sgdVec3 abs_pos_vector,
|
||||||
|
double max_alt_m,
|
||||||
|
Point3D center)
|
||||||
|
{
|
||||||
sgdVec3 sc;
|
sgdVec3 sc;
|
||||||
|
|
||||||
sgdSetVec3( sc, center[0], center[1], center[2]);
|
sgdSetVec3( sc, center[0], center[1], center[2]);
|
||||||
|
@ -449,6 +460,7 @@ int FGTileMgr::updateCurrentElevAtPos(sgdVec3 abs_pos_vector, Point3D center) {
|
||||||
// scenery center has been properly defined so any hit should
|
// scenery center has been properly defined so any hit should
|
||||||
// be valid (and not just luck)
|
// be valid (and not just luck)
|
||||||
hit = fgCurrentElev(abs_pos_vector,
|
hit = fgCurrentElev(abs_pos_vector,
|
||||||
|
max_alt_m,
|
||||||
sc,
|
sc,
|
||||||
// uncomment next paramater to fly under
|
// uncomment next paramater to fly under
|
||||||
// bridges and a slightly faster algorithm
|
// bridges and a slightly faster algorithm
|
||||||
|
|
|
@ -100,6 +100,7 @@ private:
|
||||||
// current longitude latitude
|
// current longitude latitude
|
||||||
double longitude;
|
double longitude;
|
||||||
double latitude;
|
double latitude;
|
||||||
|
double altitude_m;
|
||||||
double last_longitude;
|
double last_longitude;
|
||||||
double last_latitude;
|
double last_latitude;
|
||||||
|
|
||||||
|
@ -166,7 +167,8 @@ public:
|
||||||
int update( SGLocation *location, double visibility_meters,
|
int update( SGLocation *location, double visibility_meters,
|
||||||
sgdVec3 abs_pos_vector );
|
sgdVec3 abs_pos_vector );
|
||||||
|
|
||||||
int updateCurrentElevAtPos(sgdVec3 abs_pos_vector, Point3D center );
|
int updateCurrentElevAtPos( sgdVec3 abs_pos_vector, double altitude_m,
|
||||||
|
Point3D center );
|
||||||
|
|
||||||
// Determine scenery altitude. Normally this just happens when we
|
// Determine scenery altitude. Normally this just happens when we
|
||||||
// render the scene, but we'd also like to be able to do this
|
// render the scene, but we'd also like to be able to do this
|
||||||
|
|
Loading…
Reference in a new issue