]> git.mxchange.org Git - flightgear.git/commitdiff
Patch from Erik Hofman:
authordavid <david>
Sun, 2 Mar 2003 14:19:24 +0000 (14:19 +0000)
committerdavid <david>
Sun, 2 Mar 2003 14:19:24 +0000 (14:19 +0000)
I've updated the instrument modulator code to allow tricks like the one
described by Andy. It is now possible to define <min>, <max> and
<modulator> in one layer and if <min> and/or <max> ore within the range
of the <modulator> tag, their value will be honoured.

So, if you define

  <layer>
   <min>0</min>
   <max>50</max>
   <modulator>100</modulator>
  </layer>

The value will stay at 50, until the modulator forces it back to 0.

src/Cockpit/panel.cxx
src/Cockpit/panel.hxx
src/Cockpit/panel_io.cxx

index dd5e83afd87e23e36a99840418197e90a5b19906..b492c0bf402eb7e2b1aa29c8d24cd4d6783280a5 100644 (file)
@@ -847,11 +847,15 @@ FGInstrumentLayer::transform () const
     FGPanelTransformation *t = *it;
     if (t->test()) {
       float val = (t->node == 0 ? 0.0 : t->node->getFloatValue());
+
+      if (t->has_mod)
+          val = fmod(val, t->mod);
       if (val < t->min) {
        val = t->min;
       } else if (val > t->max) {
        val = t->max;
       }
+
       if(t->table==0) {
        val = val * t->factor + t->offset;
       } else {
index 595c5f8eeeafd0391d9d81265a3b505059273383..af1c073ae3d2ad3d5a7fcc2bdf7ad5ca0598a09e 100644 (file)
@@ -44,6 +44,7 @@
 #include <simgear/misc/props.hxx>
 #include <simgear/timing/timestamp.hxx>
 
+#include <cmath>
 #include <vector>
 #include <map>
 #include <plib/fnt.h>
@@ -303,6 +304,8 @@ public:
   const SGPropertyNode * node;
   float min;
   float max;
+  bool has_mod;
+  float mod;
   float factor;
   float offset;
   SGInterpTable * table;
index 474ed4aa45d3a3e17fa985c6ed4bb71f17cbd8bb..ef83c6b1ab2f8cc583b280b6970f5a0cd722526c 100644 (file)
@@ -251,6 +251,9 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale)
   t->node = target;
   t->min = node->getFloatValue("min", -9999999);
   t->max = node->getFloatValue("max", 99999999);
+  t->has_mod = node->hasChild("modulator");
+  if (t->has_mod)
+      t->mod = node->getFloatValue("modulator");
   t->factor = node->getFloatValue("scale", 1.0);
   t->offset = node->getFloatValue("offset", 0.0);