From 6d2181f0f137d8789efabb341bb5b64053edbcd1 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Mon, 13 Jun 2016 11:59:38 -0700 Subject: [PATCH 1/8] Combine DISTANCE_HOLDING and CONTINUE_DISTANCE_HOLDING states. --- .../system/controllers/handControllerGrab.js | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 25cd100991..f4bcefe3ac 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -157,20 +157,19 @@ var STATE_OFF = 0; var STATE_SEARCHING = 1; var STATE_HOLD_SEARCHING = 2; var STATE_DISTANCE_HOLDING = 3; -var STATE_CONTINUE_DISTANCE_HOLDING = 4; -var STATE_NEAR_GRABBING = 5; -var STATE_CONTINUE_NEAR_GRABBING = 6; -var STATE_NEAR_TRIGGER = 7; -var STATE_CONTINUE_NEAR_TRIGGER = 8; -var STATE_FAR_TRIGGER = 9; -var STATE_CONTINUE_FAR_TRIGGER = 10; -var STATE_RELEASE = 11; -var STATE_EQUIP = 12; -var STATE_HOLD = 13; -var STATE_CONTINUE_HOLD = 14; -var STATE_CONTINUE_EQUIP = 15; -var STATE_WAITING_FOR_RELEASE_THUMB_RELEASE = 16; -var STATE_WAITING_FOR_EQUIP_THUMB_RELEASE = 17; +var STATE_NEAR_GRABBING = 4; +var STATE_CONTINUE_NEAR_GRABBING = 5; +var STATE_NEAR_TRIGGER = 6; +var STATE_CONTINUE_NEAR_TRIGGER = 7; +var STATE_FAR_TRIGGER = 8; +var STATE_CONTINUE_FAR_TRIGGER = 9; +var STATE_RELEASE = 10; +var STATE_EQUIP = 11; +var STATE_HOLD = 12; +var STATE_CONTINUE_HOLD = 13; +var STATE_CONTINUE_EQUIP = 14; +var STATE_WAITING_FOR_RELEASE_THUMB_RELEASE = 15; +var STATE_WAITING_FOR_EQUIP_THUMB_RELEASE = 16; // "collidesWith" is specified by comma-separated list of group names // the possible group names are: static, dynamic, kinematic, myAvatar, otherAvatar @@ -198,12 +197,9 @@ CONTROLLER_STATE_MACHINE[STATE_HOLD_SEARCHING] = { }; CONTROLLER_STATE_MACHINE[STATE_DISTANCE_HOLDING] = { name: "distance_holding", + enterMethod: "distanceHoldingEnter", updateMethod: "distanceHolding" }; -CONTROLLER_STATE_MACHINE[STATE_CONTINUE_DISTANCE_HOLDING] = { - name: "continue_distance_holding", - updateMethod: "continueDistanceHolding" -}; CONTROLLER_STATE_MACHINE[STATE_NEAR_GRABBING] = { name: "near_grabbing", updateMethod: "nearGrabbing" @@ -1207,7 +1203,7 @@ function MyController(hand) { return (dimensions.x * dimensions.y * dimensions.z) * density; } - this.distanceHolding = function() { + this.distanceHoldingEnter = function() { // controller pose is in avatar frame var avatarControllerPose = @@ -1256,9 +1252,12 @@ function MyController(hand) { this.actionTimeout = now + (ACTION_TTL * MSECS_PER_SEC); if (this.actionID !== null) { - this.setState(STATE_CONTINUE_DISTANCE_HOLDING); this.activateEntity(this.grabbedEntity, grabbedProperties, false); this.callEntityMethodOnGrabbed("startDistanceGrab"); + } else { + // addAction failed? + this.setState(STATE_RELEASE); + return; } this.turnOffVisualizations(); @@ -1267,7 +1266,7 @@ function MyController(hand) { this.previousControllerRotation = controllerRotation; }; - this.continueDistanceHolding = function() { + this.distanceHolding = function() { if (this.triggerSmoothedReleased() && this.secondaryReleased()) { this.setState(STATE_RELEASE); this.callEntityMethodOnGrabbed("releaseGrab"); From bd3326d2fc45c66da5e403de99d4d1f905c8539c Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Mon, 13 Jun 2016 13:59:10 -0700 Subject: [PATCH 2/8] Collapse continueNearGrabbing and nearGrabbing into a single state. * Moved the update logic from STATE_NEAR_GRABBING, STATE_HOLD & STATE_EQUIP into the entryMethods for those states. * Removed STATE_CONTINUE_NEAR_GRABBING, STATE_CONTINUE_HOLD & STATE_CONTINUE_EQUIP states This functionality has been moved into the updateMethod for their respective states. This *should* be a pure re-factor no functionality was changed. --- .../system/controllers/handControllerGrab.js | 76 +++++-------------- 1 file changed, 19 insertions(+), 57 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index f4bcefe3ac..3e611b9f00 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -19,7 +19,7 @@ Script.include("/~/system/libraries/utils.js"); // add lines where the hand ray picking is happening // var WANT_DEBUG = false; -var WANT_DEBUG_STATE = false; +var WANT_DEBUG_STATE = true; var WANT_DEBUG_SEARCH_NAME = null; // @@ -158,7 +158,6 @@ var STATE_SEARCHING = 1; var STATE_HOLD_SEARCHING = 2; var STATE_DISTANCE_HOLDING = 3; var STATE_NEAR_GRABBING = 4; -var STATE_CONTINUE_NEAR_GRABBING = 5; var STATE_NEAR_TRIGGER = 6; var STATE_CONTINUE_NEAR_TRIGGER = 7; var STATE_FAR_TRIGGER = 8; @@ -166,8 +165,6 @@ var STATE_CONTINUE_FAR_TRIGGER = 9; var STATE_RELEASE = 10; var STATE_EQUIP = 11; var STATE_HOLD = 12; -var STATE_CONTINUE_HOLD = 13; -var STATE_CONTINUE_EQUIP = 14; var STATE_WAITING_FOR_RELEASE_THUMB_RELEASE = 15; var STATE_WAITING_FOR_EQUIP_THUMB_RELEASE = 16; @@ -202,27 +199,18 @@ CONTROLLER_STATE_MACHINE[STATE_DISTANCE_HOLDING] = { }; CONTROLLER_STATE_MACHINE[STATE_NEAR_GRABBING] = { name: "near_grabbing", + enterMethod: "nearGrabbingEnter", updateMethod: "nearGrabbing" }; CONTROLLER_STATE_MACHINE[STATE_EQUIP] = { name: "equip", + enterMethod: "nearGrabbingEnter", updateMethod: "nearGrabbing" }; CONTROLLER_STATE_MACHINE[STATE_HOLD] = { - name: "hold", - updateMethod: "nearGrabbing" -}; -CONTROLLER_STATE_MACHINE[STATE_CONTINUE_NEAR_GRABBING] = { - name: "continue_near_grabbing", - updateMethod: "continueNearGrabbing" -}; -CONTROLLER_STATE_MACHINE[STATE_CONTINUE_HOLD] = { name: "continue_hold", - updateMethod: "continueNearGrabbing" -}; -CONTROLLER_STATE_MACHINE[STATE_CONTINUE_EQUIP] = { - name: "continue_equip", - updateMethod: "continueNearGrabbing" + enterMethod: "nearGrabbingEnter", + updateMethod: "nearGrabbing" }; CONTROLLER_STATE_MACHINE[STATE_NEAR_TRIGGER] = { name: "near_trigger", @@ -400,6 +388,8 @@ function MyController(hand) { print("WARNING: could not find state " + this.state + " in state machine"); } + this.state = newState; + // enter the new state if (CONTROLLER_STATE_MACHINE[newState]) { var enterMethodName = CONTROLLER_STATE_MACHINE[newState].enterMethod; @@ -410,8 +400,6 @@ function MyController(hand) { } else { print("WARNING: could not find newState " + newState + " in state machine"); } - - this.state = newState; }; this.debugLine = function(closePoint, farPoint, color) { @@ -1254,10 +1242,6 @@ function MyController(hand) { if (this.actionID !== null) { this.activateEntity(this.grabbedEntity, grabbedProperties, false); this.callEntityMethodOnGrabbed("startDistanceGrab"); - } else { - // addAction failed? - this.setState(STATE_RELEASE); - return; } this.turnOffVisualizations(); @@ -1483,20 +1467,9 @@ function MyController(hand) { } } - this.nearGrabbing = function() { + this.nearGrabbingEnter = function() { var now = Date.now(); - if (this.state == STATE_NEAR_GRABBING && this.triggerSmoothedReleased()) { - this.setState(STATE_RELEASE); - this.callEntityMethodOnGrabbed("releaseGrab"); - return; - } - if (this.state == STATE_HOLD && this.secondaryReleased()) { - this.setState(STATE_RELEASE); - this.callEntityMethodOnGrabbed("releaseGrab"); - return; - } - this.lineOff(); this.overlayLineOff(); @@ -1578,17 +1551,6 @@ function MyController(hand) { this.callEntityMethodOnGrabbed("startEquip"); } - if (this.state == STATE_NEAR_GRABBING) { - // near grabbing - this.setState(STATE_CONTINUE_NEAR_GRABBING); - } else if (this.state == STATE_HOLD) { - // holding - this.setState(STATE_CONTINUE_HOLD); - } else { // (this.state == STATE_EQUIP) - // equipping - this.setState(STATE_CONTINUE_EQUIP); - } - this.currentHandControllerTipPosition = (this.hand === RIGHT_HAND) ? MyAvatar.rightHandTipPosition : MyAvatar.leftHandTipPosition; this.currentObjectTime = Date.now(); @@ -1599,29 +1561,29 @@ function MyController(hand) { this.currentAngularVelocity = ZERO_VEC; }; - this.continueNearGrabbing = function() { - if (this.state == STATE_CONTINUE_NEAR_GRABBING && this.triggerSmoothedReleased()) { + this.nearGrabbing = function() { + if (this.state == STATE_NEAR_GRABBING && this.triggerSmoothedReleased()) { this.setState(STATE_RELEASE); this.callEntityMethodOnGrabbed("releaseGrab"); return; } - if (this.state == STATE_CONTINUE_HOLD && this.secondaryReleased()) { + if (this.state == STATE_HOLD && this.secondaryReleased()) { this.setState(STATE_RELEASE); this.callEntityMethodOnGrabbed("releaseEquip"); return; } - if (this.state == STATE_CONTINUE_EQUIP && this.thumbPressed()) { + if (this.state == STATE_EQUIP && this.thumbPressed()) { this.setState(STATE_WAITING_FOR_RELEASE_THUMB_RELEASE); this.callEntityMethodOnGrabbed("releaseEquip"); return; } - if (this.state == STATE_CONTINUE_NEAR_GRABBING && this.thumbPressed()) { + if (this.state == STATE_NEAR_GRABBING && this.thumbPressed()) { this.setState(STATE_WAITING_FOR_EQUIP_THUMB_RELEASE); this.callEntityMethodOnGrabbed("releaseGrab"); this.callEntityMethodOnGrabbed("startEquip"); return; } - if (this.state == STATE_CONTINUE_HOLD && this.thumbPressed()) { + if (this.state == STATE_HOLD && this.thumbPressed()) { this.setState(STATE_WAITING_FOR_EQUIP_THUMB_RELEASE); return; } @@ -1652,9 +1614,9 @@ function MyController(hand) { print("handControllerGrab -- autoreleasing held or equipped item because it is far from hand." + props.parentID + " " + vec3toStr(props.position)); this.setState(STATE_RELEASE); - if (this.state == STATE_CONTINUE_NEAR_GRABBING) { + if (this.state == STATE_NEAR_GRABBING) { this.callEntityMethodOnGrabbed("releaseGrab"); - } else { // (this.state == STATE_CONTINUE_EQUIP || this.state == STATE_CONTINUE_HOLD) + } else { // (this.state == STATE_EQUIP || this.state == STATE_HOLD) this.callEntityMethodOnGrabbed("releaseEquip"); } return; @@ -1693,10 +1655,10 @@ function MyController(hand) { this.currentObjectTime = now; var grabData = getEntityCustomData(GRAB_USER_DATA_KEY, this.grabbedEntity, {}); - if (this.state === STATE_CONTINUE_EQUIP || this.state === STATE_CONTINUE_HOLD) { + if (this.state === STATE_EQUIP || this.state === STATE_HOLD) { this.callEntityMethodOnGrabbed("continueEquip"); } - if (this.state == STATE_CONTINUE_NEAR_GRABBING) { + if (this.state == STATE_NEAR_GRABBING) { this.callEntityMethodOnGrabbed("continueNearGrab"); } @@ -2029,7 +1991,7 @@ function MyController(hand) { this.activateEntity(this.grabbedEntity, loadedProps, true); this.isInitialGrab = true; this.callEntityMethodOnGrabbed("startEquip"); - this.setState(STATE_CONTINUE_EQUIP); + this.setState(STATE_EQUIP); } } }; From fe65df350bc23282cd5d3260a9de69dafba6efb1 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Mon, 13 Jun 2016 15:05:34 -0700 Subject: [PATCH 3/8] Combined the release and off states. --- .../system/controllers/handControllerGrab.js | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 3e611b9f00..386a4905f1 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -162,7 +162,6 @@ var STATE_NEAR_TRIGGER = 6; var STATE_CONTINUE_NEAR_TRIGGER = 7; var STATE_FAR_TRIGGER = 8; var STATE_CONTINUE_FAR_TRIGGER = 9; -var STATE_RELEASE = 10; var STATE_EQUIP = 11; var STATE_HOLD = 12; var STATE_WAITING_FOR_RELEASE_THUMB_RELEASE = 15; @@ -180,6 +179,7 @@ var CONTROLLER_STATE_MACHINE = {}; CONTROLLER_STATE_MACHINE[STATE_OFF] = { name: "off", + enterMethod: "offEnter", updateMethod: "off" }; CONTROLLER_STATE_MACHINE[STATE_SEARCHING] = { @@ -228,10 +228,6 @@ CONTROLLER_STATE_MACHINE[STATE_CONTINUE_FAR_TRIGGER] = { name: "continue_far_trigger", updateMethod: "continueFarTrigger" }; -CONTROLLER_STATE_MACHINE[STATE_RELEASE] = { - name: "release", - updateMethod: "release" -}; CONTROLLER_STATE_MACHINE[STATE_WAITING_FOR_EQUIP_THUMB_RELEASE] = { name: "waiting_for_equip_thumb_release", updateMethod: "waitingForEquipThumbRelease" @@ -918,12 +914,12 @@ function MyController(hand) { this.checkForStrayChildren(); if (this.state == STATE_SEARCHING && this.triggerSmoothedReleased()) { - this.setState(STATE_RELEASE); + this.setState(STATE_OFF); return; } if (this.state == STATE_HOLD_SEARCHING && this.secondaryReleased()) { - this.setState(STATE_RELEASE); + this.setState(STATE_OFF); return; } @@ -1252,7 +1248,7 @@ function MyController(hand) { this.distanceHolding = function() { if (this.triggerSmoothedReleased() && this.secondaryReleased()) { - this.setState(STATE_RELEASE); + this.setState(STATE_OFF); this.callEntityMethodOnGrabbed("releaseGrab"); return; } @@ -1563,12 +1559,12 @@ function MyController(hand) { this.nearGrabbing = function() { if (this.state == STATE_NEAR_GRABBING && this.triggerSmoothedReleased()) { - this.setState(STATE_RELEASE); + this.setState(STATE_OFF); this.callEntityMethodOnGrabbed("releaseGrab"); return; } if (this.state == STATE_HOLD && this.secondaryReleased()) { - this.setState(STATE_RELEASE); + this.setState(STATE_OFF); this.callEntityMethodOnGrabbed("releaseEquip"); return; } @@ -1593,7 +1589,7 @@ function MyController(hand) { var props = Entities.getEntityProperties(this.grabbedEntity, ["localPosition", "parentID", "position", "rotation"]); if (!props.position) { // server may have reset, taking our equipped entity with it. move back to "off" stte - this.setState(STATE_RELEASE); + this.setState(STATE_OFF); this.callEntityMethodOnGrabbed("releaseGrab"); return; } @@ -1613,7 +1609,7 @@ function MyController(hand) { // for whatever reason, the held/equipped entity has been pulled away. ungrab or unequip. print("handControllerGrab -- autoreleasing held or equipped item because it is far from hand." + props.parentID + " " + vec3toStr(props.position)); - this.setState(STATE_RELEASE); + this.setState(STATE_OFF); if (this.state == STATE_NEAR_GRABBING) { this.callEntityMethodOnGrabbed("releaseGrab"); } else { // (this.state == STATE_EQUIP || this.state == STATE_HOLD) @@ -1691,13 +1687,13 @@ function MyController(hand) { }; this.waitingForReleaseThumbRelease = function() { if (this.thumbReleased() && this.triggerSmoothedReleased()) { - this.setState(STATE_RELEASE); + this.setState(STATE_OFF); } }; this.nearTrigger = function() { if (this.triggerSmoothedReleased() && this.secondaryReleased()) { - this.setState(STATE_RELEASE); + this.setState(STATE_OFF); this.callEntityMethodOnGrabbed("stopNearTrigger"); return; } @@ -1707,7 +1703,7 @@ function MyController(hand) { this.farTrigger = function() { if (this.triggerSmoothedReleased() && this.secondaryReleased()) { - this.setState(STATE_RELEASE); + this.setState(STATE_OFF); this.callEntityMethodOnGrabbed("stopFarTrigger"); return; } @@ -1717,7 +1713,7 @@ function MyController(hand) { this.continueNearTrigger = function() { if (this.triggerSmoothedReleased() && this.secondaryReleased()) { - this.setState(STATE_RELEASE); + this.setState(STATE_OFF); this.callEntityMethodOnGrabbed("stopNearTrigger"); return; } @@ -1726,7 +1722,7 @@ function MyController(hand) { this.continueFarTrigger = function() { if (this.triggerSmoothedReleased() && this.secondaryReleased()) { - this.setState(STATE_RELEASE); + this.setState(STATE_OFF); this.callEntityMethodOnGrabbed("stopFarTrigger"); return; } @@ -1743,7 +1739,7 @@ function MyController(hand) { if (intersection.accurate) { this.lastPickTime = now; if (intersection.entityID != this.grabbedEntity) { - this.setState(STATE_RELEASE); + this.setState(STATE_OFF); this.callEntityMethodOnGrabbed("stopFarTrigger"); return; } @@ -1757,7 +1753,7 @@ function MyController(hand) { this.callEntityMethodOnGrabbed("continueFarTrigger"); }; - this.release = function() { + this.offEnter = function() { this.turnLightsOff(); this.turnOffVisualizations(); @@ -1780,7 +1776,6 @@ function MyController(hand) { this.deactivateEntity(this.grabbedEntity, noVelocity); this.actionID = null; - this.setState(STATE_OFF); Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({ action: 'release', From b01eb0439df25f813f1f7f9d329bd1cda0266cc5 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Mon, 13 Jun 2016 16:49:38 -0700 Subject: [PATCH 4/8] removed sticky thumb equip states. * removed STATE_WAITING_FOR_EQUIP_THUMB_RELEASE and waitingForEquipThumbRelease * removed STATE_EQUIP * removed STATE_WAITING_FOR_RELEASE_THUMB_RELEASE and waitingForReleaseThumbRelease * removed 'Hifi-Object-Manipulation' 'loaded' support and checkNewlyLoaded method. --- .../system/controllers/handControllerGrab.js | 84 ++++--------------- 1 file changed, 14 insertions(+), 70 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 386a4905f1..2857c91936 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -158,14 +158,11 @@ var STATE_SEARCHING = 1; var STATE_HOLD_SEARCHING = 2; var STATE_DISTANCE_HOLDING = 3; var STATE_NEAR_GRABBING = 4; -var STATE_NEAR_TRIGGER = 6; -var STATE_CONTINUE_NEAR_TRIGGER = 7; -var STATE_FAR_TRIGGER = 8; -var STATE_CONTINUE_FAR_TRIGGER = 9; -var STATE_EQUIP = 11; -var STATE_HOLD = 12; -var STATE_WAITING_FOR_RELEASE_THUMB_RELEASE = 15; -var STATE_WAITING_FOR_EQUIP_THUMB_RELEASE = 16; +var STATE_NEAR_TRIGGER = 4; +var STATE_CONTINUE_NEAR_TRIGGER = 6; +var STATE_FAR_TRIGGER = 7; +var STATE_CONTINUE_FAR_TRIGGER = 8; +var STATE_HOLD = 9; // "collidesWith" is specified by comma-separated list of group names // the possible group names are: static, dynamic, kinematic, myAvatar, otherAvatar @@ -202,11 +199,6 @@ CONTROLLER_STATE_MACHINE[STATE_NEAR_GRABBING] = { enterMethod: "nearGrabbingEnter", updateMethod: "nearGrabbing" }; -CONTROLLER_STATE_MACHINE[STATE_EQUIP] = { - name: "equip", - enterMethod: "nearGrabbingEnter", - updateMethod: "nearGrabbing" -}; CONTROLLER_STATE_MACHINE[STATE_HOLD] = { name: "continue_hold", enterMethod: "nearGrabbingEnter", @@ -228,14 +220,6 @@ CONTROLLER_STATE_MACHINE[STATE_CONTINUE_FAR_TRIGGER] = { name: "continue_far_trigger", updateMethod: "continueFarTrigger" }; -CONTROLLER_STATE_MACHINE[STATE_WAITING_FOR_EQUIP_THUMB_RELEASE] = { - name: "waiting_for_equip_thumb_release", - updateMethod: "waitingForEquipThumbRelease" -}; -CONTROLLER_STATE_MACHINE[STATE_WAITING_FOR_RELEASE_THUMB_RELEASE] = { - name: "waiting_for_release_thumb_release", - updateMethod: "waitingForReleaseThumbRelease" -}; function stateToName(state) { return CONTROLLER_STATE_MACHINE[state] ? CONTROLLER_STATE_MACHINE[state].name : "???"; @@ -1483,7 +1467,7 @@ function MyController(hand) { var handPosition = this.getHandPosition(); var hasPresetPosition = false; - if ((this.state == STATE_EQUIP || this.state == STATE_HOLD) && this.hasPresetOffsets()) { + if (this.state == STATE_HOLD && this.hasPresetOffsets()) { var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedEntity, DEFAULT_GRABBABLE_DATA); // if an object is "equipped" and has a predefined offset, use it. this.ignoreIK = grabbableData.ignoreIK ? grabbableData.ignoreIK : false; @@ -1499,7 +1483,7 @@ function MyController(hand) { var currentObjectPosition = grabbedProperties.position; var offset = Vec3.subtract(currentObjectPosition, handPosition); this.offsetPosition = Vec3.multiplyQbyV(Quat.inverse(Quat.multiply(handRotation, this.offsetRotation)), offset); - if (this.temporaryPositionOffset && (this.state == STATE_EQUIP)) { + if (this.temporaryPositionOffset) { this.offsetPosition = this.temporaryPositionOffset; // hasPresetPosition = true; } @@ -1543,7 +1527,7 @@ function MyController(hand) { if (this.state == STATE_NEAR_GRABBING) { this.callEntityMethodOnGrabbed("startNearGrab"); - } else { // this.state == STATE_EQUIP || this.state == STATE_HOLD + } else { // this.state == STATE_HOLD this.callEntityMethodOnGrabbed("startEquip"); } @@ -1568,21 +1552,6 @@ function MyController(hand) { this.callEntityMethodOnGrabbed("releaseEquip"); return; } - if (this.state == STATE_EQUIP && this.thumbPressed()) { - this.setState(STATE_WAITING_FOR_RELEASE_THUMB_RELEASE); - this.callEntityMethodOnGrabbed("releaseEquip"); - return; - } - if (this.state == STATE_NEAR_GRABBING && this.thumbPressed()) { - this.setState(STATE_WAITING_FOR_EQUIP_THUMB_RELEASE); - this.callEntityMethodOnGrabbed("releaseGrab"); - this.callEntityMethodOnGrabbed("startEquip"); - return; - } - if (this.state == STATE_HOLD && this.thumbPressed()) { - this.setState(STATE_WAITING_FOR_EQUIP_THUMB_RELEASE); - return; - } this.heartBeat(this.grabbedEntity); @@ -1612,7 +1581,7 @@ function MyController(hand) { this.setState(STATE_OFF); if (this.state == STATE_NEAR_GRABBING) { this.callEntityMethodOnGrabbed("releaseGrab"); - } else { // (this.state == STATE_EQUIP || this.state == STATE_HOLD) + } else { // this.state == STATE_HOLD this.callEntityMethodOnGrabbed("releaseEquip"); } return; @@ -1651,7 +1620,7 @@ function MyController(hand) { this.currentObjectTime = now; var grabData = getEntityCustomData(GRAB_USER_DATA_KEY, this.grabbedEntity, {}); - if (this.state === STATE_EQUIP || this.state === STATE_HOLD) { + if (this.state === STATE_HOLD) { this.callEntityMethodOnGrabbed("continueEquip"); } if (this.state == STATE_NEAR_GRABBING) { @@ -1680,17 +1649,6 @@ function MyController(hand) { } }; - this.waitingForEquipThumbRelease = function() { - if (this.thumbReleased() && this.triggerSmoothedReleased()) { - this.setState(STATE_EQUIP); - } - }; - this.waitingForReleaseThumbRelease = function() { - if (this.thumbReleased() && this.triggerSmoothedReleased()) { - this.setState(STATE_OFF); - } - }; - this.nearTrigger = function() { if (this.triggerSmoothedReleased() && this.secondaryReleased()) { this.setState(STATE_OFF); @@ -1968,6 +1926,8 @@ function MyController(hand) { setEntityCustomData(GRAB_USER_DATA_KEY, entityID, data); }; + // AJT: WTF TO DO WITH THIS? + /* this.checkNewlyLoaded = function(loadedEntityID) { if (this.state == STATE_OFF || this.state == STATE_SEARCHING || @@ -1989,6 +1949,7 @@ function MyController(hand) { this.setState(STATE_EQUIP); } } + */ }; var rightController = new MyController(RIGHT_HAND); @@ -2044,7 +2005,7 @@ handleHandMessages = function(channel, message, sender) { var data = JSON.parse(message); var selectedController = (data.hand === 'left') ? leftController : rightController; selectedController.release(); - selectedController.setState(STATE_EQUIP); + selectedController.setState(STATE_HOLD); selectedController.grabbedEntity = data.entityID; } catch (e) {} @@ -2066,23 +2027,6 @@ handleHandMessages = function(channel, message, sender) { } } catch (e) {} - } else if (channel === 'Hifi-Object-Manipulation') { - if (sender !== MyAvatar.sessionUUID) { - return; - } - - var parsedMessage = null; - try { - parsedMessage = JSON.parse(message); - } catch (e) { - print('error parsing Hifi-Object-Manipulation message'); - return; - } - - if (parsedMessage.action === 'loaded') { - rightController.checkNewlyLoaded(parsedMessage['grabbedEntity']); - leftController.checkNewlyLoaded(parsedMessage['grabbedEntity']); - } } } } From 28b6cc2777a577474a027ace28b350e948bf70b3 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Mon, 13 Jun 2016 18:54:21 -0700 Subject: [PATCH 5/8] handControllerGrab.js is now eslint clean. --- .../system/controllers/handControllerGrab.js | 127 ++++++------------ 1 file changed, 43 insertions(+), 84 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 2857c91936..34d4ca6294 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -10,7 +10,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 print, MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, Audio, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt, pointInExtents, vec3equal, setEntityCustomData, getEntityCustomData */ +/*global print, MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, Audio, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, Reticle, Messages, setEntityCustomData, getEntityCustomData, vec3toStr */ Script.include("/~/system/libraries/utils.js"); @@ -47,7 +47,6 @@ var DISTANCE_HOLDING_RADIUS_FACTOR = 3.5; // multiplied by distance between hand var DISTANCE_HOLDING_ACTION_TIMEFRAME = 0.1; // how quickly objects move to their new position var DISTANCE_HOLDING_UNITY_MASS = 1200; // The mass at which the distance holding action timeframe is unmodified var DISTANCE_HOLDING_UNITY_DISTANCE = 6; // The distance at which the distance holding action timeframe is unmodified -var DISTANCE_HOLDING_ROTATION_EXAGGERATION_FACTOR = 2.0; // object rotates this much more than hand did var MOVE_WITH_HEAD = true; // experimental head-control of distantly held objects var FAR_TO_NEAR_GRAB_PADDING_FACTOR = 1.2; @@ -81,13 +80,6 @@ var NEAR_GRABBING_KINEMATIC = true; // force objects to be kinematic when near-g var SHOW_GRAB_SPHERE = false; // draw a green sphere to show the grab search position and size var CHECK_TOO_FAR_UNEQUIP_TIME = 1.0; // seconds -// -// equip -// - -var EQUIP_SPRING_SHUTOFF_DISTANCE = 0.05; -var EQUIP_SPRING_TIMEFRAME = 0.4; // how quickly objects move to their new position - // // other constants // @@ -158,7 +150,7 @@ var STATE_SEARCHING = 1; var STATE_HOLD_SEARCHING = 2; var STATE_DISTANCE_HOLDING = 3; var STATE_NEAR_GRABBING = 4; -var STATE_NEAR_TRIGGER = 4; +var STATE_NEAR_TRIGGER = 5; var STATE_CONTINUE_NEAR_TRIGGER = 6; var STATE_FAR_TRIGGER = 7; var STATE_CONTINUE_FAR_TRIGGER = 8; @@ -200,7 +192,7 @@ CONTROLLER_STATE_MACHINE[STATE_NEAR_GRABBING] = { updateMethod: "nearGrabbing" }; CONTROLLER_STATE_MACHINE[STATE_HOLD] = { - name: "continue_hold", + name: "hold", enterMethod: "nearGrabbingEnter", updateMethod: "nearGrabbing" }; @@ -505,7 +497,7 @@ function MyController(hand) { this.overlayLine = Overlays.addOverlay("line3d", lineProperties); } else { - var success = Overlays.editOverlay(this.overlayLine, { + Overlays.editOverlay(this.overlayLine, { lineWidth: 5, start: closePoint, end: farPoint, @@ -621,13 +613,6 @@ function MyController(hand) { }) }; - this.renewParticleBeamLifetime = function() { - var props = Entities.getEntityProperties(this.particleBeamObject, "age"); - Entities.editEntity(this.particleBeamObject, { - lifetime: TEMPORARY_PARTICLE_BEAM_LIFETIME + props.age // renew lifetime - }) - } - this.evalLightWorldTransform = function(modelPos, modelRot) { var MODEL_LIGHT_POSITION = { @@ -648,7 +633,7 @@ function MyController(hand) { }; }; - this.handleSpotlight = function(parentID, position) { + this.handleSpotlight = function(parentID) { var LIFETIME = 100; var modelProperties = Entities.getEntityProperties(parentID, ['position', 'rotation']); @@ -672,7 +657,7 @@ function MyController(hand) { exponent: 0.3, cutoff: 20, lifetime: LIFETIME, - position: lightTransform.p, + position: lightTransform.p }; if (this.spotlight === null) { @@ -680,12 +665,12 @@ function MyController(hand) { } else { Entities.editEntity(this.spotlight, { //without this, this light would maintain rotation with its parent - rotation: Quat.fromPitchYawRollDegrees(-90, 0, 0), + rotation: Quat.fromPitchYawRollDegrees(-90, 0, 0) }) } }; - this.handlePointLight = function(parentID, position) { + this.handlePointLight = function(parentID) { var LIFETIME = 100; var modelProperties = Entities.getEntityProperties(parentID, ['position', 'rotation']); @@ -709,13 +694,11 @@ function MyController(hand) { exponent: 0.3, cutoff: 20, lifetime: LIFETIME, - position: lightTransform.p, + position: lightTransform.p }; if (this.pointlight === null) { this.pointlight = Entities.addEntity(lightProperties); - } else { - } }; @@ -915,12 +898,9 @@ function MyController(hand) { } var controllerHandInput = (this.hand === RIGHT_HAND) ? Controller.Standard.RightHand : Controller.Standard.LeftHand; - var currentHandRotation = Controller.getPoseValue(controllerHandInput).rotation; var currentControllerPosition = Vec3.sum(Vec3.multiplyQbyV(MyAvatar.orientation, Controller.getPoseValue(controllerHandInput).translation), MyAvatar.position); - var handDeltaRotation = Quat.multiply(currentHandRotation, Quat.inverse(this.startingHandRotation)); - var avatarControllerPose = Controller.getPoseValue((this.hand === RIGHT_HAND) ? Controller.Standard.RightHand : Controller.Standard.LeftHand); var controllerRotation = Quat.multiply(MyAvatar.orientation, avatarControllerPose.rotation); @@ -941,7 +921,7 @@ function MyController(hand) { this.lastPickTime = now; } - rayPickedCandidateEntities = []; // the list of candidates to consider grabbing + var rayPickedCandidateEntities = []; // the list of candidates to consider grabbing this.intersectionDistance = 0.0; for (var index = 0; index < pickRays.length; ++index) { @@ -974,8 +954,8 @@ function MyController(hand) { } } - nearPickedCandidateEntities = Entities.findEntities(handPosition, GRAB_RADIUS); - candidateEntities = rayPickedCandidateEntities.concat(nearPickedCandidateEntities); + var nearPickedCandidateEntities = Entities.findEntities(handPosition, GRAB_RADIUS); + var candidateEntities = rayPickedCandidateEntities.concat(nearPickedCandidateEntities); var forbiddenNames = ["Grab Debug Entity", "grab pointer"]; var forbiddenTypes = ['Unknown', 'Light', 'PolyLine', 'Zone']; @@ -990,9 +970,9 @@ function MyController(hand) { var propsForCandidate = Entities.getEntityProperties(candidateEntities[i], GRABBABLE_PROPERTIES); var near = (nearPickedCandidateEntities.indexOf(candidateEntities[i]) >= 0); - var isPhysical = propsArePhysical(propsForCandidate); + var physical = propsArePhysical(propsForCandidate); var grabbable; - if (isPhysical) { + if (physical) { // physical things default to grabbable grabbable = true; } else { @@ -1051,7 +1031,7 @@ function MyController(hand) { } if (this.state == STATE_SEARCHING && - !isPhysical && distance > NEAR_PICK_MAX_DISTANCE && !near && !grabbableDataForCandidate.wantsTrigger) { + !physical && distance > NEAR_PICK_MAX_DISTANCE && !near && !grabbableDataForCandidate.wantsTrigger) { // we can't distance-grab non-physical if (WANT_DEBUG_SEARCH_NAME && propsForCandidate.name == WANT_DEBUG_SEARCH_NAME) { print("grab is skipping '" + WANT_DEBUG_SEARCH_NAME + "': not physical and too far for near-grab"); @@ -1068,18 +1048,18 @@ function MyController(hand) { } if ((this.grabbedEntity !== null) && (this.triggerSmoothedGrab() || this.secondarySqueezed())) { // We are squeezing enough to grab, and we've found an entity that we'll try to do something with. - var near = (nearPickedCandidateEntities.indexOf(this.grabbedEntity) >= 0) || minDistance <= NEAR_PICK_MAX_DISTANCE; + var isNear = (nearPickedCandidateEntities.indexOf(this.grabbedEntity) >= 0) || minDistance <= NEAR_PICK_MAX_DISTANCE; var isPhysical = propsArePhysical(props); // near or far trigger if (grabbableData.wantsTrigger) { - this.setState(near ? STATE_NEAR_TRIGGER : STATE_FAR_TRIGGER); + this.setState(isNear ? STATE_NEAR_TRIGGER : STATE_FAR_TRIGGER); return; } // near grab with action or equip var grabData = getEntityCustomData(GRAB_USER_DATA_KEY, this.grabbedEntity, {}); var refCount = ("refCount" in grabData) ? grabData.refCount : 0; - if (near && (refCount < 1 || entityHasActions(this.grabbedEntity))) { + if (isNear && (refCount < 1 || entityHasActions(this.grabbedEntity))) { if (this.state == STATE_SEARCHING) { this.setState(STATE_NEAR_GRABBING); } else { // (this.state == STATE_HOLD_SEARCHING) @@ -1092,7 +1072,7 @@ function MyController(hand) { return; } // far grab - if (isPhysical && !near) { + if (isPhysical && !isNear) { if (entityIsGrabbedByOther(this.grabbedEntity)) { // don't distance grab something that is already grabbed. if (WANT_DEBUG_SEARCH_NAME && props.name == WANT_DEBUG_SEARCH_NAME) { @@ -1142,9 +1122,6 @@ function MyController(hand) { } return; } - if (WANT_DEBUG_SEARCH_NAME && props.name == WANT_DEBUG_SEARCH_NAME) { - print("grab is skipping '" + WANT_DEBUG_SEARCH_NAME + "': fell through."); - } } //search line visualizations @@ -1266,10 +1243,13 @@ function MyController(hand) { radius); // double delta controller rotation + /* + var DISTANCE_HOLDING_ROTATION_EXAGGERATION_FACTOR = 2.0; // object rotates this much more than hand did var handChange = Quat.multiply(Quat.slerp(this.previousControllerRotation, controllerRotation, DISTANCE_HOLDING_ROTATION_EXAGGERATION_FACTOR), Quat.inverse(this.previousControllerRotation)); + */ // update the currentObject position and rotation. this.currentObjectPosition = Vec3.sum(this.currentObjectPosition, handMoved); @@ -1323,9 +1303,10 @@ function MyController(hand) { } } + /* var defaultConstraintData = { axisStart: false, - axisEnd: false, + axisEnd: false } var constraintData = getEntityCustomData('lightModifierKey', this.grabbedEntity, defaultConstraintData); @@ -1343,6 +1324,7 @@ function MyController(hand) { z: this.currentObjectPosition.z } } + */ var handPosition = this.getHandPosition(); @@ -1448,7 +1430,6 @@ function MyController(hand) { } this.nearGrabbingEnter = function() { - var now = Date.now(); this.lineOff(); this.overlayLineOff(); @@ -1503,7 +1484,7 @@ function MyController(hand) { // grab entity via parenting this.actionID = null; var handJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"); - reparentProps = { + var reparentProps = { parentID: MyAvatar.sessionUUID, parentJointIndex: handJointIndex } @@ -1573,7 +1554,7 @@ function MyController(hand) { var handPosition = this.getHandPosition(); // the center of the equipped object being far from the hand isn't enough to autoequip -- we also // need to fail the findEntities test. - nearPickedCandidateEntities = Entities.findEntities(handPosition, GRAB_RADIUS); + var nearPickedCandidateEntities = Entities.findEntities(handPosition, GRAB_RADIUS); if (nearPickedCandidateEntities.indexOf(this.grabbedEntity) == -1) { // for whatever reason, the held/equipped entity has been pulled away. ungrab or unequip. print("handControllerGrab -- autoreleasing held or equipped item because it is far from hand." + @@ -1597,9 +1578,7 @@ function MyController(hand) { // from the palm. var handControllerPosition = (this.hand === RIGHT_HAND) ? MyAvatar.rightHandPosition : MyAvatar.leftHandPosition; - var now = Date.now(); - var deltaPosition = Vec3.subtract(handControllerPosition, this.currentHandControllerTipPosition); // meters var deltaTime = (now - this.currentObjectTime) / MSECS_PER_SEC; // convert to seconds if (deltaTime > 0.0) { @@ -1619,7 +1598,6 @@ function MyController(hand) { this.currentHandControllerTipPosition = handControllerPosition; this.currentObjectTime = now; - var grabData = getEntityCustomData(GRAB_USER_DATA_KEY, this.grabbedEntity, {}); if (this.state === STATE_HOLD) { this.callEntityMethodOnGrabbed("continueEquip"); } @@ -1843,6 +1821,8 @@ function MyController(hand) { } this.deactivateEntity = function(entityID, noVelocity) { + var deactiveProps; + if (!this.entityActivated) { return; } @@ -1852,7 +1832,7 @@ function MyController(hand) { if (data && data["refCount"]) { data["refCount"] = data["refCount"] - 1; if (data["refCount"] < 1) { - var deactiveProps = { + deactiveProps = { gravity: data["gravity"], collidesWith: data["collidesWith"], collisionless: data["collisionless"], @@ -1865,7 +1845,6 @@ function MyController(hand) { // it looks like the dropped thing should fall, give it a little velocity. var props = Entities.getEntityProperties(entityID, ["parentID", "velocity", "dynamic", "shapeType"]) var parentID = props.parentID; - var forceVelocity = false; var doSetVelocity = false; if (parentID != NULL_UUID && deactiveProps.parentID == NULL_UUID && propsArePhysical(props)) { @@ -1900,7 +1879,7 @@ function MyController(hand) { // the parent causes it to go off in the wrong direction. This is a bug that should // be fixed. Entities.editEntity(entityID, { - velocity: this.currentVelocity, + velocity: this.currentVelocity // angularVelocity: this.currentAngularVelocity }); } @@ -1908,7 +1887,7 @@ function MyController(hand) { data = null; } else if (this.shouldResetParentOnRelease) { // we parent-grabbed this from another parent grab. try to put it back where we found it. - var deactiveProps = { + deactiveProps = { parentID: this.previousParentID, parentJointIndex: this.previousParentJointIndex, velocity: {x: 0.0, y: 0.0, z: 0.0}, @@ -1925,32 +1904,7 @@ function MyController(hand) { } setEntityCustomData(GRAB_USER_DATA_KEY, entityID, data); }; - - // AJT: WTF TO DO WITH THIS? - /* - this.checkNewlyLoaded = function(loadedEntityID) { - if (this.state == STATE_OFF || - this.state == STATE_SEARCHING || - this.state == STATE_HOLD_SEARCHING) { - var loadedProps = Entities.getEntityProperties(loadedEntityID); - if (loadedProps.parentID != MyAvatar.sessionUUID) { - return; - } - var handJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"); - if (loadedProps.parentJointIndex != handJointIndex) { - return; - } - print("--- handControllerGrab found loaded entity ---"); - // an entity has been loaded and it's where this script would have equipped something, so switch states. - this.grabbedEntity = loadedEntityID; - this.activateEntity(this.grabbedEntity, loadedProps, true); - this.isInitialGrab = true; - this.callEntityMethodOnGrabbed("startEquip"); - this.setState(STATE_EQUIP); - } - } - */ -}; +} var rightController = new MyController(RIGHT_HAND); var leftController = new MyController(LEFT_HAND); @@ -1988,7 +1942,8 @@ Messages.subscribe('Hifi-Hand-Grab'); Messages.subscribe('Hifi-Hand-RayPick-Blacklist'); Messages.subscribe('Hifi-Object-Manipulation'); -handleHandMessages = function(channel, message, sender) { +var handleHandMessages = function(channel, message, sender) { + var data; if (sender === MyAvatar.sessionUUID) { if (channel === 'Hifi-Hand-Disabler') { if (message === 'left') { @@ -2002,17 +1957,19 @@ handleHandMessages = function(channel, message, sender) { } } else if (channel === 'Hifi-Hand-Grab') { try { - var data = JSON.parse(message); + data = JSON.parse(message); var selectedController = (data.hand === 'left') ? leftController : rightController; selectedController.release(); selectedController.setState(STATE_HOLD); selectedController.grabbedEntity = data.entityID; - } catch (e) {} + } catch (e) { + print("WARNING: error parsing Hifi-Hand-Grab message"); + } } else if (channel === 'Hifi-Hand-RayPick-Blacklist') { try { - var data = JSON.parse(message); + data = JSON.parse(message); var action = data.action; var id = data.id; var index = blacklist.indexOf(id); @@ -2026,7 +1983,9 @@ handleHandMessages = function(channel, message, sender) { } } - } catch (e) {} + } catch (e) { + print("WARNING: error parsing Hifi-Hand-RayPick-Blacklist message"); + } } } } From f11735550fbeae426aa0f2675c80764a95d04b94 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Mon, 13 Jun 2016 18:55:53 -0700 Subject: [PATCH 6/8] Fix for Vive RIGHT_GRIP LEFT_GRIP button never becoming zero. --- plugins/openvr/src/ViveControllerManager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 4e17a2edf4..97c502454b 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -370,6 +370,10 @@ void ViveControllerManager::InputDevice::handleButtonEvent(float deltaTime, uint } else if (button == vr::k_EButton_SteamVR_Touchpad) { _buttonPressedMap.insert(isLeftHand ? LS : RS); } + } else { + if (button == vr::k_EButton_Grip) { + _axisStateMap[isLeftHand ? LEFT_GRIP : RIGHT_GRIP] = 0.0f; + } } if (touched) { From cb51d00c1d50090d43a1ae03eb236f3f8e2a8fdc Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Mon, 13 Jun 2016 19:08:33 -0700 Subject: [PATCH 7/8] Removed CONTINUE_FAR_TRIGGER and CONTINUE_NEAR_TRIGGER --- .../system/controllers/handControllerGrab.js | 38 +++++-------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 34d4ca6294..6daafa425f 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -151,10 +151,8 @@ var STATE_HOLD_SEARCHING = 2; var STATE_DISTANCE_HOLDING = 3; var STATE_NEAR_GRABBING = 4; var STATE_NEAR_TRIGGER = 5; -var STATE_CONTINUE_NEAR_TRIGGER = 6; -var STATE_FAR_TRIGGER = 7; -var STATE_CONTINUE_FAR_TRIGGER = 8; -var STATE_HOLD = 9; +var STATE_FAR_TRIGGER = 6; +var STATE_HOLD = 7; // "collidesWith" is specified by comma-separated list of group names // the possible group names are: static, dynamic, kinematic, myAvatar, otherAvatar @@ -197,21 +195,15 @@ CONTROLLER_STATE_MACHINE[STATE_HOLD] = { updateMethod: "nearGrabbing" }; CONTROLLER_STATE_MACHINE[STATE_NEAR_TRIGGER] = { - name: "near_trigger", + name: "trigger", + enterMethod: "nearTriggerEnter", updateMethod: "nearTrigger" }; -CONTROLLER_STATE_MACHINE[STATE_CONTINUE_NEAR_TRIGGER] = { - name: "continue_near_trigger", - updateMethod: "continueNearTrigger" -}; CONTROLLER_STATE_MACHINE[STATE_FAR_TRIGGER] = { name: "far_trigger", + enterMethod: "farTriggerEnter", updateMethod: "farTrigger" }; -CONTROLLER_STATE_MACHINE[STATE_CONTINUE_FAR_TRIGGER] = { - name: "continue_far_trigger", - updateMethod: "continueFarTrigger" -}; function stateToName(state) { return CONTROLLER_STATE_MACHINE[state] ? CONTROLLER_STATE_MACHINE[state].name : "???"; @@ -1627,27 +1619,15 @@ function MyController(hand) { } }; - this.nearTrigger = function() { - if (this.triggerSmoothedReleased() && this.secondaryReleased()) { - this.setState(STATE_OFF); - this.callEntityMethodOnGrabbed("stopNearTrigger"); - return; - } + this.nearTriggerEnter = function() { this.callEntityMethodOnGrabbed("startNearTrigger"); - this.setState(STATE_CONTINUE_NEAR_TRIGGER); }; - this.farTrigger = function() { - if (this.triggerSmoothedReleased() && this.secondaryReleased()) { - this.setState(STATE_OFF); - this.callEntityMethodOnGrabbed("stopFarTrigger"); - return; - } + this.farTriggerEnter = function() { this.callEntityMethodOnGrabbed("startFarTrigger"); - this.setState(STATE_CONTINUE_FAR_TRIGGER); }; - this.continueNearTrigger = function() { + this.nearTrigger = function() { if (this.triggerSmoothedReleased() && this.secondaryReleased()) { this.setState(STATE_OFF); this.callEntityMethodOnGrabbed("stopNearTrigger"); @@ -1656,7 +1636,7 @@ function MyController(hand) { this.callEntityMethodOnGrabbed("continueNearTrigger"); }; - this.continueFarTrigger = function() { + this.farTrigger = function() { if (this.triggerSmoothedReleased() && this.secondaryReleased()) { this.setState(STATE_OFF); this.callEntityMethodOnGrabbed("stopFarTrigger"); From 67aac09033d0e713adb1e41b4d5bd8dca2c607b2 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Tue, 14 Jun 2016 14:59:29 -0700 Subject: [PATCH 8/8] Set state debug flag to false --- 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 6daafa425f..6e39b16f82 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -19,7 +19,7 @@ Script.include("/~/system/libraries/utils.js"); // add lines where the hand ray picking is happening // var WANT_DEBUG = false; -var WANT_DEBUG_STATE = true; +var WANT_DEBUG_STATE = false; var WANT_DEBUG_SEARCH_NAME = null; //