Threadsafe access to EntityTree in OverlayPanel

This commit is contained in:
AlessandroSigna 2016-01-06 16:17:28 -08:00
parent bc538a0f7d
commit 7b74f7407a

View file

@ -170,9 +170,10 @@ 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([&] {
transform.setTranslation(entityTree->findEntityByID(_anchorPositionBindEntity)->getPosition());
});
} else {
transform.setTranslation(getAnchorPosition());
}
@ -181,9 +182,10 @@ 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([&] {
transform.setRotation(entityTree->findEntityByID(_anchorRotationBindEntity)->getRotation());
});
} else {
transform.setRotation(getAnchorRotation());
}