From 95eb52ad178ffd4601996a551f69a2d43c7e77d5 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Mon, 17 Oct 2016 14:02:07 -0700 Subject: [PATCH 1/2] bail early when removing entity focus --- interface/src/Application.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b13c432a14..62c4488d43 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3677,7 +3677,18 @@ void Application::setKeyboardFocusEntity(QUuid id) { void Application::setKeyboardFocusEntity(EntityItemID entityItemID) { auto entityScriptingInterface = DependencyManager::get(); if (_keyboardFocusedItem.get() != entityItemID) { + // reset focused entity _keyboardFocusedItem.set(UNKNOWN_ENTITY_ID); + if (_keyboardFocusHighlight) { + _keyboardFocusHighlight->setVisible(false); + } + + // if invalid, return without expensive (locking) operations + if (entityItemID == UNKNOWN_ENTITY_ID) { + return; + } + + // if valid, query properties auto properties = entityScriptingInterface->getEntityProperties(entityItemID); if (!properties.getLocked() && properties.getVisible()) { auto entity = getEntities()->getTree()->findEntityByID(entityItemID); @@ -3688,6 +3699,8 @@ void Application::setKeyboardFocusEntity(EntityItemID entityItemID) { } _keyboardFocusedItem.set(entityItemID); _lastAcceptedKeyPress = usecTimestampNow(); + + // create a focus if (_keyboardFocusHighlightID < 0 || !getOverlays().isAddedOverlay(_keyboardFocusHighlightID)) { _keyboardFocusHighlight = std::make_shared(); _keyboardFocusHighlight->setAlpha(1.0f); @@ -3699,17 +3712,16 @@ void Application::setKeyboardFocusEntity(EntityItemID entityItemID) { _keyboardFocusHighlight->setColorPulse(1.0); _keyboardFocusHighlight->setIgnoreRayIntersection(true); _keyboardFocusHighlight->setDrawInFront(false); + _keyboardFocusHighlightID = getOverlays().addOverlay(_keyboardFocusHighlight); } + + // position the focus _keyboardFocusHighlight->setRotation(entity->getRotation()); _keyboardFocusHighlight->setPosition(entity->getPosition()); _keyboardFocusHighlight->setDimensions(entity->getDimensions() * 1.05f); _keyboardFocusHighlight->setVisible(true); - _keyboardFocusHighlightID = getOverlays().addOverlay(_keyboardFocusHighlight); } } - if (_keyboardFocusedItem.get() == UNKNOWN_ENTITY_ID && _keyboardFocusHighlight) { - _keyboardFocusHighlight->setVisible(false); - } } } From 301f3ced983d9eeae07511344140db14ae143727 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Mon, 17 Oct 2016 15:30:49 -0700 Subject: [PATCH 2/2] fix typoed threaded call --- libraries/avatars/src/AvatarData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index d30b69c5f8..9df23dad2c 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -1778,7 +1778,7 @@ void AvatarData::setAvatarEntityData(const AvatarEntityMap& avatarEntityData) { AvatarEntityIDs AvatarData::getAndClearRecentlyDetachedIDs() { AvatarEntityIDs result; if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(const_cast(this), "getRecentlyDetachedIDs", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(const_cast(this), "getAndClearRecentlyDetachedIDs", Qt::BlockingQueuedConnection, Q_RETURN_ARG(AvatarEntityIDs, result)); return result; }