mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 16:10:40 +02:00
Reduce lock time.
This commit is contained in:
parent
9e223a9502
commit
367175b8a6
2 changed files with 58 additions and 59 deletions
|
@ -355,9 +355,6 @@ AvatarSharedPointer AvatarManager::getAvatarBySessionID(const QUuid& sessionID)
|
|||
if (sessionID == _myAvatar->getSessionUUID()) {
|
||||
return std::static_pointer_cast<Avatar>(_myAvatar);
|
||||
}
|
||||
AvatarSharedPointer avatar;
|
||||
withAvatarHash([&avatar, &sessionID] (const AvatarHash& hash) {
|
||||
avatar = hash[sessionID];
|
||||
});
|
||||
return avatar;
|
||||
QReadLocker locker(&_hashLock);
|
||||
return _avatarHash[sessionID];
|
||||
}
|
||||
|
|
|
@ -1018,7 +1018,10 @@ void MyAvatar::updateLookAtTargetAvatar() {
|
|||
const float KEEP_LOOKING_AT_CURRENT_ANGLE_FACTOR = 1.3f;
|
||||
const float GREATEST_LOOKING_AT_DISTANCE = 10.0f;
|
||||
|
||||
DependencyManager::get<AvatarManager>()->withAvatarHash([&] (const AvatarHash& hash) {
|
||||
AvatarHash hash;
|
||||
DependencyManager::get<AvatarManager>()->withAvatarHash([&] (const AvatarHash& locked) {
|
||||
hash = locked; // make a shallow copy and operate on that, to minimize lock time
|
||||
});
|
||||
foreach (const AvatarSharedPointer& avatarPointer, hash) {
|
||||
auto avatar = static_pointer_cast<Avatar>(avatarPointer);
|
||||
bool isCurrentTarget = avatar->getIsLookAtTarget();
|
||||
|
@ -1083,7 +1086,6 @@ void MyAvatar::updateLookAtTargetAvatar() {
|
|||
avatar->getHead()->clearCorrectedLookAtPosition();
|
||||
}
|
||||
}
|
||||
});
|
||||
auto avatarPointer = _lookAtTargetAvatar.lock();
|
||||
if (avatarPointer) {
|
||||
static_pointer_cast<Avatar>(avatarPointer)->setIsLookAtTarget(true);
|
||||
|
|
Loading…
Reference in a new issue