]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIAircraft.cxx
Remove hard-coded values wherever possible;
[flightgear.git] / src / AIModel / AIAircraft.cxx
index 6abe6af54407f59c92f51519c6a448dc0abcd5ed..69c519f63d9824231fd4d33998b48bec2a980467 100644 (file)
@@ -820,10 +820,10 @@ bool FGAIAircraft::leadPointReached(FGAIWaypoint* curr) {
        } 
     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))) ) {
@@ -838,11 +838,12 @@ bool FGAIAircraft::leadPointReached(FGAIWaypoint* curr) {
 }
 
 
-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);
 }
 
 
@@ -887,17 +888,17 @@ bool FGAIAircraft::handleAirportEndPoints(FGAIWaypoint* prev, time_t now) {
     //        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")) {
@@ -1274,9 +1275,9 @@ void FGAIAircraft::updateActualState() {
     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);