From ed5b05eef4c4a651f3239c3dade488575fd809b9 Mon Sep 17 00:00:00 2001 From: David Back Date: Thu, 14 Jun 2018 17:43:45 -0700 Subject: [PATCH 1/6] fix auto laser on locked web entity, only auto laser at tablet or web overlays --- .../controllerModules/webSurfaceLaserInput.js | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index 949fdbb072..e30419f45e 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -50,21 +50,28 @@ Script.include("/~/system/libraries/controllers.js"); return this.hand === RIGHT_HAND ? leftOverlayLaserInput : rightOverlayLaserInput; }; - this.isPointingAtWebEntity = function(controllerData) { + this.isPointingAtTabletOrWeb = function(controllerData, triggerPressed) { var intersection = controllerData.rayPicks[this.hand]; - var entityProperty = Entities.getEntityProperties(intersection.objectID); - var entityType = entityProperty.type; - if ((intersection.type === Picks.INTERSECTED_ENTITY && entityType === "Web")) { - return true; + if (intersection.type === Picks.INTERSECTED_OVERLAY) { + var objectID = intersection.objectID; + if ((HMD.tabletScreenID && objectID === HMD.tabletScreenID) || + (HMD.homeButtonID && objectID === HMD.homeButtonID)) { + return true; + } else { + var overlayType = Overlays.getOverlayType(objectID); + if (overlayType === "web3d") { + return true; + } + } + } else if (intersection.type === Picks.INTERSECTED_ENTITY) { + var entityProperty = Entities.getEntityProperties(intersection.objectID); + var entityType = entityProperty.type; + var isLocked = entityProperty.locked; + return entityType === "Web" && (!isLocked || triggerPressed); } return false; }; - this.isPointingAtOverlay = function(controllerData) { - var intersection = controllerData.rayPicks[this.hand]; - return intersection.type === Picks.INTERSECTED_OVERLAY; - }; - this.deleteContextOverlay = function() { var farGrabModule = getEnabledModuleByName(this.hand === RIGHT_HAND ? "RightFarActionGrabEntity" : "LeftFarActionGrabEntity"); @@ -92,10 +99,10 @@ Script.include("/~/system/libraries/controllers.js"); this.isReady = function(controllerData) { var otherModuleRunning = this.getOtherModule().running; otherModuleRunning = otherModuleRunning && this.getDominantHand() !== this.hand; // Auto-swap to dominant hand. - var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE - && controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; - if ((!otherModuleRunning || isTriggerPressed) - && (this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData))) { + var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE && + controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; + var allowThisModule = !otherModuleRunning || isTriggerPressed; + if (allowThisModule && this.isPointingAtTabletOrWeb(controllerData, isTriggerPressed)) { this.updateAllwaysOn(); if (isTriggerPressed) { this.dominantHandOverride = true; // Override dominant hand. @@ -113,9 +120,10 @@ Script.include("/~/system/libraries/controllers.js"); otherModuleRunning = otherModuleRunning && this.getDominantHand() !== this.hand; // Auto-swap to dominant hand. otherModuleRunning = otherModuleRunning || this.getOtherModule().dominantHandOverride; // Override dominant hand. var grabModuleNeedsToRun = this.grabModuleWantsNearbyOverlay(controllerData); - if (!otherModuleRunning && !grabModuleNeedsToRun && (controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE - || this.parameters.handLaser.allwaysOn - && (this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData)))) { + var allowThisModule = !otherModuleRunning && !grabModuleNeedsToRun; + var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; + var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; + if (allowThisModule && (laserOn && this.isPointingAtTabletOrWeb(controllerData, isTriggerPressed))) { this.running = true; return makeRunningValues(true, [], []); } From fcccaaea4896af372571184eec8ae3db7fa65e48 Mon Sep 17 00:00:00 2001 From: David Back Date: Thu, 14 Jun 2018 17:49:02 -0700 Subject: [PATCH 2/6] tabs --- .../controllerModules/webSurfaceLaserInput.js | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index e30419f45e..cc69d17a34 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -52,18 +52,18 @@ Script.include("/~/system/libraries/controllers.js"); this.isPointingAtTabletOrWeb = function(controllerData, triggerPressed) { var intersection = controllerData.rayPicks[this.hand]; - if (intersection.type === Picks.INTERSECTED_OVERLAY) { - var objectID = intersection.objectID; - if ((HMD.tabletScreenID && objectID === HMD.tabletScreenID) || - (HMD.homeButtonID && objectID === HMD.homeButtonID)) { - return true; - } else { - var overlayType = Overlays.getOverlayType(objectID); - if (overlayType === "web3d") { - return true; - } - } - } else if (intersection.type === Picks.INTERSECTED_ENTITY) { + if (intersection.type === Picks.INTERSECTED_OVERLAY) { + var objectID = intersection.objectID; + if ((HMD.tabletScreenID && objectID === HMD.tabletScreenID) || + (HMD.homeButtonID && objectID === HMD.homeButtonID)) { + return true; + } else { + var overlayType = Overlays.getOverlayType(objectID); + if (overlayType === "web3d") { + return true; + } + } + } else if (intersection.type === Picks.INTERSECTED_ENTITY) { var entityProperty = Entities.getEntityProperties(intersection.objectID); var entityType = entityProperty.type; var isLocked = entityProperty.locked; @@ -100,8 +100,8 @@ Script.include("/~/system/libraries/controllers.js"); var otherModuleRunning = this.getOtherModule().running; otherModuleRunning = otherModuleRunning && this.getDominantHand() !== this.hand; // Auto-swap to dominant hand. var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE && - controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; - var allowThisModule = !otherModuleRunning || isTriggerPressed; + controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; + var allowThisModule = !otherModuleRunning || isTriggerPressed; if (allowThisModule && this.isPointingAtTabletOrWeb(controllerData, isTriggerPressed)) { this.updateAllwaysOn(); if (isTriggerPressed) { @@ -120,9 +120,9 @@ Script.include("/~/system/libraries/controllers.js"); otherModuleRunning = otherModuleRunning && this.getDominantHand() !== this.hand; // Auto-swap to dominant hand. otherModuleRunning = otherModuleRunning || this.getOtherModule().dominantHandOverride; // Override dominant hand. var grabModuleNeedsToRun = this.grabModuleWantsNearbyOverlay(controllerData); - var allowThisModule = !otherModuleRunning && !grabModuleNeedsToRun; - var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; - var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; + var allowThisModule = !otherModuleRunning && !grabModuleNeedsToRun; + var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; + var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; if (allowThisModule && (laserOn && this.isPointingAtTabletOrWeb(controllerData, isTriggerPressed))) { this.running = true; return makeRunningValues(true, [], []); From ed7f008517fd8ead9b0fd044a796fda0d394060c Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 30 May 2018 18:12:40 -0700 Subject: [PATCH 3/6] checking edge case of if input vectors are zero --- interface/src/ui/overlays/Billboardable.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/interface/src/ui/overlays/Billboardable.cpp b/interface/src/ui/overlays/Billboardable.cpp index 4ca024f2e5..28b6f65205 100644 --- a/interface/src/ui/overlays/Billboardable.cpp +++ b/interface/src/ui/overlays/Billboardable.cpp @@ -41,12 +41,14 @@ bool Billboardable::pointTransformAtCamera(Transform& transform, glm::quat offse glm::vec3 cameraPos = qApp->getCamera().getPosition(); // use the referencial from the avatar, y isn't always up glm::vec3 avatarUP = DependencyManager::get()->getMyAvatar()->getWorldOrientation()*Vectors::UP; - - glm::quat rotation(conjugate(toQuat(glm::lookAt(cameraPos, billboardPos, avatarUP)))); - - transform.setRotation(rotation); - transform.postRotate(offsetRotation); - return true; + glm::vec3 zeroPos{ 0.0f, 0.0f, 0.0f }; + if (!(glm::all(glm::equal(cameraPos, zeroPos)) || glm::all(glm::equal(billboardPos, zeroPos)) || + glm::all(glm::equal(avatarUP, zeroPos)))) { + glm::quat rotation(conjugate(toQuat(glm::lookAt(cameraPos, billboardPos, avatarUP)))); + transform.setRotation(rotation); + transform.postRotate(offsetRotation); + return true; + } } return false; } From 175e4b7013d6ab44bd603c0eddbebde554a93252 Mon Sep 17 00:00:00 2001 From: David Back Date: Mon, 18 Jun 2018 11:06:33 -0700 Subject: [PATCH 4/6] also check tabletID --- .../controllers/controllerModules/webSurfaceLaserInput.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index cc69d17a34..a8e30c51a8 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -54,7 +54,8 @@ Script.include("/~/system/libraries/controllers.js"); var intersection = controllerData.rayPicks[this.hand]; if (intersection.type === Picks.INTERSECTED_OVERLAY) { var objectID = intersection.objectID; - if ((HMD.tabletScreenID && objectID === HMD.tabletScreenID) || + if ((HMD.tabletID && objectID === HMD.tabletID) || + (HMD.tabletScreenID && objectID === HMD.tabletScreenID) || (HMD.homeButtonID && objectID === HMD.homeButtonID)) { return true; } else { From e381022910907f3185966ac2fa15de2deecbb2d2 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Mon, 18 Jun 2018 11:21:53 -0700 Subject: [PATCH 5/6] checking for NaN in cross products from vec3 positions --- interface/src/ui/overlays/Billboardable.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/interface/src/ui/overlays/Billboardable.cpp b/interface/src/ui/overlays/Billboardable.cpp index 28b6f65205..ea943590c7 100644 --- a/interface/src/ui/overlays/Billboardable.cpp +++ b/interface/src/ui/overlays/Billboardable.cpp @@ -41,9 +41,13 @@ bool Billboardable::pointTransformAtCamera(Transform& transform, glm::quat offse glm::vec3 cameraPos = qApp->getCamera().getPosition(); // use the referencial from the avatar, y isn't always up glm::vec3 avatarUP = DependencyManager::get()->getMyAvatar()->getWorldOrientation()*Vectors::UP; - glm::vec3 zeroPos{ 0.0f, 0.0f, 0.0f }; - if (!(glm::all(glm::equal(cameraPos, zeroPos)) || glm::all(glm::equal(billboardPos, zeroPos)) || - glm::all(glm::equal(avatarUP, zeroPos)))) { + // check to see if glm::lookAt will work / using glm::lookAt function names + + glm::highp_vec3 s(glm::cross(billboardPos - cameraPos, avatarUP)); + glm::highp_vec3 u(glm::cross(s, billboardPos - cameraPos)); + + // make sure s and u are not NaN for any component + if(glm::length2(s) > 0.0f && glm::length2(u) > 0.0f) { glm::quat rotation(conjugate(toQuat(glm::lookAt(cameraPos, billboardPos, avatarUP)))); transform.setRotation(rotation); transform.postRotate(offsetRotation); From 07e689f08619f6c237cc47f9c60b656cde71b911 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Mon, 18 Jun 2018 13:02:53 -0700 Subject: [PATCH 6/6] removing compute/check for u --- interface/src/ui/overlays/Billboardable.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/interface/src/ui/overlays/Billboardable.cpp b/interface/src/ui/overlays/Billboardable.cpp index ea943590c7..a125956b5a 100644 --- a/interface/src/ui/overlays/Billboardable.cpp +++ b/interface/src/ui/overlays/Billboardable.cpp @@ -41,13 +41,11 @@ bool Billboardable::pointTransformAtCamera(Transform& transform, glm::quat offse glm::vec3 cameraPos = qApp->getCamera().getPosition(); // use the referencial from the avatar, y isn't always up glm::vec3 avatarUP = DependencyManager::get()->getMyAvatar()->getWorldOrientation()*Vectors::UP; - // check to see if glm::lookAt will work / using glm::lookAt function names - + // check to see if glm::lookAt will work / using glm::lookAt variable name glm::highp_vec3 s(glm::cross(billboardPos - cameraPos, avatarUP)); - glm::highp_vec3 u(glm::cross(s, billboardPos - cameraPos)); - // make sure s and u are not NaN for any component - if(glm::length2(s) > 0.0f && glm::length2(u) > 0.0f) { + // make sure s is not NaN for any component + if(glm::length2(s) > 0.0f) { glm::quat rotation(conjugate(toQuat(glm::lookAt(cameraPos, billboardPos, avatarUP)))); transform.setRotation(rotation); transform.postRotate(offsetRotation);