From 55c062098a514350a5463d21c673f24e74fccbd1 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Wed, 19 Oct 2016 17:33:05 -0700 Subject: [PATCH] Adjustment to position and visibility of grab sphere. * The grab sphere used to detect near grabbing is now 10cm in radius instead of 4cm. * The visual representation of this grab sphere is always hidden, by default. * This representation can be enabled in via the "Developer > Show Grab Sphere" menu item. --- .../display-plugins/hmd/HmdDisplayPlugin.cpp | 6 +++--- .../system/controllers/handControllerGrab.js | 20 ++++++++++++++----- scripts/system/libraries/controllers.js | 9 ++------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp index 099e48dcd0..6f89c64f28 100644 --- a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp @@ -375,10 +375,10 @@ void HmdDisplayPlugin::updateFrameData() { castDirection = glm::inverse(_presentUiModelTransform.getRotation()) * castDirection; } - // this offset needs to match GRAB_POINT_SPHERE_OFFSET in scripts/system/libraries/controllers.js - static const vec3 GRAB_POINT_SPHERE_OFFSET(0.075f, 0.175f, 0.039f); + // this offset needs to match GRAB_POINT_SPHERE_OFFSET in scripts/system/libraries/controllers.js:19 + static const vec3 GRAB_POINT_SPHERE_OFFSET(0.04f, 0.13f, 0.039f); // x = upward, y = forward, z = lateral - // swizzle grab point so that (x = upward, y = inward, z = forward) + // swizzle grab point so that (x = upward, y = lateral, z = forward) vec3 grabPointOffset = glm::vec3(GRAB_POINT_SPHERE_OFFSET.x, GRAB_POINT_SPHERE_OFFSET.z, -GRAB_POINT_SPHERE_OFFSET.y); if (i == 0) { grabPointOffset.x *= -1.0f; // this changes between left and right hands diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 7ae14ce381..fb12455de7 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -11,7 +11,7 @@ // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -/* global setEntityCustomData, getEntityCustomData, flatten, Xform, Script, Quat, Vec3, MyAvatar, Entities, Overlays, Settings, Reticle, Controller, Camera, Messages, Mat4, getControllerWorldLocation, getGrabPointSphereOffset */ +/* global setEntityCustomData, getEntityCustomData, flatten, Xform, Script, Quat, Vec3, MyAvatar, Entities, Overlays, Settings, Reticle, Controller, Camera, Messages, Mat4, getControllerWorldLocation, getGrabPointSphereOffset, setGrabCommunications */ (function() { // BEGIN LOCAL_SCOPE @@ -27,7 +27,7 @@ var WANT_DEBUG_STATE = false; var WANT_DEBUG_SEARCH_NAME = null; var FORCE_IGNORE_IK = false; -var SHOW_GRAB_POINT_SPHERE = true; +var SHOW_GRAB_POINT_SPHERE = false; // // these tune time-averaging and "on" value for analog trigger @@ -101,7 +101,7 @@ var MAX_EQUIP_HOTSPOT_RADIUS = 1.0; var NEAR_GRABBING_ACTION_TIMEFRAME = 0.05; // how quickly objects move to their new position -var NEAR_GRAB_RADIUS = 0.04; // radius used for palm vs object for near grabbing. +var NEAR_GRAB_RADIUS = 0.1; // radius used for palm vs object for near grabbing. var NEAR_GRAB_MAX_DISTANCE = 1.0; // you cannot grab objects that are this far away from your hand var NEAR_GRAB_PICK_RADIUS = 0.25; // radius used for search ray vs object for near grabbing. @@ -111,7 +111,7 @@ var NEAR_GRABBING_KINEMATIC = true; // force objects to be kinematic when near-g var CHECK_TOO_FAR_UNEQUIP_TIME = 0.3; // seconds, duration between checks -var GRAB_POINT_SPHERE_RADIUS = NEAR_GRAB_RADIUS * 1.5; +var GRAB_POINT_SPHERE_RADIUS = NEAR_GRAB_RADIUS; var GRAB_POINT_SPHERE_COLOR = { red: 240, green: 240, blue: 240 }; var GRAB_POINT_SPHERE_ALPHA = 0.85; @@ -835,7 +835,7 @@ function MyController(hand) { this.grabPointSphere = Overlays.addOverlay("sphere", { localPosition: getGrabPointSphereOffset(this.handToController()), localRotation: { x: 0, y: 0, z: 0, w: 1 }, - dimensions: GRAB_POINT_SPHERE_RADIUS, + dimensions: GRAB_POINT_SPHERE_RADIUS * 2, color: GRAB_POINT_SPHERE_COLOR, alpha: GRAB_POINT_SPHERE_ALPHA, solid: true, @@ -2661,6 +2661,15 @@ mapping.from([Controller.Standard.RightPrimaryThumb]).peek().to(rightController. Controller.enableMapping(MAPPING_NAME); +function handleMenuEvent(menuItem) { + if (menuItem === "Show Grab Sphere") { + SHOW_GRAB_POINT_SPHERE = Menu.isOptionChecked("Show Grab Sphere"); + } +} + +Menu.addMenuItem({ menuName: "Developer", menuItemName: "Show Grab Sphere", isCheckable: true, isChecked: false }); +Menu.menuItemEvent.connect(handleMenuEvent); + // the section below allows the grab script to listen for messages // that disable either one or both hands. useful for two handed items var handToDisable = 'none'; @@ -2776,6 +2785,7 @@ var updateIntervalTimer = Script.setInterval(function(){ }, BASIC_TIMER_INTERVAL_MS); function cleanup() { + Menu.removeMenuItem("Developer", "Show Grab Sphere"); Script.clearInterval(updateIntervalTimer); rightController.cleanup(); leftController.cleanup(); diff --git a/scripts/system/libraries/controllers.js b/scripts/system/libraries/controllers.js index 5b3c3882d4..fb3d0302b7 100644 --- a/scripts/system/libraries/controllers.js +++ b/scripts/system/libraries/controllers.js @@ -15,13 +15,8 @@ getGrabCommunications = function getFarGrabCommunications() { return !!Settings.getValue(GRAB_COMMUNICATIONS_SETTING, ""); } - -// var GRAB_POINT_SPHERE_OFFSET = { x: 0, y: 0.2, z: 0 }; -// var GRAB_POINT_SPHERE_OFFSET = { x: 0.1, y: 0.175, z: 0.04 }; -// var GRAB_POINT_SPHERE_OFFSET = { x: 0.1, y: 0.32, z: 0.04 }; - -// this offset needs to match the one in libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp -var GRAB_POINT_SPHERE_OFFSET = { x: 0.075, y: 0.175, z: 0.039 }; // x = upward, y = forward, z = inward +// this offset needs to match the one in libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp:378 +var GRAB_POINT_SPHERE_OFFSET = { x: 0.04, y: 0.13, z: 0.039 }; // x = upward, y = forward, z = lateral getGrabPointSphereOffset = function(handController) { if (handController === Controller.Standard.RightHand) {