}
if (trafficRef) {
//cerr << "Tracking callsign : \"" << fgGetString("/ai/track-callsign") << "\"" << endl;
-/* if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
- cerr << trafficRef->getCallSign() << " " << tgt_altitude_ft << " " << _getSpeed() << " "
- << _getAltitude() << " "<< _getLatitude() << " " << _getLongitude() << " " << dist_to_go << " " << lead_dist << " " << curr->name << " " << vs << " " << tgt_vs << " " << bearing << " " << minBearing << " " << speedFraction << endl;
- }*/
+ //if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
+ //cerr << trafficRef->getCallSign() << " " << tgt_altitude_ft << " " << _getSpeed() << " "
+ // << _getAltitude() << " "<< _getLatitude() << " " << _getLongitude() << " " << dist_to_go << " " << lead_dist << " " << curr->getName() << " " << vs << " " << //tgt_vs << " " << bearing << " " << minBearing << " " << speedFraction << endl;
+ //}
}
if ((dist_to_go < lead_dist) ||
((dist_to_go > prev_dist_to_go) && (bearing > (minBearing * 1.1))) ) {
}
-bool FGAIAircraft::aiTrafficVisible() {
- SGGeod userPos(SGGeod::fromDeg(fgGetDouble("/position/longitude-deg"),
- fgGetDouble("/position/latitude-deg")));
-
- return (SGGeodesy::distanceNm(userPos, pos) <= TRAFFICTOAIDISTTODIE);
+bool FGAIAircraft::aiTrafficVisible()
+{
+ SGVec3d cartPos = SGVec3d::fromGeod(pos);
+ const double d2 = (TRAFFICTOAIDISTTODIE * SG_NM_TO_METER) *
+ (TRAFFICTOAIDISTTODIE * SG_NM_TO_METER);
+ return (distSqr(cartPos, globals->get_aircraft_positon_cart()) < d2);
}
// fp->shortenToFirst(2, "legend");
// }
//}
- /*if (prev->contains(string("final"))) {
-
- cerr << getCallSign() << " "
- << fp->getPreviousWaypoint()->getName()
- << ". Alt = " << altitude_ft
- << " vs " << vs
- << " horizontal speed " << speed
- << "Previous crossAT " << fp->getPreviousWaypoint()->getCrossat()
- << "Airport elevation" << getTrafficRef()->getArrivalAirport()->getElevation()
- << "Altitude difference " << (altitude_ft - fp->getPreviousWaypoint()->getCrossat()) << endl;
- }*/
+ //if (prev->contains(string("final"))) {
+ //
+ // cerr << getCallSign() << " "
+ // << fp->getPreviousWaypoint()->getName()
+ // << ". Alt = " << altitude_ft
+ // << " vs " << vs
+ // << " horizontal speed " << speed
+ // << "Previous crossAT " << fp->getPreviousWaypoint()->getCrossat()
+ // << "Airport elevation" << getTrafficRef()->getArrivalAirport()->getElevation()
+ // << "Altitude difference " << (altitude_ft - fp->getPreviousWaypoint()->getCrossat()) << endl;
+ //q}
// This is the last taxi waypoint, and marks the the end of the flight plan
// so, the schedule should update and wait for the next departure time.
if (prev->contains("END")) {
updatePosition();
if (onGround())
- speed = _performance->actualSpeed(this, groundTargetSpeed, dt);
+ speed = _performance->actualSpeed(this, groundTargetSpeed, dt, holdPos);
else
- speed = _performance->actualSpeed(this, (tgt_speed *speedFraction), dt);
+ speed = _performance->actualSpeed(this, (tgt_speed *speedFraction), dt, false);
//assertSpeed(speed);
updateHeading();
roll = _performance->actualBankAngle(this, tgt_roll, dt);