From: ThorstenB Date: Sun, 26 Jun 2011 14:18:36 +0000 (+0200) Subject: #178 related: avoid sim from freezing when FDM goes wild X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=68dec9af2dae7a46d2ad6a6be18150035ef1299c;p=flightgear.git #178 related: avoid sim from freezing when FDM goes wild --- diff --git a/src/Instrumentation/heading_indicator_dg.cxx b/src/Instrumentation/heading_indicator_dg.cxx index bb9c1620e..a4c478be0 100644 --- a/src/Instrumentation/heading_indicator_dg.cxx +++ b/src/Instrumentation/heading_indicator_dg.cxx @@ -153,6 +153,10 @@ HeadingIndicatorDG::update (double dt) _last_heading_deg = heading; heading += offset + align + error; + // sanity check: bail out when the FDM runs wild, to avoid + // SG_NORMALIZE_RANGE from freezing on huge/infinite numbers. + if (fabs(heading)>1e10) + return; SG_NORMALIZE_RANGE(heading, 0.0, 360.0); _heading_out_node->setDoubleValue(heading);