From 39cb0bc357e881f2cb7cdb6fff998205dd28a791 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 26 Jul 2017 16:12:54 -0700 Subject: [PATCH] WHYYYY DOESN'T THIS WORK --- .../ui/overlays/ContextOverlayInterface.cpp | 12 +++-- .../system/controllers/handControllerGrab.js | 44 ++++++++++++------- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/interface/src/ui/overlays/ContextOverlayInterface.cpp b/interface/src/ui/overlays/ContextOverlayInterface.cpp index aa162e6101..e6d1af0af5 100644 --- a/interface/src/ui/overlays/ContextOverlayInterface.cpp +++ b/interface/src/ui/overlays/ContextOverlayInterface.cpp @@ -242,11 +242,15 @@ void ContextOverlayInterface::openMarketplace() { } void ContextOverlayInterface::enableEntityHighlight(const EntityItemID& entityItemID) { - qCDebug(context_overlay) << "Setting 'shouldHighlight' to 'true' for Entity ID:" << entityItemID; - qApp->getEntities()->getTree()->findEntityByEntityItemID(entityItemID)->setShouldHighlight(true); + if (!qApp->getEntities()->getTree()->findEntityByEntityItemID(entityItemID)->getShouldHighlight()) { + qCDebug(context_overlay) << "Setting 'shouldHighlight' to 'true' for Entity ID:" << entityItemID; + qApp->getEntities()->getTree()->findEntityByEntityItemID(entityItemID)->setShouldHighlight(true); + } } void ContextOverlayInterface::disableEntityHighlight(const EntityItemID& entityItemID) { - qCDebug(context_overlay) << "Setting 'shouldHighlight' to 'false' for Entity ID:" << entityItemID; - qApp->getEntities()->getTree()->findEntityByEntityItemID(entityItemID)->setShouldHighlight(false); + if (qApp->getEntities()->getTree()->findEntityByEntityItemID(entityItemID)->getShouldHighlight()) { + qCDebug(context_overlay) << "Setting 'shouldHighlight' to 'false' for Entity ID:" << entityItemID; + qApp->getEntities()->getTree()->findEntityByEntityItemID(entityItemID)->setShouldHighlight(false); + } } diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index a3bf6d4bd8..82691003e2 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -2236,18 +2236,22 @@ function MyController(hand) { entityPropertiesCache.addEntity(rayPickInfo.entityID); } + pointerEvent = { + type: "Move", + id: this.hand + 1, // 0 is reserved for hardware mouse + pos2D: projectOntoEntityXYPlane(rayPickInfo.entityID, rayPickInfo.intersection), + pos3D: rayPickInfo.intersection, + normal: rayPickInfo.normal, + direction: rayPickInfo.searchRay.direction, + button: "None" + }; if (rayPickInfo.entityID) { + print("ZRF: " + hoveredEntityID); if (hoveredEntityID !== rayPickInfo.entityID) { - pointerEvent = { - type: "Move", - id: this.hand + 1, // 0 is reserved for hardware mouse - pos2D: projectOntoEntityXYPlane(entity, rayPickInfo.intersection), - pos3D: rayPickInfo.intersection, - normal: rayPickInfo.normal, - direction: rayPickInfo.searchRay.direction, - button: "None" - }; - + if (contextOverlayTimer) { + Script.clearTimeout(contextOverlayTimer); + contextOverlayTimer = false; + } if (hoveredEntityID) { Entities.sendHoverLeaveEntity(hoveredEntityID, pointerEvent); } @@ -2255,17 +2259,14 @@ function MyController(hand) { Entities.sendHoverEnterEntity(hoveredEntityID, pointerEvent); } - if (contextOverlayTimer && rayPickInfo.entityID != hoveredEntityID) { - Script.clearTimeout(contextOverlayTimer); - } - // If we already have a context overlay, we don't want to move it to // another entity while we're searching. - if (!entityWithContextOverlay) { + if (!entityWithContextOverlay && !contextOverlayTimer) { contextOverlayTimer = Script.setTimeout(function () { if (rayPickInfo.entityID === hoveredEntityID && - !entityWithContextOverlay - && contextualHand !== -1) { + !entityWithContextOverlay && + contextualHand !== -1 && + contextOverlayTimer) { var pointerEvent = { type: "Move", id: contextualHand + 1, // 0 is reserved for hardware mouse @@ -2284,6 +2285,15 @@ function MyController(hand) { }, 500); contextualHand = this.hand; } + } else { + if (hoveredEntityID) { + Entities.sendHoverLeaveEntity(hoveredEntityID, pointerEvent); + hoveredEntityID = false; + } + if (contextOverlayTimer) { + Script.clearTimeout(contextOverlayTimer); + contextOverlayTimer = false; + } } var candidateHotSpotEntities = Entities.findEntities(handPosition, MAX_EQUIP_HOTSPOT_RADIUS);