Expose vertical speed for MP planes
vertical speed of MP planes was always 0, calculate their (average) vertical speed since it's required for TCAS and TCAS display
This commit is contained in:
parent
b6eba5ce65
commit
0f7f7fce6b
2 changed files with 18 additions and 3 deletions
|
@ -39,12 +39,12 @@ FGAIMultiplayer::FGAIMultiplayer() : FGAIBase(otMultiplayer) {
|
||||||
mTimeOffsetSet = false;
|
mTimeOffsetSet = false;
|
||||||
mAllowExtrapolation = true;
|
mAllowExtrapolation = true;
|
||||||
mLagAdjustSystemSpeed = 10;
|
mLagAdjustSystemSpeed = 10;
|
||||||
|
mLastTimestamp = 0;
|
||||||
aip.getSceneGraph()->setNodeMask(~SG_NODEMASK_TERRAIN_BIT);
|
aip.getSceneGraph()->setNodeMask(~SG_NODEMASK_TERRAIN_BIT);
|
||||||
|
lastUpdateTime = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FGAIMultiplayer::~FGAIMultiplayer() {
|
FGAIMultiplayer::~FGAIMultiplayer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,8 +417,21 @@ void FGAIMultiplayer::update(double dt)
|
||||||
|
|
||||||
// extract the position
|
// extract the position
|
||||||
pos = SGGeod::fromCart(ecPos);
|
pos = SGGeod::fromCart(ecPos);
|
||||||
|
double recent_alt_ft = altitude_ft;
|
||||||
altitude_ft = pos.getElevationFt();
|
altitude_ft = pos.getElevationFt();
|
||||||
|
|
||||||
|
// expose a valid vertical speed
|
||||||
|
if (lastUpdateTime != 0)
|
||||||
|
{
|
||||||
|
double dT = curtime - lastUpdateTime;
|
||||||
|
double Weighting=1;
|
||||||
|
if (dt < 1.0)
|
||||||
|
Weighting = dt;
|
||||||
|
// simple smoothing over 1 second
|
||||||
|
vs = (1.0-Weighting)*vs + Weighting * (altitude_ft - recent_alt_ft) / dT * 60;
|
||||||
|
}
|
||||||
|
lastUpdateTime = curtime;
|
||||||
|
|
||||||
// The quaternion rotating from the earth centered frame to the
|
// The quaternion rotating from the earth centered frame to the
|
||||||
// horizontal local frame
|
// horizontal local frame
|
||||||
SGQuatf qEc2Hl = SGQuatf::fromLonLatRad((float)pos.getLongitudeRad(),
|
SGQuatf qEc2Hl = SGQuatf::fromLonLatRad((float)pos.getLongitudeRad(),
|
||||||
|
|
|
@ -78,6 +78,8 @@ private:
|
||||||
double mTimeOffset;
|
double mTimeOffset;
|
||||||
bool mTimeOffsetSet;
|
bool mTimeOffsetSet;
|
||||||
|
|
||||||
|
double lastUpdateTime;
|
||||||
|
|
||||||
/// Properties which are for now exposed for testing
|
/// Properties which are for now exposed for testing
|
||||||
bool mAllowExtrapolation;
|
bool mAllowExtrapolation;
|
||||||
double mLagAdjustSystemSpeed;
|
double mLagAdjustSystemSpeed;
|
||||||
|
|
Loading…
Add table
Reference in a new issue