Fixed a segfault occuring when changing the LOD ranges with a JSBSim aircraft.
Bug report and testing by Jonathan Redpath (see details in issue #276 at GitHub). The check of FGInterface::get_agl_ft return value has been discarded a few years ago (commit 86b346) on the ground that the method was returning a meaningful altitude above ground level even if it failed. See mailing lists discussions: https://sourceforge.net/p/flightgear/mailman/message/32246380/ https://sourceforge.net/p/flightgear/mailman/message/32247050/ There is no indication however that the other parameters are populated with meaningful values when FGInterface::get_agl_ft reports an error. The returned `material` pointer is therefore discarded when an error is reported. Ground reactions are still processed in all cases as was decided in 2014. Took the opportunity to initialize the `material` pointer to null, to avoid yet another problem with unitialized values.
This commit is contained in:
parent
7f319d69ca
commit
ca8fffda3e
1 changed files with 4 additions and 5 deletions
|
@ -1378,14 +1378,13 @@ FGJSBsim::get_agl_ft(double t, const FGColumnVector3& loc, 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 angularVel[3])
|
||||||
{
|
{
|
||||||
const simgear::BVHMaterial* material;
|
const simgear::BVHMaterial* material = nullptr;
|
||||||
simgear::BVHNode::Id id;
|
simgear::BVHNode::Id id;
|
||||||
double pt[3] {loc(1), loc(2), loc(3)};
|
double pt[3] {loc(1), loc(2), loc(3)};
|
||||||
|
|
||||||
// don't check the return value and continue above scenery discontinuity
|
if (!FGInterface::get_agl_ft(t, pt, alt_off, contact, normal, vel,
|
||||||
// see http://osdir.com/ml/flightgear-sim/2014-04/msg00145.html
|
angularVel, material, id))
|
||||||
FGInterface::get_agl_ft(t, pt, alt_off, contact, normal, vel,
|
material = nullptr; // Discard the material data when FGInterface reports an problem.
|
||||||
angularVel, material, id);
|
|
||||||
|
|
||||||
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);
|
||||||
|
|
Loading…
Reference in a new issue