]> git.mxchange.org Git - flightgear.git/commitdiff
Some more work on AI/ATC user interaction integration:
authorDurk Talsma <durk@localhost.(none)>
Fri, 29 Apr 2011 18:44:05 +0000 (20:44 +0200)
committerDurk Talsma <durk@localhost.(none)>
Fri, 29 Apr 2011 18:44:05 +0000 (20:44 +0200)
* Update AI aircraft object based on user position.
* Process flightplan
* Don't try to update the radar information for AIAircraft that don't have a valid manager pointer

src/AIModel/AIAircraft.cxx
src/AIModel/AIAircraft.hxx
src/ATC/atc_mgr.cxx

index c9b5b72081cf9f94fdefa5fc675184d850900088..811dbfe9a9ae30a6ce67f897b20d3235301443c5 100644 (file)
@@ -165,7 +165,12 @@ void FGAIAircraft::setPerformance(const std::string& acclass) {
      handleATCRequests(); // ATC also has a word to say
      updateSecondaryTargetValues(); // target roll, vertical speed, pitch
      updateActualState(); 
-     UpdateRadar(manager);
+    // We currently have one situation in which an AIAircraft object is used that is not attached to the 
+    // AI manager. In this particular case, the AIAircraft is used to shadow the user's aircraft's behavior in the AI world.
+    // Since we perhaps don't want a radar entry of our own aircraft, the following conditional should probably be adequate
+    // enough
+     if (manager)
+        UpdateRadar(manager);
      checkVisibility();
   }
 
index ff7afad3ef8270572bff66aa13ea1e1608dd887c..e064acfc965bb61b1762e5ecf5cd765cae5f1ceb 100644 (file)
@@ -1,3 +1,4 @@
+
 // FGAIAircraft - AIBase derived class creates an AI aircraft
 //
 // Written by David Culp, started October 2003.
index 6f526221adfbc77b47d424c054f4bade949e9d57..917d25cbb4178632e0081ba3b0b2d3ab80c17cec 100644 (file)
@@ -149,6 +149,7 @@ void FGATCManager::init() {
     
     
     fp->restart();
+    fp->setLeg(leg);
     ai_ac.SetFlightPlan(fp);
     if (controller) {
         controller->announcePosition(ai_ac.getID(), fp, fp->getCurrentWaypoint()->routeIndex,
@@ -186,6 +187,13 @@ void FGATCManager::update ( double time ) {
                                               altitude, time);
         //string airport = fgGetString("/sim/presets/airport-id");
         //FGAirport *apt = FGAirport::findByIdent(airport); 
+        // AT this stage we should update the flightplan, so that waypoint incrementing is conducted as well as leg loading. 
+        ai_ac.setLatitude(latitude);
+        ai_ac.setLongitude(longitude);
+        ai_ac.setAltitude(altitude);
+        ai_ac.setHeading(heading);
+        ai_ac.setSpeed(speed);
+        ai_ac.update(time);
         controller->render();
         //cerr << "Adding groundnetWork to the scenegraph::update" << endl;
    }