Fix of framerate drop due to broken OnActiveRunway function - don't read in the runway.mk4 file (~1MB) every frame
This commit is contained in:
parent
3f53eaeaa7
commit
541ff04072
1 changed files with 15 additions and 12 deletions
|
@ -351,6 +351,7 @@ void FGTower::DoRwyDetails() {
|
||||||
double tshlon, tshlat, tshr;
|
double tshlon, tshlat, tshr;
|
||||||
double tolon, tolat, tor;
|
double tolon, tolat, tor;
|
||||||
rwy.length = runway.length * SG_FEET_TO_METER;
|
rwy.length = runway.length * SG_FEET_TO_METER;
|
||||||
|
rwy.width = runway.width * SG_FEET_TO_METER;
|
||||||
geo_direct_wgs_84 ( aptElev, ref.lat(), ref.lon(), other_way,
|
geo_direct_wgs_84 ( aptElev, ref.lat(), ref.lon(), other_way,
|
||||||
rwy.length / 2.0 - 25.0, &tshlat, &tshlon, &tshr );
|
rwy.length / 2.0 - 25.0, &tshlat, &tshlon, &tshr );
|
||||||
geo_direct_wgs_84 ( aptElev, ref.lat(), ref.lon(), runway.heading,
|
geo_direct_wgs_84 ( aptElev, ref.lat(), ref.lon(), runway.heading,
|
||||||
|
@ -376,22 +377,24 @@ void FGTower::DoRwyDetails() {
|
||||||
// Figure out if a given position lies on the active runway
|
// Figure out if a given position lies on the active runway
|
||||||
// Might have to change when we consider more than one active rwy.
|
// Might have to change when we consider more than one active rwy.
|
||||||
bool FGTower::OnActiveRunway(Point3D pt) {
|
bool FGTower::OnActiveRunway(Point3D pt) {
|
||||||
SGPath path( globals->get_fg_root() );
|
// TODO - check that the centre calculation below isn't confused by displaced thesholds etc.
|
||||||
path.append( "Airports" );
|
Point3D xyc((rwy.end1ortho.x() + rwy.end2ortho.x())/2.0, (rwy.end1ortho.y() + rwy.end2ortho.y())/2.0, 0.0);
|
||||||
path.append( "runways.mk4" );
|
Point3D xyp = ortho.ConvertToLocal(pt);
|
||||||
FGRunways runways( path.c_str() );
|
|
||||||
|
|
||||||
FGRunway runway;
|
//cout << "Length offset = " << fabs(xyp.y() - xyc.y()) << '\n';
|
||||||
bool rwyGood = runways.search(ident, activeRwy, &runway);
|
//cout << "Width offset = " << fabs(xyp.x() - xyc.x()) << '\n';
|
||||||
if(!rwyGood) {
|
|
||||||
SG_LOG(SG_ATC, SG_WARN, "Unable to find runway " << activeRwy << " for airport ID " << ident << " in FGTower");
|
double rlen = rwy.length/2.0 + 5.0;
|
||||||
}
|
double rwidth = rwy.width/2.0;
|
||||||
return false; // TODO - this is an emergency patch to correct a framerate problem - FIXME properly!!!
|
double ldiff = fabs(xyp.y() - xyc.y());
|
||||||
//return(OnRunway(pt, &runway) ? true : false);
|
double wdiff = fabs(xyp.x() - xyc.x());
|
||||||
|
|
||||||
|
return((ldiff < rlen) && (wdiff < rwidth));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Figure out if a given position lies on any runway or not
|
// Figure out if a given position lies on any runway or not
|
||||||
|
// Only call this at startup - reading the runways database is expensive and needs to be fixed!
|
||||||
bool FGTower::OnAnyRunway(Point3D pt) {
|
bool FGTower::OnAnyRunway(Point3D pt) {
|
||||||
ATCData ad;
|
ATCData ad;
|
||||||
double dist = current_commlist->FindClosest(lon, lat, elev, ad, TOWER, 10.0);
|
double dist = current_commlist->FindClosest(lon, lat, elev, ad, TOWER, 10.0);
|
||||||
|
@ -414,7 +417,7 @@ bool FGTower::OnAnyRunway(Point3D pt) {
|
||||||
}
|
}
|
||||||
bool on = false;
|
bool on = false;
|
||||||
while(runway.id == ad.ident) {
|
while(runway.id == ad.ident) {
|
||||||
on = OnRunway(pt, &runway);
|
on = OnRunway(pt, runway);
|
||||||
//cout << "Runway " << runway.rwy_no << ": On = " << (on ? "true\n" : "false\n");
|
//cout << "Runway " << runway.rwy_no << ": On = " << (on ? "true\n" : "false\n");
|
||||||
if(on) return(true);
|
if(on) return(true);
|
||||||
runways.next(&runway);
|
runways.next(&runway);
|
||||||
|
|
Loading…
Reference in a new issue