1
0
Fork 0

Make the JSBSim terrain handling code compile time configurable by calling cmake -DJSBSIM_TERRAIN=1

This commit is contained in:
Erik Hofman 2014-01-29 13:50:06 +01:00
parent 7bdd1d617d
commit 73a519a95c
4 changed files with 38 additions and 23 deletions

View file

@ -142,6 +142,7 @@ endif()
# FlightGear build options # FlightGear build options
option(SIMGEAR_SHARED "Set to ON when SimGear was built as a shared library" OFF) 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(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(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_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) option(ENABLE_LARCSIM "Set to ON to build FlightGear with LaRCsim FDM" OFF)
@ -175,6 +176,10 @@ else()
set(FG_NDEBUG 1) set(FG_NDEBUG 1)
endif() endif()
if(JSBSIM_TERRAIN)
set(JSBSIM_USE_GROUNDREACTIONS 1)
endif()
if(SP_FDMS) if(SP_FDMS)
set(ENABLE_SP_FDM 1) set(ENABLE_SP_FDM 1)
endif() endif()

View file

@ -18,7 +18,7 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. // 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 #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 contact[3], double normal[3], double vel[3],
double angularVel[3], double *agl) double angularVel[3], double *agl)
{ {
const simgear::BVHMaterial* material; const simgear::BVHMaterial* material;
simgear::BVHNode::Id id; simgear::BVHNode::Id id;
if (!FGInterface::get_agl_ft(t, pt, alt_off, contact, normal, vel, if (!FGInterface::get_agl_ft(t, pt, alt_off, contact, normal, vel,
angularVel, material, id)) angularVel, material, id))
return false; return false;
SGGeod geodPt = SGGeod::fromCart(SG_FEET_TO_METER*SGVec3d(pt)); SGGeod geodPt = SGGeod::fromCart(SG_FEET_TO_METER*SGVec3d(pt));
SGQuatd hlToEc = SGQuatd::fromLonLat(geodPt); SGQuatd hlToEc = SGQuatd::fromLonLat(geodPt);
*agl = dot(hlToEc.rotate(SGVec3d(0, 0, 1)), SGVec3d(contact) - SGVec3d(pt)); *agl = dot(hlToEc.rotate(SGVec3d(0, 0, 1)), SGVec3d(contact) - SGVec3d(pt));
static SGPropertyNode_ptr terrain = fgGetNode("/sim/fdm/surface", true);
#ifdef JSBSIM_USE_GROUNDREACTIONS #ifdef JSBSIM_USE_GROUNDREACTIONS
static SGPropertyNode_ptr terrain_nas = fgGetNode("/fdm/jsbsim/systems/fg-terrain", false); bool terrain_active = (terrain->getIntValue("override-level", -1) > 0) ? false : true;
if (material && !terrain_nas) { terrain->setBoolValue("active", terrain_active);
double frictionFactor = (*material).get_friction_factor(); terrain->setBoolValue("valid", (material && terrain_active) ? true : false);
double rollingFriction = (*material).get_rolling_friction(); if (terrain_active)
{
if ((rollingFriction != 1.0) && (rollingFriction > 0.001)) { static bool material_valid = false;
frictionFactor = rollingFriction/0.02; if (material) {
} GroundReactions->SetStaticFFactor((*material).get_friction_factor());
GroundReactions->SetFrictionFactor(frictionFactor); GroundReactions->SetRollingFFactor((*material).get_rolling_friction()/0.02);
// 1 Pascal = 0.00014503773800721815 lbs/in^2 // 1 Pascal = 0.00014503773800721815 lbs/in^2
double pressure = (*material).get_load_resistance(); // N/m^2 (or Pascal) double pressure = (*material).get_load_resistance(); // N/m^2 (or Pascal)
GroundReactions->SetMaximumForce(pressure*0.00014503773800721815); 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->SetBumpiness((*material).get_bumpiness());
GroundReactions->SetSolid((*material).get_solid()); GroundReactions->SetSolid((*material).get_solid());
GroundReactions->SetPosition(pt); GroundReactions->SetPosition(pt);
} material_valid = true;
} else {
if (material_valid) {
GroundReactions->resetValues();
material_valid = false;
}
}
}
#else
terrain->setBoolValue("valid", false);
#endif #endif
return true;
return true;
} }
inline static double sqr(double x) inline static double sqr(double x)

View file

@ -88,7 +88,7 @@ CLASS DOCUMENTATION
documentation for main for direction on running JSBSim apart from FlightGear. documentation for main for direction on running JSBSim apart from FlightGear.
@author Curtis L. Olson (original) @author Curtis L. Olson (original)
@author Tony Peden (Maintained and refined) @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) @see main in file JSBSim.cpp (use main() wrapper for standalone usage)
*/ */

View file

@ -2,6 +2,7 @@
#cmakedefine FG_NDEBUG #cmakedefine FG_NDEBUG
#cmakedefine ENABLE_SP_FDM #cmakedefine ENABLE_SP_FDM
#cmakedefine JSBSIM_USE_GROUNDREACTIONS
// JSBSim needs this, to switch from standalone to in-FG mode // JSBSim needs this, to switch from standalone to in-FG mode
#define FGFS #define FGFS