mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 13:28:09 +02:00
Merge pull request #6168 from ZappoMan/fixScripts
fix AnyEndpoint support from JS
This commit is contained in:
commit
548dcde335
1 changed files with 17 additions and 2 deletions
|
@ -217,10 +217,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual float value() override {
|
virtual float value() override {
|
||||||
float result = 0;
|
float result = 0.0f;
|
||||||
for (auto& child : _children) {
|
for (auto& child : _children) {
|
||||||
float childResult = child->value();
|
float childResult = child->value();
|
||||||
if (childResult != 0.0f) {
|
if (childResult != 0.0f && result == 0.0f) {
|
||||||
result = childResult;
|
result = childResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -856,6 +856,21 @@ Endpoint::Pointer UserInputMapper::endpointFor(const QScriptValue& endpoint) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (endpoint.isArray()) {
|
||||||
|
int length = endpoint.property("length").toInteger();
|
||||||
|
Endpoint::List children;
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
QScriptValue arrayItem = endpoint.property(i);
|
||||||
|
Endpoint::Pointer destination = endpointFor(arrayItem);
|
||||||
|
if (!destination) {
|
||||||
|
return Endpoint::Pointer();
|
||||||
|
}
|
||||||
|
children.push_back(destination);
|
||||||
|
}
|
||||||
|
return std::make_shared<AnyEndpoint>(children);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
qWarning() << "Unsupported input type " << endpoint.toString();
|
qWarning() << "Unsupported input type " << endpoint.toString();
|
||||||
return Endpoint::Pointer();
|
return Endpoint::Pointer();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue