Fix a problem where track would not get initialised to a sensible value before getting altered
This commit is contained in:
parent
250ccf7bff
commit
406c7d7042
2 changed files with 5 additions and 1 deletions
|
@ -84,7 +84,9 @@ bool FGAIGAVFRTraffic::Init(Point3D pt, string destID, const string& callsign) {
|
||||||
_pos.setelev(_cruise_alt);
|
_pos.setelev(_cruise_alt);
|
||||||
// initially set waypoint as airport location
|
// initially set waypoint as airport location
|
||||||
_wp = _destPos;
|
_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));
|
SetTrack(GetHeadingFromTo(_pos, _wp));
|
||||||
_roll = 0.0;
|
_roll = 0.0;
|
||||||
_pitch = 0.0;
|
_pitch = 0.0;
|
||||||
|
|
|
@ -44,6 +44,7 @@ FGAIPlane::FGAIPlane() {
|
||||||
playing = false;
|
playing = false;
|
||||||
voiceOK = false;
|
voiceOK = false;
|
||||||
vPtr = NULL;
|
vPtr = NULL;
|
||||||
|
track = 0.0;
|
||||||
_tgtTrack = 0.0;
|
_tgtTrack = 0.0;
|
||||||
_trackSet = false;
|
_trackSet = false;
|
||||||
_tgtRoll = 0.0;
|
_tgtRoll = 0.0;
|
||||||
|
@ -124,6 +125,7 @@ void FGAIPlane::Update(double dt) {
|
||||||
while((track - _tgtTrack) > 180.0) track -= 360.0;
|
while((track - _tgtTrack) > 180.0) track -= 360.0;
|
||||||
double turn_time = 60.0;
|
double turn_time = 60.0;
|
||||||
track += (360.0 / turn_time) * dt * (_tgtTrack > track ? 1.0 : -1.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));
|
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.
|
if(fabs(track - _tgtTrack) < 2.0) { // TODO - might need to optimise the delta there - it's on the large (safe) side atm.
|
||||||
track = _tgtTrack;
|
track = _tgtTrack;
|
||||||
|
|
Loading…
Add table
Reference in a new issue