mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 09:33:29 +02:00
Add more efficient overlay getters, don't use blocking calls
This commit is contained in:
parent
e22a3c6af9
commit
e52c7f4395
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) {
|
||||
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);
|
||||
OverlayPropertyResult result;
|
||||
if (thisOverlay && thisOverlay->supportsGetProperty()) {
|
||||
result.value = thisOverlay->getProperty(property);
|
||||
}
|
||||
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() {
|
||||
}
|
||||
|
||||
|
|
|
@ -190,6 +190,10 @@ public slots:
|
|||
*/
|
||||
OverlayPropertyResult getProperty(OverlayID id, const QString& property);
|
||||
|
||||
OverlayPropertyResult getProperties(const OverlayID& id, const QStringList& properties);
|
||||
|
||||
OverlayPropertyResult getOverlaysProperties(const QVariant& overlaysProperties);
|
||||
|
||||
/*jsdoc
|
||||
* Find the closest 3D overlay hit by a pick ray.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue