From 3b61e8518ff734dad7f99e7695fef971acc0aebc Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 15 Aug 2017 14:46:48 -0700 Subject: [PATCH] near-trigger works? equip calls its entity methods now --- .../system/controllers/controllerDispatcherUtils.js | 7 +++++-- .../controllers/controllerModules/equipEntity.js | 10 ++++++++-- .../controllers/controllerModules/nearTrigger.js | 13 +++++-------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/scripts/system/controllers/controllerDispatcherUtils.js b/scripts/system/controllers/controllerDispatcherUtils.js index 913faf60bf..a1bf2726da 100644 --- a/scripts/system/controllers/controllerDispatcherUtils.js +++ b/scripts/system/controllers/controllerDispatcherUtils.js @@ -148,8 +148,8 @@ getGrabbableData = function (props) { } catch (err) { userDataParsed = {}; } - if (userDataParsed.grabbable) { - grabbableData = userDataParsed.grabbable; + if (userDataParsed.grabbableKey) { + grabbableData = userDataParsed.grabbableKey; } if (!grabbableData.hasOwnProperty("grabbable")) { grabbableData.grabbable = true; @@ -163,6 +163,9 @@ getGrabbableData = function (props) { if (!grabbableData.hasOwnProperty("wantsTrigger")) { grabbableData.wantsTrigger = false; } + if (!grabbableData.hasOwnProperty("triggerable")) { + grabbableData.triggerable = false; + } return grabbableData; }; diff --git a/scripts/system/controllers/controllerModules/equipEntity.js b/scripts/system/controllers/controllerModules/equipEntity.js index 34db9709b3..823247ea29 100644 --- a/scripts/system/controllers/controllerModules/equipEntity.js +++ b/scripts/system/controllers/controllerModules/equipEntity.js @@ -461,13 +461,16 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa var reparentProps = { parentID: AVATAR_SELF_ID, parentJointIndex: handJointIndex, - velocity: {x: 0, y: 0, z: 0}, - angularVelocity: {x: 0, y: 0, z: 0}, + localVelocity: {x: 0, y: 0, z: 0}, + localAngularVelocity: {x: 0, y: 0, z: 0}, localPosition: this.offsetPosition, localRotation: this.offsetRotation }; Entities.editEntity(this.targetEntityID, reparentProps); + var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID]; + Entities.callEntityMethod(this.targetEntityID, "startEquip", args); + Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({ action: 'equip', grabbedEntity: this.targetEntityID, @@ -594,6 +597,9 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa equipHotspotBuddy.update(deltaTime, timestamp, controllerData); + var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID]; + Entities.callEntityMethod(this.targetEntityID, "continueEquip", args); + return makeRunningValues(true, [this.targetEntityID], []); }; diff --git a/scripts/system/controllers/controllerModules/nearTrigger.js b/scripts/system/controllers/controllerModules/nearTrigger.js index 93f509c6b4..fbaa300e82 100644 --- a/scripts/system/controllers/controllerModules/nearTrigger.js +++ b/scripts/system/controllers/controllerModules/nearTrigger.js @@ -16,7 +16,8 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js"); (function() { function entityWantsNearTrigger(props) { - return getGrabbableData(props).triggerable; + var grabbableData = getGrabbableData(props); + return grabbableData.triggerable || grabbableData.wantsTrigger; } function NearTriggerEntity(hand) { @@ -40,21 +41,17 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js"); var props = nearbyEntityProperties[i]; var handPosition = controllerData.controllerLocations[this.hand].position; var distance = Vec3.distance(props.position, handPosition); - // if (distance > NEAR_GRAB_RADIUS) { - // print("QQQ nop 0"); - // break; - // } + if (distance > NEAR_GRAB_RADIUS) { + break; + } if (entityWantsNearTrigger(props)) { return props; - } else { - print("QQQ nop 1"); } } return null; }; this.startNearTrigger = function (controllerData) { - Controller.triggerShortHapticPulse(1.0, this.hand); var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID]; Entities.callEntityMethod(this.targetEntityID, "startNearTrigger", args); };