]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIMultiplayer.cxx
#358: Missing option to disable AI scenarios
[flightgear.git] / src / AIModel / AIMultiplayer.cxx
index 0652dfef73751daf52f67997d72028ef2e6ad916..08f5afb400f907561cb055ebab574d4ab9a742eb 100644 (file)
 
 #include "AIMultiplayer.hxx"
 
-#include <simgear/scene/util/SGNodeMasks.hxx>
 
 // #define SG_DEBUG SG_ALERT
 
-FGAIMultiplayer::FGAIMultiplayer() : FGAIBase(otMultiplayer) {
+FGAIMultiplayer::FGAIMultiplayer() :
+   FGAIBase(otMultiplayer, false)
+{
    no_roll = false;
 
    mTimeOffsetSet = false;
    mAllowExtrapolation = true;
    mLagAdjustSystemSpeed = 10;
+   mLastTimestamp = 0;
+   lastUpdateTime = 0;
 
-   aip.getSceneGraph()->setNodeMask(~SG_NODEMASK_TERRAIN_BIT);
-
-}
-
+} 
 
 FGAIMultiplayer::~FGAIMultiplayer() {
 }
@@ -417,8 +417,21 @@ void FGAIMultiplayer::update(double dt)
   
   // extract the position
   pos = SGGeod::fromCart(ecPos);
+  double recent_alt_ft = altitude_ft;
   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
   // horizontal local frame
   SGQuatf qEc2Hl = SGQuatf::fromLonLatRad((float)pos.getLongitudeRad(),