From 68dec9af2dae7a46d2ad6a6be18150035ef1299c Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sun, 26 Jun 2011 16:18:36 +0200 Subject: [PATCH] #178 related: avoid sim from freezing when FDM goes wild --- src/Instrumentation/heading_indicator_dg.cxx | 4 ++++ 1 file changed, 4 insertions(+) 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); -- 2.39.5