From 61f8631a2b250be47ea165848af0f80d55b7b3a6 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 14 Feb 2017 17:30:20 +1300 Subject: [PATCH 1/2] Fix far grabbing making entity jump upon grab --- scripts/system/controllers/handControllerGrab.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 527a9cfc2b..40959e19d6 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1987,9 +1987,11 @@ function MyController(hand) { this.clearEquipHaptics(); this.grabPointSphereOff(); - this.shouldScale = false; + this.shouldScale = false; - var worldControllerPosition = getControllerWorldLocation(this.handToController(), true).position; + var controllerLocation = getControllerWorldLocation(this.handToController(), true); + var worldControllerPosition = controllerLocation.position; + var worldControllerRotation = controllerLocation.orientation; // transform the position into room space var worldToSensorMat = Mat4.inverse(MyAvatar.getSensorToWorldMatrix()); @@ -2007,7 +2009,12 @@ function MyController(hand) { this.grabRadius = Vec3.distance(this.currentObjectPosition, worldControllerPosition); this.grabRadialVelocity = 0.0; - // compute a constant based on the initial conditions which we use below to exagerate hand motion + // offset between controller vector at the grab radius and the entity position + var targetPosition = Vec3.multiply(this.grabRadius, Quat.getUp(worldControllerRotation)); + targetPosition = Vec3.sum(targetPosition, worldControllerPosition); + this.offsetPosition = Vec3.subtract(this.currentObjectPosition, targetPosition); + + // compute a constant based on the initial conditions which we use below to exaggerate hand motion // onto the held object this.radiusScalar = Math.log(this.grabRadius + 1.0); if (this.radiusScalar < 1.0) { @@ -2124,6 +2131,7 @@ function MyController(hand) { var newTargetPosition = Vec3.multiply(this.grabRadius, Quat.getUp(worldControllerRotation)); newTargetPosition = Vec3.sum(newTargetPosition, worldControllerPosition); + newTargetPosition = Vec3.sum(newTargetPosition, this.offsetPosition); var objectToAvatar = Vec3.subtract(this.currentObjectPosition, MyAvatar.position); var handControllerData = getEntityCustomData('handControllerKey', this.grabbedEntity, defaultMoveWithHeadData); From 2672b8d10a24a0a3b8276ad3097eeccabcb0340a Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 14 Feb 2017 17:30:56 +1300 Subject: [PATCH 2/2] Fix tabs --- scripts/system/controllers/handControllerGrab.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 40959e19d6..f38d17fa2f 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1188,8 +1188,8 @@ function MyController(hand) { return; } } else { - this.homeButtonTouched = false; - } + this.homeButtonTouched = false; + } } else { this.hideStylus(); }