mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-21 16:29:27 +02:00
Fix invalid volume values in injector options
This commit is contained in:
parent
9605379265
commit
3f8b2f9cbb
1 changed files with 51 additions and 27 deletions
|
@ -9,9 +9,13 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include "AudioInjectorOptions.h"
|
||||||
|
|
||||||
|
#include <QScriptValueIterator>
|
||||||
|
|
||||||
#include <RegisteredMetaTypes.h>
|
#include <RegisteredMetaTypes.h>
|
||||||
|
|
||||||
#include "AudioInjectorOptions.h"
|
#include "AudioLogging.h"
|
||||||
|
|
||||||
AudioInjectorOptions::AudioInjectorOptions() :
|
AudioInjectorOptions::AudioInjectorOptions() :
|
||||||
position(0.0f, 0.0f, 0.0f),
|
position(0.0f, 0.0f, 0.0f),
|
||||||
|
@ -22,7 +26,7 @@ AudioInjectorOptions::AudioInjectorOptions() :
|
||||||
ambisonic(false),
|
ambisonic(false),
|
||||||
ignorePenumbra(false),
|
ignorePenumbra(false),
|
||||||
localOnly(false),
|
localOnly(false),
|
||||||
secondOffset(0.0)
|
secondOffset(0.0f)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,31 +44,51 @@ QScriptValue injectorOptionsToScriptValue(QScriptEngine* engine, const AudioInje
|
||||||
}
|
}
|
||||||
|
|
||||||
void injectorOptionsFromScriptValue(const QScriptValue& object, AudioInjectorOptions& injectorOptions) {
|
void injectorOptionsFromScriptValue(const QScriptValue& object, AudioInjectorOptions& injectorOptions) {
|
||||||
if (object.property("position").isValid()) {
|
if (!object.isObject()) {
|
||||||
vec3FromScriptValue(object.property("position"), injectorOptions.position);
|
qWarning() << "Audio injector options is not an object.";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object.property("volume").isValid()) {
|
QScriptValueIterator it(object);
|
||||||
injectorOptions.volume = object.property("volume").toNumber();
|
while (it.hasNext()) {
|
||||||
}
|
it.next();
|
||||||
|
|
||||||
if (object.property("loop").isValid()) {
|
if (it.name() == "position") {
|
||||||
injectorOptions.loop = object.property("loop").toBool();
|
vec3FromScriptValue(object.property("position"), injectorOptions.position);
|
||||||
}
|
} else if (it.name() == "orientation") {
|
||||||
|
quatFromScriptValue(object.property("orientation"), injectorOptions.orientation);
|
||||||
if (object.property("orientation").isValid()) {
|
} else if (it.name() == "volume") {
|
||||||
quatFromScriptValue(object.property("orientation"), injectorOptions.orientation);
|
if (it.value().isNumber()) {
|
||||||
}
|
injectorOptions.volume = it.value().toNumber();
|
||||||
|
} else {
|
||||||
if (object.property("ignorePenumbra").isValid()) {
|
qCWarning(audio) << "Audio injector options: volume is not a number";
|
||||||
injectorOptions.ignorePenumbra = object.property("ignorePenumbra").toBool();
|
}
|
||||||
}
|
} else if (it.name() == "loop") {
|
||||||
|
if (it.value().isBool()) {
|
||||||
if (object.property("localOnly").isValid()) {
|
injectorOptions.loop = it.value().toBool();
|
||||||
injectorOptions.localOnly = object.property("localOnly").toBool();
|
} else {
|
||||||
}
|
qCWarning(audio) << "Audio injector options: loop is not a boolean";
|
||||||
|
}
|
||||||
if (object.property("secondOffset").isValid()) {
|
} else if (it.name() == "ignorePenumbra") {
|
||||||
injectorOptions.secondOffset = object.property("secondOffset").toNumber();
|
if (it.value().isBool()) {
|
||||||
|
injectorOptions.ignorePenumbra = it.value().toBool();
|
||||||
|
} else {
|
||||||
|
qCWarning(audio) << "Audio injector options: ignorePenumbra is not a boolean";
|
||||||
|
}
|
||||||
|
} else if (it.name() == "localOnly") {
|
||||||
|
if (it.value().isBool()) {
|
||||||
|
injectorOptions.localOnly = it.value().toBool();
|
||||||
|
} else {
|
||||||
|
qCWarning(audio) << "Audio injector options: localOnly is not a boolean";
|
||||||
|
}
|
||||||
|
} else if (it.name() == "secondOffset") {
|
||||||
|
if (it.value().isNumber()) {
|
||||||
|
injectorOptions.secondOffset = it.value().toNumber();
|
||||||
|
} else {
|
||||||
|
qCWarning(audio) << "Audio injector options: secondOffset is not a number";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qCWarning(audio) << "Unknown audio injector option:" << it.name();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue