mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-08 07:22:25 +02:00
Function based endpoints should inhibit spamming with repeats of the same value
This commit is contained in:
parent
f61cf843bc
commit
5bc736952a
2 changed files with 8 additions and 3 deletions
|
@ -14,7 +14,7 @@ using namespace controller;
|
|||
|
||||
float ScriptEndpoint::value() {
|
||||
updateValue();
|
||||
return _lastValue;
|
||||
return _lastValueRead;
|
||||
}
|
||||
|
||||
void ScriptEndpoint::updateValue() {
|
||||
|
@ -23,14 +23,18 @@ void ScriptEndpoint::updateValue() {
|
|||
return;
|
||||
}
|
||||
|
||||
_lastValue = (float)_callable.call().toNumber();
|
||||
_lastValueRead = (float)_callable.call().toNumber();
|
||||
}
|
||||
|
||||
void ScriptEndpoint::apply(float newValue, float oldValue, const Pointer& source) {
|
||||
if (newValue == _lastValueWritten) {
|
||||
return;
|
||||
}
|
||||
internalApply(newValue, oldValue, source->getInput().getID());
|
||||
}
|
||||
|
||||
void ScriptEndpoint::internalApply(float newValue, float oldValue, int sourceID) {
|
||||
_lastValueWritten = newValue;
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "internalApply", Qt::QueuedConnection,
|
||||
Q_ARG(float, newValue),
|
||||
|
|
|
@ -31,7 +31,8 @@ protected:
|
|||
Q_INVOKABLE virtual void internalApply(float newValue, float oldValue, int sourceID);
|
||||
private:
|
||||
QScriptValue _callable;
|
||||
float _lastValue = 0.0f;
|
||||
float _lastValueRead { 0.0f };
|
||||
float _lastValueWritten { 0.0f };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue