From 181901ed1930f11f25c2f3762ab43747501f838b Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 2 Nov 2015 14:42:28 -0800 Subject: [PATCH 1/3] distance grab works better with hmd on --- examples/controllers/handControllerGrab.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 9f7d579f10..b882777048 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -446,7 +446,7 @@ function MyController(hand) { this.currentObjectPosition = grabbedProperties.position; this.currentObjectRotation = grabbedProperties.rotation; this.currentObjectTime = now; - this.handPreviousPosition = handControllerPosition; + this.handRelativePreviousPosition = Vec3.subtract(handControllerPosition, MyAvatar.position); this.handPreviousRotation = handRotation; this.actionID = NULL_ACTION_ID; @@ -523,11 +523,10 @@ function MyController(hand) { this.currentAvatarOrientation = currentOrientation; // how far did hand move this timestep? - var handMoved = Vec3.subtract(handControllerPosition, this.handPreviousPosition); - this.handPreviousPosition = handControllerPosition; + var handMoved = Vec3.subtract(handToAvatar, this.handRelativePreviousPosition); + this.handRelativePreviousPosition = handToAvatar; // magnify the hand movement but not the change from avatar movement & rotation - handMoved = Vec3.subtract(handMoved, avatarDeltaPosition); handMoved = Vec3.subtract(handMoved, handMovementFromTurning); var superHandMoved = Vec3.multiply(handMoved, radius); From 0a5f43bba78732ad3d31bc031bcf21c5fde4dbad Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 2 Nov 2015 16:16:13 -0800 Subject: [PATCH 2/3] fix up boolean test --- examples/controllers/handControllerGrab.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index b882777048..74c830616a 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -18,7 +18,7 @@ Script.include("../libraries/utils.js"); // // add lines where the hand ray picking is happening // -var WANT_DEBUG = false; +var WANT_DEBUG = true; // // these tune time-averaging and "on" value for analog trigger @@ -352,14 +352,14 @@ function MyController(hand) { var intersection = Entities.findRayIntersection(pickRayBacked, true); - if (intersection.intersects && intersection.properties.locked === 0) { + if (intersection.intersects && !intersection.properties.locked) { // the ray is intersecting something we can move. var intersectionDistance = Vec3.distance(pickRay.origin, intersection.intersection); this.grabbedEntity = intersection.entityID; //this code will disabled the beam for the opposite hand of the one that grabbed it if the entity says so var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, intersection.entityID, DEFAULT_GRABBABLE_DATA); - if (grabbableData["turnOffOppositeBeam"] === true) { + if (grabbableData["turnOffOppositeBeam"]) { if (this.hand === RIGHT_HAND) { disabledHand = LEFT_HAND; } else { @@ -369,7 +369,7 @@ function MyController(hand) { disabledHand = 'none'; } - if (grabbableData.grabbable === false) { + if (!grabbableData.grabbable) { this.grabbedEntity = null; continue; } @@ -391,7 +391,7 @@ function MyController(hand) { this.grabbedEntity = null; } else { // the hand is far from the intersected object. go into distance-holding mode - if (intersection.properties.collisionsWillMove === 1) { + if (intersection.properties.collisionsWillMove) { this.setState(STATE_DISTANCE_HOLDING); } else { this.setState(STATE_FAR_GRABBING_NON_COLLIDING); @@ -409,7 +409,7 @@ function MyController(hand) { for (i = 0; i < nearbyEntities.length; i++) { var grabbableDataForCandidate = getEntityCustomData(GRABBABLE_DATA_KEY, nearbyEntities[i], DEFAULT_GRABBABLE_DATA); - if (grabbableDataForCandidate.grabbable === false) { + if (!grabbableDataForCandidate.grabbable) { continue; } var propsForCandidate = @@ -427,7 +427,7 @@ function MyController(hand) { } if (grabbableData.wantsTrigger) { this.setState(STATE_NEAR_GRABBING_NON_COLLIDING); - } else if (props.locked === 0) { + } else if (!props.locked) { this.setState(STATE_NEAR_GRABBING); } } @@ -569,7 +569,7 @@ function MyController(hand) { var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedEntity, DEFAULT_GRABBABLE_DATA); var turnOffOtherHand = grabbableData["turnOffOtherHand"]; - if (turnOffOtherHand === true) { + if (turnOffOtherHand) { //don't activate the second hand grab because the script is handling the second hand logic return; } @@ -782,11 +782,11 @@ function MyController(hand) { // we haven't been touched before, but either right or left is touching us now _this.allTouchedIDs[id] = true; _this.startTouch(id); - } else if ((leftIsTouching || rightIsTouching) && _this.allTouchedIDs[id] === true) { + } else if ((leftIsTouching || rightIsTouching) && _this.allTouchedIDs[id]) { // we have been touched before and are still being touched // continue touch _this.continueTouch(id); - } else if (_this.allTouchedIDs[id] === true) { + } else if (_this.allTouchedIDs[id]) { delete _this.allTouchedIDs[id]; _this.stopTouch(id); From fe2c0effd04099c4c6cd256cb74af6b40f0667ef Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 2 Nov 2015 16:17:46 -0800 Subject: [PATCH 3/3] oops left debug on --- examples/controllers/handControllerGrab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 74c830616a..30c99f43f8 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -18,7 +18,7 @@ Script.include("../libraries/utils.js"); // // add lines where the hand ray picking is happening // -var WANT_DEBUG = true; +var WANT_DEBUG = false; // // these tune time-averaging and "on" value for analog trigger