]> git.mxchange.org Git - flightgear.git/commitdiff
Make the JSBSim terrain handling code compile time configurable by calling cmake...
authorErik Hofman <erik@ehofman.com>
Wed, 29 Jan 2014 12:50:06 +0000 (13:50 +0100)
committerErik Hofman <erik@ehofman.com>
Wed, 29 Jan 2014 12:50:06 +0000 (13:50 +0100)
CMakeLists.txt
src/FDM/JSBSim/JSBSim.cxx
src/FDM/JSBSim/JSBSim.hxx
src/Include/config_cmake.h.in

index 143793f49d42ada0c883762a92b5aeaf2f907b92..817733681322574f2bfaa888bc64fe481cbdb40b 100644 (file)
@@ -142,6 +142,7 @@ endif()
 # FlightGear build options
 option(SIMGEAR_SHARED    "Set to ON when SimGear was built as a shared library" OFF)
 option(LOGGING           "Set to ON to build FlightGear with logging support (default)" ON)
+option(JSBSIM_TERRAIN    "Set to ON to build FlightGear with JSBSim terrain handling code" OFF)
 option(SP_FDMS           "Set to ON to build FlightGear with special-purpose FDMs" OFF)
 option(ENABLE_UIUC_MODEL "Set to ON to build FlightGear with UIUCModel FDM" OFF)
 option(ENABLE_LARCSIM    "Set to ON to build FlightGear with LaRCsim FDM" OFF)
@@ -175,6 +176,10 @@ else()
     set(FG_NDEBUG 1)
 endif()
 
+if(JSBSIM_TERRAIN)
+   set(JSBSIM_USE_GROUNDREACTIONS 1)
+endif()
+
 if(SP_FDMS)
     set(ENABLE_SP_FDM 1)
 endif()
index 6a4b937706753536abd47669609f045e391e8589..45b4b9e841f08004262844fc5a4b5c309d4ed2c8 100644 (file)
@@ -18,7 +18,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
 //
-// $Id: JSBSim.cxx,v 1.64 2010/10/31 04:49:25 jberndt Exp $
+// $Id: FlightGear.cxx,v 1.15 2014/01/28 09:42:20 ehofman Exp $
 
 
 #ifdef HAVE_CONFIG_H
@@ -1331,27 +1331,28 @@ FGJSBsim::get_agl_ft(double t, const double pt[3], double alt_off,
                      double contact[3], double normal[3], double vel[3],
                      double angularVel[3], double *agl)
 {
-   const simgear::BVHMaterial* material;
-   simgear::BVHNode::Id id;
-   if (!FGInterface::get_agl_ft(t, pt, alt_off, contact, normal, vel,
-                                angularVel, material, id))
-       return false;
+  const simgear::BVHMaterial* material;
+  simgear::BVHNode::Id id;
+  if (!FGInterface::get_agl_ft(t, pt, alt_off, contact, normal, vel,
+                               angularVel, material, id))
+    return false;
 
-   SGGeod geodPt = SGGeod::fromCart(SG_FEET_TO_METER*SGVec3d(pt));
-   SGQuatd hlToEc = SGQuatd::fromLonLat(geodPt);
-   *agl = dot(hlToEc.rotate(SGVec3d(0, 0, 1)), SGVec3d(contact) - SGVec3d(pt));
+  SGGeod geodPt = SGGeod::fromCart(SG_FEET_TO_METER*SGVec3d(pt));
+  SGQuatd hlToEc = SGQuatd::fromLonLat(geodPt);
+  *agl = dot(hlToEc.rotate(SGVec3d(0, 0, 1)), SGVec3d(contact) - SGVec3d(pt));
 
-#ifdef JSBSIM_USE_GROUNDREACTIONS
-   static SGPropertyNode_ptr terrain_nas = fgGetNode("/fdm/jsbsim/systems/fg-terrain", false);
-   if (material && !terrain_nas) {
-      double frictionFactor = (*material).get_friction_factor();
-      double rollingFriction = (*material).get_rolling_friction();
-      
-      if ((rollingFriction != 1.0) && (rollingFriction > 0.001)) {
-        frictionFactor = rollingFriction/0.02;
-      }
-      GroundReactions->SetFrictionFactor(frictionFactor);
+  static SGPropertyNode_ptr terrain = fgGetNode("/sim/fdm/surface", true);
 
+#ifdef JSBSIM_USE_GROUNDREACTIONS
+  bool terrain_active = (terrain->getIntValue("override-level", -1) > 0) ? false : true;
+  terrain->setBoolValue("active", terrain_active);
+  terrain->setBoolValue("valid", (material && terrain_active) ? true : false);
+  if (terrain_active)
+  {
+    static bool material_valid = false;
+    if (material) {
+      GroundReactions->SetStaticFFactor((*material).get_friction_factor());
+      GroundReactions->SetRollingFFactor((*material).get_rolling_friction()/0.02);
       // 1 Pascal = 0.00014503773800721815 lbs/in^2
       double pressure = (*material).get_load_resistance(); // N/m^2 (or Pascal)
       GroundReactions->SetMaximumForce(pressure*0.00014503773800721815);
@@ -1359,10 +1360,18 @@ FGJSBsim::get_agl_ft(double t, const double pt[3], double alt_off,
       GroundReactions->SetBumpiness((*material).get_bumpiness());
       GroundReactions->SetSolid((*material).get_solid());
       GroundReactions->SetPosition(pt);
-   }
+      material_valid = true;
+    } else {
+       if (material_valid) {
+         GroundReactions->resetValues();
+         material_valid = false;
+      }
+    }
+  }
+#else
+  terrain->setBoolValue("valid", false);
 #endif
-
-   return true;
+  return true;
 }
 
 inline static double sqr(double x)
index 56552dcacf4297cf9029fe882ad04545116daab0..31c63ced7a2f595436cc00aa980171589d428c59 100644 (file)
@@ -88,7 +88,7 @@ CLASS DOCUMENTATION
     documentation for main for direction on running JSBSim apart from FlightGear.
     @author Curtis L. Olson (original)
     @author Tony Peden (Maintained and refined)
-    @version $Id: JSBSim.hxx,v 1.15 2010/10/07 03:45:40 jberndt Exp $
+    @version $Id: FlightGear.hxx,v 1.16 2014/01/28 09:42:21 ehofman Exp $
     @see main in file JSBSim.cpp (use main() wrapper for standalone usage)
 */
 
index 1faa29f441c9e84cc4546f7a95756475edfecf47..ac6579352e07efd9de1c76d409aeed63f2f193ef 100644 (file)
@@ -2,6 +2,7 @@
 
 #cmakedefine FG_NDEBUG
 #cmakedefine ENABLE_SP_FDM
+#cmakedefine JSBSIM_USE_GROUNDREACTIONS
 
 // JSBSim needs this, to switch from standalone to in-FG mode
 #define FGFS