From dc22b579f749827f6b278af15a38cd29247dbe7b Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 5 Aug 2016 15:28:37 -0700 Subject: [PATCH 1/4] adjust code that auto-unequips items when they are pulled too far from the equipping hand --- .../system/controllers/handControllerGrab.js | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 9e11f839b3..b17a2354a7 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -107,7 +107,10 @@ var NEAR_GRAB_PICK_RADIUS = 0.25; // radius used for search ray vs object for ne var PICK_BACKOFF_DISTANCE = 0.2; // helps when hand is intersecting the grabble object var NEAR_GRABBING_KINEMATIC = true; // force objects to be kinematic when near-grabbed -var CHECK_TOO_FAR_UNEQUIP_TIME = 1.0; // seconds + +// if an equipped item is "adjusted" to be too far from the hand it's in, it will be unequipped. +var CHECK_TOO_FAR_UNEQUIP_TIME = 0.3; // seconds, duration between checks +var AUTO_UNEQUIP_DISTANCE_FACTOR = 1.2; // multiplied by maximum dimention of held item, > this means drop // // other constants @@ -220,6 +223,17 @@ CONTROLLER_STATE_MACHINE[STATE_FAR_TRIGGER] = { updateMethod: "farTrigger" }; +function getMaxDimensions(props) { + var maxDimension = props.dimensions.x; + if (props.dimensions.y > maxDimension) { + maxDimension = props.dimensions.y; + } + if (props.dimensions.z > maxDimension) { + maxDimension = props.dimensions.z; + } + return maxDimension; +} + function stateToName(state) { return CONTROLLER_STATE_MACHINE[state] ? CONTROLLER_STATE_MACHINE[state].name : "???"; } @@ -1818,7 +1832,8 @@ function MyController(hand) { this.heartBeat(this.grabbedEntity); - var props = Entities.getEntityProperties(this.grabbedEntity, ["localPosition", "parentID", "position", "rotation"]); + var props = Entities.getEntityProperties(this.grabbedEntity, ["localPosition", "parentID", + "position", "rotation", "dimensions"]); if (!props.position) { // server may have reset, taking our equipped entity with it. move back to "off" stte this.callEntityMethodOnGrabbed("releaseGrab"); @@ -1830,10 +1845,11 @@ function MyController(hand) { if (now - this.lastUnequipCheckTime > MSECS_PER_SEC * CHECK_TOO_FAR_UNEQUIP_TIME) { this.lastUnequipCheckTime = now; + var maxDimension = getMaxDimensions(props); if (props.parentID == MyAvatar.sessionUUID && - Vec3.length(props.localPosition) > NEAR_GRAB_MAX_DISTANCE) { + Vec3.length(props.localPosition) > maxDimension * AUTO_UNEQUIP_DISTANCE_FACTOR) { var handPosition = this.getHandPosition(); - // the center of the equipped object being far from the hand isn't enough to autoequip -- we also + // the center of the equipped object being far from the hand isn't enough to auto-unequip -- we also // need to fail the findEntities test. var nearPickedCandidateEntities = Entities.findEntities(handPosition, NEAR_GRAB_RADIUS); if (nearPickedCandidateEntities.indexOf(this.grabbedEntity) == -1) { @@ -2416,4 +2432,4 @@ function cleanup() { } Script.scriptEnding.connect(cleanup); -Script.update.connect(update); \ No newline at end of file +Script.update.connect(update); From e59c010642a4e376c293cbe7d677d50f1cbf6d73 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 5 Aug 2016 15:39:20 -0700 Subject: [PATCH 2/4] speling --- scripts/system/controllers/handControllerGrab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index b17a2354a7..ea95422c7f 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -110,7 +110,7 @@ var NEAR_GRABBING_KINEMATIC = true; // force objects to be kinematic when near-g // if an equipped item is "adjusted" to be too far from the hand it's in, it will be unequipped. var CHECK_TOO_FAR_UNEQUIP_TIME = 0.3; // seconds, duration between checks -var AUTO_UNEQUIP_DISTANCE_FACTOR = 1.2; // multiplied by maximum dimention of held item, > this means drop +var AUTO_UNEQUIP_DISTANCE_FACTOR = 1.2; // multiplied by maximum dimension of held item, > this means drop // // other constants From 090a0a6e9a7f9fc85184f80bb76410ec80172b51 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 5 Aug 2016 18:01:48 -0700 Subject: [PATCH 3/4] only use hand-sphere vs equipped-item bounding box when deciding to auto-unequip --- scripts/system/controllers/handControllerGrab.js | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index ea95422c7f..f29fdfb00a 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -223,17 +223,6 @@ CONTROLLER_STATE_MACHINE[STATE_FAR_TRIGGER] = { updateMethod: "farTrigger" }; -function getMaxDimensions(props) { - var maxDimension = props.dimensions.x; - if (props.dimensions.y > maxDimension) { - maxDimension = props.dimensions.y; - } - if (props.dimensions.z > maxDimension) { - maxDimension = props.dimensions.z; - } - return maxDimension; -} - function stateToName(state) { return CONTROLLER_STATE_MACHINE[state] ? CONTROLLER_STATE_MACHINE[state].name : "???"; } @@ -1845,9 +1834,7 @@ function MyController(hand) { if (now - this.lastUnequipCheckTime > MSECS_PER_SEC * CHECK_TOO_FAR_UNEQUIP_TIME) { this.lastUnequipCheckTime = now; - var maxDimension = getMaxDimensions(props); - if (props.parentID == MyAvatar.sessionUUID && - Vec3.length(props.localPosition) > maxDimension * AUTO_UNEQUIP_DISTANCE_FACTOR) { + if (props.parentID == MyAvatar.sessionUUID) { var handPosition = this.getHandPosition(); // the center of the equipped object being far from the hand isn't enough to auto-unequip -- we also // need to fail the findEntities test. From f348b56106247f067467fd1dd705d55ce9da561d Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 5 Aug 2016 18:16:48 -0700 Subject: [PATCH 4/4] remove hidden attribute from advanced settings button --- domain-server/resources/web/settings/index.shtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domain-server/resources/web/settings/index.shtml b/domain-server/resources/web/settings/index.shtml index 4c937d6139..802038d806 100644 --- a/domain-server/resources/web/settings/index.shtml +++ b/domain-server/resources/web/settings/index.shtml @@ -25,7 +25,7 @@ - +