From b0c7e91737255b5c87218f89f746577d41360a7f Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 1 Sep 2016 15:33:12 -0700 Subject: [PATCH] Disable ray picking against invisible objects in far grab and teleport --- libraries/entities/src/EntityTree.cpp | 2 +- scripts/system/controllers/handControllerGrab.js | 8 ++++---- scripts/system/controllers/teleport.js | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index df14c0bce5..2e9fdf136a 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -572,7 +572,7 @@ bool EntityTree::findRayIntersection(const glm::vec3& origin, const glm::vec3& d OctreeElementPointer& element, float& distance, BoxFace& face, glm::vec3& surfaceNormal, const QVector& entityIdsToInclude, const QVector& entityIdsToDiscard, bool visibleOnly, void** intersectedObject, Octree::lockType lockType, bool* accurateResult, bool precisionPicking) { - RayArgs args = { origin, direction, element, distance, face, surfaceNormal, entityIdsToInclude, entityIdsToDiscard, intersectedObject, false, precisionPicking }; + RayArgs args = { origin, direction, element, distance, face, surfaceNormal, entityIdsToInclude, entityIdsToDiscard, visibleOnly, intersectedObject, false, precisionPicking }; distance = FLT_MAX; bool requireLock = lockType == Octree::Lock; diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index f11fb3129b..764fd705cb 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -344,7 +344,7 @@ function entityHasActions(entityID) { } function findRayIntersection(pickRay, precise, include, exclude) { - var entities = Entities.findRayIntersection(pickRay, precise, include, exclude); + var entities = Entities.findRayIntersection(pickRay, precise, include, exclude, true); var overlays = Overlays.findRayIntersection(pickRay); if (!overlays.intersects || (entities.intersects && (entities.distance <= overlays.distance))) { return entities; @@ -1155,9 +1155,9 @@ function MyController(hand) { var intersection; if (USE_BLACKLIST === true && blacklist.length !== 0) { - intersection = findRayIntersection(pickRay, true, [], blacklist); + intersection = findRayIntersection(pickRay, true, [], blacklist, true); } else { - intersection = findRayIntersection(pickRay, true); + intersection = findRayIntersection(pickRay, true, [], [], true); } if (intersection.intersects) { @@ -2211,7 +2211,7 @@ function MyController(hand) { var now = Date.now(); if (now - this.lastPickTime > MSECS_PER_SEC / PICKS_PER_SECOND_PER_HAND) { - var intersection = findRayIntersection(pickRay, true); + var intersection = findRayIntersection(pickRay, true, [], [], true); if (intersection.accurate || intersection.overlayID) { this.lastPickTime = now; if (intersection.entityID != this.grabbedEntity) { diff --git a/scripts/system/controllers/teleport.js b/scripts/system/controllers/teleport.js index b4a8eefcd2..3cd0615d2e 100644 --- a/scripts/system/controllers/teleport.js +++ b/scripts/system/controllers/teleport.js @@ -279,7 +279,7 @@ function Teleporter() { var location = Vec3.sum(rightPickRay.origin, Vec3.multiply(rightPickRay.direction, 50)); - var rightIntersection = Entities.findRayIntersection(teleporter.rightPickRay, true, [], [this.targetEntity]); + var rightIntersection = Entities.findRayIntersection(teleporter.rightPickRay, true, [], [this.targetEntity], true); if (rightIntersection.intersects) { if (this.tooClose === true) { @@ -342,7 +342,7 @@ function Teleporter() { var location = Vec3.sum(MyAvatar.position, Vec3.multiply(leftPickRay.direction, 50)); - var leftIntersection = Entities.findRayIntersection(teleporter.leftPickRay, true, [], [this.targetEntity]); + var leftIntersection = Entities.findRayIntersection(teleporter.leftPickRay, true, [], [this.targetEntity], true); if (leftIntersection.intersects) {