Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all
Unified · Split
| @@ -3677,7 +3677,18 @@ void Application::setKeyboardFocusEntity(QUuid id) { · 3676 unmodified lines | |||
| 3677 | void Application::setKeyboardFocusEntity(EntityItemID entityItemID) { | 3677 | void Application::setKeyboardFocusEntity(EntityItemID entityItemID) { |
| 3678 | auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); | 3678 | auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); |
| 3679 | if (_keyboardFocusedItem.get() != entityItemID) { | 3679 | if (_keyboardFocusedItem.get() != entityItemID) { |
| 3680 | // reset focused entity | ||
| 3680 | _keyboardFocusedItem.set(UNKNOWN_ENTITY_ID); | 3681 | _keyboardFocusedItem.set(UNKNOWN_ENTITY_ID); |
| 3682 | if (_keyboardFocusHighlight) { | ||
| 3683 | _keyboardFocusHighlight->setVisible(false); | ||
| 3684 | } | ||
| 3685 | |||
| 3686 | // if invalid, return without expensive (locking) operations | ||
| 3687 | if (entityItemID == UNKNOWN_ENTITY_ID) { | ||
| 3688 | return; | ||
| 3689 | } | ||
| 3690 | |||
| 3691 | // if valid, query properties | ||
| 3681 | auto properties = entityScriptingInterface->getEntityProperties(entityItemID); | 3692 | auto properties = entityScriptingInterface->getEntityProperties(entityItemID); |
| 3682 | if (!properties.getLocked() && properties.getVisible()) { | 3693 | if (!properties.getLocked() && properties.getVisible()) { |
| 3683 | auto entity = getEntities()->getTree()->findEntityByID(entityItemID); | 3694 | auto entity = getEntities()->getTree()->findEntityByID(entityItemID); |
| @@ -3688,6 +3699,8 @@ void Application::setKeyboardFocusEntity(EntityItemID entityItemID) { · 4 unmodified lines | |||
| 3688 | } | 3699 | } |
| 3689 | _keyboardFocusedItem.set(entityItemID); | 3700 | _keyboardFocusedItem.set(entityItemID); |
| 3690 | _lastAcceptedKeyPress = usecTimestampNow(); | 3701 | _lastAcceptedKeyPress = usecTimestampNow(); |
| 3702 | |||
| 3703 | // create a focus | ||
| 3691 | if (_keyboardFocusHighlightID < 0 || !getOverlays().isAddedOverlay(_keyboardFocusHighlightID)) { | 3704 | if (_keyboardFocusHighlightID < 0 || !getOverlays().isAddedOverlay(_keyboardFocusHighlightID)) { |
| 3692 | _keyboardFocusHighlight = std::make_shared<Cube3DOverlay>(); | 3705 | _keyboardFocusHighlight = std::make_shared<Cube3DOverlay>(); |
| 3693 | _keyboardFocusHighlight->setAlpha(1.0f); | 3706 | _keyboardFocusHighlight->setAlpha(1.0f); |
| @@ -3699,17 +3712,16 @@ void Application::setKeyboardFocusEntity(EntityItemID entityItemID) { · 5 unmodified lines | |||
| 3699 | _keyboardFocusHighlight->setColorPulse(1.0); | 3712 | _keyboardFocusHighlight->setColorPulse(1.0); |
| 3700 | _keyboardFocusHighlight->setIgnoreRayIntersection(true); | 3713 | _keyboardFocusHighlight->setIgnoreRayIntersection(true); |
| 3701 | _keyboardFocusHighlight->setDrawInFront(false); | 3714 | _keyboardFocusHighlight->setDrawInFront(false); |
| 3715 | _keyboardFocusHighlightID = getOverlays().addOverlay(_keyboardFocusHighlight); | ||
| 3702 | } | 3716 | } |
| 3717 | |||
| 3718 | // position the focus | ||
| 3703 | _keyboardFocusHighlight->setRotation(entity->getRotation()); | 3719 | _keyboardFocusHighlight->setRotation(entity->getRotation()); |
| 3704 | _keyboardFocusHighlight->setPosition(entity->getPosition()); | 3720 | _keyboardFocusHighlight->setPosition(entity->getPosition()); |
| 3705 | _keyboardFocusHighlight->setDimensions(entity->getDimensions() * 1.05f); | 3721 | _keyboardFocusHighlight->setDimensions(entity->getDimensions() * 1.05f); |
| 3706 | _keyboardFocusHighlight->setVisible(true); | 3722 | _keyboardFocusHighlight->setVisible(true); |
| 3707 | _keyboardFocusHighlightID = getOverlays().addOverlay(_keyboardFocusHighlight); | ||
| 3708 | } | 3723 | } |
| 3709 | } | 3724 | } |
| 3710 | if (_keyboardFocusedItem.get() == UNKNOWN_ENTITY_ID && _keyboardFocusHighlight) { | ||
| 3711 | _keyboardFocusHighlight->setVisible(false); | ||
| 3712 | } | ||
| 3713 | } | 3725 | } |
| 3714 | } | 3726 | } |
| 3715 | 3727 | ||