]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/JSBSim.cxx
Fixed incomplete merge of JSBSim.cxx
[flightgear.git] / src / FDM / JSBSim / JSBSim.cxx
index 612424629aa053d9098a421695ed052c88925563..8b693bcab8221a2fd8f47f34524c29753e0dd243 100644 (file)
@@ -18,7 +18,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 //
-// $Id: JSBSim.cxx,v 1.63 2010/10/07 03:45:40 jberndt Exp $
+// $Id: JSBSim.cxx,v 1.64 2010/10/31 04:49:25 jberndt Exp $
 
 
 #ifdef HAVE_CONFIG_H
@@ -143,7 +143,7 @@ FGJSBsim::FGJSBsim( double dt )
             break;
         }
     }
-
+    
     fdmex = new FGFDMExec( (FGPropertyManager*)globals->get_props() );
 
     // Register ground callback.
@@ -290,6 +290,8 @@ FGJSBsim::FGJSBsim( double dt )
         fgGetDouble("/fdm/jsbsim/systems/hook/tailhook-offset-x-in", 196),
         fgGetDouble("/fdm/jsbsim/systems/hook/tailhook-offset-y-in", 0),
         fgGetDouble("/fdm/jsbsim/systems/hook/tailhook-offset-z-in", -16));
+    last_hook_tip[0] = 0; last_hook_tip[1] = 0; last_hook_tip[2] = 0;
+    last_hook_root[0] = 0; last_hook_root[1] = 0; last_hook_root[2] = 0;
 
     crashed = false;
 }
@@ -420,6 +422,14 @@ void FGJSBsim::init()
 
 /******************************************************************************/
 
+void FGJSBsim::unbind()
+{
+  fdmex->Unbind();
+  FGInterface::unbind();
+}
+
+/******************************************************************************/
+
 // Run an iteration of the EOM (equations of motion)
 
 void FGJSBsim::update( double dt )
@@ -452,7 +462,7 @@ void FGJSBsim::update( double dt )
     // ground in this area.
     double groundCacheRadius = acrad + 2*dt*Propagate->GetUVW().Magnitude();
     double alt, slr, lat, lon;
-    FGColumnVector3 cart = Auxiliary->GetLocationVRP();
+    FGLocation cart = Auxiliary->GetLocationVRP();
     if ( needTrim && startup_trim->getBoolValue() ) {
       alt = fgic->GetAltitudeASLFtIC();
       slr = fgic->GetSeaLevelRadiusFtIC();
@@ -488,9 +498,9 @@ void FGJSBsim::update( double dt )
 
     if ( needTrim ) {
       if ( startup_trim->getBoolValue() ) {
-        double contact[3], d[3], agl;
+        double contact[3], d[3], vel[3], agl;
         get_agl_ft(fdmex->GetSimTime(), cart_pos, SG_METER_TO_FEET*2, contact,
-                   d, d, d, &agl);
+                   d, vel, d, &agl);
         double terrain_alt = sqrt(contact[0]*contact[0] + contact[1]*contact[1]
              + contact[2]*contact[2]) - fgic->GetSeaLevelRadiusFtIC();
 
@@ -498,6 +508,13 @@ void FGJSBsim::update( double dt )
           "Ready to trim, terrain elevation is: "
             << terrain_alt * SG_METER_TO_FEET );
 
+        if (fgGetBool("/sim/presets/onground")) {
+          FGColumnVector3 gndVelNED = cart.GetTec2l()
+                                    * FGColumnVector3(vel[0], vel[1], vel[2]);
+          fgic->SetVNorthFpsIC(gndVelNED(1));
+          fgic->SetVEastFpsIC(gndVelNED(2));
+          fgic->SetVDownFpsIC(gndVelNED(3));
+        }
         fgic->SetTerrainElevationFtIC( terrain_alt );
         do_trim();
       } else {