From 7bc3435cfa5d17ae37531e2265860bdbde7ee328 Mon Sep 17 00:00:00 2001 From: volansystech Date: Thu, 13 Apr 2017 02:51:30 +0530 Subject: [PATCH] Initial Commit.. If distanceToObject from avatar is more than 15, we are accelarting entity travel by 2x. This will help user to grab the entity in lesser time. --- .../system/controllers/handControllerGrab.js | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 9a6760a37b..307c7fba16 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -75,7 +75,8 @@ var WEB_TOUCH_Y_OFFSET = 0.05; // how far forward (or back with a negative numbe // // distant manipulation // - +var shouldTravelAtRapidPace = false; +var accelarationStartingPoint = 0; var DISTANCE_HOLDING_RADIUS_FACTOR = 3.5; // multiplied by distance between hand and object 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 @@ -2524,7 +2525,19 @@ function MyController(hand) { // compute the mass for the purpose of energy and how quickly to move object this.mass = this.getMass(grabbedProperties.dimensions, grabbedProperties.density); + this.shouldTravelAtRapidPace = false; var distanceToObject = Vec3.length(Vec3.subtract(MyAvatar.position, grabbedProperties.position)); + + if(distanceToObject >= 15){ // Apply Rapid Pace only if distanceToObject is far than 15. + this.shouldTravelAtRapidPace = true; + var MyAvatarHipsPosition = MyAvatar.getJointPosition("Hips"); + var distanceToHandFromAvatarHips = worldControllerPosition.x - MyAvatarHipsPosition.x; + var ACCELERATION_START_THRESHOLD = 0.90; + this.accelarationStartingPoint = (distanceToHandFromAvatarHips * ACCELERATION_START_THRESHOLD); + }else{ + this.shouldTravelAtRapidPace = false; + } + var timeScale = this.distanceGrabTimescale(this.mass, distanceToObject); this.actionID = NULL_UUID; @@ -2619,16 +2632,22 @@ function MyController(hand) { this.grabRadius * RADIAL_GRAB_AMPLIFIER); } + if(this.shouldTravelAtRapidPace = true){ + var MyAvatarHipsPosition = MyAvatar.getJointPosition("Hips"); + var distanceToHandFromAvatarHips_x = worldControllerPosition.x - MyAvatarHipsPosition.x; + if(distanceToHandFromAvatarHips_x <= this.accelarationStartingPoint){ + var RAPID_PACE_RATE = 2; + this.grabRadius = (this.grabRadius / RAPID_PACE_RATE); + } + } // don't let grabRadius go all the way to zero, because it can't come back from that var MINIMUM_GRAB_RADIUS = 0.1; if (this.grabRadius < MINIMUM_GRAB_RADIUS) { this.grabRadius = MINIMUM_GRAB_RADIUS; } - 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.grabbedThingID, defaultMoveWithHeadData); if (handControllerData.disableMoveWithHead !== true) {