From f208f5e2d17b70297ff3ea13fd4ae3da43703ac7 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 24 Feb 2017 11:34:10 -0800 Subject: [PATCH] fix a couple of problems related to grabbing tablet while edit.js is active --- interface/src/ui/overlays/Overlays.cpp | 33 +++++++++---------- .../system/controllers/handControllerGrab.js | 10 +++--- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index 5cc0686984..709d86c305 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -341,27 +341,26 @@ OverlayID Overlays::getOverlayAtPoint(const glm::vec2& point) { return UNKNOWN_OVERLAY_ID; } QMapIterator i(_overlaysHUD); - i.toBack(); const float LARGE_NEGATIVE_FLOAT = -9999999; glm::vec3 origin(pointCopy.x, pointCopy.y, LARGE_NEGATIVE_FLOAT); glm::vec3 direction(0, 0, 1); - BoxFace thisFace; + // BoxFace thisFace; glm::vec3 thisSurfaceNormal; - float distance; + // float distance; unsigned int bestStackOrder = 0; OverlayID bestOverlayID = UNKNOWN_OVERLAY_ID; - while (i.hasPrevious()) { - i.previous(); + while (i.hasNext()) { + i.next(); OverlayID thisID = i.key(); if (i.value()->is3D()) { - auto thisOverlay = std::dynamic_pointer_cast(i.value()); - if (thisOverlay && !thisOverlay->getIgnoreRayIntersection()) { - if (thisOverlay->findRayIntersection(origin, direction, distance, thisFace, thisSurfaceNormal)) { - return thisID; - } - } + // auto thisOverlay = std::dynamic_pointer_cast(i.value()); + // if (thisOverlay && !thisOverlay->getIgnoreRayIntersection()) { + // if (thisOverlay->findRayIntersection(origin, direction, distance, thisFace, thisSurfaceNormal)) { + // return thisID; + // } + // } } else { auto thisOverlay = std::dynamic_pointer_cast(i.value()); if (thisOverlay && thisOverlay->getVisible() && thisOverlay->isLoaded() && @@ -423,9 +422,8 @@ RayToOverlayIntersectionResult Overlays::findRayIntersectionInternal(const PickR RayToOverlayIntersectionResult result; QMapIterator i(_overlaysWorld); - i.toBack(); - while (i.hasPrevious()) { - i.previous(); + while (i.hasNext()) { + i.next(); OverlayID thisID = i.key(); auto thisOverlay = std::dynamic_pointer_cast(i.value()); @@ -849,9 +847,10 @@ QVector Overlays::findOverlays(const glm::vec3& center, float radius) con QVector result; QMapIterator i(_overlaysWorld); - i.toBack(); - while (i.hasPrevious()) { - i.previous(); + int checked = 0; + while (i.hasNext()) { + checked++; + i.next(); OverlayID thisID = i.key(); auto overlay = std::dynamic_pointer_cast(i.value()); if (overlay && overlay->getVisible() && !overlay->getIgnoreRayIntersection() && overlay->isLoaded()) { diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 015cbf1221..86f080ae8d 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -863,7 +863,7 @@ function MyController(hand) { }; this.setState = function(newState, reason) { - if ((isInEditMode() && this.grabbedEntity !== HMD.tabletID) && + if ((isInEditMode() && this.grabbedThingID !== HMD.tabletID) && (newState !== STATE_OFF && newState !== STATE_SEARCHING && newState !== STATE_OVERLAY_STYLUS_TOUCHING && @@ -1446,7 +1446,7 @@ function MyController(hand) { var okToEquipFromOtherHand = ((this.getOtherHandController().state == STATE_NEAR_GRABBING || this.getOtherHandController().state == STATE_DISTANCE_HOLDING) && - this.getOtherHandController().grabbedEntity == hotspot.entityID); + this.getOtherHandController().grabbedThingID == hotspot.entityID); var hasParent = true; if (props.parentID === NULL_UUID) { hasParent = false; @@ -1666,7 +1666,7 @@ function MyController(hand) { grabbableOverlays.sort(function(a, b) { var aPosition = Overlays.getProperty(a, "position"); var aDistance = Vec3.distance(aPosition, handPosition); - var bPosition = Overlays.getProperty(a, "position"); + var bPosition = Overlays.getProperty(b, "position"); var bDistance = Vec3.distance(bPosition, handPosition); return aDistance - bDistance; }); @@ -3352,8 +3352,8 @@ var handleHandMessages = function(channel, message, sender) { selectedController.release(); var wearableEntity = data.entityID; entityPropertiesCache.addEntity(wearableEntity); - selectedController.grabbedEntity = wearableEntity; - var hotspots = selectedController.collectEquipHotspots(selectedController.grabbedEntity); + selectedController.grabbedThingID = wearableEntity; + var hotspots = selectedController.collectEquipHotspots(selectedController.grabbedThingID); if (hotspots.length > 0) { if (hotspotIndex >= hotspots.length) { hotspotIndex = 0;