mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 11:54:20 +02:00
Merge pull request #6786 from AlessandroSigna/overlays
Thread-safe access to EntityTree in OverlayPanel
This commit is contained in:
commit
fca5b29e6f
1 changed files with 14 additions and 6 deletions
|
@ -170,9 +170,13 @@ void OverlayPanel::applyTransformTo(Transform& transform, bool force) {
|
|||
transform.setTranslation(DependencyManager::get<AvatarManager>()->getMyAvatar()
|
||||
->getPosition());
|
||||
} else if (!_anchorPositionBindEntity.isNull()) {
|
||||
transform.setTranslation(DependencyManager::get<EntityScriptingInterface>()
|
||||
->getEntityTree()->findEntityByID(_anchorPositionBindEntity)
|
||||
->getPosition());
|
||||
EntityTreePointer entityTree = DependencyManager::get<EntityScriptingInterface>()->getEntityTree();
|
||||
entityTree->withReadLock([&] {
|
||||
EntityItemPointer foundEntity = entityTree->findEntityByID(_anchorPositionBindEntity);
|
||||
if (foundEntity) {
|
||||
transform.setTranslation(foundEntity->getPosition());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
transform.setTranslation(getAnchorPosition());
|
||||
}
|
||||
|
@ -181,9 +185,13 @@ void OverlayPanel::applyTransformTo(Transform& transform, bool force) {
|
|||
transform.setRotation(DependencyManager::get<AvatarManager>()->getMyAvatar()
|
||||
->getOrientation());
|
||||
} else if (!_anchorRotationBindEntity.isNull()) {
|
||||
transform.setRotation(DependencyManager::get<EntityScriptingInterface>()
|
||||
->getEntityTree()->findEntityByID(_anchorRotationBindEntity)
|
||||
->getRotation());
|
||||
EntityTreePointer entityTree = DependencyManager::get<EntityScriptingInterface>()->getEntityTree();
|
||||
entityTree->withReadLock([&] {
|
||||
EntityItemPointer foundEntity = entityTree->findEntityByID(_anchorRotationBindEntity);
|
||||
if (foundEntity) {
|
||||
transform.setRotation(foundEntity->getRotation());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
transform.setRotation(getAnchorRotation());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue