1
0
Fork 0

Merge branch 'durk/traffic'

This commit is contained in:
Tim Moore 2009-12-22 00:15:13 +01:00
commit bb419b588c

View file

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