From 4b2fb546eb1615ad68200d441c556594e56f9644 Mon Sep 17 00:00:00 2001 From: Anthony Thibault Date: Sat, 16 Jul 2016 12:21:08 -0700 Subject: [PATCH] Re-enable storing of attach points in user settings * bug fix, use localOffset property of grabbed entity, which is dynamically updated as the near grab action moves the entity. --- .../system/controllers/handControllerGrab.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 66c9e10795..36b0725f45 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -271,8 +271,7 @@ function propsArePhysical(props) { return isPhysical; } -// currently disabled. -var USE_ATTACH_POINT_SETTINGS = false; +var USE_ATTACH_POINT_SETTINGS = true; var ATTACH_POINT_SETTINGS = "io.highfidelity.attachPoints"; function getAttachPointSettings() { @@ -2091,16 +2090,10 @@ function MyController(hand) { this.holdExit = function () { // store the offset attach points into preferences. if (USE_ATTACH_POINT_SETTINGS && this.grabbedHotspot && this.grabbedEntity) { - entityPropertiesCache.addEntity(this.grabbedEntity); - var props = entityPropertiesCache.getProps(this.grabbedEntity); - var entityXform = new Xform(props.rotation, props.position); - var avatarXform = new Xform(MyAvatar.orientation, MyAvatar.position); - var handRot = (this.hand === RIGHT_HAND) ? MyAvatar.getRightPalmRotation() : MyAvatar.getLeftPalmRotation(); - var avatarHandPos = (this.hand === RIGHT_HAND) ? MyAvatar.rightHandPosition : MyAvatar.leftHandPosition; - var palmXform = new Xform(handRot, avatarXform.xformPoint(avatarHandPos)); - var offsetXform = Xform.mul(palmXform.inv(), entityXform); - - storeAttachPointForHotspotInSettings(this.grabbedHotspot, this.hand, offsetXform.pos, offsetXform.rot); + var props = Entities.getEntityProperties(this.grabbedEntity, ["localPosition", "localRotation"]); + if (props && props.localPosition && props.localRotation) { + storeAttachPointForHotspotInSettings(this.grabbedHotspot, this.hand, props.localPosition, props.localRotation); + } } };