From 406c7d7042a1c266f84de4c05e042163f2298710 Mon Sep 17 00:00:00 2001 From: daveluff Date: Thu, 4 Mar 2004 10:11:29 +0000 Subject: [PATCH] Fix a problem where track would not get initialised to a sensible value before getting altered --- src/ATC/AIGAVFRTraffic.cxx | 4 +++- src/ATC/AIPlane.cxx | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ATC/AIGAVFRTraffic.cxx b/src/ATC/AIGAVFRTraffic.cxx index 8449f236c..dd1827ee7 100644 --- a/src/ATC/AIGAVFRTraffic.cxx +++ b/src/ATC/AIGAVFRTraffic.cxx @@ -84,7 +84,9 @@ bool FGAIGAVFRTraffic::Init(Point3D pt, string destID, const string& callsign) { _pos.setelev(_cruise_alt); // initially set waypoint as airport location _wp = _destPos; - //_hdg = GetHeadingFromTo(_pos, _wp); + // Set the initial track + track = GetHeadingFromTo(_pos, _wp); + // And set the plane to keep following it. SetTrack(GetHeadingFromTo(_pos, _wp)); _roll = 0.0; _pitch = 0.0; diff --git a/src/ATC/AIPlane.cxx b/src/ATC/AIPlane.cxx index 91434828d..867bdcd05 100644 --- a/src/ATC/AIPlane.cxx +++ b/src/ATC/AIPlane.cxx @@ -44,6 +44,7 @@ FGAIPlane::FGAIPlane() { playing = false; voiceOK = false; vPtr = NULL; + track = 0.0; _tgtTrack = 0.0; _trackSet = false; _tgtRoll = 0.0; @@ -124,6 +125,7 @@ void FGAIPlane::Update(double dt) { while((track - _tgtTrack) > 180.0) track -= 360.0; double turn_time = 60.0; track += (360.0 / turn_time) * dt * (_tgtTrack > track ? 1.0 : -1.0); + // TODO - bank a bit less for small turns. Bank(25.0 * (_tgtTrack > track ? 1.0 : -1.0)); if(fabs(track - _tgtTrack) < 2.0) { // TODO - might need to optimise the delta there - it's on the large (safe) side atm. track = _tgtTrack; -- 2.39.5