Merge branch 'master' of https://github.com/highfidelity/hifi into running-fix

This commit is contained in:
r3tk0n 2019-04-15 09:47:26 -07:00
commit a40fdf3f77
14 changed files with 350 additions and 157 deletions
interface/src
libraries
avatars-renderer/src/avatars-renderer
avatars/src
render-utils/src
shared/src
tools/jsdoc/plugins

View file

@ -19,14 +19,22 @@ class FancyCamera : public Camera {
Q_OBJECT
/**jsdoc
* @namespace
* @augments Camera
*/
// FIXME: JSDoc 3.5.5 doesn't augment @property definitions. The following definition is repeated in Camera.h.
/**jsdoc
* @property {Uuid} cameraEntity The ID of the entity that the camera position and orientation follow when the camera is in
* entity mode.
* The <code>Camera</code> API provides access to the "camera" that defines your view in desktop and HMD display modes.
*
* @namespace Camera
*
* @hifi-interface
* @hifi-client-entity
* @hifi-avatar
*
* @property {Vec3} position - The position of the camera. You can set this value only when the camera is in independent
* mode.
* @property {Quat} orientation - The orientation of the camera. You can set this value only when the camera is in
* independent mode.
* @property {Camera.Mode} mode - The camera mode.
* @property {ViewFrustum} frustum - The camera frustum.
* @property {Uuid} cameraEntity - The ID of the entity that is used for the camera position and orientation when the
* camera is in entity mode.
*/
Q_PROPERTY(QUuid cameraEntity READ getCameraEntity WRITE setCameraEntity)
@ -38,25 +46,25 @@ public:
public slots:
/**jsdoc
* Get the ID of the entity that the camera is set to use the position and orientation from when it's in entity mode. You can
* also get the entity ID using the <code>Camera.cameraEntity</code> property.
* @function Camera.getCameraEntity
* @returns {Uuid} The ID of the entity that the camera is set to follow when in entity mode; <code>null</code> if no camera
* entity has been set.
*/
/**jsdoc
* Gets the ID of the entity that the camera is set to follow (i.e., use the position and orientation from) when it's in
* entity mode. You can also get the entity ID using the {@link Camera|Camera.cameraEntity} property.
* @function Camera.getCameraEntity
* @returns {Uuid} The ID of the entity that the camera is set to follow when in entity mode; <code>null</code> if no
* camera entity has been set.
*/
QUuid getCameraEntity() const;
/**jsdoc
* Set the entity that the camera should use the position and orientation from when it's in entity mode. You can also set the
* entity using the <code>Camera.cameraEntity</code> property.
* @function Camera.setCameraEntity
* @param {Uuid} entityID The entity that the camera should follow when it's in entity mode.
* @example <caption>Move your camera to the position and orientation of the closest entity.</caption>
* Camera.setModeString("entity");
* var entity = Entities.findClosestEntity(MyAvatar.position, 100.0);
* Camera.setCameraEntity(entity);
*/
* Sets the entity that the camera should follow (i.e., use the position and orientation from) when it's in entity mode.
* You can also set the entity using the {@link Camera|Camera.cameraEntity} property.
* @function Camera.setCameraEntity
* @param {Uuid} entityID - The entity that the camera should follow when it's in entity mode.
* @example <caption>Move your camera to the position and orientation of the closest entity.</caption>
* Camera.setModeString("entity");
* var entity = Entities.findClosestEntity(MyAvatar.position, 100.0);
* Camera.setCameraEntity(entity);
*/
void setCameraEntity(QUuid entityID);
private:

View file

@ -932,6 +932,18 @@ void AvatarManager::setAvatarSortCoefficient(const QString& name, const QScriptV
}
}
/**jsdoc
* PAL (People Access List) data for an avatar.
* @typedef {object} AvatarManager.PalData
* @property {Uuid} sessionUUID - The avatar's session ID. <code>""</code> if the avatar is your own.
* @property {string} sessionDisplayName - The avatar's display name, sanitized and versioned, as defined by the avatar mixer.
* It is unique among all avatars present in the domain at the time.
* @property {number} audioLoudness - The instantaneous loudness of the audio input that the avatar is injecting into the
* domain.
* @property {boolean} isReplicated - <strong>Deprecated.</strong>
* @property {Vec3} position - The position of the avatar.
* @property {number} palOrbOffset - The vertical offset from the avatar's position that an overlay orb should be displayed at.
*/
QVariantMap AvatarManager::getPalData(const QStringList& specificAvatarIdentifiers) {
QJsonArray palData;

View file

@ -37,10 +37,11 @@
using SortedAvatar = std::pair<float, std::shared_ptr<Avatar>>;
/**jsdoc
* The AvatarManager API has properties and methods which manage Avatars within the same domain.
* The <code>AvatarManager</code> API provides information about avatars within the current domain. The avatars available are
* those that Interface has displayed and therefore knows about.
*
* <p><strong>Note:</strong> This API is also provided to Interface and client entity scripts as the synonym,
* <code>AvatarList</code>. For assignment client scripts, see the separate {@link AvatarList} API.
* <p><strong>Warning:</strong> This API is also provided to Interface, client entity, and avatar scripts as the synonym,
* "<code>AvatarList</code>". For assignment client scripts, see the separate {@link AvatarList} API.</p>
*
* @namespace AvatarManager
*
@ -48,8 +49,9 @@ using SortedAvatar = std::pair<float, std::shared_ptr<Avatar>>;
* @hifi-client-entity
* @hifi-avatar
*
* @borrows AvatarList.getAvatarIdentifiers as getAvatarIdentifiers
* @borrows AvatarList.getAvatarsInRange as getAvatarsInRange
* @borrows AvatarList.getAvatar as getAvatar
* @comment AvatarList.getAvatarIdentifiers as getAvatarIdentifiers - Don't borrow because behavior is slightly different.
* @comment AvatarList.getAvatarsInRange as getAvatarsInRange - Don't borrow because behavior is slightly different.
* @borrows AvatarList.avatarAddedEvent as avatarAddedEvent
* @borrows AvatarList.avatarRemovedEvent as avatarRemovedEvent
* @borrows AvatarList.avatarSessionChangedEvent as avatarSessionChangedEvent
@ -67,6 +69,31 @@ class AvatarManager : public AvatarHashMap {
public:
/**jsdoc
* Gets the IDs of all avatars known about in the domain.
* Your own avatar is included in the list as a <code>null</code> value.
* @function AvatarManager.getAvatarIdentifiers
* @returns {Uuid[]} The IDs of all known avatars in the domain.
* @example <caption>Report the IDS of all avatars within the domain.</caption>
* var avatars = AvatarManager.getAvatarIdentifiers();
* print("Avatars in the domain: " + JSON.stringify(avatars));
* // A null item is included for your avatar.
*/
/**jsdoc
* Gets the IDs of all avatars known about within a specified distance from a point.
* Your own avatar's ID is included in the list if it is in range.
* @function AvatarManager.getAvatarsInRange
* @param {Vec3} position - The point about which the search is performed.
* @param {number} range - The search radius.
* @returns {Uuid[]} The IDs of all known avatars within the search distance from the position.
* @example <caption>Report the IDs of all avatars within 10m of your avatar.</caption>
* var RANGE = 10;
* var avatars = AvatarManager.getAvatarsInRange(MyAvatar.position, RANGE);
* print("Nearby avatars: " + JSON.stringify(avatars));
* print("Own avatar: " + MyAvatar.sessionUUID);
*/
/// Registers the script types associated with the avatar manager.
static void registerMetaTypes(QScriptEngine* engine);
@ -79,9 +106,7 @@ public:
glm::vec3 getMyAvatarPosition() const { return _myAvatar->getWorldPosition(); }
/**jsdoc
* @function AvatarManager.getAvatar
* @param {Uuid} avatarID
* @returns {AvatarData}
* @comment Uses the base class's JSDoc.
*/
// Null/Default-constructed QUuids will return MyAvatar
Q_INVOKABLE virtual ScriptAvatarData* getAvatar(QUuid avatarID) override { return new ScriptAvatar(getAvatarBySessionID(avatarID)); }
@ -112,36 +137,53 @@ public:
void handleCollisionEvents(const CollisionEvents& collisionEvents);
/**jsdoc
* Gets the amount of avatar mixer data being generated by an avatar other than your own.
* @function AvatarManager.getAvatarDataRate
* @param {Uuid} sessionID
* @param {string} [rateName=""]
* @returns {number}
* @param {Uuid} sessionID - The ID of the avatar whose data rate you're retrieving.
* @param {AvatarDataRate} [rateName=""] - The type of avatar mixer data to get the data rate of.
* @returns {number} The data rate in kbps; <code>0</code> if the avatar is your own.
*/
Q_INVOKABLE float getAvatarDataRate(const QUuid& sessionID, const QString& rateName = QString("")) const;
/**jsdoc
* Gets the update rate of avatar mixer data being generated by an avatar other than your own.
* @function AvatarManager.getAvatarUpdateRate
* @param {Uuid} sessionID
* @param {string} [rateName=""]
* @returns {number}
* @param {Uuid} sessionID - The ID of the avatar whose update rate you're retrieving.
* @param {AvatarUpdateRate} [rateName=""] - The type of avatar mixer data to get the update rate of.
* @returns {number} The update rate in Hz; <code>0</code> if the avatar is your own.
*/
Q_INVOKABLE float getAvatarUpdateRate(const QUuid& sessionID, const QString& rateName = QString("")) const;
/**jsdoc
* Gets the simulation rate of an avatar other than your own.
* @function AvatarManager.getAvatarSimulationRate
* @param {Uuid} sessionID
* @param {string} [rateName=""]
* @returns {number}
* @param {Uuid} sessionID - The ID of the avatar whose simulation you're retrieving.
* @param {AvatarSimulationRate} [rateName=""] - The type of avatar data to get the simulation rate of.
* @returns {number} The simulation rate in Hz; <code>0</code> if the avatar is your own.
*/
Q_INVOKABLE float getAvatarSimulationRate(const QUuid& sessionID, const QString& rateName = QString("")) const;
/**jsdoc
* Find the first avatar intersected by a {@link PickRay}.
* @function AvatarManager.findRayIntersection
* @param {PickRay} ray
* @param {Uuid[]} [avatarsToInclude=[]]
* @param {Uuid[]} [avatarsToDiscard=[]]
* @param {boolean} pickAgainstMesh
* @returns {RayToAvatarIntersectionResult}
* @param {PickRay} ray - The ray to use for finding avatars.
* @param {Uuid[]} [avatarsToInclude=[]] - If not empty then search is restricted to these avatars.
* @param {Uuid[]} [avatarsToDiscard=[]] - Avatars to ignore in the search.
* @param {boolean} [pickAgainstMesh=true] - If <code>true</code> then the exact intersection with the avatar mesh is
* calculated, if <code>false</code> then the intersection is approximate.
* @returns {RayToAvatarIntersectionResult} The result of the search for the first intersected avatar.
* @example <caption>Find the first avatar directly in front of you.</caption>
* var pickRay = {
* origin: MyAvatar.position,
* direction: Quat.getFront(MyAvatar.orientation)
* };
*
* var intersection = AvatarManager.findRayIntersection(pickRay);
* if (intersection.intersects) {
* print("Avatar found: " + JSON.stringify(intersection));
* } else {
* print("No avatar found.");
* }
*/
Q_INVOKABLE RayToAvatarIntersectionResult findRayIntersection(const PickRay& ray,
const QScriptValue& avatarIdsToInclude = QScriptValue(),
@ -149,11 +191,12 @@ public:
bool pickAgainstMesh = true);
/**jsdoc
* @function AvatarManager.findRayIntersectionVector
* @param {PickRay} ray
* @param {Uuid[]} avatarsToInclude
* @param {Uuid[]} avatarsToDiscard
* @param {boolean} pickAgainstMesh
* @returns {RayToAvatarIntersectionResult}
* @param {PickRay} ray - Ray.
* @param {Uuid[]} avatarsToInclude - Avatars to include.
* @param {Uuid[]} avatarsToDiscard - Avatars to discard.
* @param {boolean} pickAgainstMesh - Pick against mesh.
* @returns {RayToAvatarIntersectionResult} Intersection result.
* @deprecated This function is deprecated and will be removed.
*/
Q_INVOKABLE RayToAvatarIntersectionResult findRayIntersectionVector(const PickRay& ray,
const QVector<EntityItemID>& avatarsToInclude,
@ -162,10 +205,11 @@ public:
/**jsdoc
* @function AvatarManager.findParabolaIntersectionVector
* @param {PickParabola} pick
* @param {Uuid[]} avatarsToInclude
* @param {Uuid[]} avatarsToDiscard
* @returns {ParabolaToAvatarIntersectionResult}
* @param {PickParabola} pick - Pick.
* @param {Uuid[]} avatarsToInclude - Avatars to include.
* @param {Uuid[]} avatarsToDiscard - Avatars to discard.
* @returns {ParabolaToAvatarIntersectionResult} Intersection result.
* @deprecated This function is deprecated and will be removed.
*/
Q_INVOKABLE ParabolaToAvatarIntersectionResult findParabolaIntersectionVector(const PickParabola& pick,
const QVector<EntityItemID>& avatarsToInclude,
@ -173,27 +217,31 @@ public:
/**jsdoc
* @function AvatarManager.getAvatarSortCoefficient
* @param {string} name
* @returns {number}
* @param {string} name - Name.
* @returns {number} Value.
* @deprecated This function is deprecated and will be removed.
*/
// TODO: remove this HACK once we settle on optimal default sort coefficients
Q_INVOKABLE float getAvatarSortCoefficient(const QString& name);
/**jsdoc
* @function AvatarManager.setAvatarSortCoefficient
* @param {string} name
* @param {number} value
* @param {string} name - Name
* @param {number} value - Value.
* @deprecated This function is deprecated and will be removed.
*/
Q_INVOKABLE void setAvatarSortCoefficient(const QString& name, const QScriptValue& value);
/**jsdoc
* Used in the PAL for getting PAL-related data about avatars nearby. Using this method is faster
* than iterating over each avatar and obtaining data about them in JavaScript, as that method
* locks and unlocks each avatar's data structure potentially hundreds of times per update tick.
* Gets PAL (People Access List) data for one or more avatars. Using this method is faster than iterating over each avatar
* and obtaining data about each individually.
* @function AvatarManager.getPalData
* @param {string[]} [specificAvatarIdentifiers=[]] - The list of IDs of the avatars you want the PAL data for.
* If an empty list, the PAL data for all nearby avatars is returned.
* @returns {object[]} An array of objects, each object being the PAL data for an avatar.
* @param {string[]} [avatarIDs=[]] - The IDs of the avatars to get the PAL data for. If empty, then PAL data is obtained
* for all avatars.
* @returns {object<"data", AvatarManager.PalData[]>} An array of objects, each object being the PAL data for an avatar.
* @example <caption>Report the PAL data for an avatar nearby.</caption>
* var palData = AvatarManager.getPalData();
* print("PAL data for one avatar: " + JSON.stringify(palData.data[0]));
*/
Q_INVOKABLE QVariantMap getPalData(const QStringList& specificAvatarIdentifiers = QStringList());
@ -209,7 +257,8 @@ public:
public slots:
/**jsdoc
* @function AvatarManager.updateAvatarRenderStatus
* @param {boolean} shouldRenderAvatars
* @param {boolean} shouldRenderAvatars - Should render avatars.
* @deprecated This function is deprecated and will be removed.
*/
void updateAvatarRenderStatus(bool shouldRenderAvatars);

View file

@ -334,7 +334,9 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
eyeParams.leftEyeJointIndex = _rig.indexOfJoint("LeftEye");
eyeParams.rightEyeJointIndex = _rig.indexOfJoint("RightEye");
_rig.updateFromEyeParameters(eyeParams);
if (_owningAvatar->getHasProceduralEyeFaceMovement()) {
_rig.updateFromEyeParameters(eyeParams);
}
updateFingers();
}

View file

@ -509,6 +509,26 @@ void Avatar::relayJointDataToChildren() {
_reconstructSoftEntitiesJointMap = false;
}
/**jsdoc
* An avatar has different types of data simulated at different rates, in Hz.
*
* <table>
* <thead>
* <tr><th>Rate Name</th><th>Description</th></tr>
* </thead>
* <tbody>
* <tr><td><code>"avatar" or ""</code></td><td>The rate at which the avatar is updated even if not in view.</td></tr>
* <tr><td><code>"avatarInView"</code></td><td>The rate at which the avatar is updated if in view.</td></tr>
* <tr><td><code>"skeletonModel"</code></td><td>The rate at which the skeleton model is being updated, even if there are no
* joint data available.</td></tr>
* <tr><td><code>"jointData"</code></td><td>The rate at which joint data are being updated.</td></tr>
* <tr><td><code>""</code></td><td>When no rate name is specified, the <code>"avatar"</code> update rate is
* provided.</td></tr>
* </tbody>
* </table>
*
* @typedef {string} AvatarSimulationRate
*/
float Avatar::getSimulationRate(const QString& rateName) const {
if (rateName == "") {
return _simulationRate.rate();

View file

@ -501,8 +501,8 @@ public:
/**jsdoc
* @function MyAvatar.getSimulationRate
* @param {string} [rateName=""] - Rate name.
* @returns {number} Simulation rate.
* @param {AvatarSimulationRate} [rateName=""] - Rate name.
* @returns {number} Simulation rate in Hz.
* @deprecated This function is deprecated and will be removed.
*/
Q_INVOKABLE float getSimulationRate(const QString& rateName = QString("")) const;

View file

@ -1545,7 +1545,6 @@ float AvatarData::getDataRate(const QString& rateName) const {
* <tr><th>Rate Name</th><th>Description</th></tr>
* </thead>
* <tbody>
* <tr><td><code>"globalPosition"</code></td><td>Global position.</td></tr>
* <tr><td><code>"localPosition"</code></td><td>Local position.</td></tr>
* <tr><td><code>"avatarBoundingBox"</code></td><td>Avatar bounding box.</td></tr>
@ -1559,7 +1558,6 @@ float AvatarData::getDataRate(const QString& rateName) const {
* <tr><td><code>"faceTracker"</code></td><td>Face tracker data.</td></tr>
* <tr><td><code>"jointData"</code></td><td>Joint data.</td></tr>
* <tr><td><code>"farGrabJointData"</code></td><td>Far grab joint data.</td></tr>
* <tr><td><code>""</code></td><td>When no rate name is specified, the overall update rate is provided.</td></tr>
* </tbody>
* </table>
@ -1721,7 +1719,6 @@ glm::vec3 AvatarData::getJointTranslation(const QString& name) const {
// on another thread in between the call to getJointIndex and getJointTranslation
// return getJointTranslation(getJointIndex(name));
return readLockWithNamedJointIndex<glm::vec3>(name, [this](int index) {
return _jointData.at(index).translation;
return getJointTranslation(index);
});
}
@ -1809,8 +1806,8 @@ glm::quat AvatarData::getJointRotation(const QString& name) const {
// Can't do this, not thread safe
// return getJointRotation(getJointIndex(name));
return readLockWithNamedJointIndex<glm::quat>(name, [&](int index) {
return _jointData.at(index).rotation;
return readLockWithNamedJointIndex<glm::quat>(name, [this](int index) {
return getJointRotation(index);
});
}
@ -2905,6 +2902,20 @@ glm::mat4 AvatarData::getControllerRightHandMatrix() const {
return _controllerRightHandMatrixCache.get();
}
/**jsdoc
* Information about a ray-to-avatar intersection.
* @typedef {object} RayToAvatarIntersectionResult
* @property {boolean} intersects - <code>true</code> if an avatar is intersected, <code>false</code> if it isn't.
* @property {string} avatarID - The ID of the avatar that is intersected.
* @property {number} distance - The distance from the ray origin to the intersection.
* @property {string} face - The name of the box face that is intersected; <code>"UNKNOWN_FACE"</code> if mesh was picked
* against.
* @property {Vec3} intersection - The ray intersection point in world coordinates.
* @property {Vec3} surfaceNormal - The surface normal at the intersection point.
* @property {number} jointIndex - The index of the joint intersected.
* @property {SubmeshIntersection} extraInfo - Extra information on the mesh intersected if mesh was picked against,
* <code>{}</code> if it wasn't.
*/
QScriptValue RayToAvatarIntersectionResultToScriptValue(QScriptEngine* engine, const RayToAvatarIntersectionResult& value) {
QScriptValue obj = engine->newObject();
obj.setProperty("intersects", value.intersects);

View file

@ -479,7 +479,8 @@ class AvatarData : public QObject, public SpatiallyNestable {
* avatar. <em>Read-only.</em>
* @property {number} sensorToWorldScale - The scale that transforms dimensions in the user's real world to the avatar's
* size in the virtual world. <em>Read-only.</em>
* @property {boolean} hasPriority - is the avatar in a Hero zone? <em>Read-only.</em>
* @property {boolean} hasPriority - <code>true</code> if the avatar is in a "hero" zone, <code>false</code> if it isn't.
* <em>Read-only.</em>
*/
Q_PROPERTY(glm::vec3 position READ getWorldPosition WRITE setPositionViaScript)
Q_PROPERTY(float scale READ getDomainLimitedScale WRITE setTargetScale)
@ -1751,14 +1752,11 @@ protected:
template <typename T, typename F>
T readLockWithNamedJointIndex(const QString& name, const T& defaultValue, F f) const {
int index = getFauxJointIndex(name);
QReadLocker readLock(&_jointDataLock);
// The first conditional is superfluous, but illustrative
if (index == -1 || index < _jointData.size()) {
int index = getJointIndex(name);
if (index == -1) {
return defaultValue;
}
return f(index);
}
@ -1769,8 +1767,8 @@ protected:
template <typename F>
void writeLockWithNamedJointIndex(const QString& name, F f) {
int index = getFauxJointIndex(name);
QWriteLocker writeLock(&_jointDataLock);
int index = getJointIndex(name);
if (index == -1) {
return;
}

View file

@ -36,8 +36,10 @@ const int CLIENT_TO_AVATAR_MIXER_BROADCAST_FRAMES_PER_SECOND = 50;
const quint64 MIN_TIME_BETWEEN_MY_AVATAR_DATA_SENDS = USECS_PER_SECOND / CLIENT_TO_AVATAR_MIXER_BROADCAST_FRAMES_PER_SECOND;
/**jsdoc
* <strong>Note:</strong> An <code>AvatarList</code> API is also provided for Interface and client entity scripts: it is a
* synonym for the {@link AvatarManager} API.
* The <code>AvatarList</code> API provides information about avatars within the current domain.
*
* <p><strong>Warning:</strong> An API named "<code>AvatarList</code>" is also provided for Interface, client entity, and avatar
* scripts, however, it is a synonym for the {@link AvatarManager} API.</p>
*
* @namespace AvatarList
*
@ -78,23 +80,37 @@ public:
// Currently, your own avatar will be included as the null avatar id.
/**jsdoc
* Gets the IDs of all avatars in the domain.
* <p><strong>Warning:</strong> If the AC script is acting as an avatar (i.e., <code>Agent.isAvatar == true</code>) the
* avatar's ID is NOT included in results.</p>
* @function AvatarList.getAvatarIdentifiers
* @returns {Uuid[]}
* @returns {Uuid[]} The IDs of all avatars in the domain (excluding AC script's avatar).
* @example <caption>Report the IDS of all avatars within the domain.</caption>
* var avatars = AvatarList.getAvatarIdentifiers();
* print("Avatars in the domain: " + JSON.stringify(avatars));
*/
Q_INVOKABLE QVector<QUuid> getAvatarIdentifiers();
/**jsdoc
* Gets the IDs of all avatars within a specified distance from a point.
* <p><strong>Warning:</strong> If the AC script is acting as an avatar (i.e., <code>Agent.isAvatar == true</code>) the
* avatar's ID is NOT included in results.</p>
* @function AvatarList.getAvatarsInRange
* @param {Vec3} position
* @param {number} range
* @returns {Uuid[]}
* @param {Vec3} position - The point about which the search is performed.
* @param {number} range - The search radius.
* @returns {Uuid[]} The IDs of all avatars within the search distance from the position (excluding AC script's avatar).
* @example <caption>Report the IDs of all avatars within 10m of the origin.</caption>
* var RANGE = 10;
* var avatars = AvatarList.getAvatarsInRange(Vec3.ZERO, RANGE);
* print("Avatars near the origin: " + JSON.stringify(avatars));
*/
Q_INVOKABLE QVector<QUuid> getAvatarsInRange(const glm::vec3& position, float rangeMeters) const;
/**jsdoc
* Gets information about an avatar.
* @function AvatarList.getAvatar
* @param {Uuid} avatarID
* @returns {AvatarData}
* @param {Uuid} avatarID - The ID of the avatar.
* @returns {AvatarData} Information about the avatar.
*/
// Null/Default-constructed QUuids will return MyAvatar
Q_INVOKABLE virtual ScriptAvatarData* getAvatar(QUuid avatarID) { return new ScriptAvatarData(getAvatarBySessionID(avatarID)); }
@ -110,34 +126,57 @@ public:
signals:
/**jsdoc
* Triggered when an avatar arrives in the domain.
* @function AvatarList.avatarAddedEvent
* @param {Uuid} sessionUUID
* @param {Uuid} sessionUUID - The ID of the avatar that arrived in the domain.
* @returns {Signal}
* @example <caption>Report when an avatar arrives in the domain.</caption>
* AvatarManager.avatarAddedEvent.connect(function (sessionID) {
* print("Avatar arrived: " + sessionID);
* });
*
* // Note: If using from the AvatarList API, replace "AvatarManager" with "AvatarList".
*/
void avatarAddedEvent(const QUuid& sessionUUID);
/**jsdoc
* Triggered when an avatar leaves the domain.
* @function AvatarList.avatarRemovedEvent
* @param {Uuid} sessionUUID
* @param {Uuid} sessionUUID - The ID of the avatar that left the domain.
* @returns {Signal}
* @example <caption>Report when an avatar leaves the domain.</caption>
* AvatarManager.avatarRemovedEvent.connect(function (sessionID) {
* print("Avatar left: " + sessionID);
* });
*
* // Note: If using from the AvatarList API, replace "AvatarManager" with "AvatarList".
*/
void avatarRemovedEvent(const QUuid& sessionUUID);
/**jsdoc
* Triggered when an avatar's session ID changes.
* @function AvatarList.avatarSessionChangedEvent
* @param {Uuid} sessionUUID
* @param {Uuid} oldSessionUUID
* @param {Uuid} newSessionUUID - The new session ID.
* @param {Uuid} oldSessionUUID - The old session ID.
* @returns {Signal}
* @example <caption>Report when an avatar's session ID changes.</caption>
* AvatarManager.avatarSessionChangedEvent.connect(function (newSessionID, oldSessionID) {
* print("Avatar session ID changed from " + oldSessionID + " to " + newSessionID);
* });
*
* // Note: If using from the AvatarList API, replace "AvatarManager" with "AvatarList".
*/
void avatarSessionChangedEvent(const QUuid& sessionUUID,const QUuid& oldUUID);
public slots:
/**jsdoc
* Checks whether there is an avatar within a specified distance from a point.
* @function AvatarList.isAvatarInRange
* @param {string} position
* @param {string} range
* @returns {boolean}
* @param {string} position - The test position.
* @param {string} range - The test distance.
* @returns {boolean} <code>true</code> if there's an avatar within the specified distance of the point, <code>false</code>
* if not.
*/
bool isAvatarInRange(const glm::vec3 & position, const float range);
@ -145,36 +184,41 @@ protected slots:
/**jsdoc
* @function AvatarList.sessionUUIDChanged
* @param {Uuid} sessionUUID
* @param {Uuid} oldSessionUUID
* @param {Uuid} sessionUUID - New session ID.
* @param {Uuid} oldSessionUUID - Old session ID.
* @deprecated This function is deprecated and will be removed.
*/
void sessionUUIDChanged(const QUuid& sessionUUID, const QUuid& oldUUID);
/**jsdoc
* @function AvatarList.processAvatarDataPacket
* @param {} message
* @param {} sendingNode
* @param {object} message - Message.
* @param {object} sendingNode - Sending node.
* @deprecated This function is deprecated and will be removed.
*/
void processAvatarDataPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode);
/**jsdoc
* @function AvatarList.processAvatarIdentityPacket
* @param {} message
* @param {} sendingNode
* @param {object} message - Message.
* @param {object} sendingNode - Sending node.
* @deprecated This function is deprecated and will be removed.
*/
void processAvatarIdentityPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode);
/**jsdoc
* @function AvatarList.processBulkAvatarTraits
* @param {} message
* @param {} sendingNode
* @param {object} message - Message.
* @param {object} sendingNode - Sending node.
* @deprecated This function is deprecated and will be removed.
*/
void processBulkAvatarTraits(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode);
/**jsdoc
* @function AvatarList.processKillAvatar
* @param {} message
* @param {} sendingNode
* @param {object} message - Message.
* @param {object} sendingNode - Sending node.
* @deprecated This function is deprecated and will be removed.
*/
void processKillAvatar(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode);

View file

@ -16,6 +16,52 @@
#include "AvatarData.h"
/**jsdoc
* Information about an avatar.
* @typedef {object} AvatarData
* @property {Vec3} position - The avatar's position.
* @property {number} scale - The target scale of the avatar without any restrictions on permissible values imposed by the
* domain.
* @property {Vec3} handPosition - A user-defined hand position, in world coordinates. The position moves with the avatar but
* is otherwise not used or changed by Interface.
* @property {number} bodyPitch - The pitch of the avatar's body, in degrees.
* @property {number} bodyYaw - The yaw of the avatar's body, in degrees.
* @property {number} bodyRoll - The roll of the avatar's body, in degrees.
* @property {Quat} orientation - The orientation of the avatar's body.
* @property {Quat} headOrientation - The orientation of the avatar's head.
* @property {number} headPitch - The pitch of the avatar's head relative to the body, in degrees.
* @property {number} headYaw - The yaw of the avatar's head relative to the body, in degrees.
* @property {number} headRoll - The roll of the avatar's head relative to the body, in degrees.
*
* @property {Vec3} velocity - The linear velocity of the avatar.
* @property {Vec3} angularVelocity - The angular velocity of the avatar.
*
* @property {Uuid} sessionUUID - The avatar's session ID.
* @property {string} displayName - The avatar's display name.
* @property {string} sessionDisplayName - The avatar's display name, sanitized and versioned, as defined by the avatar mixer.
* It is unique among all avatars present in the domain at the time.
* @property {boolean} isReplicated - <strong>Deprecated.</strong>
* @property {boolean} lookAtSnappingEnabled - <code>true</code> if the avatar's eyes snap to look at another avatar's eyes
* when the other avatar is in the line of sight and also has <code>lookAtSnappingEnabled == true</code>.
*
* @property {string} skeletonModelURL - The avatar's FST file.
* @property {AttachmentData[]} attachmentData - Information on the avatar's attachments.<br />
* <strong>Deprecated:</strong> Use avatar entities instead.
* @property {string[]} jointNames - The list of joints in the current avatar model.
*
* @property {number} audioLoudness - The instantaneous loudness of the audio input that the avatar is injecting into the
* domain.
* @property {number} audioAverageLoudness - The rolling average loudness of the audio input that the avatar is injecting into
* the domain.
*
* @property {Mat4} sensorToWorldMatrix - The scale, rotation, and translation transform from the user's real world to the
* avatar's size, orientation, and position in the virtual world.
* @property {Mat4} controllerLeftHandMatrix - The rotation and translation of the left hand controller relative to the avatar.
* @property {Mat4} controllerRightHandMatrix - The rotation and translation of the right hand controller relative to the
* avatar.
*
* @property {boolean} hasPriority - <code>true</code> if the avatar is in a "hero" zone, <code>false</code> if it isn't.
*/
class ScriptAvatarData : public QObject {
Q_OBJECT

View file

@ -444,6 +444,19 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g
}
}
/**jsdoc
* Information about a submesh intersection point.
* @typedef {object} SubmeshIntersection
* @property {Vec3} worldIntersectionPoint - The intersection point in world coordinates.
* @property {Vec3} meshIntersectionPoint - The intersection point in model coordinates.
* @property {number} partIndex - The index of the intersected mesh part within the submesh.
* @property {number} shapeID - The index of the mesh part within the model.
* @property {number} subMeshIndex - The index of the intersected submesh within the model.
* @property {string} subMeshName - The name of the intersected submesh.
* @property {Triangle} subMeshTriangleWorld - The vertices of the intersected mesh part triangle in world coordinates.
* @property {Vec3} subMeshNormal - The normal of the intersected mesh part triangle in model coordinates.
* @property {Triangle} subMeshTriangle - The vertices of the intersected mesh part triangle in model coordinates.
*/
if (intersectedSomething) {
distance = bestDistance;
face = bestFace;

View file

@ -119,6 +119,13 @@ void swingTwistDecomposition(const glm::quat& rotation,
glm::quat& swing,
glm::quat& twist);
/**jsdoc
* A triangle in a mesh.
* @typedef {object} Triangle
* @property {Vec3} v0 - The position of vertex 0 in the triangle.
* @property {Vec3} v1 - The position of vertex 1 in the triangle.
* @property {Vec3} v2 - The position of vertex 2 in the triangle.
*/
class Triangle {
public:
glm::vec3 v0;

View file

@ -36,25 +36,6 @@ static int cameraModeId = qRegisterMetaType<CameraMode>();
class Camera : public QObject {
Q_OBJECT
/**jsdoc
* The Camera API provides access to the "camera" that defines your view in desktop and HMD display modes.
*
* @namespace Camera
*
* @hifi-interface
* @hifi-client-entity
* @hifi-avatar
*
* @property {Vec3} position - The position of the camera. You can set this value only when the camera is in independent
* mode.
* @property {Quat} orientation - The orientation of the camera. You can set this value only when the camera is in
* independent mode.
* @property {Camera.Mode} mode - The camera mode.
* @property {ViewFrustum} frustum - The camera frustum.
* @property {Uuid} cameraEntity - The ID of the entity that is used for the camera position and orientation when the
* camera is in entity mode.
*/
// FIXME: The cameraEntity property definition is copied from FancyCamera.h.
Q_PROPERTY(glm::vec3 position READ getPosition WRITE setPosition)
Q_PROPERTY(glm::quat orientation READ getOrientation WRITE setOrientation)
Q_PROPERTY(QString mode READ getModeString WRITE setModeString)
@ -82,53 +63,54 @@ public:
public slots:
/**jsdoc
* Get the current camera mode. You can also get the mode using the <code>Camera.mode</code> property.
* Gets the current camera mode. You can also get the mode using the {@link Camera|Camera.mode} property.
* @function Camera.getModeString
* @returns {Camera.Mode} The current camera mode.
*/
QString getModeString() const;
/**jsdoc
* Set the camera mode. You can also set the mode using the <code>Camera.mode</code> property.
* @function Camera.setModeString
* @param {Camera.Mode} mode - The mode to set the camera to.
*/
* Sets the camera mode. You can also set the mode using the {@link Camera|Camera.mode} property.
* @function Camera.setModeString
* @param {Camera.Mode} mode - The mode to set the camera to.
*/
void setModeString(const QString& mode);
/**jsdoc
* Get the current camera position. You can also get the position using the <code>Camera.position</code> property.
* @function Camera.getPosition
* @returns {Vec3} The current camera position.
*/
* Gets the current camera position. You can also get the position using the {@link Camera|Camera.position} property.
* @function Camera.getPosition
* @returns {Vec3} The current camera position.
*/
glm::vec3 getPosition() const { return _position; }
/**jsdoc
* Set the camera position. You can also set the position using the <code>Camera.position</code> property. Only works if the
* camera is in independent mode.
* @function Camera.setPosition
* @param {Vec3} position - The position to set the camera at.
*/
* Sets the camera position. You can also set the position using the {@link Camera|Camera.position} property. Only works if
* the camera is in independent mode.
* @function Camera.setPosition
* @param {Vec3} position - The position to set the camera at.
*/
void setPosition(const glm::vec3& position);
/**jsdoc
* Get the current camera orientation. You can also get the orientation using the <code>Camera.orientation</code> property.
* @function Camera.getOrientation
* @returns {Quat} The current camera orientation.
*/
* Gets the current camera orientation. You can also get the orientation using the {@link Camera|Camera.orientation}
* property.
* @function Camera.getOrientation
* @returns {Quat} The current camera orientation.
*/
glm::quat getOrientation() const { return _orientation; }
/**jsdoc
* Set the camera orientation. You can also set the orientation using the <code>Camera.orientation</code> property. Only
* works if the camera is in independent mode.
* @function Camera.setOrientation
* @param {Quat} orientation - The orientation to set the camera to.
*/
* Sets the camera orientation. You can also set the orientation using the {@link Camera|Camera.orientation} property. Only
* works if the camera is in independent mode.
* @function Camera.setOrientation
* @param {Quat} orientation - The orientation to set the camera to.
*/
void setOrientation(const glm::quat& orientation);
/**jsdoc
* Compute a {@link PickRay} based on the current camera configuration and the specified <code>x, y</code> position on the
* screen. The {@link PickRay} can be used in functions such as {@link Entities.findRayIntersection} and
* {@link Overlays.findRayIntersection}.
* Computes a {@link PickRay} based on the current camera configuration and the specified <code>x, y</code> position on the
* screen. The {@link PickRay} can be used in functions such as {@link Entities.findRayIntersection} and
* {@link Overlays.findRayIntersection}.
* @function Camera.computePickRay
* @param {number} x - X-coordinate on screen.
* @param {number} y - Y-coordinate on screen.
@ -147,9 +129,9 @@ public slots:
virtual PickRay computePickRay(float x, float y) const = 0;
/**jsdoc
* Rotate the camera to look at the specified <code>position</code>. Only works if the camera is in independent mode.
* Rotates the camera to look at the specified <code>position</code>. Only works if the camera is in independent mode.
* @function Camera.lookAt
* @param {Vec3} position - Position to look at.
* @param {Vec3} position - The position to look at.
* @example <caption>Rotate your camera to look at entities as you click on them with your mouse.</caption>
* function onMousePressEvent(event) {
* var pickRay = Camera.computePickRay(event.x, event.y);
@ -168,15 +150,15 @@ public slots:
void lookAt(const glm::vec3& position);
/**jsdoc
* Set the camera to continue looking at the specified <code>position</code> even while the camera moves. Only works if the
* camera is in independent mode.
* Sets the camera to continue looking at the specified <code>position</code> even while the camera moves. Only works if
* the camera is in independent mode.
* @function Camera.keepLookingAt
* @param {Vec3} position - Position to keep looking at.
* @param {Vec3} position - The position to keep looking at.
*/
void keepLookingAt(const glm::vec3& position);
/**jsdoc
* Stops the camera from continually looking at the position that was set with <code>Camera.keepLookingAt</code>.
* Stops the camera from continually looking at the position that was set with {@link Camera.keepLookingAt}.
* @function Camera.stopLookingAt
*/
void stopLooking() { _isKeepLookingAt = false; }

View file

@ -58,6 +58,7 @@ exports.handlers = {
'../../libraries/physics/src',
'../../libraries/plugins/src/plugins',
'../../libraries/pointers/src',
'../../libraries/render-utils/src',
'../../libraries/script-engine/src',
'../../libraries/shared/src',
'../../libraries/shared/src/shared',