]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/YASim/YASim.cxx
latest updates from JSBSim
[flightgear.git] / src / FDM / YASim / YASim.cxx
index 27fcbff6d64672baa49f822b3daa06ef74b7f9d6..70c7459d2fabba8d304638c191ac435c5ee3fa81 100644 (file)
@@ -43,7 +43,8 @@ static const float W2HP = 1.3416e-3;
 static const float INHG2PA = 3386.389;
 static const float SLUG2KG = 14.59390;
 
-YASim::YASim(double dt)
+YASim::YASim(double dt) :
+    _simTime(0)
 {
 //     set_delta_t(dt);
     _fdm = new FGFDM();
@@ -54,6 +55,11 @@ YASim::YASim(double dt)
     _fdm->getAirplane()->getModel()->getIntegrator()->setInterval(_dt);
 }
 
+YASim::~YASim()
+{
+    delete _fdm;
+}
+
 void YASim::report()
 {
     Airplane* a = _fdm->getAirplane();
@@ -204,7 +210,7 @@ void YASim::update(double dt)
     // build the environment cache.
     float vr = _fdm->getVehicleRadius();
     vr += 2.0*FT2M*dt*Math::mag3(v);
-    prepare_ground_cache_m( 0.0, xyz, vr );
+    prepare_ground_cache_m( _simTime, _simTime + dt, xyz, vr );
 
     // Track time increments.
     FGGround* gr
@@ -212,14 +218,15 @@ void YASim::update(double dt)
 
     int i;
     for(i=0; i<iterations; i++) {
-        gr->setTimeOffset(i*_dt);
+        gr->setTimeOffset(_simTime + i*_dt);
         copyToYASim(false);
         _fdm->iterate(_dt);
         copyFromYASim();
     }
 
-    // Reset the time increment.
-    gr->setTimeOffset(0.0);
+    // Increment the local sim time
+    _simTime += dt;
+    gr->setTimeOffset(_simTime);
 }
 
 void YASim::copyToYASim(bool copyState)
@@ -411,7 +418,7 @@ void YASim::copyFromYASim()
     _set_V_rel_wind(Math::mag3(v)*M2FT); // units?
 
     float P = fgGetDouble("/environment/pressure-inhg") * INHG2PA;
-    float T = fgGetDouble("/environment/temperature-degC") + 273.15;
+    float T = fgGetDouble("/environment/temperature-degc") + 273.15;
     float D = fgGetFloat("/environment/density-slugft3")
         *SLUG2KG * M2FT*M2FT*M2FT;
     _set_V_equiv_kts(Atmosphere::calcVEAS(v[0], P, T, D)*MPS2KTS);
@@ -472,6 +479,8 @@ void YASim::copyFromYASim()
        node->setFloatValue("compression-m", g->getCompressDist());
         node->setFloatValue("caster-angle-deg", g->getCasterAngle() * RAD2DEG);
         node->setFloatValue("rollspeed-ms", g->getRollSpeed());
+        node->setBoolValue("ground-is-solid", g->getGroundIsSolid()!=0);
+        node->setFloatValue("ground-friction-factor", g->getGroundFrictionFactor());
     }
 
     Hook* h = airplane->getHook();