Patch from Erik Hofman:
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.
This commit is contained in:
parent
c8b8722a14
commit
45f3eb7f99
3 changed files with 10 additions and 0 deletions
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue