From ed1c974f755edae363e0d1934ce18f5ef87d4e0d Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 17 Oct 2017 15:58:51 +1300 Subject: [PATCH] Use MyAvatar.SELF_ID instead of Uuid.SELF --- interface/src/avatar/MyAvatar.h | 9 +++++++-- libraries/script-engine/src/ScriptUUID.h | 6 +----- scripts/system/away.js | 2 +- scripts/system/controllers/controllerDisplay.js | 4 ++-- scripts/system/libraries/WebTablet.js | 4 ++-- scripts/system/libraries/controllerDispatcherUtils.js | 6 +++--- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 952315a85f..6e735c6357 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -106,6 +106,8 @@ class MyAvatar : public Avatar { * "scripts/system/controllers/toggleAdvancedMovementForHandControllers.js". * @property userHeight {number} The height of the user in sensor space. (meters). * @property userEyeHeight {number} Estimated height of the users eyes in sensor space. (meters) + * @property SELF_ID {string} READ-ONLY. UUID representing "my avatar". Only use for local-only entities and overlays in situations where MyAvatar.sessionUUID is not available (e.g., if not connected to a domain). + * Note: Likely to be deprecated. */ // FIXME: `glm::vec3 position` is not accessible from QML, so this exposes position in a QML-native type @@ -152,6 +154,8 @@ class MyAvatar : public Avatar { Q_PROPERTY(float userHeight READ getUserHeight WRITE setUserHeight) Q_PROPERTY(float userEyeHeight READ getUserEyeHeight) + + Q_PROPERTY(QString SELF_ID READ SELF_UUID CONSTANT) const QString DOMINANT_LEFT_HAND = "left"; const QString DOMINANT_RIGHT_HAND = "right"; @@ -648,8 +652,6 @@ private: void setVisibleInSceneIfReady(Model* model, const render::ScenePointer& scene, bool visiblity); -private: - virtual void updatePalms() override {} void lateUpdatePalms(); @@ -826,6 +828,9 @@ private: // height of user in sensor space, when standing erect. ThreadSafeValueCache _userHeight { DEFAULT_AVATAR_HEIGHT }; + + const QString SELF_UUID() { return SELF_ID; } + const QString SELF_ID { AVATAR_SELF_ID.toString() }; }; QScriptValue audioListenModeToScriptValue(QScriptEngine* engine, const AudioListenerMode& audioListenerMode); diff --git a/libraries/script-engine/src/ScriptUUID.h b/libraries/script-engine/src/ScriptUUID.h index e5360754ae..3f504c35ba 100644 --- a/libraries/script-engine/src/ScriptUUID.h +++ b/libraries/script-engine/src/ScriptUUID.h @@ -21,7 +21,6 @@ class ScriptUUID : public QObject, protected QScriptable { Q_OBJECT Q_PROPERTY(QString NULL READ NULL_UUID CONSTANT) // String for use in scripts. - Q_PROPERTY(QString SELF READ SELF_UUID CONSTANT) public slots: QUuid fromString(const QString& string); @@ -33,10 +32,7 @@ public slots: private: const QString NULL_UUID() { return NULL_ID; } - const QString SELF_UUID() { return SELF_ID; } - - const QString NULL_ID{ "{00000000-0000-0000-0000-000000000000}" }; - const QString SELF_ID{ AVATAR_SELF_ID.toString() }; + const QString NULL_ID { "{00000000-0000-0000-0000-000000000000}" }; }; #endif // hifi_ScriptUUID_h diff --git a/scripts/system/away.js b/scripts/system/away.js index 38589050f2..2a45786d0d 100644 --- a/scripts/system/away.js +++ b/scripts/system/away.js @@ -43,7 +43,7 @@ var OVERLAY_DATA_HMD = { scale: 2 * MyAvatar.sensorToWorldScale, emissive: true, drawInFront: true, - parentID: Uuid.SELF, + parentID: MyAvatar.SELF_ID, parentJointIndex: CAMERA_MATRIX }; diff --git a/scripts/system/controllers/controllerDisplay.js b/scripts/system/controllers/controllerDisplay.js index 0296243018..dc7c9b37bd 100644 --- a/scripts/system/controllers/controllerDisplay.js +++ b/scripts/system/controllers/controllerDisplay.js @@ -176,7 +176,7 @@ createControllerDisplay = function(config) { dimensions: Vec3.multiply(sensorScaleFactor, controller.dimensions), localRotation: controller.rotation, localPosition: Vec3.multiply(sensorScaleFactor, position), - parentID: Uuid.SELF, + parentID: MyAvatar.SELF_ID, parentJointIndex: controller.jointIndex, ignoreRayIntersection: true }); @@ -196,7 +196,7 @@ createControllerDisplay = function(config) { url: part.modelURL, localPosition: partPosition, localRotation: innerRotation, - parentID: Uuid.SELF, + parentID: MyAvatar.SELF_ID, parentJointIndex: controller.jointIndex, ignoreRayIntersection: true }; diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index ba5d5962d8..c46cfaa073 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -99,7 +99,7 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) { "grabbableKey": {"grabbable": true} }), dimensions: { x: tabletWidth, y: tabletHeight, z: tabletDepth }, - parentID: Uuid.SELF, + parentID: MyAvatar.SELF_ID, visible: visible }; @@ -470,7 +470,7 @@ WebTablet.prototype.register = function() { WebTablet.prototype.cleanUpOldTabletsOnJoint = function(jointIndex) { var children = Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, jointIndex); - children = children.concat(Entities.getChildrenIDsOfJoint(Uuid.SELF, jointIndex)); + children = children.concat(Entities.getChildrenIDsOfJoint(MyAvatar.SELF_ID, jointIndex)); children.forEach(function(childID) { var props = Entities.getEntityProperties(childID, ["name"]); if (props.name === "WebTablet Tablet") { diff --git a/scripts/system/libraries/controllerDispatcherUtils.js b/scripts/system/libraries/controllerDispatcherUtils.js index 03af4c8253..cd3f1a711f 100644 --- a/scripts/system/libraries/controllerDispatcherUtils.js +++ b/scripts/system/libraries/controllerDispatcherUtils.js @@ -311,19 +311,19 @@ findHandChildEntities = function(hand) { // find children of avatar's hand joint var handJointIndex = MyAvatar.getJointIndex(hand === RIGHT_HAND ? "RightHand" : "LeftHand"); var children = Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, handJointIndex); - children = children.concat(Entities.getChildrenIDsOfJoint(Uuid.SELF, handJointIndex)); + children = children.concat(Entities.getChildrenIDsOfJoint(MyAvatar.SELF_ID, handJointIndex)); // find children of faux controller joint var controllerJointIndex = getControllerJointIndex(hand); children = children.concat(Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, controllerJointIndex)); - children = children.concat(Entities.getChildrenIDsOfJoint(Uuid.SELF, controllerJointIndex)); + children = children.concat(Entities.getChildrenIDsOfJoint(MyAvatar.SELF_ID, controllerJointIndex)); // find children of faux camera-relative controller joint var controllerCRJointIndex = MyAvatar.getJointIndex(hand === RIGHT_HAND ? "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND"); children = children.concat(Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, controllerCRJointIndex)); - children = children.concat(Entities.getChildrenIDsOfJoint(Uuid.SELF, controllerCRJointIndex)); + children = children.concat(Entities.getChildrenIDsOfJoint(MyAvatar.SELF_ID, controllerCRJointIndex)); return children.filter(function (childID) { var childType = Entities.getNestableType(childID);