diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 952315a85f..16ed9ea5b4 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -16,6 +16,8 @@ #include +#include + #include #include #include @@ -106,6 +108,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 +156,8 @@ class MyAvatar : public Avatar { Q_PROPERTY(float userHeight READ getUserHeight WRITE setUserHeight) Q_PROPERTY(float userEyeHeight READ getUserEyeHeight) + + Q_PROPERTY(QUuid SELF_ID READ getSelfID CONSTANT) const QString DOMINANT_LEFT_HAND = "left"; const QString DOMINANT_RIGHT_HAND = "right"; @@ -546,6 +552,8 @@ public: virtual SpatialParentTree* getParentTree() const override; + const QUuid& getSelfID() const { return AVATAR_SELF_ID; } + public slots: void increaseSize(); void decreaseSize(); @@ -648,8 +656,6 @@ private: void setVisibleInSceneIfReady(Model* model, const render::ScenePointer& scene, bool visiblity); -private: - virtual void updatePalms() override {} void lateUpdatePalms(); diff --git a/libraries/script-engine/src/Quat.h b/libraries/script-engine/src/Quat.h index 3b3a6fde7c..d3fb2ed5c2 100644 --- a/libraries/script-engine/src/Quat.h +++ b/libraries/script-engine/src/Quat.h @@ -33,6 +33,7 @@ /// Scriptable interface a Quaternion helper class object. Used exclusively in the JavaScript API class Quat : public QObject, protected QScriptable { Q_OBJECT + Q_PROPERTY(glm::quat IDENTITY READ IDENTITY CONSTANT) public slots: glm::quat multiply(const glm::quat& q1, const glm::quat& q2); @@ -63,6 +64,10 @@ public slots: bool equal(const glm::quat& q1, const glm::quat& q2); glm::quat cancelOutRollAndPitch(const glm::quat& q); glm::quat cancelOutRoll(const glm::quat& q); + +private: + const glm::quat& IDENTITY() const { return Quaternions::IDENTITY; } + }; #endif // hifi_Quat_h diff --git a/libraries/script-engine/src/ScriptUUID.h b/libraries/script-engine/src/ScriptUUID.h index 221f9c46f0..3f504c35ba 100644 --- a/libraries/script-engine/src/ScriptUUID.h +++ b/libraries/script-engine/src/ScriptUUID.h @@ -20,6 +20,7 @@ /// Scriptable interface for a UUID helper class object. Used exclusively in the JavaScript API class ScriptUUID : public QObject, protected QScriptable { Q_OBJECT + Q_PROPERTY(QString NULL READ NULL_UUID CONSTANT) // String for use in scripts. public slots: QUuid fromString(const QString& string); @@ -28,6 +29,10 @@ public slots: bool isEqual(const QUuid& idA, const QUuid& idB); bool isNull(const QUuid& id); void print(const QString& label, const QUuid& id); + +private: + const QString NULL_UUID() { return NULL_ID; } + const QString NULL_ID { "{00000000-0000-0000-0000-000000000000}" }; }; #endif // hifi_ScriptUUID_h diff --git a/scripts/developer/tests/avatarToWorldTests.js b/scripts/developer/tests/avatarToWorldTests.js index c6e23fc81b..c2da49cbd4 100644 --- a/scripts/developer/tests/avatarToWorldTests.js +++ b/scripts/developer/tests/avatarToWorldTests.js @@ -1,5 +1,3 @@ -var AVATAR_SELF_ID = "{00000000-0000-0000-0000-000000000001}"; - var debugSphereBaseProperties = { type: "Sphere", dimensions: { x: 0.2, y: 0.2, z: 0.2 }, diff --git a/scripts/system/attachedEntitiesManager.js b/scripts/system/attachedEntitiesManager.js index ee852d8d65..c0144e772f 100644 --- a/scripts/system/attachedEntitiesManager.js +++ b/scripts/system/attachedEntitiesManager.js @@ -12,7 +12,6 @@ Script.include("libraries/utils.js"); -var NULL_UUID = "{00000000-0000-0000-0000-000000000000}"; var DEFAULT_WEARABLE_DATA = { joints: {} }; @@ -116,7 +115,7 @@ function AttachedEntitiesManager() { var allowedJoints = getEntityCustomData('wearable', grabbedEntity, DEFAULT_WEARABLE_DATA).joints; var props = Entities.getEntityProperties(grabbedEntity, ["position", "parentID", "parentJointIndex"]); - if (props.parentID === NULL_UUID || props.parentID === MyAvatar.sessionUUID) { + if (props.parentID === Uuid.NULL || props.parentID === MyAvatar.sessionUUID) { var bestJointName = ""; var bestJointIndex = -1; var bestJointDistance = 0; @@ -168,7 +167,7 @@ function AttachedEntitiesManager() { if (updatePresets) { this.updateRelativeOffsets(newEntity); } - } else if (props.parentID != NULL_UUID) { + } else if (props.parentID != Uuid.NULL) { // drop the entity and set it to have no parent (not on the avatar), unless it's being equipped in a hand. if (props.parentID === MyAvatar.sessionUUID && (props.parentJointIndex == MyAvatar.getJointIndex("RightHand") || @@ -176,7 +175,7 @@ function AttachedEntitiesManager() { // this is equipped on a hand -- don't clear the parent. } else { var wearProps = Entities.getEntityProperties(grabbedEntity); - wearProps.parentID = NULL_UUID; + wearProps.parentID = Uuid.NULL; wearProps.parentJointIndex = -1; delete wearProps.id; delete wearProps.created; diff --git a/scripts/system/away.js b/scripts/system/away.js index 18eb5fa946..2a45786d0d 100644 --- a/scripts/system/away.js +++ b/scripts/system/away.js @@ -30,7 +30,6 @@ var OVERLAY_DATA = { }; var AVATAR_MOVE_FOR_ACTIVE_DISTANCE = 0.8; // meters -- no longer away if avatar moves this far while away -var AVATAR_SELF_ID = "{00000000-0000-0000-0000-000000000001}"; var CAMERA_MATRIX = -7; var OVERLAY_DATA_HMD = { @@ -44,7 +43,7 @@ var OVERLAY_DATA_HMD = { scale: 2 * MyAvatar.sensorToWorldScale, emissive: true, drawInFront: true, - parentID: AVATAR_SELF_ID, + parentID: MyAvatar.SELF_ID, parentJointIndex: CAMERA_MATRIX }; diff --git a/scripts/system/controllers/controllerDisplay.js b/scripts/system/controllers/controllerDisplay.js index 3c2794cf96..dc7c9b37bd 100644 --- a/scripts/system/controllers/controllerDisplay.js +++ b/scripts/system/controllers/controllerDisplay.js @@ -9,8 +9,6 @@ /* globals createControllerDisplay:true deleteControllerDisplay:true */ -var PARENT_ID = "{00000000-0000-0000-0000-000000000001}"; - function clamp(value, min, max) { if (value < min) { return min; @@ -178,7 +176,7 @@ createControllerDisplay = function(config) { dimensions: Vec3.multiply(sensorScaleFactor, controller.dimensions), localRotation: controller.rotation, localPosition: Vec3.multiply(sensorScaleFactor, position), - parentID: PARENT_ID, + parentID: MyAvatar.SELF_ID, parentJointIndex: controller.jointIndex, ignoreRayIntersection: true }); @@ -198,7 +196,7 @@ createControllerDisplay = function(config) { url: part.modelURL, localPosition: partPosition, localRotation: innerRotation, - parentID: PARENT_ID, + parentID: MyAvatar.SELF_ID, parentJointIndex: controller.jointIndex, ignoreRayIntersection: true }; diff --git a/scripts/system/controllers/controllerModules/equipEntity.js b/scripts/system/controllers/controllerModules/equipEntity.js index ef7a7ab062..565a67e116 100644 --- a/scripts/system/controllers/controllerModules/equipEntity.js +++ b/scripts/system/controllers/controllerModules/equipEntity.js @@ -6,8 +6,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID, - getControllerJointIndex, NULL_UUID, enableDispatcherModule, disableDispatcherModule, +/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, + getControllerJointIndex, enableDispatcherModule, disableDispatcherModule, Messages, makeDispatcherModuleParameters, makeRunningValues, Settings, entityHasActions, Vec3, Overlays, flatten, Xform, getControllerWorldLocation, ensureDynamic, entityIsCloneable, cloneEntity, DISPATCHER_PROPERTIES @@ -333,7 +333,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa var props = controllerData.nearbyEntityPropertiesByID[hotspot.entityID]; var hasParent = true; - if (props.parentID === NULL_UUID) { + if (props.parentID === Uuid.NULL) { hasParent = false; } @@ -491,7 +491,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa } var reparentProps = { - parentID: AVATAR_SELF_ID, + parentID: MyAvatar.SELF_ID, parentJointIndex: handJointIndex, localVelocity: {x: 0, y: 0, z: 0}, localAngularVelocity: {x: 0, y: 0, z: 0}, @@ -539,7 +539,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa this.endEquipEntity = function () { Entities.editEntity(this.targetEntityID, { - parentID: NULL_UUID, + parentID: Uuid.NULL, parentJointIndex: -1 }); diff --git a/scripts/system/controllers/controllerModules/farActionGrabEntity.js b/scripts/system/controllers/controllerModules/farActionGrabEntity.js index 3e980d7f16..ee2db6f6e0 100644 --- a/scripts/system/controllers/controllerModules/farActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/farActionGrabEntity.js @@ -8,11 +8,11 @@ /* jslint bitwise: true */ /* global Script, Controller, LaserPointers, RayPick, RIGHT_HAND, LEFT_HAND, Mat4, MyAvatar, Vec3, Camera, Quat, - getGrabPointSphereOffset, getEnabledModuleByName, makeRunningValues, Entities, NULL_UUID, - enableDispatcherModule, disableDispatcherModule, entityIsDistanceGrabbable, + getGrabPointSphereOffset, getEnabledModuleByName, makeRunningValues, Entities, + enableDispatcherModule, disableDispatcherModule, entityIsDistanceGrabbable, entityIsGrabbable, makeDispatcherModuleParameters, MSECS_PER_SEC, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, - AVATAR_SELF_ID, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic, + DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic, getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, Reticle, Overlays, isPointingAtUI */ @@ -35,7 +35,7 @@ Script.include("/~/system/libraries/controllers.js"); lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawInFront: true, // Even when burried inside of something, show it. - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var halfEnd = { type: "sphere", @@ -57,7 +57,7 @@ Script.include("/~/system/libraries/controllers.js"); lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawInFront: true, // Even when burried inside of something, show it. - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var fullEnd = { type: "sphere", @@ -79,7 +79,7 @@ Script.include("/~/system/libraries/controllers.js"); lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawInFront: true, // Even when burried inside of something, show it. - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var renderStates = [ @@ -232,7 +232,7 @@ Script.include("/~/system/libraries/controllers.js"); tag: "far-grab-" + MyAvatar.sessionUUID, ttl: ACTION_TTL }); - if (this.actionID === NULL_UUID) { + if (this.actionID === Uuid.NULL) { this.actionID = null; } diff --git a/scripts/system/controllers/controllerModules/farTrigger.js b/scripts/system/controllers/controllerModules/farTrigger.js index 84d4c4d307..de60e2e227 100644 --- a/scripts/system/controllers/controllerModules/farTrigger.js +++ b/scripts/system/controllers/controllerModules/farTrigger.js @@ -9,7 +9,7 @@ /* global Script, Controller, LaserPointers, RayPick, RIGHT_HAND, LEFT_HAND, MyAvatar, getGrabPointSphereOffset, makeRunningValues, Entities, enableDispatcherModule, disableDispatcherModule, makeDispatcherModuleParameters, PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, - AVATAR_SELF_ID, DEFAULT_SEARCH_SPHERE_DISTANCE, getGrabbableData + DEFAULT_SEARCH_SPHERE_DISTANCE, getGrabbableData */ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); @@ -28,7 +28,7 @@ Script.include("/~/system/libraries/controllers.js"); lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawInFront: true, // Even when burried inside of something, show it. - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var halfEnd = { type: "sphere", @@ -50,7 +50,7 @@ Script.include("/~/system/libraries/controllers.js"); lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawInFront: true, // Even when burried inside of something, show it. - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var fullEnd = { type: "sphere", @@ -72,7 +72,7 @@ Script.include("/~/system/libraries/controllers.js"); lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawInFront: true, // Even when burried inside of something, show it. - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var renderStates = [ diff --git a/scripts/system/controllers/controllerModules/hudOverlayPointer.js b/scripts/system/controllers/controllerModules/hudOverlayPointer.js index 9576b3ecc9..23802893a8 100644 --- a/scripts/system/controllers/controllerModules/hudOverlayPointer.js +++ b/scripts/system/controllers/controllerModules/hudOverlayPointer.js @@ -11,11 +11,11 @@ // /* global Script, Controller, LaserPointers, RayPick, RIGHT_HAND, LEFT_HAND, Mat4, MyAvatar, Vec3, Camera, Quat, - getGrabPointSphereOffset, getEnabledModuleByName, makeRunningValues, Entities, NULL_UUID, + getGrabPointSphereOffset, getEnabledModuleByName, makeRunningValues, Entities, enableDispatcherModule, disableDispatcherModule, entityIsDistanceGrabbable, makeDispatcherModuleParameters, MSECS_PER_SEC, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, - AVATAR_SELF_ID, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic, + DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic, getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, Reticle, Overlays, isPointingAtUI */ @@ -34,7 +34,7 @@ lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawHUDLayer: true, - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var halfEnd = { type: "sphere", @@ -56,7 +56,7 @@ lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawHUDLayer: true, - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var fullEnd = { type: "sphere", @@ -78,7 +78,7 @@ lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawHUDLayer: true, - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var renderStates = [ diff --git a/scripts/system/controllers/controllerModules/inEditMode.js b/scripts/system/controllers/controllerModules/inEditMode.js index bf96f90a75..f68389080e 100644 --- a/scripts/system/controllers/controllerModules/inEditMode.js +++ b/scripts/system/controllers/controllerModules/inEditMode.js @@ -8,7 +8,7 @@ /* jslint bitwise: true */ /* global Script, Controller, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule, makeRunningValues, - Messages, makeDispatcherModuleParameters, AVATAR_SELF_ID, HMD, getGrabPointSphereOffset, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, + Messages, makeDispatcherModuleParameters, HMD, getGrabPointSphereOffset, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, getEnabledModuleByName, PICK_MAX_DISTANCE, isInEditMode, LaserPointers, RayPick */ @@ -30,7 +30,7 @@ Script.include("/~/system/libraries/utils.js"); lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawInFront: true, // Even when burried inside of something, show it. - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var halfEnd = { type: "sphere", @@ -52,7 +52,7 @@ Script.include("/~/system/libraries/utils.js"); lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawInFront: true, // Even when burried inside of something, show it. - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var fullEnd = { type: "sphere", @@ -74,7 +74,7 @@ Script.include("/~/system/libraries/utils.js"); lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawInFront: true, // Even when burried inside of something, show it. - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var renderStates = [ diff --git a/scripts/system/controllers/controllerModules/nearActionGrabEntity.js b/scripts/system/controllers/controllerModules/nearActionGrabEntity.js index 12d1533703..6b2a986f0f 100644 --- a/scripts/system/controllers/controllerModules/nearActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearActionGrabEntity.js @@ -6,7 +6,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html /* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, - getControllerJointIndex, getGrabbableData, NULL_UUID, enableDispatcherModule, disableDispatcherModule, + getControllerJointIndex, getGrabbableData, enableDispatcherModule, disableDispatcherModule, propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, entityIsGrabbable, Quat, Vec3, MSECS_PER_SEC, getControllerWorldLocation, makeDispatcherModuleParameters, makeRunningValues, TRIGGER_OFF_VALUE, NEAR_GRAB_RADIUS, findGroupParent, entityIsCloneable, propsAreCloneDynamic, cloneEntity, @@ -101,7 +101,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); kinematicSetVelocity: true, ignoreIK: this.ignoreIK }); - if (this.actionID === NULL_UUID) { + if (this.actionID === Uuid.NULL) { this.actionID = null; return; } @@ -189,7 +189,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); if (targetProps) { if ((!propsArePhysical(targetProps) && !propsAreCloneDynamic(targetProps)) || - targetProps.parentID != NULL_UUID) { + targetProps.parentID !== Uuid.NULL) { return makeRunningValues(false, [], []); // let nearParentGrabEntity handle it } else { this.targetEntityID = targetProps.id; diff --git a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js index 87d4811967..178d459b1d 100644 --- a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js @@ -6,7 +6,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID, getControllerJointIndex, NULL_UUID, +/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, getControllerJointIndex, enableDispatcherModule, disableDispatcherModule, propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, TRIGGER_OFF_VALUE, makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues, NEAR_GRAB_RADIUS, findGroupParent, Vec3, cloneEntity, entityIsCloneable, propsAreCloneDynamic, HAPTIC_PULSE_STRENGTH, @@ -50,7 +50,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); return false; } - if (props.parentID !== MyAvatar.sessionUUID && props.parentID !== AVATAR_SELF_ID) { + if (props.parentID !== MyAvatar.sessionUUID && props.parentID !== MyAvatar.SELF_ID) { return false; } @@ -90,7 +90,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); Entities.callEntityMethod(targetProps.id, "startNearGrab", args); var reparentProps = { - parentID: AVATAR_SELF_ID, + parentID: MyAvatar.SELF_ID, parentJointIndex: handJointIndex, localVelocity: {x: 0, y: 0, z: 0}, localAngularVelocity: {x: 0, y: 0, z: 0} @@ -120,7 +120,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); this.hapticTargetID = null; var props = controllerData.nearbyEntityPropertiesByID[this.targetEntityID]; if (this.thisHandIsParent(props)) { - if (this.previousParentID[this.targetEntityID] === NULL_UUID || this.previousParentID === undefined) { + if (this.previousParentID[this.targetEntityID] === Uuid.NULL || this.previousParentID === undefined) { Entities.editEntity(this.targetEntityID, { parentID: this.previousParentID[this.targetEntityID], parentJointIndex: this.previousParentJointIndex[this.targetEntityID] @@ -152,7 +152,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); var now = Date.now(); if (now - this.lastUnequipCheckTime > MSECS_PER_SEC * TEAR_AWAY_CHECK_TIME) { this.lastUnequipCheckTime = now; - if (props.parentID == AVATAR_SELF_ID) { + if (props.parentID === MyAvatar.SELF_ID) { var sensorScaleFactor = MyAvatar.sensorToWorldScale; var handPosition = controllerData.controllerLocations[this.hand].position; var dist = distanceBetweenPointAndEntityBoundingBox(handPosition, props); @@ -198,7 +198,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); var UNHOOK_LOOP_DETECT_MS = 200; if (_this.previouslyUnhooked[childID]) { if (now - _this.previouslyUnhooked[childID] < UNHOOK_LOOP_DETECT_MS) { - previousParentID = NULL_UUID; + previousParentID = Uuid.NULL; previousParentJointIndex = -1; } } @@ -209,7 +209,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); parentJointIndex: previousParentJointIndex }); } else { - Entities.editEntity(childID, { parentID: NULL_UUID }); + Entities.editEntity(childID, { parentID: Uuid.NULL }); } }); } @@ -258,7 +258,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); if (targetProps) { if ((propsArePhysical(targetProps) || propsAreCloneDynamic(targetProps)) && - targetProps.parentID == NULL_UUID) { + targetProps.parentID === Uuid.NULL) { return makeRunningValues(false, [], []); // let nearActionGrabEntity handle it } else { this.targetEntityID = targetProps.id; @@ -273,7 +273,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); this.run = function (controllerData, deltaTime) { if (this.grabbing) { if (controllerData.triggerClicks[this.hand] < TRIGGER_OFF_VALUE && - controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) { + controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) { this.endNearParentingGrabEntity(controllerData); return makeRunningValues(false, [], []); } diff --git a/scripts/system/controllers/controllerModules/nearParentGrabOverlay.js b/scripts/system/controllers/controllerModules/nearParentGrabOverlay.js index 471ee89926..925c50df5e 100644 --- a/scripts/system/controllers/controllerModules/nearParentGrabOverlay.js +++ b/scripts/system/controllers/controllerModules/nearParentGrabOverlay.js @@ -6,7 +6,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -/* global Script, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID, getControllerJointIndex, NULL_UUID, +/* global Script, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, getControllerJointIndex, enableDispatcherModule, disableDispatcherModule, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, makeDispatcherModuleParameters, Overlays, makeRunningValues, Vec3, resizeTablet, getTabletWidthFromSettings, NEAR_GRAB_RADIUS @@ -48,7 +48,7 @@ Script.include("/~/system/libraries/utils.js"); }; this.thisHandIsParent = function(props) { - if (props.parentID !== MyAvatar.sessionUUID && props.parentID !== AVATAR_SELF_ID) { + if (props.parentID !== MyAvatar.sessionUUID && props.parentID !== MyAvatar.SELF_ID) { return false; } @@ -94,7 +94,7 @@ Script.include("/~/system/libraries/utils.js"); var grabbedProperties = this.getGrabbedProperties(); var reparentProps = { - parentID: AVATAR_SELF_ID, + parentID: MyAvatar.SELF_ID, parentJointIndex: handJointIndex, velocity: {x: 0, y: 0, z: 0}, angularVelocity: {x: 0, y: 0, z: 0} @@ -130,9 +130,9 @@ Script.include("/~/system/libraries/utils.js"); this.endNearParentingGrabOverlay = function () { var previousParentID = this.previousParentID[this.grabbedThingID]; - if ((previousParentID === NULL_UUID || previousParentID === null) && !this.robbed) { + if ((previousParentID === Uuid.NULL || previousParentID === null) && !this.robbed) { Overlays.editOverlay(this.grabbedThingID, { - parentID: NULL_UUID, + parentID: Uuid.NULL, parentJointIndex: -1 }); } else if (!this.robbed){ diff --git a/scripts/system/controllers/controllerModules/overlayLaserInput.js b/scripts/system/controllers/controllerModules/overlayLaserInput.js index 349d9c0b5c..9cd355f060 100644 --- a/scripts/system/controllers/controllerModules/overlayLaserInput.js +++ b/scripts/system/controllers/controllerModules/overlayLaserInput.js @@ -5,8 +5,8 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -/* global Script, Entities, Controller, RIGHT_HAND, LEFT_HAND, NULL_UUID, enableDispatcherModule, disableDispatcherModule, - makeRunningValues, Messages, Quat, Vec3, makeDispatcherModuleParameters, Overlays, ZERO_VEC, AVATAR_SELF_ID, HMD, +/* global Script, Entities, Controller, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule, + makeRunningValues, Messages, Quat, Vec3, makeDispatcherModuleParameters, Overlays, ZERO_VEC, HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, getGrabPointSphereOffset, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, TRIGGER_OFF_VALUE, getEnabledModuleByName, PICK_MAX_DISTANCE, LaserPointers, RayPick, ContextOverlay @@ -29,7 +29,7 @@ Script.include("/~/system/libraries/controllers.js"); lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawInFront: true, // Even when burried inside of something, show it. - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var halfEnd = { type: "sphere", @@ -51,7 +51,7 @@ Script.include("/~/system/libraries/controllers.js"); lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawInFront: true, // Even when burried inside of something, show it. - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var fullEnd = { type: "sphere", @@ -73,7 +73,7 @@ Script.include("/~/system/libraries/controllers.js"); lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawInFront: true, // Even when burried inside of something, show it. - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var renderStates = [ @@ -228,7 +228,7 @@ Script.include("/~/system/libraries/controllers.js"); var POINTER_PRESS_TO_MOVE_DELAY = 0.33; // seconds if (this.deadspotExpired || this.touchingEnterTimer > POINTER_PRESS_TO_MOVE_DELAY || distance2D(this.laserTarget.position2D, - this.pressEnterLaserTarget.position2D) > this.deadspotRadius) { + this.pressEnterLaserTarget.position2D) > this.deadspotRadius) { TouchEventUtils.sendTouchMoveEventToTouchTarget(this.hand, this.laserTarget); this.deadspotExpired = true; } diff --git a/scripts/system/controllers/controllerModules/tabletStylusInput.js b/scripts/system/controllers/controllerModules/tabletStylusInput.js index b633c6e058..beb86d0ef4 100644 --- a/scripts/system/controllers/controllerModules/tabletStylusInput.js +++ b/scripts/system/controllers/controllerModules/tabletStylusInput.js @@ -6,9 +6,9 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html /* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, - NULL_UUID, enableDispatcherModule, disableDispatcherModule, makeRunningValues, + enableDispatcherModule, disableDispatcherModule, makeRunningValues, Messages, Quat, Vec3, getControllerWorldLocation, makeDispatcherModuleParameters, Overlays, ZERO_VEC, - AVATAR_SELF_ID, HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, Settings, getGrabPointSphereOffset, + HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, Settings, getGrabPointSphereOffset, getEnabledModuleByName */ @@ -172,7 +172,7 @@ Script.include("/~/system/libraries/controllers.js"); visible: true, ignoreRayIntersection: true, drawInFront: false, - parentID: AVATAR_SELF_ID, + parentID: MyAvatar.SELF_ID, parentJointIndex: MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND") @@ -288,7 +288,7 @@ Script.include("/~/system/libraries/controllers.js"); } // add the tabletScreen, if it is valid - if (HMD.tabletScreenID && HMD.tabletScreenID !== NULL_UUID && + if (HMD.tabletScreenID && HMD.tabletScreenID !== Uuid.NULL && Overlays.getProperty(HMD.tabletScreenID, "visible")) { stylusTarget = TouchEventUtils.calculateTouchTargetFromOverlay(this.stylusTip, HMD.tabletScreenID); if (stylusTarget) { @@ -297,7 +297,7 @@ Script.include("/~/system/libraries/controllers.js"); } // add the tablet home button. - if (HMD.homeButtonID && HMD.homeButtonID !== NULL_UUID && + if (HMD.homeButtonID && HMD.homeButtonID !== Uuid.NULL && Overlays.getProperty(HMD.homeButtonID, "visible")) { stylusTarget = TouchEventUtils.calculateTouchTargetFromOverlay(this.stylusTip, HMD.homeButtonID); if (stylusTarget) { diff --git a/scripts/system/controllers/controllerModules/teleport.js b/scripts/system/controllers/controllerModules/teleport.js index d2717a1348..1c6652dc50 100644 --- a/scripts/system/controllers/controllerModules/teleport.js +++ b/scripts/system/controllers/controllerModules/teleport.js @@ -10,7 +10,7 @@ /* jslint bitwise: true */ -/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID, getControllerJointIndex, NULL_UUID, +/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, getControllerJointIndex, enableDispatcherModule, disableDispatcherModule, Messages, makeDispatcherModuleParameters, makeRunningValues, Vec3, LaserPointers, RayPick, HMD, Uuid, AvatarList */ diff --git a/scripts/system/controllers/controllerModules/webEntityLaserInput.js b/scripts/system/controllers/controllerModules/webEntityLaserInput.js index 62cb05f32f..39969df614 100644 --- a/scripts/system/controllers/controllerModules/webEntityLaserInput.js +++ b/scripts/system/controllers/controllerModules/webEntityLaserInput.js @@ -8,9 +8,9 @@ /* jslint bitwise: true */ /* global Script, Controller, LaserPointers, RayPick, RIGHT_HAND, LEFT_HAND, Vec3, Quat, getGrabPointSphereOffset, - makeRunningValues, Entities, NULL_UUID, enableDispatcherModule, disableDispatcherModule, makeDispatcherModuleParameters, + makeRunningValues, Entities, enableDispatcherModule, disableDispatcherModule, makeDispatcherModuleParameters, PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, - AVATAR_SELF_ID, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, ZERO_VEC, Overlays + DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, ZERO_VEC, Overlays */ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); @@ -29,7 +29,7 @@ Script.include("/~/system/libraries/controllers.js"); lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawInFront: true, // Even when burried inside of something, show it. - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var halfEnd = { type: "sphere", @@ -51,7 +51,7 @@ Script.include("/~/system/libraries/controllers.js"); lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawInFront: true, // Even when burried inside of something, show it. - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var fullEnd = { type: "sphere", @@ -73,7 +73,7 @@ Script.include("/~/system/libraries/controllers.js"); lineWidth: 5, ignoreRayIntersection: true, // always ignore this drawInFront: true, // Even when burried inside of something, show it. - parentID: AVATAR_SELF_ID + parentID: MyAvatar.SELF_ID }; var renderStates = [ @@ -94,15 +94,15 @@ Script.include("/~/system/libraries/controllers.js"); var HAPTIC_STYLUS_DURATION = 20.0; function laserTargetHasKeyboardFocus(laserTarget) { - if (laserTarget && laserTarget !== NULL_UUID) { + if (laserTarget && laserTarget !== Uuid.NULL) { return Entities.keyboardFocusOverlay === laserTarget; } } function setKeyboardFocusOnLaserTarget(laserTarget) { - if (laserTarget && laserTarget !== NULL_UUID) { + if (laserTarget && laserTarget !== Uuid.NULL) { Entities.wantsHandControllerPointerEvents(laserTarget); - Overlays.keyboardFocusOverlay = NULL_UUID; + Overlays.keyboardFocusOverlay = Uuid.NULL; Entities.keyboardFocusEntity = laserTarget; } } @@ -121,7 +121,7 @@ Script.include("/~/system/libraries/controllers.js"); button: "None" }; - if (laserTarget.entityID && laserTarget.entityID !== NULL_UUID) { + if (laserTarget.entityID && laserTarget.entityID !== Uuid.NULL) { Entities.sendHoverEnterEntity(laserTarget.entityID, pointerEvent); } } @@ -141,7 +141,7 @@ Script.include("/~/system/libraries/controllers.js"); button: "None" }; - if (laserTarget.entityID && laserTarget.entityID !== NULL_UUID) { + if (laserTarget.entityID && laserTarget.entityID !== Uuid.NULL) { Entities.sendMouseMoveOnEntity(laserTarget.entityID, pointerEvent); Entities.sendHoverOverEntity(laserTarget.entityID, pointerEvent); } @@ -160,7 +160,7 @@ Script.include("/~/system/libraries/controllers.js"); isPrimaryHeld: true }; - if (laserTarget.entityID && laserTarget.entityID !== NULL_UUID) { + if (laserTarget.entityID && laserTarget.entityID !== Uuid.NULL) { Entities.sendMousePressOnEntity(laserTarget.entityID, pointerEvent); Entities.sendClickDownOnEntity(laserTarget.entityID, pointerEvent); } @@ -177,7 +177,7 @@ Script.include("/~/system/libraries/controllers.js"); button: "Primary" }; - if (laserTarget.entityID && laserTarget.entityID !== NULL_UUID) { + if (laserTarget.entityID && laserTarget.entityID !== Uuid.NULL) { Entities.sendMouseReleaseOnEntity(laserTarget.entityID, pointerEvent); Entities.sendClickReleaseOnEntity(laserTarget.entityID, pointerEvent); Entities.sendHoverLeaveEntity(laserTarget.entityID, pointerEvent); @@ -196,7 +196,7 @@ Script.include("/~/system/libraries/controllers.js"); isPrimaryHeld: true }; - if (laserTarget.entityID && laserTarget.entityID !== NULL_UUID) { + if (laserTarget.entityID && laserTarget.entityID !== Uuid.NULL) { Entities.sendMouseMoveOnEntity(laserTarget.entityID, pointerEvent); Entities.sendHoldingClickOnEntity(laserTarget.entityID, pointerEvent); } diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 39ab946aa3..2ae1e142a0 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1360,7 +1360,7 @@ function unparentSelectedEntities() { } selectedEntities.forEach(function (id, index) { var parentId = Entities.getEntityProperties(id, ["parentID"]).parentID; - if (parentId !== null && parentId.length > 0 && parentId !== "{00000000-0000-0000-0000-000000000000}") { + if (parentId !== null && parentId.length > 0 && parentId !== Uuid.NULL) { parentCheck = true; } Entities.editEntity(id, {parentID: null}); diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 3fa3283ff1..c46cfaa073 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -25,7 +25,6 @@ var ROT_LANDSCAPE = {x: 1.0, y: 1.0, z: 0, w: 0}; var ROT_LANDSCAPE_WINDOW = {x: 0.0, y: 0.0, z: 0.0, w: 0}; var TABLET_TEXTURE_RESOLUTION = { x: 480, y: 706 }; var INCHES_TO_METERS = 1 / 39.3701; -var AVATAR_SELF_ID = "{00000000-0000-0000-0000-000000000001}"; var NO_HANDS = -1; var DELAY_FOR_30HZ = 33; // milliseconds @@ -100,7 +99,7 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) { "grabbableKey": {"grabbable": true} }), dimensions: { x: tabletWidth, y: tabletHeight, z: tabletDepth }, - parentID: AVATAR_SELF_ID, + parentID: MyAvatar.SELF_ID, visible: visible }; @@ -471,7 +470,7 @@ WebTablet.prototype.register = function() { WebTablet.prototype.cleanUpOldTabletsOnJoint = function(jointIndex) { var children = Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, jointIndex); - children = children.concat(Entities.getChildrenIDsOfJoint(AVATAR_SELF_ID, 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 d6d80541ee..cd3f1a711f 100644 --- a/scripts/system/libraries/controllerDispatcherUtils.js +++ b/scripts/system/libraries/controllerDispatcherUtils.js @@ -7,7 +7,7 @@ /* global module, Camera, HMD, MyAvatar, controllerDispatcherPlugins:true, Quat, Vec3, Overlays, Xform, - MSECS_PER_SEC:true , LEFT_HAND:true, RIGHT_HAND:true, NULL_UUID:true, AVATAR_SELF_ID:true, FORBIDDEN_GRAB_TYPES:true, + MSECS_PER_SEC:true , LEFT_HAND:true, RIGHT_HAND:true, FORBIDDEN_GRAB_TYPES:true, HAPTIC_PULSE_STRENGTH:true, HAPTIC_PULSE_DURATION:true, ZERO_VEC:true, ONE_VEC:true, DEFAULT_REGISTRATION_POINT:true, INCHES_TO_METERS:true, TRIGGER_OFF_VALUE:true, @@ -60,9 +60,6 @@ ONE_VEC = { x: 1, y: 1, z: 1 }; LEFT_HAND = 0; RIGHT_HAND = 1; -NULL_UUID = "{00000000-0000-0000-0000-000000000000}"; -AVATAR_SELF_ID = "{00000000-0000-0000-0000-000000000001}"; - FORBIDDEN_GRAB_TYPES = ["Unknown", "Light", "PolyLine", "Zone"]; HAPTIC_PULSE_STRENGTH = 1.0; @@ -284,7 +281,7 @@ ensureDynamic = function (entityID) { // if we distance hold something and keep it very still before releasing it, it ends up // non-dynamic in bullet. If it's too still, give it a little bounce so it will fall. var props = Entities.getEntityProperties(entityID, ["velocity", "dynamic", "parentID"]); - if (props.dynamic && props.parentID === NULL_UUID) { + if (props.dynamic && props.parentID === Uuid.NULL) { var velocity = props.velocity; if (Vec3.length(velocity) < 0.05) { // see EntityMotionState.cpp DYNAMIC_LINEAR_VELOCITY_THRESHOLD velocity = { x: 0.0, y: 0.2, z: 0.0 }; @@ -295,7 +292,7 @@ ensureDynamic = function (entityID) { findGroupParent = function (controllerData, targetProps) { while (targetProps.parentID && - targetProps.parentID !== NULL_UUID && + targetProps.parentID !== Uuid.NULL && Entities.getNestableType(targetProps.parentID) == "entity") { var parentProps = Entities.getEntityProperties(targetProps.parentID, DISPATCHER_PROPERTIES); if (!parentProps) { @@ -314,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(AVATAR_SELF_ID, 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(AVATAR_SELF_ID, 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(AVATAR_SELF_ID, controllerCRJointIndex)); + children = children.concat(Entities.getChildrenIDsOfJoint(MyAvatar.SELF_ID, controllerCRJointIndex)); return children.filter(function (childID) { var childType = Entities.getNestableType(childID); diff --git a/scripts/system/libraries/entityCameraTool.js b/scripts/system/libraries/entityCameraTool.js index 6becc81d9b..0e52353dfb 100644 --- a/scripts/system/libraries/entityCameraTool.js +++ b/scripts/system/libraries/entityCameraTool.js @@ -118,20 +118,12 @@ CameraManager = function() { that.targetYaw = 0; that.targetPitch = 0; - that.focalPoint = { - x: 0, - y: 0, - z: 0 - }; - that.targetFocalPoint = { - x: 0, - y: 0, - z: 0 - }; + that.focalPoint = Vec3.ZERO; + that.targetFocalPoint = Vec3.ZERO; easing = false; easingTime = 0; - startOrientation = Quat.fromPitchYawRollDegrees(0, 0, 0); + startOrientation = Quat.IDENTITY; that.previousCameraMode = null; diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 9715cc454c..88d1e627c3 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -71,44 +71,16 @@ SelectionManager = (function() { that.selections = []; var listeners = []; - that.localRotation = Quat.fromPitchYawRollDegrees(0, 0, 0); - that.localPosition = { - x: 0, - y: 0, - z: 0 - }; - that.localDimensions = { - x: 0, - y: 0, - z: 0 - }; - that.localRegistrationPoint = { - x: 0.5, - y: 0.5, - z: 0.5 - }; + that.localRotation = Quat.IDENTITY; + that.localPosition = Vec3.ZERO; + that.localDimensions = Vec3.ZERO; + that.localRegistrationPoint = Vec3.HALF; - that.worldRotation = Quat.fromPitchYawRollDegrees(0, 0, 0); - that.worldPosition = { - x: 0, - y: 0, - z: 0 - }; - that.worldDimensions = { - x: 0, - y: 0, - z: 0 - }; - that.worldRegistrationPoint = { - x: 0.5, - y: 0.5, - z: 0.5 - }; - that.centerPosition = { - x: 0, - y: 0, - z: 0 - }; + that.worldRotation = Quat.IDENTITY; + that.worldPosition = Vec3.ZERO; + that.worldDimensions = Vec3.ZERO; + that.worldRegistrationPoint = Vec3.HALF; + that.centerPosition = Vec3.ZERO; that.saveProperties = function() { that.savedProperties = {}; @@ -350,11 +322,7 @@ SelectionDisplay = (function() { }; var grabberLineWidth = 0.5; var grabberSolid = true; - var grabberMoveUpPosition = { - x: 0, - y: 0, - z: 0 - }; + var grabberMoveUpPosition = Vec3.ZERO; var lightOverlayColor = { red: 255, @@ -363,11 +331,7 @@ SelectionDisplay = (function() { }; var grabberPropertiesCorner = { - position: { - x: 0, - y: 0, - z: 0 - }, + position: Vec3.ZERO, size: grabberSizeCorner, color: grabberColorCorner, alpha: 1, @@ -380,11 +344,7 @@ SelectionDisplay = (function() { }; var grabberPropertiesEdge = { - position: { - x: 0, - y: 0, - z: 0 - }, + position: Vec3.ZERO, size: grabberSizeEdge, color: grabberColorEdge, alpha: 1, @@ -397,11 +357,7 @@ SelectionDisplay = (function() { }; var grabberPropertiesFace = { - position: { - x: 0, - y: 0, - z: 0 - }, + position: Vec3.ZERO, size: grabberSizeFace, color: grabberColorFace, alpha: 1, @@ -414,11 +370,7 @@ SelectionDisplay = (function() { }; var grabberPropertiesCloner = { - position: { - x: 0, - y: 0, - z: 0 - }, + position: Vec3.ZERO, size: grabberSizeCorner, color: grabberColorCloner, alpha: 1, @@ -436,11 +388,7 @@ SelectionDisplay = (function() { }; var highlightBox = Overlays.addOverlay("cube", { - position: { - x: 0, - y: 0, - z: 0 - }, + position: Vec3.ZERO, size: 1, color: { red: 90, @@ -457,11 +405,7 @@ SelectionDisplay = (function() { }); var selectionBox = Overlays.addOverlay("cube", { - position: { - x: 0, - y: 0, - z: 0 - }, + position: Vec3.ZERO, size: 1, color: { red: 255, @@ -478,11 +422,7 @@ SelectionDisplay = (function() { var selectionBoxes = []; var rotationDegreesDisplay = Overlays.addOverlay("text3d", { - position: { - x: 0, - y: 0, - z: 0 - }, + position: Vec3.ZERO, text: "", color: { red: 0, @@ -513,11 +453,7 @@ SelectionDisplay = (function() { var grabberMoveUp = Overlays.addOverlay("image3d", { url: HIFI_PUBLIC_BUCKET + "images/up-arrow.svg", - position: { - x: 0, - y: 0, - z: 0 - }, + position: Vec3.ZERO, color: handleColor, alpha: handleAlpha, visible: false, @@ -720,16 +656,8 @@ SelectionDisplay = (function() { var xRailOverlay = Overlays.addOverlay("line3d", { visible: false, lineWidth: 1.0, - start: { - x: 0, - y: 0, - z: 0 - }, - end: { - x: 0, - y: 0, - z: 0 - }, + start: Vec3.ZERO, + end: Vec3.ZERO, color: { red: 255, green: 0, @@ -740,16 +668,8 @@ SelectionDisplay = (function() { var yRailOverlay = Overlays.addOverlay("line3d", { visible: false, lineWidth: 1.0, - start: { - x: 0, - y: 0, - z: 0 - }, - end: { - x: 0, - y: 0, - z: 0 - }, + start: Vec3.ZERO, + end: Vec3.ZERO, color: { red: 0, green: 255, @@ -760,16 +680,8 @@ SelectionDisplay = (function() { var zRailOverlay = Overlays.addOverlay("line3d", { visible: false, lineWidth: 1.0, - start: { - x: 0, - y: 0, - z: 0 - }, - end: { - x: 0, - y: 0, - z: 0 - }, + start: Vec3.ZERO, + end: Vec3.ZERO, color: { red: 0, green: 0, @@ -781,16 +693,8 @@ SelectionDisplay = (function() { var rotateZeroOverlay = Overlays.addOverlay("line3d", { visible: false, lineWidth: 2.0, - start: { - x: 0, - y: 0, - z: 0 - }, - end: { - x: 0, - y: 0, - z: 0 - }, + start: Vec3.ZERO, + end: Vec3.ZERO, color: { red: 255, green: 0, @@ -802,16 +706,8 @@ SelectionDisplay = (function() { var rotateCurrentOverlay = Overlays.addOverlay("line3d", { visible: false, lineWidth: 2.0, - start: { - x: 0, - y: 0, - z: 0 - }, - end: { - x: 0, - y: 0, - z: 0 - }, + start: Vec3.ZERO, + end: Vec3.ZERO, color: { red: 0, green: 0, @@ -822,11 +718,7 @@ SelectionDisplay = (function() { var rotateOverlayInner = Overlays.addOverlay("circle3d", { - position: { - x: 0, - y: 0, - z: 0 - }, + position: Vec3.ZERO, size: 1, color: { red: 51, @@ -856,11 +748,7 @@ SelectionDisplay = (function() { }); var rotateOverlayOuter = Overlays.addOverlay("circle3d", { - position: { - x: 0, - y: 0, - z: 0 - }, + position: Vec3.ZERO, size: 1, color: { red: 51, @@ -891,11 +779,7 @@ SelectionDisplay = (function() { }); var rotateOverlayCurrent = Overlays.addOverlay("circle3d", { - position: { - x: 0, - y: 0, - z: 0 - }, + position: Vec3.ZERO, size: 1, color: { red: 224, @@ -922,11 +806,7 @@ SelectionDisplay = (function() { var yawHandle = Overlays.addOverlay("image3d", { url: ROTATE_ARROW_WEST_NORTH_URL, - position: { - x: 0, - y: 0, - z: 0 - }, + position: Vec3.ZERO, color: handleColor, alpha: handleAlpha, visible: false, @@ -939,11 +819,7 @@ SelectionDisplay = (function() { var pitchHandle = Overlays.addOverlay("image3d", { url: ROTATE_ARROW_WEST_NORTH_URL, - position: { - x: 0, - y: 0, - z: 0 - }, + position: Vec3.ZERO, color: handleColor, alpha: handleAlpha, visible: false, @@ -956,11 +832,7 @@ SelectionDisplay = (function() { var rollHandle = Overlays.addOverlay("image3d", { url: ROTATE_ARROW_WEST_NORTH_URL, - position: { - x: 0, - y: 0, - z: 0 - }, + position: Vec3.ZERO, color: handleColor, alpha: handleAlpha, visible: false, @@ -1636,7 +1508,7 @@ SelectionDisplay = (function() { position = SelectionManager.localPosition; registrationPoint = SelectionManager.localRegistrationPoint; } else { - rotation = Quat.fromPitchYawRollDegrees(0, 0, 0); + rotation = Quat.IDENTITY; dimensions = SelectionManager.worldDimensions; position = SelectionManager.worldPosition; registrationPoint = SelectionManager.worldRegistrationPoint; @@ -2692,7 +2564,7 @@ SelectionDisplay = (function() { var onBegin = function(event, pickRay, pickResult) { var properties = Entities.getEntityProperties(SelectionManager.selections[0]); initialProperties = properties; - rotation = (spaceMode === SPACE_LOCAL) ? properties.rotation : Quat.fromPitchYawRollDegrees(0, 0, 0); + rotation = (spaceMode === SPACE_LOCAL) ? properties.rotation : Quat.IDENTITY; if (spaceMode === SPACE_LOCAL) { rotation = SelectionManager.localRotation; diff --git a/scripts/system/libraries/overlayUtils.js b/scripts/system/libraries/overlayUtils.js index a5622ec435..366cdbcc97 100644 --- a/scripts/system/libraries/overlayUtils.js +++ b/scripts/system/libraries/overlayUtils.js @@ -18,7 +18,7 @@ OverlayGroup = function(opts) { var overlays = {}; var rootPosition = opts.position || { x: 0, y: 0, z: 0 }; - var rootRotation = opts.rotation || Quat.fromPitchYawRollRadians(0, 0, 0); + var rootRotation = opts.rotation || Quat.IDENTITY; var visible = opts.visible == true; function updateOverlays() { @@ -36,7 +36,7 @@ OverlayGroup = function(opts) { that.createOverlay = function(type, properties) { properties.position = properties.position || { x: 0, y: 0, z: 0 }; - properties.rotation = properties.rotation || Quat.fromPitchYawRollRadians(0, 0, 0); + properties.rotation = properties.rotation || Quat.IDENTITY; var overlay = Overlays.addOverlay(type, properties); diff --git a/scripts/system/libraries/touchEventUtils.js b/scripts/system/libraries/touchEventUtils.js index fbd56e16ae..3c76c4c144 100644 --- a/scripts/system/libraries/touchEventUtils.js +++ b/scripts/system/libraries/touchEventUtils.js @@ -6,28 +6,28 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html /* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, - controllerDispatcher.NULL_UUID, enableDispatcherModule, disableDispatcherModule, makeRunningValues, + enableDispatcherModule, disableDispatcherModule, makeRunningValues, Messages, Quat, Vec3, getControllerWorldLocation, makeDispatcherModuleParameters, Overlays, controllerDispatcher.ZERO_VEC, - AVATAR_SELF_ID, HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, Settings, getGrabPointSphereOffset + HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, Settings, getGrabPointSphereOffset */ var controllerDispatcher = Script.require("/~/system/libraries/controllerDispatcherUtils.js"); function touchTargetHasKeyboardFocus(touchTarget) { - if (touchTarget.entityID && touchTarget.entityID !== controllerDispatcher.NULL_UUID) { + if (touchTarget.entityID && touchTarget.entityID !== Uuid.NULL) { return Entities.keyboardFocusEntity === touchTarget.entityID; - } else if (touchTarget.overlayID && touchTarget.overlayID !== controllerDispatcher.NULL_UUID) { + } else if (touchTarget.overlayID && touchTarget.overlayID !== Uuid.NULL) { return Overlays.keyboardFocusOverlay === touchTarget.overlayID; } } function setKeyboardFocusOnTouchTarget(touchTarget) { - if (touchTarget.entityID && touchTarget.entityID !== controllerDispatcher.NULL_UUID && + if (touchTarget.entityID && touchTarget.entityID !== Uuid.NULL && Entities.wantsHandControllerPointerEvents(touchTarget.entityID)) { - Overlays.keyboardFocusOverlay = controllerDispatcher.NULL_UUID; + Overlays.keyboardFocusOverlay = Uuid.NULL; Entities.keyboardFocusEntity = touchTarget.entityID; - } else if (touchTarget.overlayID && touchTarget.overlayID !== controllerDispatcher.NULL_UUID) { + } else if (touchTarget.overlayID && touchTarget.overlayID !== Uuid.NULL) { Overlays.keyboardFocusOverlay = touchTarget.overlayID; - Entities.keyboardFocusEntity = controllerDispatcher.NULL_UUID; + Entities.keyboardFocusEntity = Uuid.NULL; } } @@ -42,9 +42,9 @@ function sendHoverEnterEventToTouchTarget(hand, touchTarget) { button: "None" }; - if (touchTarget.entityID && touchTarget.entityID !== controllerDispatcher.NULL_UUID) { + if (touchTarget.entityID && touchTarget.entityID !== Uuid.NULL) { Entities.sendHoverEnterEntity(touchTarget.entityID, pointerEvent); - } else if (touchTarget.overlayID && touchTarget.overlayID !== controllerDispatcher.NULL_UUID) { + } else if (touchTarget.overlayID && touchTarget.overlayID !== Uuid.NULL) { Overlays.sendHoverEnterOverlay(touchTarget.overlayID, pointerEvent); } } @@ -60,10 +60,10 @@ function sendHoverOverEventToTouchTarget(hand, touchTarget) { button: "None" }; - if (touchTarget.entityID && touchTarget.entityID !== controllerDispatcher.NULL_UUID) { + if (touchTarget.entityID && touchTarget.entityID !== Uuid.NULL) { Entities.sendMouseMoveOnEntity(touchTarget.entityID, pointerEvent); Entities.sendHoverOverEntity(touchTarget.entityID, pointerEvent); - } else if (touchTarget.overlayID && touchTarget.overlayID !== controllerDispatcher.NULL_UUID) { + } else if (touchTarget.overlayID && touchTarget.overlayID !== Uuid.NULL) { Overlays.sendMouseMoveOnOverlay(touchTarget.overlayID, pointerEvent); Overlays.sendHoverOverOverlay(touchTarget.overlayID, pointerEvent); } @@ -81,10 +81,10 @@ function sendTouchStartEventToTouchTarget(hand, touchTarget) { isPrimaryHeld: true }; - if (touchTarget.entityID && touchTarget.entityID !== controllerDispatcher.NULL_UUID) { + if (touchTarget.entityID && touchTarget.entityID !== Uuid.NULL) { Entities.sendMousePressOnEntity(touchTarget.entityID, pointerEvent); Entities.sendClickDownOnEntity(touchTarget.entityID, pointerEvent); - } else if (touchTarget.overlayID && touchTarget.overlayID !== controllerDispatcher.NULL_UUID) { + } else if (touchTarget.overlayID && touchTarget.overlayID !== Uuid.NULL) { Overlays.sendMousePressOnOverlay(touchTarget.overlayID, pointerEvent); } } @@ -100,11 +100,11 @@ function sendTouchEndEventToTouchTarget(hand, touchTarget) { button: "Primary" }; - if (touchTarget.entityID && touchTarget.entityID !== controllerDispatcher.NULL_UUID) { + if (touchTarget.entityID && touchTarget.entityID !== Uuid.NULL) { Entities.sendMouseReleaseOnEntity(touchTarget.entityID, pointerEvent); Entities.sendClickReleaseOnEntity(touchTarget.entityID, pointerEvent); Entities.sendHoverLeaveEntity(touchTarget.entityID, pointerEvent); - } else if (touchTarget.overlayID && touchTarget.overlayID !== controllerDispatcher.NULL_UUID) { + } else if (touchTarget.overlayID && touchTarget.overlayID !== Uuid.NULL) { Overlays.sendMouseReleaseOnOverlay(touchTarget.overlayID, pointerEvent); } } @@ -121,10 +121,10 @@ function sendTouchMoveEventToTouchTarget(hand, touchTarget) { isPrimaryHeld: true }; - if (touchTarget.entityID && touchTarget.entityID !== controllerDispatcher.NULL_UUID) { + if (touchTarget.entityID && touchTarget.entityID !== Uuid.NULL) { Entities.sendMouseMoveOnEntity(touchTarget.entityID, pointerEvent); Entities.sendHoldingClickOnEntity(touchTarget.entityID, pointerEvent); - } else if (touchTarget.overlayID && touchTarget.overlayID !== controllerDispatcher.NULL_UUID) { + } else if (touchTarget.overlayID && touchTarget.overlayID !== Uuid.NULL) { Overlays.sendMouseMoveOnOverlay(touchTarget.overlayID, pointerEvent); } } diff --git a/scripts/system/nameTag.js b/scripts/system/nameTag.js index 17944bcf85..69e5dac1bf 100644 --- a/scripts/system/nameTag.js +++ b/scripts/system/nameTag.js @@ -13,7 +13,6 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html const CLIENTONLY = false; -const NULL_UUID = "{00000000-0000-0000-0000-000000000000}"; const ENTITY_CHECK_INTERVAL = 5000; // ms = 5 seconds const STARTUP_DELAY = 2000; // ms = 2 second const OLD_AGE = 3500; // we recreate the entity if older than this time in seconds @@ -24,7 +23,7 @@ const SIZE_Y = 0.075; const LETTER_OFFSET = 0.03; // arbitrary value to dynamically change width, could be more accurate by detecting characters const LINE_HEIGHT = 0.05; -var nameTagEntityID = NULL_UUID; +var nameTagEntityID = Uuid.NULL; var lastCheckForEntity = 0; // create the name tag entity after a brief delay @@ -62,9 +61,9 @@ function updateNameTag() { }; function deleteNameTag() { - if(nameTagEntityID !== NULL_UUID) { + if(nameTagEntityID !== Uuid.NULL) { Entities.deleteEntity(nameTagEntityID); - nameTagEntityID = NULL_UUID; + nameTagEntityID = Uuid.NULL; } } @@ -85,7 +84,7 @@ function cleanup() { Script.update.connect(update); function update() { // if no entity we return - if(nameTagEntityID == NULL_UUID) { + if(nameTagEntityID == Uuid.NULL) { return; } diff --git a/scripts/tutorials/createTetherballStick.js b/scripts/tutorials/createTetherballStick.js index 8d36d8ee59..35f5fb0344 100644 --- a/scripts/tutorials/createTetherballStick.js +++ b/scripts/tutorials/createTetherballStick.js @@ -14,7 +14,6 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -var NULL_UUID = "{00000000-0000-0000-0000-000000000000}"; var LIFETIME = 3600; var BALL_SIZE = 0.175; var BALL_DAMPING = 0.5; diff --git a/unpublishedScripts/marketplace/shapes/utilities/utilities.js b/unpublishedScripts/marketplace/shapes/utilities/utilities.js index 71986455d4..b67ba0d9d2 100644 --- a/unpublishedScripts/marketplace/shapes/utilities/utilities.js +++ b/unpublishedScripts/marketplace/shapes/utilities/utilities.js @@ -27,6 +27,7 @@ if (typeof Vec3.abs !== "function") { } if (typeof Quat.ZERO !== "object") { + // TODO: Change to Quat.IDENTITY. Quat.ZERO = Quat.fromVec3Radians(Vec3.ZERO); }