1
0
Fork 0

AIWingman Join bug fix

Also removal of redundant code (always true conditions).
This commit is contained in:
Scott Giese 2021-12-26 12:41:06 -06:00
parent 27b518e306
commit f008531fd5
2 changed files with 23 additions and 29 deletions

View file

@ -188,12 +188,12 @@ void FGAIAircraft::setPerformance(const std::string& acType, const std::string&
// enough
const bool isUserAircraft = (manager == nullptr);
bool outOfSight = false,
flightplanActive = true;
bool flightplanActive = true;
// user aircraft speed, heading and position are synchronzied in
// FGAIManager::fetchUserState()
if (!isUserAircraft) {
bool outOfSight = false;
updatePrimaryTargetValues(dt, flightplanActive, outOfSight); // target hdg, alt, speed
if (outOfSight) {
return;
@ -1057,7 +1057,7 @@ void FGAIAircraft::controlSpeed(FGAIWaypoint* curr, FGAIWaypoint* next) {
if (fabs(speed_diff) > 10) {
prevSpeed = speed;
if (next) {
if (next && !curr->contains("END") && !curr->contains("PushBackPointlegend")) {
if (!curr->contains("END") && !curr->contains("PushBackPointlegend")) {
fp->setLeadDistance(speed, tgt_heading, curr, next);
} else {
// If we are ending in a parking the heading will be a
@ -1183,23 +1183,21 @@ void FGAIAircraft::updateHeading(double dt) {
headingChangeRate = -30;
}
} else {
if (speed != 0) {
if( sign(headingChangeRate) == sign(headingDiff)) {
// left/right change
headingChangeRate = 3 * dt * sign(headingDiff) * -1;
} else {
headingChangeRate -= 3 * dt * sign(headingDiff);
}
/*
if (headingChangeRate > headingDiff ||
headingChangeRate < headingDiff) {
headingChangeRate = headingDiff*sign(roll);
}
else {
headingChangeRate += dt * sign(roll);
}
*/
if( sign(headingChangeRate) == sign(headingDiff)) {
// left/right change
headingChangeRate = 3 * dt * sign(headingDiff) * -1;
} else {
headingChangeRate -= 3 * dt * sign(headingDiff);
}
/*
if (headingChangeRate > headingDiff ||
headingChangeRate < headingDiff) {
headingChangeRate = headingDiff*sign(roll);
}
else {
headingChangeRate += dt * sign(roll);
}
*/
}
}

View file

@ -280,16 +280,12 @@ void FGAIWingman::formateToAC(double dt){
if(p_agl <= 10 || p_wow == 1) {
_height = p_ht;
//cout << "ht case1 " ;
} else if (p_agl > 10 && p_agl <= 150 ) {
} else if (p_agl <= 150 ) {
setHt(p_ht, dt, 1.0);
//cout << "ht case2 " ;
} else if (p_agl > 150 && p_agl <= 250) {
setHt(_offsetpos.getElevationFt()+ h_feet, dt, 0.75);
//cout << "ht case3 " ;
} else if (p_agl <= 250) {
setHt(_offsetpos.getElevationFt() + h_feet, dt, 0.75);
} else{
setHt(_offsetpos.getElevationFt()+ h_feet, dt, 0.5);
//cout << "ht case4 " ;
setHt(_offsetpos.getElevationFt() + h_feet, dt, 0.5);
}
pos.setElevationFt(_height);
@ -404,7 +400,7 @@ void FGAIWingman::Join(double dt) {
setPch(angle, dt, _coeff_pch);
//cout << _name << " backing up HEADING " << hdg
// << " RANGE " << range;
} else if (rel_brg >= -5 || rel_brg <= 5) {
} else if (rel_brg >= -5 && rel_brg <= 5) {
// station is in front of us - slow down
setSpeed(parent_spd + ((frm_spd/100) * range));
//SGMiscd::clip