From dd0a16df047d9472088c469defe6c7d486f6a803 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 30 Sep 2015 14:19:59 -0700 Subject: [PATCH] don't leave search state if we intersect something that someone else is already grabbing --- examples/actionInspector.js | 4 ++-- examples/controllers/handControllerGrab.js | 21 ++++++++++----------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/examples/actionInspector.js b/examples/actionInspector.js index 7e342b9e11..934120ddf6 100644 --- a/examples/actionInspector.js +++ b/examples/actionInspector.js @@ -49,8 +49,8 @@ function actionArgumentsToString(actionArguments) { function updateOverlay(entityID, actionText) { - var properties = Entities.getEntityProperties(entityID, ["position"]); - var position = Vec3.sum(properties.position, {x:0, y:1, z:0}); + var properties = Entities.getEntityProperties(entityID, ["position", "dimensions"]); + var position = Vec3.sum(properties.position, {x:0, y:properties.dimensions.y, z:0}); // print("position: " + vec3toStr(position) + " " + actionText); if (entityID in overlays) { var overlay = overlays[entityID]; diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index aaa894a887..4037ae66dc 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -273,7 +273,8 @@ function MyController(hand, triggerAction) { var intersection = Entities.findRayIntersection(pickRay, true); if (intersection.intersects && intersection.properties.collisionsWillMove === 1 && - intersection.properties.locked === 0) { + intersection.properties.locked === 0 && + !entityIsGrabbedByOther(intersection.entityID)) { // the ray is intersecting something we can move. var handControllerPosition = Controller.getSpatialControlPosition(this.palm); var intersectionDistance = Vec3.distance(handControllerPosition, intersection.intersection); @@ -342,16 +343,14 @@ function MyController(hand, triggerAction) { this.handPreviousRotation = handRotation; this.actionID = NULL_ACTION_ID; - if (!entityIsGrabbedByOther(this.grabbedEntity)) { - this.actionID = Entities.addAction("spring", this.grabbedEntity, { - targetPosition: this.currentObjectPosition, - linearTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME, - targetRotation: this.currentObjectRotation, - angularTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME, - tag: getTag(), - lifetime: 5 - }); - } + this.actionID = Entities.addAction("spring", this.grabbedEntity, { + targetPosition: this.currentObjectPosition, + linearTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME, + targetRotation: this.currentObjectRotation, + angularTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME, + tag: getTag(), + lifetime: 5 + }); if (this.actionID === NULL_ACTION_ID) { this.actionID = null; }