mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 16:14:35 +02:00
Add more efficient overlay getters, don't use blocking calls
This commit is contained in:
parent
fc8b7c7cc5
commit
7e9ea596a0
2 changed files with 38 additions and 7 deletions
|
@ -414,20 +414,47 @@ OverlayID Overlays::getOverlayAtPoint(const glm::vec2& point) {
|
||||||
}
|
}
|
||||||
|
|
||||||
OverlayPropertyResult Overlays::getProperty(OverlayID id, const QString& property) {
|
OverlayPropertyResult Overlays::getProperty(OverlayID id, const QString& property) {
|
||||||
if (QThread::currentThread() != thread()) {
|
|
||||||
OverlayPropertyResult result;
|
|
||||||
BLOCKING_INVOKE_METHOD(this, "getProperty", Q_RETURN_ARG(OverlayPropertyResult, result), Q_ARG(OverlayID, id), Q_ARG(QString, property));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
OverlayPropertyResult result;
|
|
||||||
Overlay::Pointer thisOverlay = getOverlay(id);
|
Overlay::Pointer thisOverlay = getOverlay(id);
|
||||||
|
OverlayPropertyResult result;
|
||||||
if (thisOverlay && thisOverlay->supportsGetProperty()) {
|
if (thisOverlay && thisOverlay->supportsGetProperty()) {
|
||||||
result.value = thisOverlay->getProperty(property);
|
result.value = thisOverlay->getProperty(property);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OverlayPropertyResult Overlays::getProperties(const OverlayID& id, const QStringList& properties) {
|
||||||
|
Overlay::Pointer thisOverlay = getOverlay(id);
|
||||||
|
OverlayPropertyResult result;
|
||||||
|
if (thisOverlay && thisOverlay->supportsGetProperty()) {
|
||||||
|
QVariantMap mapResult;
|
||||||
|
for (const auto& property : properties) {
|
||||||
|
mapResult.insert(property, thisOverlay->getProperty(property));
|
||||||
|
}
|
||||||
|
result.value = mapResult;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
OverlayPropertyResult Overlays::getOverlaysProperties(const QVariant& propertiesById) {
|
||||||
|
QVariantMap map = propertiesById.toMap();
|
||||||
|
OverlayPropertyResult result;
|
||||||
|
QVariantMap resultMap;
|
||||||
|
for (const auto& key : map.keys()) {
|
||||||
|
OverlayID id = OverlayID(key);
|
||||||
|
QVariantMap overlayResult;
|
||||||
|
Overlay::Pointer thisOverlay = getOverlay(id);
|
||||||
|
if (thisOverlay && thisOverlay->supportsGetProperty()) {
|
||||||
|
QStringList propertiesToFetch = map[key].toStringList();
|
||||||
|
for (const auto& property : propertiesToFetch) {
|
||||||
|
overlayResult[property] = thisOverlay->getProperty(property);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resultMap[key] = overlayResult;
|
||||||
|
}
|
||||||
|
result.value = resultMap;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
OverlayPropertyResult::OverlayPropertyResult() {
|
OverlayPropertyResult::OverlayPropertyResult() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -190,6 +190,10 @@ public slots:
|
||||||
*/
|
*/
|
||||||
OverlayPropertyResult getProperty(OverlayID id, const QString& property);
|
OverlayPropertyResult getProperty(OverlayID id, const QString& property);
|
||||||
|
|
||||||
|
OverlayPropertyResult getProperties(const OverlayID& id, const QStringList& properties);
|
||||||
|
|
||||||
|
OverlayPropertyResult getOverlaysProperties(const QVariant& overlaysProperties);
|
||||||
|
|
||||||
/*jsdoc
|
/*jsdoc
|
||||||
* Find the closest 3D overlay hit by a pick ray.
|
* Find the closest 3D overlay hit by a pick ray.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue