Merge branch 'durk/traffic'
This commit is contained in:
commit
bb419b588c
1 changed files with 54 additions and 59 deletions
|
@ -205,6 +205,9 @@ bool FGAISchedule::update(time_t now)
|
|||
userLatitude,
|
||||
userLongitude;
|
||||
|
||||
SGVec3d newPos(0, 0, 0);
|
||||
|
||||
|
||||
if (fgGetBool("/sim/traffic-manager/enabled") == false)
|
||||
return true;
|
||||
|
||||
|
@ -302,6 +305,7 @@ bool FGAISchedule::update(time_t now)
|
|||
if (!(dep && arr))
|
||||
return false;
|
||||
|
||||
if (dep != arr) {
|
||||
SGVec3d a = SGVec3d::fromGeoc(SGGeoc::fromDegM(dep->getLongitude(),
|
||||
dep->getLatitude(), 1));
|
||||
SGVec3d b = SGVec3d::fromGeoc(SGGeoc::fromDegM(arr->getLongitude(),
|
||||
|
@ -332,36 +336,27 @@ bool FGAISchedule::update(time_t now)
|
|||
remainingTimeEnroute = totalTimeEnroute;
|
||||
SG_LOG (SG_GENERAL, SG_DEBUG, "Traffic Manager: Flight is pending.");
|
||||
}
|
||||
|
||||
angle *= ( (double) elapsedTimeEnroute/ (double) totalTimeEnroute);
|
||||
|
||||
|
||||
//cout << "a = " << a[0] << " " << a[1] << " " << a[2]
|
||||
// << "b = " << b[0] << " " << b[1] << " " << b[2] << endl;
|
||||
sgdMat4 matrix;
|
||||
sgdMakeRotMat4(matrix, angle, _cross.data());
|
||||
SGVec3d newPos(0, 0, 0);
|
||||
for(int j = 0; j < 3; j++)
|
||||
{
|
||||
for (int k = 0; k<3; k++)
|
||||
{
|
||||
for(int j = 0; j < 3; j++) {
|
||||
for (int k = 0; k<3; k++) {
|
||||
newPos[j] += matrix[j][k]*a[k];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
SGGeod current;
|
||||
if (now > (*i)->getDepartureTime())
|
||||
{
|
||||
if ((now > (*i)->getDepartureTime() && (dep != arr))) {
|
||||
current = SGGeod::fromCart(newPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
current = dep->geod();
|
||||
}
|
||||
|
||||
SGGeod user = SGGeod::fromDegM(userLongitude, userLatitude, (*i)->getCruiseAlt());
|
||||
speed = SGGeodesy::distanceNm(current, arr->geod()) /
|
||||
((double) remainingTimeEnroute/3600.0);
|
||||
} else {
|
||||
current = dep->geod();
|
||||
speed = 450;
|
||||
}
|
||||
SGGeod user = SGGeod::fromDegM(userLongitude, userLatitude, (*i)->getCruiseAlt());
|
||||
|
||||
distanceToUser = SGGeodesy::distanceNm(current, user);
|
||||
|
||||
|
|
Loading…
Reference in a new issue