Overte C++ Documentation
MyAvatar.h
1 //
2 // MyAvatar.h
3 // interface/src/avatar
4 //
5 // Created by Mark Peng on 8/16/13.
6 // Copyright 2012 High Fidelity, Inc.
7 // Copyright 2021 Vircadia contributors.
8 // Copyright 2022-2023 Overte e.V.
9 //
10 // Distributed under the Apache License, Version 2.0.
11 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
12 // SPDX-License-Identifier: Apache-2.0
13 //
14 
15 #ifndef hifi_MyAvatar_h
16 #define hifi_MyAvatar_h
17 
18 #include <bitset>
19 #include <memory>
20 
21 #include <glm/glm.hpp>
22 
23 #include <QUuid>
24 
25 #include <AvatarConstants.h>
26 #include <avatars-renderer/Avatar.h>
27 #include <avatars-renderer/ScriptAvatar.h>
28 #include <controllers/Pose.h>
29 #include <controllers/Actions.h>
30 #include <EntityItem.h>
31 #include <HelperScriptEngine.h>
32 #include <ThreadSafeValueCache.h>
33 #include <Rig.h>
34 #include <SettingHandle.h>
35 #include <Sound.h>
36 #include <shared/Camera.h>
37 #include <ScriptValue.h>
38 
39 #include "AtRestDetector.h"
40 #include "MyCharacterController.h"
41 #include "RingBufferHistory.h"
42 
43 class AvatarActionHold;
44 class ModelItemID;
45 class MyHead;
46 class DetailedMotionState;
47 class ScriptEngine;
48 using ScriptEnginePointer = std::shared_ptr<ScriptEngine>;
49 
50 /*@jsdoc
51  * <p>Locomotion control types.</p>
52  * <table>
53  * <thead>
54  * <tr><th>Value</th><th>Name</th><th>Description</th></tr>
55  * </thead>
56  * <tbody>
57  * <tr><td><code>0</code></td><td>Default</td><td>Your walking speed is constant; it doesn't change depending on how far
58  * forward you push your controller's joystick. Fully pushing your joystick forward makes your avatar run.</td></tr>
59  * <tr><td><code>1</code></td><td>Analog</td><td>Your walking speed changes in steps based on how far forward you push your
60  * controller's joystick. Fully pushing your joystick forward makes your avatar run.</td></tr>
61  * <tr><td><code>2</code></td><td>AnalogPlus</td><td>Your walking speed changes proportionally to how far forward you push
62  * your controller's joystick. Fully pushing your joystick forward makes your avatar run.</td></tr>
63  * </tbody>
64  * </table>
65  * @typedef {number} MyAvatar.LocomotionControlsMode
66  */
67 enum LocomotionControlsMode {
68  CONTROLS_DEFAULT = 0,
69  CONTROLS_ANALOG,
70  CONTROLS_ANALOG_PLUS
71 };
72 
73 enum LocomotionRelativeMovementMode {
74  MOVEMENT_HMD_RELATIVE = 0,
75  MOVEMENT_HAND_RELATIVE,
76  MOVEMENT_HAND_RELATIVE_LEVELED
77 };
78 
79 enum eyeContactTarget {
80  LEFT_EYE,
81  RIGHT_EYE,
82  MOUTH
83 };
84 
85 enum AudioListenerMode {
86  FROM_HEAD = 0,
87  FROM_CAMERA,
88  CUSTOM
89 };
90 
91 Q_DECLARE_METATYPE(AudioListenerMode);
92 
93 class MyAvatar : public Avatar {
94  Q_OBJECT
95  friend class AnimStats;
96 
97  /*@jsdoc
98  * Your avatar is your in-world representation of you. The <code>MyAvatar</code> API is used to manipulate the avatar.
99  * For example, you can customize the avatar's appearance, run custom avatar animations,
100  * change the avatar's position within the domain, or manage the avatar's collisions with the environment and other avatars.
101  *
102  * <p>For assignment client scripts, see {@link Avatar}.</p>
103  *
104  * @namespace MyAvatar
105  *
106  * @hifi-interface
107  * @hifi-client-entity
108  * @hifi-avatar
109  *
110  * @comment IMPORTANT: This group of properties is copied from AvatarData.h; they should NOT be edited here.
111  * @property {Vec3} position - The position of the avatar.
112  * @property {number} scale=1.0 - The scale of the avatar. The value can be set to anything between <code>0.005</code> and
113  * <code>1000.0</code>. When the scale value is fetched, it may temporarily be further limited by the domain's settings.
114  * @property {number} density - The density of the avatar in kg/m<sup>3</sup>. The density is used to work out its mass in
115  * the application of physics. <em>Read-only.</em>
116  * @property {Vec3} handPosition - A user-defined hand position, in world coordinates. The position moves with the avatar
117  * but is otherwise not used or changed by Interface.
118  * @property {number} bodyYaw - The left or right rotation about an axis running from the head to the feet of the avatar.
119  * Yaw is sometimes called "heading".
120  * @property {number} bodyPitch - The rotation about an axis running from shoulder to shoulder of the avatar. Pitch is
121  * sometimes called "elevation".
122  * @property {number} bodyRoll - The rotation about an axis running from the chest to the back of the avatar. Roll is
123  * sometimes called "bank".
124  * @property {Quat} orientation - The orientation of the avatar.
125  * @property {Quat} headOrientation - The orientation of the avatar's head.
126  * @property {number} headPitch - The rotation about an axis running from ear to ear of the avatar's head. Pitch is
127  * sometimes called "elevation".
128  * @property {number} headYaw - The rotation left or right about an axis running from the base to the crown of the avatar's
129  * head. Yaw is sometimes called "heading".
130  * @property {number} headRoll - The rotation about an axis running from the nose to the back of the avatar's head. Roll is
131  * sometimes called "bank".
132  * @property {Vec3} velocity - The current velocity of the avatar.
133  * @property {Vec3} angularVelocity - The current angular velocity of the avatar.
134  * @property {number} audioLoudness - The instantaneous loudness of the audio input that the avatar is injecting into the
135  * domain.
136  * @property {number} audioAverageLoudness - The rolling average loudness of the audio input that the avatar is injecting
137  * into the domain.
138  * @property {string} displayName - The avatar's display name.
139  * @property {string} sessionDisplayName - <code>displayName's</code> sanitized and default version defined by the avatar
140  * mixer rather than Interface clients. The result is unique among all avatars present in the domain at the time.
141  * @property {boolean} lookAtSnappingEnabled=true - <code>true</code> if the avatar's eyes snap to look at another avatar's
142  * eyes when the other avatar is in the line of sight and also has <code>lookAtSnappingEnabled == true</code>.
143  * @property {string} skeletonModelURL - The avatar's FST file.
144  * @property {AttachmentData[]} attachmentData - Information on the avatar's attachments.
145  * <p class="important">Deprecated: This property is deprecated and will be removed. Use avatar entities instead.</p>
146  * @property {string[]} jointNames - The list of joints in the current avatar model. <em>Read-only.</em>
147  * @property {Uuid} sessionUUID - Unique ID of the avatar in the domain. <em>Read-only.</em>
148  * @property {Mat4} sensorToWorldMatrix - The scale, rotation, and translation transform from the user's real world to the
149  * avatar's size, orientation, and position in the virtual world. <em>Read-only.</em>
150  * @property {Mat4} controllerLeftHandMatrix - The rotation and translation of the left hand controller relative to the
151  * avatar. <em>Read-only.</em>
152  * @property {Mat4} controllerRightHandMatrix - The rotation and translation of the right hand controller relative to the
153  * avatar. <em>Read-only.</em>
154  * @property {number} sensorToWorldScale - The scale that transforms dimensions in the user's real world to the avatar's
155  * size in the virtual world. <em>Read-only.</em>
156  * @property {boolean} hasPriority - <code>true</code> if the avatar is in a "hero" zone, <code>false</code> if it isn't.
157  * <em>Read-only.</em>
158  * @property {boolean} hasScriptedBlendshapes=false - <code>true</code> if blend shapes are controlled by scripted actions,
159  * otherwise <code>false</code>. Set this to <code>true</code> before using the {@link MyAvatar.setBlendshape} method,
160  * and set back to <code>false</code> after you no longer want scripted control over the blend shapes.
161  * <p><strong>Note:</strong> This property will automatically be set to <code>true</code> if the controller system has
162  * valid facial blend shape actions.</p>
163  * @property {boolean} hasProceduralBlinkFaceMovement=true - <code>true</code> if avatars blink automatically by animating
164  * facial blend shapes, <code>false</code> if automatic blinking is disabled. Set to <code>false</code> to fully control
165  * the blink facial blend shapes via the {@link MyAvatar.setBlendshape} method.
166  * @property {boolean} hasProceduralEyeFaceMovement=true - <code>true</code> if the facial blend shapes for an avatar's eyes
167  * adjust automatically as the eyes move, <code>false</code> if this automatic movement is disabled. Set this property
168  * to <code>true</code> to prevent the iris from being obscured by the upper or lower lids. Set to <code>false</code> to
169  * fully control the eye blend shapes via the {@link MyAvatar.setBlendshape} method.
170  * @property {boolean} hasAudioEnabledFaceMovement=true - <code>true</code> if the avatar's mouth blend shapes animate
171  * automatically based on detected microphone input, <code>false</code> if this automatic movement is disabled. Set
172  * this property to <code>false</code> to fully control the mouth facial blend shapes via the
173  * {@link MyAvatar.setBlendshape} method.
174  *
175  * @comment IMPORTANT: This group of properties is copied from Avatar.h; they should NOT be edited here.
176  * @property {Vec3} skeletonOffset - Can be used to apply a translation offset between the avatar's position and the
177  * registration point of the 3D model.
178  *
179  * @property {Vec3} qmlPosition - A synonym for <code>position</code> for use by QML.
180  * <p class="important">Deprecated: This property is deprecated and will be removed.</p>
181  *
182  * @property {Vec3} feetPosition - The position of the avatar's feet.
183  * @property {boolean} shouldRenderLocally=true - If <code>true</code> then your avatar is rendered for you in Interface,
184  * otherwise it is not rendered for you (but it is still rendered for other users).
185  * @property {Vec3} motorVelocity=Vec3.ZERO - The target velocity of your avatar to be achieved by a scripted motor.
186  * @property {number} motorTimescale=1000000 - The timescale for the scripted motor to achieve the target
187  * <code>motorVelocity</code> avatar velocity. Smaller values result in higher acceleration.
188  * @property {string} motorReferenceFrame="camera" - Reference frame of the <code>motorVelocity</code>. Must be one of the
189  * following: <code>"camera"</code>, <code>"avatar"</code>, and <code>"world"</code>.
190  * @property {string} motorMode="simple" - The Type of scripted motor behavior: <code>"simple"</code> to use the
191  * <code>motorTimescale</code> time scale; <code>"dynamic"</code> to use character controller timescales.
192  * @property {string} collisionSoundURL="Body_Hits_Impact.wav" - The sound that's played when the avatar experiences a
193  * collision. It can be a mono or stereo 16-bit WAV file running at either 24kHz or 48kHz. The latter is down-sampled
194  * by the audio mixer, so all audio effectively plays back at a 24khz. 48kHz RAW files are also supported.
195  * @property {number} audioListenerMode=0 - Specifies the listening position when hearing spatialized audio. Must be one
196  * of the following property values:
197  * <ul>
198  * <li><code>MyAvatar.audioListenerModeHead</code></li>
199  * <li><code>MyAvatar.audioListenerModeCamera</code></li>
200  * <li><code>MyAvatar.audioListenerModeCustom</code></li>
201  * </ul>
202  * @property {number} audioListenerModeHead=0 - The audio listening position is at the avatar's head. <em>Read-only.</em>
203  * @property {number} audioListenerModeCamera=1 - The audio listening position is at the camera. <em>Read-only.</em>
204  * @property {number} audioListenerModeCustom=2 - The audio listening position is at a the position specified by set by the
205  * <code>customListenPosition</code> and <code>customListenOrientation</code> property values. <em>Read-only.</em>
206  * @property {Vec3} customListenPosition=Vec3.ZERO - The listening position used when the <code>audioListenerMode</code>
207  * property value is <code>audioListenerModeCustom</code>.
208  * @property {Quat} customListenOrientation=Quat.IDENTITY - The listening orientation used when the
209  * <code>audioListenerMode</code> property value is <code>audioListenerModeCustom</code>.
210  * @property {number} rotationRecenterFilterLength - Configures how quickly the avatar root rotates to recenter its facing
211  * direction to match that of the user's torso based on head and hands orientation. A smaller value makes the
212  * recentering happen more quickly. The minimum value is <code>0.01</code>.
213  * @property {number} rotationThreshold - The angle in radians that the user's torso facing direction (based on head and
214  * hands orientation) can differ from that of the avatar before the avatar's root is rotated to match the user's torso.
215  * @property {boolean} enableStepResetRotation - If <code>true</code> then after the user's avatar takes a step, the
216  * avatar's root immediately rotates to recenter its facing direction to match that of the user's torso based on head
217  * and hands orientation.
218  * @property {boolean} enableDrawAverageFacing - If <code>true</code>, debug graphics are drawn that show the average
219  * facing direction of the user's torso (based on head and hands orientation). This can be useful if you want to try
220  * out different filter lengths and thresholds.
221  *
222  * @property {Vec3} leftHandPosition - The position of the left hand in avatar coordinates if it's being positioned by
223  * controllers, otherwise {@link Vec3(0)|Vec3.ZERO}. <em>Read-only.</em>
224  * @property {Vec3} rightHandPosition - The position of the right hand in avatar coordinates if it's being positioned by
225  * controllers, otherwise {@link Vec3(0)|Vec3.ZERO}. <em>Read-only.</em>
226  * @property {Vec3} leftHandTipPosition - The position 0.3m in front of the left hand's position, in the direction along the
227  * palm, in avatar coordinates. If the hand isn't being positioned by a controller, the value is
228  * {@link Vec3(0)|Vec3.ZERO}. <em>Read-only.</em>
229  * @property {Vec3} rightHandTipPosition - The position 0.3m in front of the right hand's position, in the direction along
230  * the palm, in avatar coordinates. If the hand isn't being positioned by a controller, the value is
231  * {@link Vec3(0)|Vec3.ZERO}. <em>Read-only.</em>
232  *
233  * @property {Pose} leftHandPose - The left hand's pose as determined by the hand controllers, relative to the avatar.
234  * <em>Read-only.</em>
235  * @property {Pose} rightHandPose - The right hand's pose as determined by the hand controllers, relative to the avatar.
236  * <em>Read-only.</em>
237  * @property {Pose} leftHandTipPose - The left hand's pose as determined by the hand controllers, relative to the avatar,
238  * with the position adjusted by 0.3m along the direction of the palm. <em>Read-only.</em>
239  * @property {Pose} rightHandTipPose - The right hand's pose as determined by the hand controllers, relative to the avatar,
240  * with the position adjusted by 0.3m along the direction of the palm. <em>Read-only.</em>
241  *
242  * @property {number} energy - <span class="important">Deprecated: This property will be removed.</span>
243  * @property {boolean} isAway - <code>true</code> if your avatar is away (i.e., inactive), <code>false</code> if it is
244  * active.
245  *
246  * @property {boolean} centerOfGravityModelEnabled=true - <code>true</code> if the avatar hips are placed according to
247  * the center of gravity model that balances the center of gravity over the base of support of the feet. Set the
248  * value to <code>false</code> for default behavior where the hips are positioned under the head.
249  * @property {boolean} hmdLeanRecenterEnabled=true - <code>true</code> IF the avatar is re-centered to be under the
250  * head's position. In room-scale VR, this behavior is what causes your avatar to follow your HMD as you walk around
251  * the room. Setting the value <code>false</code> is useful if you want to pin the avatar to a fixed position.
252  * @property {boolean} collisionsEnabled - Set to <code>true</code> to enable the avatar to collide with the environment,
253  * <code>false</code> to disable collisions with the environment. May return <code>true</code> even though the value
254  * was set <code>false</code> because the zone may disallow collisionless avatars.
255  * @property {boolean} otherAvatarsCollisionsEnabled - Set to <code>true</code> to enable the avatar to collide with other
256  * avatars, <code>false</code> to disable collisions with other avatars.
257  * @property {boolean} characterControllerEnabled - Synonym of <code>collisionsEnabled</code>.
258  * <p class="important">Deprecated: This property is deprecated and will be removed. Use <code>collisionsEnabled</code>
259  * instead.</p>
260  * @property {boolean} useAdvancedMovementControls - Returns and sets the value of the Interface setting, Settings >
261  * Controls > Walking. Note: Setting the value has no effect unless Interface is restarted.
262  * @property {boolean} showPlayArea - Returns and sets the value of the Interface setting, Settings > Controls > Show room
263  * boundaries while teleporting.
264  * <p><strong>Note:</strong> Setting the value has no effect unless Interface is restarted.</p>
265  *
266  * @property {number} yawSpeed=75 - The mouse X sensitivity value in Settings > General. <em>Read-only.</em>
267  * @property {number} pitchSpeed=50 - The mouse Y sensitivity value in Settings > General. <em>Read-only.</em>
268  *
269  * @property {boolean} hmdRollControlEnabled=true - If <code>true</code>, the roll angle of your HMD turns your avatar
270  * while flying.
271  * @property {number} hmdRollControlDeadZone=8 - The amount of HMD roll, in degrees, required before your avatar turns if
272  * <code>hmdRollControlEnabled</code> is enabled.
273  * @property {number} hmdRollControlRate If <code>MyAvatar.hmdRollControlEnabled</code> is true, this value determines the
274  * maximum turn rate of your avatar when rolling your HMD in degrees per second.
275  *
276  * @property {number} userHeight=1.75 - The height of the user in sensor space.
277  * @property {number} userEyeHeight=1.65 - The estimated height of the user's eyes in sensor space. <em>Read-only.</em>
278  *
279  * @property {Uuid} SELF_ID - UUID representing "my avatar". Only use for local-only entities in situations
280  * where MyAvatar.sessionUUID is not available (e.g., if not connected to a domain). Note: Likely to be deprecated.
281  * <em>Read-only.</em>
282  *
283  * @property {number} walkSpeed - The walk speed of your avatar for the current control scheme (see
284  * {@link MyAvatar.getControlScheme|getControlScheme}).
285  * @property {number} walkBackwardSpeed - The walk backward speed of your avatar for the current control scheme (see
286  * {@link MyAvatar.getControlScheme|getControlScheme}).
287  * @property {number} sprintSpeed - The sprint (run) speed of your avatar for the current control scheme (see
288  * {@link MyAvatar.getControlScheme|getControlScheme}).
289  * @property {number} analogPlusWalkSpeed - The walk speed of your avatar for the "AnalogPlus" control scheme.
290  * <p><strong>Warning:</strong> Setting this value also sets the value of <code>analogPlusSprintSpeed</code> to twice
291  * the value.</p>
292  * @property {number} analogPlusSprintSpeed - The sprint (run) speed of your avatar for the "AnalogPlus" control scheme.
293  * @property {MyAvatar.SitStandModelType} userRecenterModel - Controls avatar leaning and recentering behavior.
294  * <p class="important">Deprecated: This property is deprecated and will be removed.</p>
295  * @property {boolean} isInSittingState - <code>true</code> if the user wearing the HMD is determined to be sitting;
296  * <code>false</code> if the user wearing the HMD is determined to be standing. This can affect whether the avatar
297  * is allowed to stand, lean or recenter its footing, depending on user preferences.
298  * The property value automatically updates as the user sits or stands. Setting the property value overrides the current
299  * sitting / standing state, which is updated when the user next sits or stands.
300  * @property {boolean} isSitStandStateLocked - <code>true</code> to lock the avatar sitting/standing state, i.e., use this
301  * to disable automatically changing state.
302  * <p class="important">Deprecated: This property is deprecated and will be removed.
303  * See also: <code>getUserRecenterModel</code> and <code>setUserRecenterModel</code>.</p>
304  * @property {boolean} allowTeleporting - <code>true</code> if teleporting is enabled in the Interface settings,
305  * <code>false</code> if it isn't. <em>Read-only.</em>
306  *
307  * @borrows Avatar.getDomainMinScale as getDomainMinScale
308  * @borrows Avatar.getDomainMaxScale as getDomainMaxScale
309  * @borrows Avatar.getEyeHeight as getEyeHeight
310  * @borrows Avatar.getHeight as getHeight
311  * @borrows Avatar.setHandState as setHandState
312  * @borrows Avatar.getHandState as getHandState
313  * @borrows Avatar.setRawJointData as setRawJointData
314  * @borrows Avatar.setJointData as setJointData
315  * @borrows Avatar.setJointRotation as setJointRotation
316  * @borrows Avatar.setJointTranslation as setJointTranslation
317  * @borrows Avatar.clearJointData as clearJointData
318  * @borrows Avatar.isJointDataValid as isJointDataValid
319  * @borrows Avatar.getJointRotation as getJointRotation
320  * @borrows Avatar.getJointTranslation as getJointTranslation
321  * @borrows Avatar.getJointRotations as getJointRotations
322  * @borrows Avatar.getJointTranslations as getJointTranslations
323  * @borrows Avatar.setJointRotations as setJointRotations
324  * @borrows Avatar.setJointTranslations as setJointTranslations
325  * @borrows Avatar.clearJointsData as clearJointsData
326  * @borrows Avatar.getJointIndex as getJointIndex
327  * @borrows Avatar.getJointNames as getJointNames
328  * @borrows Avatar.setBlendshape as setBlendshape
329  * @borrows Avatar.getAttachmentsVariant as getAttachmentsVariant
330  * @borrows Avatar.setAttachmentsVariant as setAttachmentsVariant
331  * @borrows Avatar.updateAvatarEntity as updateAvatarEntity
332  * @borrows Avatar.clearAvatarEntity as clearAvatarEntity
333  * @borrows Avatar.setForceFaceTrackerConnected as setForceFaceTrackerConnected
334  * @borrows Avatar.setSkeletonModelURL as setSkeletonModelURL
335  * @borrows Avatar.getAttachmentData as getAttachmentData
336  * @borrows Avatar.setAttachmentData as setAttachmentData
337  * @borrows Avatar.attach as attach
338  * @borrows Avatar.detachOne as detachOne
339  * @borrows Avatar.detachAll as detachAll
340  * @comment Avatar.getAvatarEntityData as getAvatarEntityData - Don't borrow because implementation is different.
341  * @comment Avatar.setAvatarEntityData as setAvatarEntityData - Don't borrow because implementation is different.
342  * @borrows Avatar.getSensorToWorldMatrix as getSensorToWorldMatrix
343  * @borrows Avatar.getSensorToWorldScale as getSensorToWorldScale
344  * @borrows Avatar.getControllerLeftHandMatrix as getControllerLeftHandMatrix
345  * @borrows Avatar.getControllerRightHandMatrix as getControllerRightHandMatrix
346  * @borrows Avatar.getDataRate as getDataRate
347  * @borrows Avatar.getUpdateRate as getUpdateRate
348  * @borrows Avatar.displayNameChanged as displayNameChanged
349  * @borrows Avatar.sessionDisplayNameChanged as sessionDisplayNameChanged
350  * @borrows Avatar.skeletonModelURLChanged as skeletonModelURLChanged
351  * @borrows Avatar.lookAtSnappingChanged as lookAtSnappingChanged
352  * @borrows Avatar.sessionUUIDChanged as sessionUUIDChanged
353  * @borrows Avatar.sendAvatarDataPacket as sendAvatarDataPacket
354  * @borrows Avatar.sendIdentityPacket as sendIdentityPacket
355  * @borrows Avatar.setSessionUUID as setSessionUUID
356  * @comment Avatar.getAbsoluteJointRotationInObjectFrame as getAbsoluteJointRotationInObjectFrame - Don't borrow because implementation is different.
357  * @comment Avatar.getAbsoluteJointTranslationInObjectFrame as getAbsoluteJointTranslationInObjectFrame - Don't borrow because implementation is different.
358  * @comment Avatar.setAbsoluteJointRotationInObjectFrame as setAbsoluteJointRotationInObjectFrame - Don't borrow because implementation is different.
359  * @comment Avatar.setAbsoluteJointTranslationInObjectFrame as setAbsoluteJointTranslationInObjectFrame - Don't borrow because implementation is different.
360  * @borrows Avatar.getTargetScale as getTargetScale
361  * @borrows Avatar.resetLastSent as resetLastSent
362  */
363  // FIXME: `glm::vec3 position` is not accessible from QML, so this exposes position in a QML-native type
364  Q_PROPERTY(QVector3D qmlPosition READ getQmlPosition)
365  QVector3D getQmlPosition() { auto p = getWorldPosition(); return QVector3D(p.x, p.y, p.z); }
366 
367  Q_PROPERTY(glm::vec3 feetPosition READ getWorldFeetPosition WRITE goToFeetLocation)
368  Q_PROPERTY(bool shouldRenderLocally READ getShouldRenderLocally WRITE setShouldRenderLocally)
369  Q_PROPERTY(glm::vec3 motorVelocity READ getScriptedMotorVelocity WRITE setScriptedMotorVelocity)
370  Q_PROPERTY(float motorTimescale READ getScriptedMotorTimescale WRITE setScriptedMotorTimescale)
371  Q_PROPERTY(QString motorReferenceFrame READ getScriptedMotorFrame WRITE setScriptedMotorFrame)
372  Q_PROPERTY(QString motorMode READ getScriptedMotorMode WRITE setScriptedMotorMode)
373  Q_PROPERTY(QString collisionSoundURL READ getCollisionSoundURL WRITE setCollisionSoundURL)
374  Q_PROPERTY(AudioListenerMode audioListenerMode READ getAudioListenerMode WRITE setAudioListenerMode)
375  Q_PROPERTY(AudioListenerMode audioListenerModeHead READ getAudioListenerModeHead)
376  Q_PROPERTY(AudioListenerMode audioListenerModeCamera READ getAudioListenerModeCamera)
377  Q_PROPERTY(AudioListenerMode audioListenerModeCustom READ getAudioListenerModeCustom)
378  Q_PROPERTY(glm::vec3 customListenPosition READ getCustomListenPosition WRITE setCustomListenPosition)
379  Q_PROPERTY(glm::quat customListenOrientation READ getCustomListenOrientation WRITE setCustomListenOrientation)
380  Q_PROPERTY(float rotationRecenterFilterLength READ getRotationRecenterFilterLength WRITE setRotationRecenterFilterLength)
381  Q_PROPERTY(float rotationThreshold READ getRotationThreshold WRITE setRotationThreshold)
382  Q_PROPERTY(bool enableStepResetRotation READ getEnableStepResetRotation WRITE setEnableStepResetRotation)
383  Q_PROPERTY(bool enableDrawAverageFacing READ getEnableDrawAverageFacing WRITE setEnableDrawAverageFacing)
384  //TODO: make gravity feature work Q_PROPERTY(glm::vec3 gravity READ getGravity WRITE setGravity)
385 
386  Q_PROPERTY(glm::vec3 leftHandPosition READ getLeftHandPosition)
387  Q_PROPERTY(glm::vec3 rightHandPosition READ getRightHandPosition)
388  Q_PROPERTY(glm::vec3 leftHandTipPosition READ getLeftHandTipPosition)
389  Q_PROPERTY(glm::vec3 rightHandTipPosition READ getRightHandTipPosition)
390 
391  Q_PROPERTY(controller::Pose leftHandPose READ getLeftHandPose)
392  Q_PROPERTY(controller::Pose rightHandPose READ getRightHandPose)
393  Q_PROPERTY(controller::Pose leftHandTipPose READ getLeftHandTipPose)
394  Q_PROPERTY(controller::Pose rightHandTipPose READ getRightHandTipPose)
395 
396  Q_PROPERTY(float energy READ getEnergy WRITE setEnergy)
397  Q_PROPERTY(bool isAway READ getIsAway WRITE setAway)
398 
399  Q_PROPERTY(bool centerOfGravityModelEnabled READ getCenterOfGravityModelEnabled WRITE setCenterOfGravityModelEnabled)
400  Q_PROPERTY(bool hmdLeanRecenterEnabled READ getHMDLeanRecenterEnabled WRITE setHMDLeanRecenterEnabled)
401  Q_PROPERTY(bool collisionsEnabled READ getCollisionsEnabled WRITE setCollisionsEnabled)
402  Q_PROPERTY(bool otherAvatarsCollisionsEnabled READ getOtherAvatarsCollisionsEnabled WRITE setOtherAvatarsCollisionsEnabled)
403  Q_PROPERTY(bool characterControllerEnabled READ getCharacterControllerEnabled WRITE setCharacterControllerEnabled)
404  Q_PROPERTY(bool useAdvancedMovementControls READ useAdvancedMovementControls WRITE setUseAdvancedMovementControls)
405  Q_PROPERTY(bool showPlayArea READ getShowPlayArea WRITE setShowPlayArea)
406 
407  Q_PROPERTY(float yawSpeed MEMBER _yawSpeed)
408  Q_PROPERTY(float hmdYawSpeed MEMBER _hmdYawSpeed)
409  Q_PROPERTY(float pitchSpeed MEMBER _pitchSpeed)
410 
411  Q_PROPERTY(bool hmdRollControlEnabled READ getHMDRollControlEnabled WRITE setHMDRollControlEnabled)
412  Q_PROPERTY(float hmdRollControlDeadZone READ getHMDRollControlDeadZone WRITE setHMDRollControlDeadZone)
413  Q_PROPERTY(float hmdRollControlRate READ getHMDRollControlRate WRITE setHMDRollControlRate)
414 
415  Q_PROPERTY(float userHeight READ getUserHeight WRITE setUserHeight)
416  Q_PROPERTY(float userEyeHeight READ getUserEyeHeight)
417 
418  Q_PROPERTY(QUuid SELF_ID READ getSelfID CONSTANT)
419 
420  Q_PROPERTY(float walkSpeed READ getWalkSpeed WRITE setWalkSpeed);
421  Q_PROPERTY(float analogPlusWalkSpeed READ getAnalogPlusWalkSpeed WRITE setAnalogPlusWalkSpeed NOTIFY analogPlusWalkSpeedChanged);
422  Q_PROPERTY(float analogPlusSprintSpeed READ getAnalogPlusSprintSpeed WRITE setAnalogPlusSprintSpeed NOTIFY analogPlusSprintSpeedChanged);
423  Q_PROPERTY(float walkBackwardSpeed READ getWalkBackwardSpeed WRITE setWalkBackwardSpeed NOTIFY walkBackwardSpeedChanged);
424  Q_PROPERTY(float sprintSpeed READ getSprintSpeed WRITE setSprintSpeed NOTIFY sprintSpeedChanged);
425  Q_PROPERTY(bool isInSittingState READ getIsInSittingState WRITE setIsInSittingState);
426  Q_PROPERTY(MyAvatar::SitStandModelType userRecenterModel READ getUserRecenterModel WRITE setUserRecenterModel); // Deprecated
427  Q_PROPERTY(bool isSitStandStateLocked READ getIsSitStandStateLocked WRITE setIsSitStandStateLocked); // Deprecated
428  Q_PROPERTY(bool allowTeleporting READ getAllowTeleporting)
429 
430  const QString DOMINANT_LEFT_HAND = "left";
431  const QString DOMINANT_RIGHT_HAND = "right";
432  const QString DEFAULT_HMD_AVATAR_ALIGNMENT_TYPE = "head";
433 
434  using Clock = std::chrono::system_clock;
435  using TimePoint = Clock::time_point;
436 
437  const float DEFAULT_GEAR_1 = 0.2f;
438  const float DEFAULT_GEAR_2 = 0.4f;
439  const float DEFAULT_GEAR_3 = 0.8f;
440  const float DEFAULT_GEAR_4 = 0.9f;
441  const float DEFAULT_GEAR_5 = 1.0f;
442 
443  const bool DEFAULT_STRAFE_ENABLED = true;
444 public:
445 
446  /*@jsdoc
447  * The <code>DriveKeys</code> API provides constant numeric values that represent different logical keys that drive your
448  * avatar and camera.
449  *
450  * @namespace DriveKeys
451  *
452  * @hifi-interface
453  * @hifi-client-entity
454  * @hifi-avatar
455  *
456  * @property {number} TRANSLATE_X - Move the user's avatar in the direction of its x-axis, if the camera isn't in
457  * independent or mirror modes.
458  * @property {number} TRANSLATE_Y - Move the user's avatar in the direction of its y-axis, if the camera isn't in
459  * independent or mirror modes.
460  * @property {number} TRANSLATE_Z - Move the user's avatar in the direction of its z-axis, if the camera isn't in
461  * independent or mirror modes.
462  * @property {number} YAW - Rotate the user's avatar about its y-axis at a rate proportional to the control value, if the
463  * camera isn't in independent or mirror modes.
464  * @property {number} STEP_TRANSLATE_X - No action.
465  * @property {number} STEP_TRANSLATE_Y - No action.
466  * @property {number} STEP_TRANSLATE_Z - No action.
467  * @property {number} STEP_YAW - Rotate the user's avatar about its y-axis in a step increment, if the camera isn't in
468  * independent or mirror modes.
469  * @property {number} PITCH - Rotate the user's avatar head and attached camera about its negative x-axis (i.e., positive
470  * values pitch down) at a rate proportional to the control value, if the camera isn't in HMD, independent, or mirror
471  * modes.
472  * @property {number} ZOOM - Zoom the camera in or out.
473  * @property {number} DELTA_YAW - Rotate the user's avatar about its y-axis by an amount proportional to the control value,
474  * if the camera isn't in independent or mirror modes.
475  * @property {number} DELTA_PITCH - Rotate the user's avatar head and attached camera about its negative x-axis (i.e.,
476  * positive values pitch down) by an amount proportional to the control value, if the camera isn't in HMD, independent,
477  * or mirror modes.
478  */
479 
480  /*@jsdoc
481  * <p>Logical keys that drive your avatar and camera.</p>
482  * <table>
483  * <thead>
484  * <tr><th>Value</th><th>Description</th></tr>
485  * </thead>
486  * <tbody>
487  * <tr><td><code>{@link DriveKeys|DriveKeys.TRANSLATE_X}</code></td><td>Move the user's avatar in the direction of its
488  * x-axis, if the camera isn't in independent or mirror modes.</td></tr>
489  * <tr><td><code>{@link DriveKeys|DriveKeys.TRANSLATE_Y}</code></td><td>Move the user's avatar in the direction of its
490  * -axis, if the camera isn't in independent or mirror modes.</td></tr>
491  * <tr><td><code>{@link DriveKeys|DriveKeys.TRANSLATE_Z}</code></td><td>Move the user's avatar in the direction of its
492  * z-axis, if the camera isn't in independent or mirror modes.</td></tr>
493  * <tr><td><code>{@link DriveKeys|DriveKeys.YAW}</code></td><td>Rotate the user's avatar about its y-axis at a rate
494  * proportional to the control value, if the camera isn't in independent or mirror modes.</td></tr>
495  * <tr><td><code>{@link DriveKeys|DriveKeys.STEP_TRANSLATE_X}</code></td><td>No action.</td></tr>
496  * <tr><td><code>{@link DriveKeys|DriveKeys.STEP_TRANSLATE_Y}</code></td><td>No action.</td></tr>
497  * <tr><td><code>{@link DriveKeys|DriveKeys.STEP_TRANSLATE_Z}</code></td><td>No action.</td></tr>
498  * <tr><td><code>{@link DriveKeys|DriveKeys.STEP_YAW}</code></td><td>Rotate the user's avatar about its y-axis in a
499  * step increment, if the camera isn't in independent or mirror modes.</td></tr>
500  * <tr><td><code>{@link DriveKeys|DriveKeys.PITCH}</code></td><td>Rotate the user's avatar head and attached camera
501  * about its negative x-axis (i.e., positive values pitch down) at a rate proportional to the control value, if the
502  * camera isn't in HMD, independent, or mirror modes.</td></tr>
503  * <tr><td><code>{@link DriveKeys|DriveKeys.ZOOM}</code></td><td>Zoom the camera in or out.</td></tr>
504  * <tr><td><code>{@link DriveKeys|DriveKeys.DELTA_YAW}</code></td><td>Rotate the user's avatar about its y-axis by an
505  * amount proportional to the control value, if the camera isn't in independent or mirror modes.</td></tr>
506  * <tr><td><code>{@link DriveKeys|DriveKeys.DELTA_PITCH}</code></td><td>Rotate the user's avatar head and attached
507  * camera about its negative x-axis (i.e., positive values pitch down) by an amount proportional to the control
508  * value, if the camera isn't in HMD, independent, or mirror modes.</td></tr>
509  * </tbody>
510  * </table>
511  * @typedef {number} DriveKey
512  */
513  enum DriveKeys {
514  TRANSLATE_X = 0,
515  TRANSLATE_Y,
516  TRANSLATE_Z,
517  YAW,
518  STEP_TRANSLATE_X,
519  STEP_TRANSLATE_Y,
520  STEP_TRANSLATE_Z,
521  STEP_YAW,
522  PITCH,
523  ZOOM,
524  DELTA_YAW,
525  DELTA_PITCH,
526  MAX_DRIVE_KEYS
527  };
528  Q_ENUM(DriveKeys)
529 
530  /*@jsdoc
531  * <p>Specifies different avatar leaning and recentering behaviors.</p>
532  * <p class="important">Deprecated: This type is deprecated and will be removed.</p>
533  * <table>
534  * <thead>
535  * <tr><th>Value</th><th>Name</th><th>Description</th></tr>
536  * </thead>
537  * <tbody>
538  * <tr><td><code>0</code></td><td>ForceSit</td><td>Assumes the user is seated in the real world. Disables avatar
539  * leaning regardless of what the avatar is doing in the virtual world (i.e., avatar always recenters).</td></tr>
540  * <tr><td><code>1</code></td><td>ForceStand</td><td>Assumes the user is standing in the real world. Enables avatar
541  * leaning regardless of what the avatar is doing in the virtual world (i.e., avatar leans, then if leans too far it
542  * recenters).</td></tr>
543  * <tr><td><code>2</code></td><td>Auto</td><td>Interface detects when the user is standing or seated in the real world.
544  * Avatar leaning is disabled when the user is sitting (i.e., avatar always recenters), and avatar leaning is enabled
545  * when the user is standing (i.e., avatar leans, then if leans too far it recenters).</td></tr>
546  * <tr><td><code>3</code></td><td>DisableHMDLean</td><td><p>Both avatar leaning and recentering are disabled regardless of
547  * what the user is doing in the real world and no matter what their avatar is doing in the virtual world. Enables
548  * the avatar to sit on the floor when the user sits on the floor.</p>
549  * <p><strong>Note:</strong> Experimental.</p></td></tr>
550  * </tbody>
551  * </table>
552  * @typedef {number} MyAvatar.SitStandModelType
553  */
554  enum SitStandModelType {
555  ForceSit = 0,
556  ForceStand,
557  Auto,
558  DisableHMDLean,
559  NumSitStandTypes
560  };
561  Q_ENUM(SitStandModelType)
562 
563  // Note: The option strings in setupPreferences (PreferencesDialog.cpp) must match this order.
564  enum class AllowAvatarStandingPreference : uint {
565  WhenUserIsStanding,
566  Always,
567  Count,
568  Default = Always
569  };
570  Q_ENUM(AllowAvatarStandingPreference)
571 
572  // Note: The option strings in setupPreferences (PreferencesDialog.cpp) must match this order.
573  enum class AllowAvatarLeaningPreference : uint {
574  WhenUserIsStanding,
575  Always,
576  Never,
577  AlwaysNoRecenter, // experimental
578  Count,
579  Default = WhenUserIsStanding
580  };
581  Q_ENUM(AllowAvatarLeaningPreference)
582 
583  static const std::array<QString, (uint)AllowAvatarStandingPreference::Count> allowAvatarStandingPreferenceStrings;
584  static const std::array<QString, (uint)AllowAvatarLeaningPreference::Count> allowAvatarLeaningPreferenceStrings;
585 
586  explicit MyAvatar(QThread* thread);
587  virtual ~MyAvatar();
588 
589  void instantiableAvatar() override {};
590  static void registerMetaTypes(ScriptEnginePointer engine);
591  void registerProperties(ScriptEnginePointer engine);
592 
593  virtual void simulateAttachments(float deltaTime) override;
594 
595  AudioListenerMode getAudioListenerModeHead() const { return FROM_HEAD; }
596  AudioListenerMode getAudioListenerModeCamera() const { return FROM_CAMERA; }
597  AudioListenerMode getAudioListenerModeCustom() const { return CUSTOM; }
598 
599  void reset(bool andRecenter = false, bool andReload = true, bool andHead = true);
600 
601  void setCollisionWithOtherAvatarsFlags() override;
602 
603  /*@jsdoc
604  * Resets the sensor positioning of your HMD (if in use) and recenters your avatar body and head.
605  * @function MyAvatar.resetSensorsAndBody
606  */
607  Q_INVOKABLE void resetSensorsAndBody();
608 
609  /*@jsdoc
610  * Moves and orients the avatar, such that it is directly underneath the HMD, with toes pointed forward in the direction of
611  * the HMD.
612  * @function MyAvatar.centerBody
613  */
614  Q_INVOKABLE void centerBody(); // thread-safe
615 
616 
617  /*@jsdoc
618  * Clears inverse kinematics joint limit history.
619  * <p>The internal inverse-kinematics system maintains a record of which joints are "locked". Sometimes it is useful to
620  * forget this history to prevent contorted joints, e.g., after finishing with an override animation.</p>
621  * @function MyAvatar.clearIKJointLimitHistory
622  */
623  Q_INVOKABLE void clearIKJointLimitHistory(); // thread-safe
624 
625  void update(float deltaTime);
626  virtual void postUpdate(float deltaTime, const render::ScenePointer& scene) override;
627  void preDisplaySide(const RenderArgs* renderArgs);
628 
629  const glm::mat4& getHMDSensorMatrix() const { return _hmdSensorMatrix; }
630  const glm::vec3& getHMDSensorPosition() const { return _hmdSensorPosition; }
631  const glm::quat& getHMDSensorOrientation() const { return _hmdSensorOrientation; }
632 
633  /*@jsdoc
634  * Gets the avatar orientation. Suitable for use in QML.
635  * @function MyAvatar.setOrientationVar
636  * @param {object} newOrientationVar - The avatar's orientation.
637  */
638  Q_INVOKABLE void setOrientationVar(const QVariant& newOrientationVar);
639 
640  /*@jsdoc
641  * Gets the avatar orientation. Suitable for use in QML.
642  * @function MyAvatar.getOrientationVar
643  * @returns {object} The avatar's orientation.
644  */
645  Q_INVOKABLE QVariant getOrientationVar() const;
646 
647  // A method intended to be overriden by MyAvatar for polling orientation for network transmission.
648  glm::quat getOrientationOutbound() const override;
649 
650  // Pass a recent sample of the HMD to the avatar.
651  // This can also update the avatar's position to follow the HMD
652  // as it moves through the world.
653  void updateFromHMDSensorMatrix(const glm::mat4& hmdSensorMatrix);
654 
655  // compute the hip to hand average azimuth.
656  glm::vec2 computeHandAzimuth() const;
657 
658  // read the location of a hand controller and save the transform
659  void updateJointFromController(controller::Action poseKey, ThreadSafeValueCache<glm::mat4>& matrixCache);
660 
661  // best called at end of main loop, just before rendering.
662  // update sensor to world matrix from current body position and hmd sensor.
663  // This is so the correct camera can be used for rendering.
664  void updateSensorToWorldMatrix();
665 
666  void setRealWorldFieldOfView(float realWorldFov) { _realWorldFieldOfView.set(realWorldFov); }
667 
668  /*@jsdoc
669  * Gets the position in world coordinates of the point directly between your avatar's eyes assuming your avatar was in its
670  * default pose. This is a reference position; it does not change as your avatar's head moves relative to the avatar
671  * position.
672  * @function MyAvatar.getDefaultEyePosition
673  * @returns {Vec3} Default position between your avatar's eyes in world coordinates.
674  * @example <caption>Report your avatar's default eye position.</caption>
675  * var defaultEyePosition = MyAvatar.getDefaultEyePosition();
676  * print(JSON.stringify(defaultEyePosition));
677  */
678  Q_INVOKABLE glm::vec3 getDefaultEyePosition() const;
679 
680  float getRealWorldFieldOfView() { return _realWorldFieldOfView.get(); }
681 
682  /*@jsdoc
683  * Overrides the default avatar animations.
684  * <p>The avatar animation system includes a set of default animations along with rules for how those animations are blended
685  * together with procedural data (such as look at vectors, hand sensors etc.). <code>overrideAnimation()</code> is used to
686  * completely override all motion from the default animation system (including inverse kinematics for hand and head
687  * controllers) and play a set of specified animations. To end these animations and restore the default animations, use
688  * {@link MyAvatar.restoreAnimation}.</p>
689  * <p>Note: When using pre-built animation data, it's critical that the joint orientation of the source animation and target
690  * rig are equivalent, since the animation data applies absolute values onto the joints. If the orientations are different,
691  * the avatar will move in unpredictable ways. For more information about avatar joint orientation standards, see
692  * <a href="https://docs.overte.org/create/avatars/avatar-standards.html">Avatar Standards</a>.</p>
693  * @function MyAvatar.overrideAnimation
694  * @param {string} url - The URL to the animation file. Animation files may be in glTF or FBX format, but only need to
695  * contain the avatar skeleton and animation data. glTF models may be in JSON or binary format (".gltf" or ".glb" URLs
696  * respectively).
697  * <p><strong>Warning:</strong> glTF animations currently do not always animate correctly.</p>
698  * @param {number} fps - The frames per second (FPS) rate for the animation playback. 30 FPS is normal speed.
699  * @param {boolean} loop - <code>true</code> if the animation should loop, <code>false</code> if it shouldn't.
700  * @param {number} firstFrame - The frame to start the animation at.
701  * @param {number} lastFrame - The frame to end the animation at.
702  * @example <caption> Play a clapping animation on your avatar for three seconds. </caption>
703  * var ANIM_URL = "https://apidocs.overte.org/examples/ClapHands_Standing.fbx";
704  * MyAvatar.overrideAnimation(ANIM_URL, 30, true, 0, 53);
705  * Script.setTimeout(function () {
706  * MyAvatar.restoreAnimation();
707  * MyAvatar.clearIKJointLimitHistory();
708  * }, 3000);
709  */
710  Q_INVOKABLE void overrideAnimation(const QString& url, float fps, bool loop, float firstFrame, float lastFrame);
711 
712  /*@jsdoc
713  * Overrides the default hand poses that are triggered with controller buttons.
714  * Use {@link MyAvatar.restoreHandAnimation} to restore the default poses.
715  * @function MyAvatar.overrideHandAnimation
716  * @param isLeft {boolean} <code>true</code> to override the left hand, <code>false</code> to override the right hand.
717  * @param {string} url - The URL of the animation file. Animation files need to be in glTF or FBX format, but only need to
718  * contain the avatar skeleton and animation data. glTF models may be in JSON or binary format (".gltf" or ".glb" URLs
719  * respectively).
720  * <p><strong>Warning:</strong> glTF animations currently do not always animate correctly.</p>
721  * @param {number} fps - The frames per second (FPS) rate for the animation playback. 30 FPS is normal speed.
722  * @param {boolean} loop - <code>true</code> if the animation should loop, <code>false</code> if it shouldn't.
723  * @param {number} firstFrame - The frame to start the animation at.
724  * @param {number} lastFrame - The frame to end the animation at.
725  * @example <caption> Override left hand animation for three seconds.</caption>
726  * var ANIM_URL = "https://apidocs.overte.org/examples/ClapHands_Standing.fbx";
727  * MyAvatar.overrideHandAnimation(isLeft, ANIM_URL, 30, true, 0, 53);
728  * Script.setTimeout(function () {
729  * MyAvatar.restoreHandAnimation();
730  * }, 3000);
731  */
732  Q_INVOKABLE void overrideHandAnimation(bool isLeft, const QString& url, float fps, bool loop, float firstFrame, float lastFrame);
733 
734  /*@jsdoc
735  * Restores the default animations.
736  * <p>The avatar animation system includes a set of default animations along with rules for how those animations are blended
737  * together with procedural data (such as look at vectors, hand sensors etc.). Playing your own custom animations will
738  * override the default animations. <code>restoreAnimation()</code> is used to restore all motion from the default
739  * animation system including inverse kinematics for hand and head controllers. If you aren't currently playing an override
740  * animation, this function has no effect.</p>
741  * @function MyAvatar.restoreAnimation
742  * @example <caption> Play a clapping animation on your avatar for three seconds. </caption>
743  * var ANIM_URL = "https://apidocs.overte.org/examples/ClapHands_Standing.fbx";
744  * MyAvatar.overrideAnimation(ANIM_URL, 30, true, 0, 53);
745  * Script.setTimeout(function () {
746  * MyAvatar.restoreAnimation();
747  * }, 3000);
748  */
749  Q_INVOKABLE void restoreAnimation();
750 
751  /*@jsdoc
752  * Restores the default hand animation state machine that is driven by the state machine in the avatar-animation JSON.
753  * <p>The avatar animation system includes a set of default animations along with rules for how those animations are blended
754  * together with procedural data (such as look at vectors, hand sensors etc.). Playing your own custom animations will
755  * override the default animations. <code>restoreHandAnimation()</code> is used to restore the default hand poses.
756  * If you aren't currently playing an override hand animation, this function has no effect.</p>
757  * @function MyAvatar.restoreHandAnimation
758  * @param isLeft {boolean} Set to true if using the left hand
759  * @example <caption> Override left hand animation for three seconds. </caption>
760  * var ANIM_URL = "https://apidocs.overte.org/examples/ClapHands_Standing.fbx";
761  * MyAvatar.overrideHandAnimation(isLeft, ANIM_URL, 30, true, 0, 53);
762  * Script.setTimeout(function () {
763  * MyAvatar.restoreHandAnimation();
764  * }, 3000);
765  */
766  Q_INVOKABLE void restoreHandAnimation(bool isLeft);
767 
768  /*@jsdoc
769  * Gets the current animation roles.
770  * <p>Each avatar has an avatar-animation.json file that defines which animations are used and how they are blended together
771  * with procedural data (such as look at vectors, hand sensors etc.). Each animation specified in the avatar-animation.json
772  * file is known as an animation role. Animation roles map to easily understandable actions that the avatar can perform,
773  * such as <code>"idleStand"</code>, <code>"idleTalk"</code>, or <code>"walkFwd"</code>. <code>getAnimationRoles()</code>
774  * is used get the list of animation roles defined in the avatar-animation.json.</p>
775  * @function MyAvatar.getAnimationRoles
776  * @returns {string[]} Array of role strings.
777  * @example <caption>Print the list of animation roles defined in the avatar's avatar-animation.json file to the debug log.</caption>
778  * var roles = MyAvatar.getAnimationRoles();
779  * print("Animation Roles:");
780  * for (var i = 0; i < roles.length; i++) {
781  * print(roles[i]);
782  * }
783  */
784  Q_INVOKABLE QStringList getAnimationRoles();
785 
786  /*@jsdoc
787  * Overrides a specific animation role.
788  * <p>Each avatar has an avatar-animation.json file that defines a set of animation roles. Animation roles map to easily
789  * understandable actions that the avatar can perform, such as <code>"idleStand"</code>, <code>"idleTalk"</code>, or
790  * <code>"walkFwd"</code>. To get the full list of roles, use {@ link MyAvatar.getAnimationRoles}.
791  * For each role, the avatar-animation.json defines when the animation is used, the animation clip (glTF or FBX) used, and
792  * how animations are blended together with procedural data (such as look at vectors, hand sensors etc.).
793  * <code>overrideRoleAnimation()</code> is used to change the animation clip (glTF or FBX) associated with a specified
794  * animation role. To end the role animation and restore the default, use {@link MyAvatar.restoreRoleAnimation}.</p>
795  * <p>Note: Hand roles only affect the hand. Other "main" roles, like "idleStand", "idleTalk", and "takeoffStand", are full
796  * body.</p>
797  * <p>Note: When using pre-built animation data, it's critical that the joint orientation of the source animation and target
798  * rig are equivalent, since the animation data applies absolute values onto the joints. If the orientations are different,
799  * the avatar will move in unpredictable ways. For more information about avatar joint orientation standards, see
800  * <a href="https://docs.overte.org/create/avatars/avatar-standards.html">Avatar Standards</a>.
801  * @function MyAvatar.overrideRoleAnimation
802  * @param {string} role - The animation role to override
803  * @param {string} url - The URL to the animation file. Animation files need to be in glTF or FBX format, but only need to
804  * contain the avatar skeleton and animation data. glTF models may be in JSON or binary format (".gltf" or ".glb" URLs
805  * respectively).
806  * <p><strong>Warning:</strong> glTF animations currently do not always animate correctly.</p>
807  * @param {number} fps - The frames per second (FPS) rate for the animation playback. 30 FPS is normal speed.
808  * @param {boolean} loop - <code>true</code> if the animation should loop, <code>false</code> if it shouldn't.
809  * @param {number} firstFrame - The frame the animation should start at.
810  * @param {number} lastFrame - The frame the animation should end at.
811  * @example <caption>The default avatar-animation.json defines an "idleStand" animation role. This role specifies that when the avatar is not moving,
812  * an animation clip of the avatar idling with hands hanging at its side will be used. It also specifies that when the avatar moves, the animation
813  * will smoothly blend to the walking animation used by the "walkFwd" animation role.
814  * In this example, the "idleStand" role animation clip has been replaced with a clapping animation clip. Now instead of standing with its arms
815  * hanging at its sides when it is not moving, the avatar will stand and clap its hands. Note that just as it did before, as soon as the avatar
816  * starts to move, the animation will smoothly blend into the walk animation used by the "walkFwd" animation role.</caption>
817  * // An animation of the avatar clapping its hands while standing. Restore default after 30s.
818  * var ANIM_URL = "https://apidocs.overte.org/examples/ClapHands_Standing.fbx";
819  * MyAvatar.overrideRoleAnimation("idleStand", ANIM_URL, 30, true, 0, 53);
820  * Script.setTimeout(function () {
821  * MyAvatar.restoreRoleAnimation();
822  * }, 30000);
823  */
824  Q_INVOKABLE void overrideRoleAnimation(const QString& role, const QString& url, float fps, bool loop, float firstFrame, float lastFrame);
825 
826  /*@jsdoc
827  * Restores a default role animation.
828  * <p>Each avatar has an avatar-animation.json file that defines a set of animation roles. Animation roles map to easily
829  * understandable actions that the avatar can perform, such as <code>"idleStand"</code>, <code>"idleTalk"</code>, or
830  * <code>"walkFwd"</code>. To get the full list of roles, use {@link MyAvatar.getAnimationRoles}. For each role,
831  * the avatar-animation.json defines when the animation is used, the animation clip (glTF or FBX) used, and how animations
832  * are blended together with procedural data (such as look-at vectors, hand sensors etc.). You can change the animation
833  * clip (glTF or FBX) associated with a specified animation role using {@link MyAvatar.overrideRoleAnimation}.
834  * <code>restoreRoleAnimation()</code> is used to restore a specified animation role's default animation clip. If you have
835  * not specified an override animation for the specified role, this function has no effect.
836  * @function MyAvatar.restoreRoleAnimation
837  * @param role {string} The animation role clip to restore.
838  */
839  Q_INVOKABLE void restoreRoleAnimation(const QString& role);
840 
841  // Adds handler(animStateDictionaryIn) => animStateDictionaryOut, which will be invoked just before each animGraph state update.
842  // The handler will be called with an animStateDictionaryIn that has all those properties specified by the (possibly empty)
843  // propertiesList argument. However for debugging, if the properties argument is null, all internal animGraph state is provided.
844  // The animStateDictionaryOut can be a different object than animStateDictionaryIn. Any properties set in animStateDictionaryOut
845  // will override those of the internal animation machinery.
846  // The animStateDictionaryIn may be shared among multiple handlers, and thus may contain additional properties specified when
847  // adding one of the other handlers. While any handler may change a value in animStateDictionaryIn (or supply different values in animStateDictionaryOut)
848  // a handler must not remove properties from animStateDictionaryIn, nor change property values that it does not intend to change.
849  // It is not specified in what order multiple handlers are called.
850  /*@jsdoc
851  * Adds an animation state handler function that is invoked just before each animation graph update. More than one
852  * animation state handler function may be added by calling <code>addAnimationStateHandler</code> multiple times. It is not
853  * specified in what order multiple handlers are called.
854  * <p>The animation state handler function is called with an {@link MyAvatar.AnimStateDictionary|AnimStateDictionary}
855  * "<code>animStateDictionaryIn</code>" parameter and is expected to return an
856  * {@link MyAvatar.AnimStateDictionary|AnimStateDictionary} "<code>animStateDictionaryOut</code>" object. The
857  * <code>animStateDictionaryOut</code> object can be the same object as <code>animStateDictionaryIn</code>, or it can be a
858  * different object. The <code>animStateDictionaryIn</code> may be shared among multiple handlers and thus may contain
859  * additional properties specified when adding the different handlers.</p>
860  * <p>A handler may change a value from <code>animStateDictionaryIn</code> or add different values in the
861  * <code>animStateDictionaryOut</code> returned. Any property values set in <code>animStateDictionaryOut</code> will
862  * override those of the internal animation machinery.</p>
863  * @function MyAvatar.addAnimationStateHandler
864  * @param {function} handler - The animation state handler function to add.
865  * @param {Array<string>|null} propertiesList - The list of {@link MyAvatar.AnimStateDictionary|AnimStateDictionary}
866  * properties that should be included in the parameter that the handler function is called with. If <code>null</code>
867  * then all properties are included in the call parameter.
868  * @returns {number} The ID of the animation state handler function if successfully added, <code>undefined</code> if not.
869  * @example <caption>Log all the animation state dictionary parameters for a short while.</caption>
870  * function animStateHandler(dictionary) {
871  * print("Anim state dictionary: " + JSON.stringify(dictionary));
872  * }
873  *
874  * var handler = MyAvatar.addAnimationStateHandler(animStateHandler, null);
875  *
876  * Script.setTimeout(function () {
877  * MyAvatar.removeAnimationStateHandler(handler);
878  * }, 100);
879  */
880  Q_INVOKABLE ScriptValue addAnimationStateHandler(const ScriptValue& handler, const ScriptValue& propertiesList) { return _skeletonModel->getRig().addAnimationStateHandler(handler, propertiesList); }
881 
882  /*@jsdoc
883  * Removes an animation state handler function.
884  * @function MyAvatar.removeAnimationStateHandler
885  * @param {number} handler - The ID of the animation state handler function to remove.
886  */
887  // Removes a handler previously added by addAnimationStateHandler.
888  Q_INVOKABLE void removeAnimationStateHandler(const ScriptValue& handler) { _skeletonModel->getRig().removeAnimationStateHandler(handler); }
889 
890 
891  /*@jsdoc
892  * Gets whether you do snap turns in HMD mode.
893  * @function MyAvatar.getSnapTurn
894  * @returns {boolean} <code>true</code> if you do snap turns in HMD mode; <code>false</code> if you do smooth turns in HMD
895  * mode.
896  */
897  Q_INVOKABLE bool getSnapTurn() const { return _useSnapTurn; }
898 
899  /*@jsdoc
900  * Sets whether you do snap turns or smooth turns in HMD mode.
901  * @function MyAvatar.setSnapTurn
902  * @param {boolean} on - <code>true</code> to do snap turns in HMD mode; <code>false</code> to do smooth turns in HMD mode.
903  */
904  Q_INVOKABLE void setSnapTurn(bool on) { _useSnapTurn = on; }
905 
906  /*@jsdoc
907  * Gets the control scheme that is in use.
908  * @function MyAvatar.getControlScheme
909  * @returns {MyAvatar.LocomotionControlsMode} The control scheme that is in use.
910  */
911  Q_INVOKABLE int getControlScheme() const { return _controlSchemeIndex; }
912 
913  /*@jsdoc
914  * Sets the control scheme to use.
915  * @function MyAvatar.setControlScheme
916  * @param {MyAvatar.LocomotionControlsMode} controlScheme - The control scheme to use.
917  */
918  Q_INVOKABLE void setControlScheme(int index) { _controlSchemeIndex = (index >= 0 && index <= 2) ? index : 0; }
919 
920  /*@jsdoc
921  * Gets whether your avatar hovers when its feet are not on the ground.
922  * @function MyAvatar.hoverWhenUnsupported
923  * @returns {boolean} <code>true</code> if your avatar hovers when its feet are not on the ground, <code>false</code> if it
924  * falls.
925  */
926  // FIXME: Should be named, getHoverWhenUnsupported().
927  Q_INVOKABLE bool hoverWhenUnsupported() const { return _hoverWhenUnsupported; }
928 
929  /*@jsdoc
930  * Sets whether your avatar hovers when its feet are not on the ground.
931  * @function MyAvatar.setHoverWhenUnsupported
932  * @param {boolean} hover - <code>true</code> if your avatar hovers when its feet are not on the ground, <code>false</code>
933  * if it falls.
934  */
935  Q_INVOKABLE void setHoverWhenUnsupported(bool on) { _hoverWhenUnsupported = on; }
936 
937  /*@jsdoc
938  * Sets the avatar's dominant hand.
939  * @function MyAvatar.setDominantHand
940  * @param {string} hand - The dominant hand: <code>"left"</code> for the left hand or <code>"right"</code> for the right
941  * hand. Any other value has no effect.
942  */
943  Q_INVOKABLE void setDominantHand(const QString& hand);
944 
945  /*@jsdoc
946  * Gets the avatar's dominant hand.
947  * @function MyAvatar.getDominantHand
948  * @returns {string} <code>"left"</code> for the left hand, <code>"right"</code> for the right hand.
949  */
950  Q_INVOKABLE QString getDominantHand() const;
951 
952  /*@jsdoc
953  * Sets whether strafing is enabled.
954  * @function MyAvatar.setStrafeEnabled
955  * @param {boolean} enabled - <code>true</code> if strafing is enabled, <code>false</code> if it isn't.
956  */
957  Q_INVOKABLE void setStrafeEnabled(bool enabled);
958 
959  /*@jsdoc
960  * Gets whether strafing is enabled.
961  * @function MyAvatar.getStrafeEnabled
962  * @returns {boolean} <code>true</code> if strafing is enabled, <code>false</code> if it isn't.
963  */
964  Q_INVOKABLE bool getStrafeEnabled() const;
965 
966  /*@jsdoc
967  * Sets the HMD alignment relative to your avatar.
968  * @function MyAvatar.setHmdAvatarAlignmentType
969  * @param {string} type - <code>"head"</code> to align your head and your avatar's head, <code>"eyes"</code> to align your
970  * eyes and your avatar's eyes.
971  */
972  Q_INVOKABLE void setHmdAvatarAlignmentType(const QString& type);
973 
974  /*@jsdoc
975  * Gets the HMD alignment relative to your avatar.
976  * @function MyAvatar.getHmdAvatarAlignmentType
977  * @returns {string} <code>"head"</code> if aligning your head and your avatar's head, <code>"eyes"</code> if aligning your
978  * eyes and your avatar's eyes.
979  */
980  Q_INVOKABLE QString getHmdAvatarAlignmentType() const;
981 
982  /*@jsdoc
983  * Sets whether the avatar's hips are balanced over the feet or positioned under the head.
984  * @function MyAvatar.setCenterOfGravityModelEnabled
985  * @param {boolean} enabled - <code>true</code> to balance the hips over the feet, <code>false</code> to position the hips
986  * under the head.
987  */
988  Q_INVOKABLE void setCenterOfGravityModelEnabled(bool value) { _centerOfGravityModelEnabled = value; }
989 
990  /*@jsdoc
991  * Gets whether the avatar hips are being balanced over the feet or placed under the head.
992  * @function MyAvatar.getCenterOfGravityModelEnabled
993  * @returns {boolean} <code>true</code> if the hips are being balanced over the feet, <code>false</code> if the hips are
994  * being positioned under the head.
995  */
996  Q_INVOKABLE bool getCenterOfGravityModelEnabled() const { return _centerOfGravityModelEnabled; }
997 
998  /*@jsdoc
999  * Sets whether the avatar's position updates to recenter the avatar under the head. In room-scale VR, recentering
1000  * causes your avatar to follow your HMD as you walk around the room. Disabling recentering is useful if you want to pin
1001  * the avatar to a fixed position.
1002  * @function MyAvatar.setHMDLeanRecenterEnabled
1003  * @param {boolean} enabled - <code>true</code> to recenter the avatar under the head as it moves, <code>false</code> to
1004  * disable recentering.
1005  */
1006  Q_INVOKABLE void setHMDLeanRecenterEnabled(bool value) { _hmdLeanRecenterEnabled = value; }
1007 
1008  /*@jsdoc
1009  * Gets whether the avatar's position updates to recenter the avatar under the head. In room-scale VR, recentering
1010  * causes your avatar to follow your HMD as you walk around the room.
1011  * @function MyAvatar.getHMDLeanRecenterEnabled
1012  * @returns {boolean} <code>true</code> if recentering is enabled, <code>false</code> if not.
1013  */
1014  Q_INVOKABLE bool getHMDLeanRecenterEnabled() const { return _hmdLeanRecenterEnabled; }
1015 
1016  /*@jsdoc
1017  * Requests that the hand touch effect is disabled for your avatar. Any resulting change in the status of the hand touch
1018  * effect will be signaled by {@link MyAvatar.shouldDisableHandTouchChanged}.
1019  * <p>The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that
1020  * it is really touching that object.</p>
1021  * @function MyAvatar.requestEnableHandTouch
1022  */
1023  Q_INVOKABLE void requestEnableHandTouch();
1024 
1025  /*@jsdoc
1026  * Requests that the hand touch effect is enabled for your avatar. Any resulting change in the status of the hand touch
1027  * effect will be signaled by {@link MyAvatar.shouldDisableHandTouchChanged}.
1028  * <p>The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that
1029  * it is really touching that object.</p>
1030  * @function MyAvatar.requestDisableHandTouch
1031  */
1032  Q_INVOKABLE void requestDisableHandTouch();
1033 
1034  /*@jsdoc
1035  * Disables the hand touch effect on a specific entity.
1036  * <p>The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that
1037  * it is really touching that object.</p>
1038  * @function MyAvatar.disableHandTouchForID
1039  * @param {Uuid} entityID - The entity that the hand touch effect will be disabled for.
1040  */
1041  Q_INVOKABLE void disableHandTouchForID(const QUuid& entityID);
1042 
1043  /*@jsdoc
1044  * Enables the hand touch effect on a specific entity.
1045  * <p>The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that
1046  * it is really touching that object.</p>
1047  * @function MyAvatar.enableHandTouchForID
1048  * @param {Uuid} entityID - The entity that the hand touch effect will be enabled for.
1049  */
1050  Q_INVOKABLE void enableHandTouchForID(const QUuid& entityID);
1051 
1052  bool useAdvancedMovementControls() const { return _useAdvancedMovementControls.get(); }
1053  void setUseAdvancedMovementControls(bool useAdvancedMovementControls)
1054  { _useAdvancedMovementControls.set(useAdvancedMovementControls); }
1055 
1056  bool getAllowTeleporting() { return _allowTeleportingSetting.get(); }
1057  void setAllowTeleporting(bool allowTeleporting) { _allowTeleportingSetting.set(allowTeleporting); }
1058 
1059  bool getShowPlayArea() const { return _showPlayArea.get(); }
1060  void setShowPlayArea(bool showPlayArea) { _showPlayArea.set(showPlayArea); }
1061 
1062  void setHMDRollControlEnabled(bool value) { _hmdRollControlEnabled = value; }
1063  bool getHMDRollControlEnabled() const { return _hmdRollControlEnabled; }
1064  void setHMDRollControlDeadZone(float value) { _hmdRollControlDeadZone = value; }
1065  float getHMDRollControlDeadZone() const { return _hmdRollControlDeadZone; }
1066  void setHMDRollControlRate(float value) { _hmdRollControlRate = value; }
1067  float getHMDRollControlRate() const { return _hmdRollControlRate; }
1068 
1069  // get/set avatar data
1070  void resizeAvatarEntitySettingHandles(uint32_t maxIndex);
1071  void saveData();
1072  void saveAvatarEntityDataToSettings();
1073  void loadData();
1074  void loadAvatarEntityDataFromSettings();
1075 
1076  void saveAttachmentData(const AttachmentData& attachment) const;
1077  AttachmentData loadAttachmentData(const QUrl& modelURL, const QString& jointName = QString()) const;
1078 
1079  // Set what driving keys are being pressed to control thrust levels
1080  void clearDriveKeys();
1081  void setDriveKey(DriveKeys key, float val);
1082  void setSprintMode(bool sprint);
1083  float getDriveKey(DriveKeys key) const;
1084 
1085  /*@jsdoc
1086  * Gets the value of a drive key, regardless of whether it is disabled.
1087  * @function MyAvatar.getRawDriveKey
1088  * @param {DriveKey} key - The drive key.
1089  * @returns {number} The value of the drive key.
1090  */
1091  Q_INVOKABLE float getRawDriveKey(DriveKeys key) const;
1092 
1093  void relayDriveKeysToCharacterController();
1094 
1095  /*@jsdoc
1096  * Disables the action associated with a drive key.
1097  * @function MyAvatar.disableDriveKey
1098  * @param {DriveKey} key - The drive key to disable.
1099  * @example <caption>Disable rotating your avatar using the keyboard for a couple of seconds.</caption>
1100  * print("Disable");
1101  * MyAvatar.disableDriveKey(DriveKeys.YAW);
1102  * Script.setTimeout(function () {
1103  * print("Enable");
1104  * MyAvatar.enableDriveKey(YAW);
1105  * }, 5000);
1106  */
1107  Q_INVOKABLE void disableDriveKey(DriveKeys key);
1108 
1109  /*@jsdoc
1110  * Enables the action associated with a drive key. The action may have been disabled with
1111  * {@link MyAvatar.disableDriveKey|disableDriveKey}.
1112  * @function MyAvatar.enableDriveKey
1113  * @param {DriveKey} key - The drive key to enable.
1114  */
1115  Q_INVOKABLE void enableDriveKey(DriveKeys key);
1116 
1117  /*@jsdoc
1118  * Checks whether a drive key is disabled.
1119  * @function MyAvatar.isDriveKeyDisabled
1120  * @param {DriveKey} key - The drive key to check.
1121  * @returns {boolean} <code>true</code> if the drive key is disabled, <code>false</code> if it isn't.
1122  */
1123  Q_INVOKABLE bool isDriveKeyDisabled(DriveKeys key) const;
1124 
1125 
1126  /*@jsdoc
1127  * Recenter the avatar in the vertical direction, if <code>{@link MyAvatar|MyAvatar.hmdLeanRecenterEnabled}</code> is
1128  * <code>false</code>.
1129  * @function MyAvatar.triggerVerticalRecenter
1130  */
1131  Q_INVOKABLE void triggerVerticalRecenter();
1132 
1133  /*@jsdoc
1134  * Recenter the avatar in the horizontal direction, if <code>{@link MyAvatar|MyAvatar.hmdLeanRecenterEnabled}</code> is
1135  * <code>false</code>.
1136  * @function MyAvatar.triggerHorizontalRecenter
1137  */
1138  Q_INVOKABLE void triggerHorizontalRecenter();
1139 
1140  /*@jsdoc
1141  * Recenter the avatar's rotation, if <code>{@link MyAvatar|MyAvatar.hmdLeanRecenterEnabled}</code> is <code>false</code>.
1142  * @function MyAvatar.triggerRotationRecenter
1143  */
1144  Q_INVOKABLE void triggerRotationRecenter();
1145 
1146  /*@jsdoc
1147  * Gets whether the avatar is configured to keep its center of gravity under its head.
1148  * @function MyAvatar.isRecenteringHorizontally
1149  * @returns {boolean} <code>true</code> if the avatar is keeping its center of gravity under its head position,
1150  * <code>false</code> if not.
1151  */
1152  Q_INVOKABLE bool isRecenteringHorizontally() const;
1153 
1154  eyeContactTarget getEyeContactTarget();
1155 
1156  const MyHead* getMyHead() const;
1157 
1158  /*@jsdoc
1159  * Gets the current position of the avatar's "Head" joint.
1160  * @function MyAvatar.getHeadPosition
1161  * @returns {Vec3} The current position of the avatar's "Head" joint.
1162  * @example <caption>Report the current position of your avatar's head.</caption>
1163  * print(JSON.stringify(MyAvatar.getHeadPosition()));
1164  */
1165  Q_INVOKABLE glm::vec3 getHeadPosition() const { return getHead()->getPosition(); }
1166 
1167  /*@jsdoc
1168  * Gets the yaw of the avatar's head relative to its body.
1169  * @function MyAvatar.getHeadFinalYaw
1170  * @returns {number} The yaw of the avatar's head, in degrees.
1171  */
1172  Q_INVOKABLE float getHeadFinalYaw() const { return getHead()->getFinalYaw(); }
1173 
1174  /*@jsdoc
1175  * Gets the roll of the avatar's head relative to its body.
1176  * @function MyAvatar.getHeadFinalRoll
1177  * @returns {number} The roll of the avatar's head, in degrees.
1178  */
1179  Q_INVOKABLE float getHeadFinalRoll() const { return getHead()->getFinalRoll(); }
1180 
1181  /*@jsdoc
1182  * Gets the pitch of the avatar's head relative to its body.
1183  * @function MyAvatar.getHeadFinalPitch
1184  * @returns {number} The pitch of the avatar's head, in degrees.
1185  */
1186  Q_INVOKABLE float getHeadFinalPitch() const { return getHead()->getFinalPitch(); }
1187 
1188  /*@jsdoc
1189  * If a face tracker is connected and being used, gets the estimated pitch of the user's head scaled. This is scale such
1190  * that the avatar looks at the edge of the view frustum when the user looks at the edge of their screen.
1191  * @function MyAvatar.getHeadDeltaPitch
1192  * @returns {number} The pitch that the avatar's head should be if a face tracker is connected and being used, otherwise
1193  * <code>0</code>, in degrees.
1194  */
1195  Q_INVOKABLE float getHeadDeltaPitch() const { return getHead()->getDeltaPitch(); }
1196 
1197  /*@jsdoc
1198  * Gets the current position of the point directly between the avatar's eyes.
1199  * @function MyAvatar.getEyePosition
1200  * @returns {Vec3} The current position of the point directly between the avatar's eyes.
1201  * @example <caption>Report your avatar's current eye position.</caption>
1202  * var eyePosition = MyAvatar.getEyePosition();
1203  * print(JSON.stringify(eyePosition));
1204  */
1205  Q_INVOKABLE glm::vec3 getEyePosition() const { return getHead()->getEyePosition(); }
1206 
1207  /*@jsdoc
1208  * Gets the position of the avatar your avatar is currently looking at.
1209  * @function MyAvatar.getTargetAvatarPosition
1210  * @returns {Vec3} The position of the avatar beeing looked at.
1211  * @example <caption>Report the position of the avatar you're currently looking at.</caption>
1212  * print(JSON.stringify(MyAvatar.getTargetAvatarPosition()));
1213  */
1214  // FIXME: If not looking at an avatar, the most recently looked-at position is returned. This should be fixed to return
1215  // undefined or {NaN, NaN, NaN} or similar.
1216  Q_INVOKABLE glm::vec3 getTargetAvatarPosition() const { return _targetAvatarPosition; }
1217 
1218  /*@jsdoc
1219  * Gets information on the avatar your avatar is currently looking at.
1220  * @function MyAvatar.getTargetAvatar
1221  * @returns {ScriptAvatar} Information on the avatar being looked at, <code>null</code> if no avatar is being looked at.
1222  */
1223  Q_INVOKABLE ScriptAvatarData* getTargetAvatar() const;
1224 
1225 
1226  /*@jsdoc
1227  * Gets the position of the avatar's left hand, relative to the avatar, as positioned by a hand controller (e.g., Oculus
1228  * Touch or Vive).
1229  * <p>Note: The Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints
1230  * for hand animation.)</p>
1231  * @function MyAvatar.getLeftHandPosition
1232  * @returns {Vec3} The position of the left hand in avatar coordinates if positioned by a hand controller, otherwise
1233  * <code>{@link Vec3(0)|Vec3.ZERO}</code>.
1234  * @example <caption>Report the position of your left hand relative to your avatar.</caption>
1235  * print(JSON.stringify(MyAvatar.getLeftHandPosition()));
1236  */
1237  Q_INVOKABLE glm::vec3 getLeftHandPosition() const;
1238 
1239  /*@jsdoc
1240  * Gets the position of the avatar's right hand, relative to the avatar, as positioned by a hand controller (e.g., Oculus
1241  * Touch or Vive).
1242  * <p>Note: The Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints
1243  * for hand animation.)</p>
1244  * @function MyAvatar.getRightHandPosition
1245  * @returns {Vec3} The position of the right hand in avatar coordinates if positioned by a hand controller, otherwise
1246  * <code>{@link Vec3(0)|Vec3.ZERO}</code>.
1247  * @example <caption>Report the position of your right hand relative to your avatar.</caption>
1248  * print(JSON.stringify(MyAvatar.getLeftHandPosition()));
1249  */
1250  Q_INVOKABLE glm::vec3 getRightHandPosition() const;
1251 
1252  /*@jsdoc
1253  * Gets the position 0.3m in front of the left hand's position in the direction along the palm, in avatar coordinates, as
1254  * positioned by a hand controller.
1255  * @function MyAvatar.getLeftHandTipPosition
1256  * @returns {Vec3} The position 0.3m in front of the left hand's position in the direction along the palm, in avatar
1257  * coordinates. If the hand isn't being positioned by a controller, <code>{@link Vec3(0)|Vec3.ZERO}</code> is returned.
1258  */
1259  Q_INVOKABLE glm::vec3 getLeftHandTipPosition() const;
1260 
1261  /*@jsdoc
1262  * Gets the position 0.3m in front of the right hand's position in the direction along the palm, in avatar coordinates, as
1263  * positioned by a hand controller.
1264  * @function MyAvatar.getRightHandTipPosition
1265  * @returns {Vec3} The position 0.3m in front of the right hand's position in the direction along the palm, in avatar
1266  * coordinates. If the hand isn't being positioned by a controller, <code>{@link Vec3(0)|Vec3.ZERO}</code> is returned.
1267  */
1268  Q_INVOKABLE glm::vec3 getRightHandTipPosition() const;
1269 
1270 
1271  /*@jsdoc
1272  * Gets the pose (position, rotation, velocity, and angular velocity) of the avatar's left hand as positioned by a
1273  * hand controller (e.g., Oculus Touch or Vive).
1274  * <p>Note: The Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints
1275  * for hand animation.) If you are using the Leap Motion, the return value's <code>valid</code> property will be
1276  * <code>false</code> and any pose values returned will not be meaningful.</p>
1277  * @function MyAvatar.getLeftHandPose
1278  * @returns {Pose} The pose of the avatar's left hand, relative to the avatar, as positioned by a hand controller.
1279  * @example <caption>Report the pose of your avatar's left hand.</caption>
1280  * print(JSON.stringify(MyAvatar.getLeftHandPose()));
1281  */
1282  Q_INVOKABLE controller::Pose getLeftHandPose() const;
1283 
1284  /*@jsdoc
1285  * Gets the pose (position, rotation, velocity, and angular velocity) of the avatar's left hand as positioned by a
1286  * hand controller (e.g., Oculus Touch or Vive).
1287  * <p>Note: The Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints
1288  * for hand animation.) If you are using the Leap Motion, the return value's <code>valid</code> property will be
1289  * <code>false</code> and any pose values returned will not be meaningful.</p>
1290  * @function MyAvatar.getRightHandPose
1291  * @returns {Pose} The pose of the avatar's right hand, relative to the avatar, as positioned by a hand controller.
1292  * @example <caption>Report the pose of your avatar's right hand.</caption>
1293  * print(JSON.stringify(MyAvatar.getRightHandPose()));
1294  */
1295  Q_INVOKABLE controller::Pose getRightHandPose() const;
1296 
1297  /*@jsdoc
1298  * Gets the pose (position, rotation, velocity, and angular velocity) of the avatar's left hand, relative to the avatar, as
1299  * positioned by a hand controller (e.g., Oculus Touch or Vive), and translated 0.3m along the palm.
1300  * <p>Note: Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints
1301  * for hand animation.) If you are using Leap Motion, the return value's <code>valid</code> property will be
1302  * <code>false</code> and any pose values returned will not be meaningful.</p>
1303  * @function MyAvatar.getLeftHandTipPose
1304  * @returns {Pose} The pose of the avatar's left hand, relative to the avatar, as positioned by a hand controller, and
1305  * translated 0.3m along the palm.
1306  */
1307  Q_INVOKABLE controller::Pose getLeftHandTipPose() const;
1308 
1309  /*@jsdoc
1310  * Gets the pose (position, rotation, velocity, and angular velocity) of the avatar's right hand, relative to the avatar, as
1311  * positioned by a hand controller (e.g., Oculus Touch or Vive), and translated 0.3m along the palm.
1312  * <p>Note: Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints
1313  * for hand animation.) If you are using Leap Motion, the return value's <code>valid</code> property will be
1314  * <code>false</code> and any pose values returned will not be meaningful.</p>
1315  * @function MyAvatar.getRightHandTipPose
1316  * @returns {Pose} The pose of the avatar's right hand, relative to the avatar, as positioned by a hand controller, and
1317  * translated 0.3m along the palm.
1318  */
1319  Q_INVOKABLE controller::Pose getRightHandTipPose() const;
1320 
1321  AvatarWeakPointer getLookAtTargetAvatar() const { return _lookAtTargetAvatar; }
1322  void updateLookAtTargetAvatar();
1323  void computeMyLookAtTarget(const AvatarHash& hash);
1324  void snapOtherAvatarLookAtTargetsToMe(const AvatarHash& hash);
1325  void clearLookAtTargetAvatar();
1326 
1327  virtual void setJointRotations(const QVector<glm::quat>& jointRotations) override;
1328  virtual void setJointData(int index, const glm::quat& rotation, const glm::vec3& translation) override;
1329  virtual void setJointRotation(int index, const glm::quat& rotation) override;
1330  virtual void setJointTranslation(int index, const glm::vec3& translation) override;
1331  virtual void clearJointData(int index) override;
1332 
1333  virtual void setJointData(const QString& name, const glm::quat& rotation, const glm::vec3& translation) override;
1334  virtual void setJointRotation(const QString& name, const glm::quat& rotation) override;
1335  virtual void setJointTranslation(const QString& name, const glm::vec3& translation) override;
1336  virtual void clearJointData(const QString& name) override;
1337  virtual void clearJointsData() override;
1338 
1339  /*@jsdoc
1340  * Sets and locks a joint's position and orientation.
1341  * <p><strong>Note:</strong> Only works on the hips joint.</p>
1342  * @function MyAvatar.pinJoint
1343  * @param {number} index - The index of the joint.
1344  * @param {Vec3} position - The position of the joint in world coordinates.
1345  * @param {Quat} orientation - The orientation of the joint in world coordinates.
1346  * @returns {boolean} <code>true</code> if the joint was pinned, <code>false</code> if it wasn't.
1347  */
1348  Q_INVOKABLE bool pinJoint(int index, const glm::vec3& position, const glm::quat& orientation);
1349 
1350  bool isJointPinned(int index);
1351 
1352  /*@jsdoc
1353  * Clears a lock on a joint's position and orientation, as set by {@link MyAvatar.pinJoint|pinJoint}.
1354  * <p><strong>Note:</strong> Only works on the hips joint.</p>
1355  * @function MyAvatar.clearPinOnJoint
1356  * @param {number} index - The index of the joint.
1357  * @returns {boolean} <code>true</code> if the joint was unpinned, <code>false</code> if it wasn't.
1358  */
1359  Q_INVOKABLE bool clearPinOnJoint(int index);
1360 
1361  /*@jsdoc
1362  * Gets the maximum error distance from the most recent inverse kinematics (IK) solution.
1363  * @function MyAvatar.getIKErrorOnLastSolve
1364  * @returns {number} The maximum IK error distance.
1365  */
1366  Q_INVOKABLE float getIKErrorOnLastSolve() const;
1367 
1368  /*@jsdoc
1369  * Changes the user's avatar and associated descriptive name.
1370  * @function MyAvatar.useFullAvatarURL
1371  * @param {string} fullAvatarURL - The URL of the avatar's <code>.fst</code> file.
1372  * @param {string} [modelName=""] - Descriptive name of the avatar.
1373  */
1374  Q_INVOKABLE void useFullAvatarURL(const QUrl& fullAvatarURL, const QString& modelName = QString());
1375 
1376  /*@jsdoc
1377  * Gets the complete URL for the current avatar.
1378  * @function MyAvatar.getFullAvatarURLFromPreferences
1379  * @returns {string} The full avatar model name.
1380  * @example <caption>Report the URL for the current avatar.</caption>
1381  * print(MyAvatar.getFullAvatarURLFromPreferences());
1382  */
1383  Q_INVOKABLE QUrl getFullAvatarURLFromPreferences() const { return _fullAvatarURLFromPreferences; }
1384 
1385  /*@jsdoc
1386  * Gets the full avatar model name for the current avatar.
1387  * @function MyAvatar.getFullAvatarModelName
1388  * @returns {string} The full avatar model name.
1389  * @example <caption>Report the current full avatar model name.</caption>
1390  * print(MyAvatar.getFullAvatarModelName());
1391  */
1392  Q_INVOKABLE QString getFullAvatarModelName() const { return _fullAvatarModelName; }
1393 
1394  void resetFullAvatarURL();
1395 
1396  MyCharacterController* getCharacterController() { return &_characterController; }
1397  const MyCharacterController* getCharacterController() const { return &_characterController; }
1398 
1399  void updateMotors();
1400  void prepareForPhysicsSimulation();
1401  void nextAttitude(glm::vec3 position, glm::quat orientation); // Can be safely called at any time.
1402  void harvestResultsFromPhysicsSimulation(float deltaTime);
1403 
1404  const QString& getCollisionSoundURL() { return _collisionSoundURL; }
1405  void setCollisionSoundURL(const QString& url);
1406 
1407  SharedSoundPointer getCollisionSound();
1408  void setCollisionSound(SharedSoundPointer sound) { _collisionSound = sound; }
1409 
1410  void clearScriptableSettings();
1411 
1412  float getBoomLength() const { return _boomLength; }
1413  void setBoomLength(float boomLength) { _boomLength = boomLength; }
1414 
1415  float getPitchSpeed() const { return _pitchSpeed; }
1416  void setPitchSpeed(float speed) { _pitchSpeed = speed; }
1417 
1418  float getYawSpeed() const { return _yawSpeed; }
1419  void setYawSpeed(float speed) { _yawSpeed = speed; }
1420 
1421  float getHMDYawSpeed() const { return _hmdYawSpeed; }
1422  void setHMDYawSpeed(float speed) { _hmdYawSpeed = speed; }
1423 
1424  static const float ZOOM_MIN;
1425  static const float ZOOM_MAX;
1426  static const float ZOOM_DEFAULT;
1427 
1428  void destroyAnimGraph();
1429 
1430  AudioListenerMode getAudioListenerMode() { return _audioListenerMode; }
1431  void setAudioListenerMode(AudioListenerMode audioListenerMode);
1432  glm::vec3 getCustomListenPosition() { return _customListenPosition; }
1433  void setCustomListenPosition(glm::vec3 customListenPosition) { _customListenPosition = customListenPosition; }
1434  glm::quat getCustomListenOrientation() { return _customListenOrientation; }
1435  void setCustomListenOrientation(glm::quat customListenOrientation) { _customListenOrientation = customListenOrientation; }
1436 
1437  virtual void rebuildCollisionShape() override;
1438 
1439  const glm::vec2& getHipToHandController() const { return _hipToHandController; }
1440  void setHipToHandController(glm::vec2 currentHipToHandController) { _hipToHandController = currentHipToHandController; }
1441  const glm::vec2& getHeadControllerFacing() const { return _headControllerFacing; }
1442  void setHeadControllerFacing(glm::vec2 currentHeadControllerFacing) { _headControllerFacing = currentHeadControllerFacing; }
1443  const glm::vec2& getHeadControllerFacingMovingAverage() const { return _headControllerFacingMovingAverage; }
1444  void setHeadControllerFacingMovingAverage(glm::vec2 currentHeadControllerFacing) { _headControllerFacingMovingAverage = currentHeadControllerFacing; }
1445  float getCurrentStandingHeight() const { return _currentStandingHeight; }
1446  void setCurrentStandingHeight(float newMode) { _currentStandingHeight = newMode; }
1447  const glm::quat getAverageHeadRotation() const { return _averageHeadRotation; }
1448  void setAverageHeadRotation(glm::quat rotation) { _averageHeadRotation = rotation; }
1449  bool getResetMode() const { return _resetMode; }
1450  void setResetMode(bool hasBeenReset) { _resetMode = hasBeenReset; }
1451 
1452  void setControllerPoseInSensorFrame(controller::Action action, const controller::Pose& pose);
1453  controller::Pose getControllerPoseInSensorFrame(controller::Action action) const;
1454  controller::Pose getControllerPoseInWorldFrame(controller::Action action) const;
1455  controller::Pose getControllerPoseInAvatarFrame(controller::Action action) const;
1456 
1457  bool hasDriveInput() const;
1458 
1459  /*@jsdoc
1460  * Gets the current avatar entity IDs and their properties.
1461  * @function MyAvatar.getAvatarEntitiesVariant
1462  * @returns {MyAvatar.AvatarEntityData[]} The current avatar entity IDs and their properties.
1463  */
1464  Q_INVOKABLE QVariantList getAvatarEntitiesVariant();
1465 
1466  void removeWornAvatarEntity(const EntityItemID& entityID);
1467  void clearWornAvatarEntities();
1468  bool hasAvatarEntities() const;
1469 
1470  /*@jsdoc
1471  * Checks whether your avatar is flying.
1472  * @function MyAvatar.isFlying
1473  * @returns {boolean} <code>true</code> if your avatar is flying and not taking off or falling, <code>false</code> if not.
1474  */
1475  Q_INVOKABLE bool isFlying();
1476 
1477  /*@jsdoc
1478  * Checks whether your avatar is in the air.
1479  * @function MyAvatar.isInAir
1480  * @returns {boolean} <code>true</code> if your avatar is taking off, flying, or falling, otherwise <code>false</code>
1481  * because your avatar is on the ground.
1482  */
1483  Q_INVOKABLE bool isInAir();
1484 
1485  /*@jsdoc
1486  * Sets your preference for flying in your current desktop or HMD display mode. Note that your ability to fly also depends
1487  * on whether the domain you're in allows you to fly.
1488  * @function MyAvatar.setFlyingEnabled
1489  * @param {boolean} enabled - Set <code>true</code> if you want to enable flying in your current desktop or HMD display
1490  * mode, otherwise set <code>false</code>.
1491  */
1492  Q_INVOKABLE void setFlyingEnabled(bool enabled);
1493 
1494  /*@jsdoc
1495  * Gets your preference for flying in your current desktop or HMD display mode. Note that your ability to fly also depends
1496  * on whether the domain you're in allows you to fly.
1497  * @function MyAvatar.getFlyingEnabled
1498  * @returns {boolean} <code>true</code> if your preference is to enable flying in your current desktop or HMD display mode,
1499  * otherwise <code>false</code>.
1500  */
1501  Q_INVOKABLE bool getFlyingEnabled();
1502 
1503  /*@jsdoc
1504  * Sets your preference for flying in desktop display mode. Note that your ability to fly also depends on whether the domain
1505  * you're in allows you to fly.
1506  * @function MyAvatar.setFlyingDesktopPref
1507  * @param {boolean} enabled - Set <code>true</code> if you want to enable flying in desktop display mode, otherwise set
1508  * <code>false</code>.
1509  */
1510  Q_INVOKABLE void setFlyingDesktopPref(bool enabled);
1511 
1512  /*@jsdoc
1513  * Gets your preference for flying in desktop display mode. Note that your ability to fly also depends on whether the domain
1514  * you're in allows you to fly.
1515  * @function MyAvatar.getFlyingDesktopPref
1516  * @returns {boolean} <code>true</code> if your preference is to enable flying in desktop display mode, otherwise
1517  * <code>false</code>.
1518  */
1519  Q_INVOKABLE bool getFlyingDesktopPref();
1520 
1521  /*@jsdoc
1522  * Sets your preference for flying in HMD display mode. Note that your ability to fly also depends on whether the domain
1523  * you're in allows you to fly.
1524  * @function MyAvatar.setFlyingHMDPref
1525  * @param {boolean} enabled - Set <code>true</code> if you want to enable flying in HMD display mode, otherwise set
1526  * <code>false</code>.
1527  */
1528  Q_INVOKABLE void setFlyingHMDPref(bool enabled);
1529 
1530  /*@jsdoc
1531  * Gets your preference for flying in HMD display mode. Note that your ability to fly also depends on whether the domain
1532  * you're in allows you to fly.
1533  * @function MyAvatar.getFlyingHMDPref
1534  * @returns {boolean} <code>true</code> if your preference is to enable flying in HMD display mode, otherwise
1535  * <code>false</code>.
1536  */
1537  Q_INVOKABLE bool getFlyingHMDPref();
1538 
1539  /*@jsdoc
1540  * Set your preference for hand-relative movement.
1541  * @function MyAvatar.setHandRelativeMovement
1542  * @param {number} enabled - Set <code>true</code> if you want to enable hand-relative movement, otherwise set to <code>false</code>.
1543  *
1544  */
1545  Q_INVOKABLE void setMovementReference(int enabled);
1546 
1547  /*@jsdoc
1548  * Get your preference for hand-relative movement.
1549  * @function MyAvatar.getHandRelativeMovement
1550  * @returns {number} <code>true</code> if your preference is for user locomotion to be relative to the direction your
1551  * controller is pointing, otherwise <code>false</code>.
1552  */
1553  Q_INVOKABLE int getMovementReference();
1554 
1555  /*@jsdoc
1556  * Set the first 'shifting point' for acceleration step function.
1557  * @function MyAvatar.setDriveGear1
1558  * @param {number} shiftPoint - Set the first shift point for analog movement acceleration step function, between [0.0, 1.0]. Must be less than or equal to Gear 2.
1559  */
1560  Q_INVOKABLE void setDriveGear1(float shiftPoint);
1561 
1562  /*@jsdoc
1563  * Get the first 'shifting point' for acceleration step function.
1564  * @function MyAvatar.getDriveGear1
1565  * @returns {number} Value between [0.0, 1.0].
1566  */
1567  Q_INVOKABLE float getDriveGear1();
1568 
1569  /*@jsdoc
1570  * Set the second 'shifting point' for acceleration step function.
1571  * @function MyAvatar.setDriveGear2
1572  * @param {number} shiftPoint - Defines the second shift point for analog movement acceleration step function, between [0, 1]. Must be greater than or equal to Gear 1 and less than or equal to Gear 2.
1573  */
1574  Q_INVOKABLE void setDriveGear2(float shiftPoint);
1575 
1576  /*@jsdoc
1577  * Get the second 'shifting point' for acceleration step function.
1578  * @function MyAvatar.getDriveGear2
1579  * @returns {number} Value between [0.0, 1.0].
1580  */
1581  Q_INVOKABLE float getDriveGear2();
1582 
1583  /*@jsdoc
1584  * Set the third 'shifting point' for acceleration step function.
1585  * @function MyAvatar.setDriveGear3
1586  * @param {number} shiftPoint - Defines the third shift point for analog movement acceleration step function, between [0, 1]. Must be greater than or equal to Gear 2 and less than or equal to Gear 4.
1587  */
1588  Q_INVOKABLE void setDriveGear3(float shiftPoint);
1589 
1590  /*@jsdoc
1591  * Get the third 'shifting point' for acceleration step function.
1592  * @function MyAvatar.getDriveGear3
1593  * @returns {number} Value between [0.0, 1.0].
1594  */
1595  Q_INVOKABLE float getDriveGear3();
1596 
1597  /*@jsdoc
1598  * Set the fourth 'shifting point' for acceleration step function.
1599  * @function MyAvatar.setDriveGear4
1600  * @param {number} shiftPoint - Defines the fourth shift point for analog movement acceleration step function, between [0, 1]. Must be greater than Gear 3 and less than Gear 5.
1601  */
1602  Q_INVOKABLE void setDriveGear4(float shiftPoint);
1603 
1604  /*@jsdoc
1605  * Get the fourth 'shifting point' for acceleration step function.
1606  * @function MyAvatar.getDriveGear4
1607  * @returns {number} Value between [0.0, 1.0].
1608  */
1609  Q_INVOKABLE float getDriveGear4();
1610 
1611  /*@jsdoc
1612  * Set the fifth 'shifting point' for acceleration step function.
1613  * @function MyAvatar.setDriveGear5
1614  * @param {number} shiftPoint - Defines the fifth shift point for analog movement acceleration step function, between [0, 1]. Must be greater than or equal to Gear 4.
1615  */
1616  Q_INVOKABLE void setDriveGear5(float shiftPoint);
1617 
1618  /*@jsdoc
1619  * Get the fifth 'shifting point' for acceleration step function.
1620  * @function MyAvatar.getDriveGear5
1621  * @returns {number} Value between [0.0, 1.0].
1622  */
1623  Q_INVOKABLE float getDriveGear5();
1624 
1625  void setControlSchemeIndex(int index);
1626 
1627  int getControlSchemeIndex();
1628 
1629  /*@jsdoc
1630  * Gets the target scale of the avatar. The target scale is the desired scale of the avatar without any restrictions on
1631  * permissible scale values imposed by the domain.
1632  * @function MyAvatar.getAvatarScale
1633  * @returns {number} The target scale for the avatar, range <code>0.005</code> &ndash; <code>1000.0</code>.
1634  */
1635  Q_INVOKABLE float getAvatarScale() const;
1636 
1637  /*@jsdoc
1638  * Sets the target scale of the avatar. The target scale is the desired scale of the avatar without any restrictions on
1639  * permissible scale values imposed by the domain.
1640  * @function MyAvatar.setAvatarScale
1641  * @param {number} scale - The target scale for the avatar, range <code>0.005</code> &ndash; <code>1000.0</code>.
1642  */
1643  Q_INVOKABLE void setAvatarScale(float scale);
1644 
1645  /*@jsdoc
1646  * Sets whether the avatar should collide with entities.
1647  * <p><strong>Note:</strong> A <code>false</code> value won't disable collisions if the avatar is in a zone that disallows
1648  * collisionless avatars. However, the <code>false</code> value will be set so that collisions are disabled as soon as the
1649  * avatar moves to a position where collisionless avatars are allowed.
1650  * @function MyAvatar.setCollisionsEnabled
1651  * @param {boolean} enabled - <code>true</code> to enable the avatar to collide with entities, <code>false</code> to
1652  * disable.
1653  */
1654  Q_INVOKABLE void setCollisionsEnabled(bool enabled);
1655 
1656  /*@jsdoc
1657  * Gets whether the avatar will currently collide with entities.
1658  * <p><strong>Note:</strong> The avatar will always collide with entities if in a zone that disallows collisionless avatars.
1659  * @function MyAvatar.getCollisionsEnabled
1660  * @returns {boolean} <code>true</code> if the avatar will currently collide with entities, <code>false</code> if it won't.
1661  */
1662  Q_INVOKABLE bool getCollisionsEnabled();
1663 
1664  /*@jsdoc
1665  * Sets whether the avatar should collide with other avatars.
1666  * @function MyAvatar.setOtherAvatarsCollisionsEnabled
1667  * @param {boolean} enabled - <code>true</code> to enable the avatar to collide with other avatars, <code>false</code>
1668  * to disable.
1669  */
1670  Q_INVOKABLE void setOtherAvatarsCollisionsEnabled(bool enabled);
1671 
1672  /*@jsdoc
1673  * Gets whether the avatar will collide with other avatars.
1674  * @function MyAvatar.getOtherAvatarsCollisionsEnabled
1675  * @returns {boolean} <code>true</code> if the avatar will collide with other avatars, <code>false</code> if it won't.
1676  */
1677  Q_INVOKABLE bool getOtherAvatarsCollisionsEnabled();
1678 
1679  /*@jsdoc
1680  * Gets the avatar's collision capsule: a cylinder with hemispherical ends that approximates the extents or the avatar.
1681  * <p><strong>Warning:</strong> The values returned are in world coordinates but aren't necessarily up to date with the
1682  * avatar's current position.</p>
1683  * @function MyAvatar.getCollisionCapsule
1684  * @returns {MyAvatar.CollisionCapsule} The avatar's collision capsule.
1685  */
1686  Q_INVOKABLE QVariantMap getCollisionCapsule() const;
1687 
1688  /*@jsdoc
1689  * @function MyAvatar.setCharacterControllerEnabled
1690  * @param {boolean} enabled - <code>true</code> to enable the avatar to collide with entities, <code>false</code> to
1691  * disable.
1692  * @deprecated This function is deprecated and will be removed. Use {@link MyAvatar.setCollisionsEnabled} instead.
1693  */
1694  Q_INVOKABLE void setCharacterControllerEnabled(bool enabled); // deprecated
1695 
1696  /*@jsdoc
1697  * @function MyAvatar.getCharacterControllerEnabled
1698  * @returns {boolean} <code>true</code> if the avatar will currently collide with entities, <code>false</code> if it won't.
1699  * @deprecated This function is deprecated and will be removed. Use {@link MyAvatar.getCollisionsEnabled} instead.
1700  */
1701  Q_INVOKABLE bool getCharacterControllerEnabled(); // deprecated
1702 
1703  /*@jsdoc
1704  * Gets the rotation of a joint relative to the avatar.
1705  * @comment Different behavior to the Avatar version of this method.
1706  * @function MyAvatar.getAbsoluteJointRotationInObjectFrame
1707  * @param {number} index - The index of the joint.
1708  * @returns {Quat} The rotation of the joint relative to the avatar.
1709  * @example <caption>Report the rotation of your avatar's head joint relative to your avatar.</caption>
1710  * var headIndex = MyAvatar.getJointIndex("Head");
1711  * var headRotation = MyAvatar.getAbsoluteJointRotationInObjectFrame(headIndex);
1712  * print("Head rotation: " + JSON.stringify(Quat.safeEulerAngles(headRotation))); // Degrees
1713  */
1714  virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override;
1715 
1716  /*@jsdoc
1717  * Gets the translation of a joint relative to the avatar.
1718  * @comment Different behavior to the Avatar version of this method.
1719  * @function MyAvatar.getAbsoluteJointTranslationInObjectFrame
1720  * @param {number} index - The index of the joint.
1721  * @returns {Vec3} The translation of the joint relative to the avatar.
1722  * @example <caption>Report the translation of your avatar's head joint relative to your avatar.</caption>
1723  * var headIndex = MyAvatar.getJointIndex("Head");
1724  * var headTranslation = MyAvatar.getAbsoluteJointTranslationInObjectFrame(headIndex);
1725  * print("Head translation: " + JSON.stringify(headTranslation));
1726  */
1727  virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override;
1728 
1729  // all calibration matrices are in absolute sensor space.
1730  glm::mat4 getCenterEyeCalibrationMat() const;
1731  glm::mat4 getHeadCalibrationMat() const;
1732  glm::mat4 getSpine2CalibrationMat() const;
1733  glm::mat4 getHipsCalibrationMat() const;
1734  glm::mat4 getLeftFootCalibrationMat() const;
1735  glm::mat4 getRightFootCalibrationMat() const;
1736  glm::mat4 getRightArmCalibrationMat() const;
1737  glm::mat4 getLeftArmCalibrationMat() const;
1738  glm::mat4 getLeftHandCalibrationMat() const;
1739  glm::mat4 getRightHandCalibrationMat() const;
1740 
1741  void addHoldAction(AvatarActionHold* holdAction); // thread-safe
1742  void removeHoldAction(AvatarActionHold* holdAction); // thread-safe
1743  void updateHoldActions(const AnimPose& prePhysicsPose, const AnimPose& postUpdatePose);
1744 
1745 
1746  // derive avatar body position and orientation from the current HMD Sensor location.
1747  // results are in sensor frame (-z forward)
1748  glm::mat4 deriveBodyFromHMDSensor(const bool forceFollowYPos = false) const;
1749 
1750  glm::mat4 getSpine2RotationRigSpace() const;
1751 
1752  glm::vec3 computeCounterBalance();
1753 
1754  // derive avatar body position and orientation from using the current HMD Sensor location in relation to the previous
1755  // location of the base of support of the avatar.
1756  // results are in sensor frame (-z foward)
1757  glm::mat4 deriveBodyUsingCgModel();
1758 
1759  /*@jsdoc
1760  * Tests whether a vector is pointing in the general direction of the avatar's "up" direction (i.e., dot product of vectors
1761  * is <code>&gt; 0</code>).
1762  * @function MyAvatar.isUp
1763  * @param {Vec3} direction - The vector to test.
1764  * @returns {boolean} <code>true</code> if the direction vector is pointing generally in the direction of the avatar's "up"
1765  * direction.
1766  */
1767  Q_INVOKABLE bool isUp(const glm::vec3& direction) { return glm::dot(direction, _worldUpDirection) > 0.0f; }; // true iff direction points up wrt avatar's definition of up.
1768 
1769  /*@jsdoc
1770  * Tests whether a vector is pointing in the general direction of the avatar's "down" direction (i.e., dot product of
1771  * vectors is <code>&lt; 0</code>).
1772  * @function MyAvatar.isDown
1773  * @param {Vec3} direction - The vector to test.
1774  * @returns {boolean} <code>true</code> if the direction vector is pointing generally in the direction of the avatar's
1775  * "down" direction.
1776  */
1777  Q_INVOKABLE bool isDown(const glm::vec3& direction) { return glm::dot(direction, _worldUpDirection) < 0.0f; };
1778 
1779  void setUserHeight(float value);
1780  float getUserHeight() const;
1781  float getUserEyeHeight() const;
1782 
1783  virtual SpatialParentTree* getParentTree() const override;
1784  virtual glm::vec3 scaleForChildren() const override { return glm::vec3(getSensorToWorldScale()); }
1785 
1786  const QUuid& getSelfID() const { return AVATAR_SELF_ID; }
1787 
1788  void setIsInWalkingState(bool isWalking);
1789  bool getIsInWalkingState() const;
1790  void setIsInSittingState(bool isSitting);
1791  bool getIsInSittingState() const;
1792  void setUserRecenterModel(MyAvatar::SitStandModelType modelName); // Deprecated, will be removed.
1793  MyAvatar::SitStandModelType getUserRecenterModel() const; // Deprecated, will be removed.
1794  void setIsSitStandStateLocked(bool isLocked); // Deprecated, will be removed.
1795  bool getIsSitStandStateLocked() const; // Deprecated, will be removed.
1796  void setAllowAvatarStandingPreference(const AllowAvatarStandingPreference preference);
1797  AllowAvatarStandingPreference getAllowAvatarStandingPreference() const;
1798  void setAllowAvatarLeaningPreference(const AllowAvatarLeaningPreference preference);
1799  AllowAvatarLeaningPreference getAllowAvatarLeaningPreference() const;
1800  void setWalkSpeed(float value);
1801  float getWalkSpeed() const;
1802  void setWalkBackwardSpeed(float value);
1803  float getWalkBackwardSpeed() const;
1804  void setSprintSpeed(float value);
1805  float getSprintSpeed() const;
1806  void setAnalogWalkSpeed(float value);
1807  float getAnalogWalkSpeed() const;
1808  void setAnalogSprintSpeed(float value);
1809  float getAnalogSprintSpeed() const;
1810  void setAnalogPlusWalkSpeed(float value);
1811  float getAnalogPlusWalkSpeed() const;
1812  void setAnalogPlusSprintSpeed(float value);
1813  float getAnalogPlusSprintSpeed() const;
1814  void setSitStandStateChange(bool stateChanged);
1815  bool getSitStandStateChange() const;
1816  void updateSitStandState(float newHeightReading, float dt);
1817 
1818  QVector<QString> getScriptUrls();
1819 
1820  bool isReadyForPhysics() const;
1821 
1822  float computeStandingHeightMode(const controller::Pose& head);
1823  glm::quat computeAverageHeadRotation(const controller::Pose& head);
1824 
1825  virtual void setAttachmentData(const QVector<AttachmentData>& attachmentData) override;
1826  virtual QVector<AttachmentData> getAttachmentData() const override;
1827 
1828  virtual QVariantList getAttachmentsVariant() const override;
1829  virtual void setAttachmentsVariant(const QVariantList& variant) override;
1830 
1831  glm::vec3 getNextPosition() { return _goToPending ? _goToPosition : getWorldPosition(); }
1832  void prepareAvatarEntityDataForReload();
1833 
1834  /*@jsdoc
1835  * Turns the avatar's head until it faces the target point within a +90/-90 degree range.
1836  * Once this method is called, API calls have full control of the head for a limited time.
1837  * If this method is not called for 2 seconds, the engine regains control of the head.
1838  * @function MyAvatar.setHeadLookAt
1839  * @param {Vec3} lookAtTarget - The target point in world coordinates.
1840  */
1841  Q_INVOKABLE void setHeadLookAt(const glm::vec3& lookAtTarget);
1842 
1843  /*@jsdoc
1844  * Gets the current target point of the head's look direction in world coordinates.
1845  * @function MyAvatar.getHeadLookAt
1846  * @returns {Vec3} The head's look-at target in world coordinates.
1847  */
1848  Q_INVOKABLE glm::vec3 getHeadLookAt() { return _lookAtCameraTarget; }
1849 
1850  /*@jsdoc
1851  * Returns control of the avatar's head to the engine, and releases control from API calls.
1852  * @function MyAvatar.releaseHeadLookAtControl
1853  */
1854  Q_INVOKABLE void releaseHeadLookAtControl();
1855 
1856  /*@jsdoc
1857  * Forces the avatar's eyes to look at a specified location. Once this method is called, API calls
1858  * full control of the eyes for a limited time. If this method is not called for 2 seconds,
1859  * the engine regains control of the eyes.
1860  * @function MyAvatar.setEyesLookAt
1861  * @param {Vec3} lookAtTarget - The target point in world coordinates.
1862  */
1863  Q_INVOKABLE void setEyesLookAt(const glm::vec3& lookAtTarget);
1864 
1865  /*@jsdoc
1866  * Gets the current target point of the eyes look direction in world coordinates.
1867  * @function MyAvatar.getEyesLookAt
1868  * @returns {Vec3} The eyes' look-at target in world coordinates.
1869  */
1870  Q_INVOKABLE glm::vec3 getEyesLookAt() { return _eyesLookAtTarget.get(); }
1871 
1872  /*@jsdoc
1873  * Returns control of the avatar's eyes to the engine, and releases control from API calls.
1874  * @function MyAvatar.releaseEyesLookAtControl
1875  */
1876  Q_INVOKABLE void releaseEyesLookAtControl();
1877 
1878  /*@jsdoc
1879  * Sets the point-at target for the <code>"point"</code> reaction that may be started with {@link MyAvatar.beginReaction}.
1880  * The point-at target is set only if it is in front of the avatar.
1881  * <p>Note: The <code>"point"</code> reaction should be started before calling this method.</p>
1882  * @function MyAvatar.setPointAt
1883  * @param {Vec3} pointAtTarget - The target to point at, in world coordinates.
1884  * @returns {boolean} <code>true</code> if the target point was set, <code>false</code> if it wasn't.
1885  */
1886  Q_INVOKABLE bool setPointAt(const glm::vec3& pointAtTarget);
1887 
1888  glm::quat getLookAtRotation() { return _lookAtYaw * _lookAtPitch; }
1889 
1890  /*@jsdoc
1891  * Creates a new grab that grabs an entity.
1892  * @function MyAvatar.grab
1893  * @param {Uuid} targetID - The ID of the entity to grab.
1894  * @param {number} parentJointIndex - The avatar joint to use to grab the entity.
1895  * @param {Vec3} offset - The target's local position relative to the joint.
1896  * @param {Quat} rotationalOffset - The target's local rotation relative to the joint.
1897  * @returns {Uuid} The ID of the new grab.
1898  * @example <caption>Create and grab an entity for a short while.</caption>
1899  * var entityPosition = Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, { x: 0, y: 0, z: -5 }));
1900  * var entityRotation = MyAvatar.orientation;
1901  * var entityID = Entities.addEntity({
1902  * type: "Box",
1903  * position: entityPosition,
1904  * rotation: entityRotation,
1905  * dimensions: { x: 0.5, y: 0.5, z: 0.5 }
1906  * });
1907  * var rightHandJoint = MyAvatar.getJointIndex("RightHand");
1908  * var relativePosition = Entities.worldToLocalPosition(entityPosition, MyAvatar.SELF_ID, rightHandJoint);
1909  * var relativeRotation = Entities.worldToLocalRotation(entityRotation, MyAvatar.SELF_ID, rightHandJoint);
1910  * var grabID = MyAvatar.grab(entityID, rightHandJoint, relativePosition, relativeRotation);
1911  *
1912  * Script.setTimeout(function () {
1913  * MyAvatar.releaseGrab(grabID);
1914  * Entities.deleteEntity(entityID);
1915  * }, 10000);
1916  */
1917  Q_INVOKABLE const QUuid grab(const QUuid& targetID, int parentJointIndex,
1918  glm::vec3 positionalOffset, glm::quat rotationalOffset);
1919 
1920  /*@jsdoc
1921  * Releases (deletes) a grab to stop grabbing an entity.
1922  * @function MyAvatar.releaseGrab
1923  * @param {Uuid} grabID - The ID of the grab to release.
1924  */
1925  Q_INVOKABLE void releaseGrab(const QUuid& grabID);
1926 
1927  /*@jsdoc
1928  * Gets details of all avatar entities.
1929  * <p><strong>Warning:</strong> Potentially an expensive call. Do not use if possible.</p>
1930  * @function MyAvatar.getAvatarEntityData
1931  * @returns {AvatarEntityMap} Details of all avatar entities.
1932  * @example <caption>Report the current avatar entities.</caption>
1933  * var avatarEntityData = MyAvatar.getAvatarEntityData();
1934  * print("Avatar entities: " + JSON.stringify(avatarEntityData));
1935  */
1936  AvatarEntityMap getAvatarEntityData() const override;
1937 
1938  AvatarEntityMap getAvatarEntityDataNonDefault() const override;
1939 
1940  /*@jsdoc
1941  * Sets all avatar entities from an object.
1942  * @function MyAvatar.setAvatarEntityData
1943  * @param {AvatarEntityMap} avatarEntityData - Details of the avatar entities.
1944  */
1945  void setAvatarEntityData(const AvatarEntityMap& avatarEntityData) override;
1946 
1947  /*@jsdoc
1948  * @comment Uses the base class's JSDoc.
1949  */
1950  void updateAvatarEntity(const QUuid& entityID, const QByteArray& entityData) override;
1951 
1952  void avatarEntityDataToJson(QJsonObject& root) const override;
1953 
1954  void storeAvatarEntityDataPayload(const QUuid& entityID, const QByteArray& payload) override;
1955 
1956  /*@jsdoc
1957  * @comment Uses the base class's JSDoc.
1958  */
1959  int sendAvatarDataPacket(bool sendAll = false) override;
1960 
1961  void addAvatarHandsToFlow(const std::shared_ptr<Avatar>& otherAvatar);
1962 
1963  /*@jsdoc
1964  * Enables and disables flow simulation of physics on the avatar's hair, clothes, and body parts. See
1965  * {@link https://docs.overte.org/create/avatars/add-flow.html|Add Flow to Your Avatar} for more
1966  * information.
1967  * @function MyAvatar.useFlow
1968  * @param {boolean} isActive - <code>true</code> if flow simulation is enabled on the joint, <code>false</code> if it isn't.
1969  * @param {boolean} isCollidable - <code>true</code> to enable collisions in the flow simulation, <code>false</code> to
1970  * disable.
1971  * @param {Object<JointName, MyAvatar.FlowPhysicsOptions>} [physicsConfig] - Physics configurations for particular entity
1972  * and avatar joints.
1973  * @param {Object<JointName, MyAvatar.FlowCollisionsOptions>} [collisionsConfig] - Collision configurations for particular
1974  * entity and avatar joints.
1975  */
1976  Q_INVOKABLE void useFlow(bool isActive, bool isCollidable, const QVariantMap& physicsConfig = QVariantMap(), const QVariantMap& collisionsConfig = QVariantMap());
1977 
1978  /*@jsdoc
1979  * Gets the current flow configuration.
1980  * @function MyAvatar.getFlowData
1981  * @returns {MyAvatar.FlowData}
1982  */
1983  Q_INVOKABLE QVariantMap getFlowData();
1984 
1985  /*@jsdoc
1986  * Gets the indexes of currently colliding flow joints.
1987  * @function MyAvatar.getCollidingFlowJoints
1988  * @returns {number[]} The indexes of currently colliding flow joints.
1989  */
1990  Q_INVOKABLE QVariantList getCollidingFlowJoints();
1991 
1992  /*@jsdoc
1993  * Starts a sitting action for the avatar.
1994  * @function MyAvatar.beginSit
1995  * @param {Vec3} position - The position where the avatar should sit.
1996  * @param {Quat} rotation - The initial orientation of the seated avatar.
1997  */
1998  Q_INVOKABLE void beginSit(const glm::vec3& position, const glm::quat& rotation);
1999 
2000  /*@jsdoc
2001  * Ends a sitting action for the avatar.
2002  * @function MyAvatar.endSit
2003  * @param {Vec3} position - The position of the avatar when standing up.
2004  * @param {Quat} rotation - The orientation of the avatar when standing up.
2005  */
2006  Q_INVOKABLE void endSit(const glm::vec3& position, const glm::quat& rotation);
2007 
2008  /*@jsdoc
2009  * Gets whether the avatar is in a seated pose. The seated pose is set by calling {@link MyAvatar.beginSit}.
2010  * @function MyAvatar.isSeated
2011  * @returns {boolean} <code>true</code> if the avatar is in a seated pose, <code>false</code> if it isn't.
2012  */
2013  Q_INVOKABLE bool isSeated() { return _characterController.getSeated(); }
2014 
2015  int getOverrideJointCount() const;
2016  bool getFlowActive() const;
2017  bool getNetworkGraphActive() const;
2018 
2019  void updateEyesLookAtPosition(float deltaTime);
2020 
2021  // sets the reaction enabled and triggered parameters of the passed in params
2022  // also clears internal reaction triggers
2023  void updateRigControllerParameters(Rig::ControllerParameters& params);
2024 
2025  // Don't substitute verify-fail:
2026  virtual const QUrl& getSkeletonModelURL() const override { return _skeletonModelURL; }
2027 
2028  void debugDrawPose(controller::Action action, const char* channelName, float size);
2029 
2030  bool getIsJointOverridden(int jointIndex) const;
2031  glm::vec3 getLookAtPivotPoint();
2032  glm::vec3 getCameraEyesPosition(float deltaTime);
2033  bool isJumping();
2034  bool getHMDCrouchRecenterEnabled() const;
2035  bool isAllowedToLean() const;
2036  bool areFeetTracked() const { return _isBodyPartTracked._feet; }; // Determine if the feet are under direct control.
2037  bool areHipsTracked() const { return _isBodyPartTracked._hips; }; // Determine if the hips are under direct control.
2038 
2039 public slots:
2040 
2041  /*@jsdoc
2042  * @comment Uses the base class's JSDoc.
2043  */
2044  virtual void setSessionUUID(const QUuid& sessionUUID) override;
2045 
2046  /*@jsdoc
2047  * Increases the avatar's scale by five percent, up to a minimum scale of <code>1000</code>.
2048  * @function MyAvatar.increaseSize
2049  * @example <caption>Reset your avatar's size to default then grow it 5 times.</caption>
2050  * MyAvatar.resetSize();
2051  *
2052  * for (var i = 0; i < 5; i++){
2053  * print("Growing by 5 percent");
2054  * MyAvatar.increaseSize();
2055  * }
2056  */
2057  void increaseSize();
2058 
2059  /*@jsdoc
2060  * Decreases the avatar's scale by five percent, down to a minimum scale of <code>0.25</code>.
2061  * @function MyAvatar.decreaseSize
2062  * @example <caption>Reset your avatar's size to default then shrink it 5 times.</caption>
2063  * MyAvatar.resetSize();
2064  *
2065  * for (var i = 0; i < 5; i++){
2066  * print("Shrinking by 5 percent");
2067  * MyAvatar.decreaseSize();
2068  * }
2069  */
2070  void decreaseSize();
2071 
2072  /*@jsdoc
2073  * Resets the avatar's scale back to the default scale of <code>1.0</code>.
2074  * @function MyAvatar.resetSize
2075  */
2076  void resetSize();
2077 
2078  /*@jsdoc
2079  * @function MyAvatar.animGraphLoaded
2080  * @deprecated This function is deprecated and will be removed.
2081  */
2082  void animGraphLoaded();
2083 
2084  /*@jsdoc
2085  * Sets the amount of gravity applied to the avatar in the y-axis direction. (Negative values are downward.)
2086  * @function MyAvatar.setGravity
2087  * @param {number} gravity - The amount of gravity to be applied to the avatar, in m/s<sup>2</sup>.
2088  */
2089  void setGravity(float gravity);
2090 
2091  /*@jsdoc
2092  * Sets the amount of gravity applied to the avatar in the y-axis direction. (Negative values are downward.) The default
2093  * value is <code>-5</code> m/s<sup>2</sup>.
2094  * @function MyAvatar.getGravity
2095  * @returns {number} The amount of gravity currently applied to the avatar, in m/s<sup>2</sup>.
2096  */
2097  float getGravity();
2098 
2099  /*@jsdoc
2100  * Moves the avatar to a new position and/or orientation in the domain, with safe landing, while taking into account avatar
2101  * leg length.
2102  * @function MyAvatar.goToFeetLocation
2103  * @param {Vec3} position - The new position for the avatar, in world coordinates.
2104  * @param {boolean} [hasOrientation=false] - Set to <code>true</code> to set the orientation of the avatar.
2105  * @param {Quat} [orientation=Quat.IDENTITY] - The new orientation for the avatar.
2106  * @param {boolean} [shouldFaceLocation=false] - Set to <code>true</code> to position the avatar a short distance away from
2107  * the new position and orientate the avatar to face the position.
2108  */
2109  void goToFeetLocation(const glm::vec3& newPosition, bool hasOrientation = false,
2110  const glm::quat& newOrientation = glm::quat(), bool shouldFaceLocation = false);
2111 
2112  /*@jsdoc
2113  * Moves the avatar to a new position and/or orientation in the domain.
2114  * @function MyAvatar.goToLocation
2115  * @param {Vec3} position - The new position for the avatar, in world coordinates.
2116  * @param {boolean} [hasOrientation=false] - Set to <code>true</code> to set the orientation of the avatar.
2117  * @param {Quat} [orientation=Quat.IDENTITY] - The new orientation for the avatar.
2118  * @param {boolean} [shouldFaceLocation=false] - Set to <code>true</code> to position the avatar a short distance away from
2119  * the new position and orientate the avatar to face the position.
2120  * @param {boolean} [withSafeLanding=true] - Set to <code>false</code> to disable safe landing when teleporting.
2121  */
2122  void goToLocation(const glm::vec3& newPosition,
2123  bool hasOrientation = false, const glm::quat& newOrientation = glm::quat(),
2124  bool shouldFaceLocation = false, bool withSafeLanding = true);
2125  /*@jsdoc
2126  * Moves the avatar to a new position and (optional) orientation in the domain, with safe landing.
2127  * @function MyAvatar.goToLocation
2128  * @param {MyAvatar.GoToProperties} target - The goto target.
2129  */
2130  void goToLocation(const QVariant& properties);
2131 
2132  /*@jsdoc
2133  * Moves the avatar to a new position, with safe landing, and enables collisions.
2134  * @function MyAvatar.goToLocationAndEnableCollisions
2135  * @param {Vec3} position - The new position for the avatar, in world coordinates.
2136  */
2137  void goToLocationAndEnableCollisions(const glm::vec3& newPosition);
2138 
2139  /*@jsdoc
2140  * @function MyAvatar.safeLanding
2141  * @param {Vec3} position -The new position for the avatar, in world coordinates.
2142  * @returns {boolean} <code>true</code> if the avatar was moved, <code>false</code> if it wasn't.
2143  * @deprecated This function is deprecated and will be removed.
2144  */
2145  bool safeLanding(const glm::vec3& position);
2146 
2147 
2148  /*@jsdoc
2149  * @function MyAvatar.restrictScaleFromDomainSettings
2150  * @param {object} domainSettings - Domain settings.
2151  * @deprecated This function is deprecated and will be removed.
2152  */
2153  void restrictScaleFromDomainSettings(const QJsonObject& domainSettingsObject);
2154 
2155  /*@jsdoc
2156  * @function MyAvatar.clearScaleRestriction
2157  * @deprecated This function is deprecated and will be removed.
2158  */
2159  void clearScaleRestriction();
2160 
2161 
2162  /*@jsdoc
2163  * Adds a thrust to your avatar's current thrust to be applied for a short while.
2164  * @function MyAvatar.addThrust
2165  * @param {Vec3} thrust - The thrust direction and magnitude.
2166  * @deprecated This function is deprecated and will be removed. Use {@link MyAvatar|MyAvatar.motorVelocity} and related
2167  * properties instead.
2168  */
2169  // Set/Get update the thrust that will move the avatar around
2170  void addThrust(glm::vec3 newThrust) { _thrust += newThrust; };
2171 
2172  /*@jsdoc
2173  * Gets the thrust currently being applied to your avatar.
2174  * @function MyAvatar.getThrust
2175  * @returns {Vec3} The thrust currently being applied to your avatar.
2176  * @deprecated This function is deprecated and will be removed. Use {@link MyAvatar|MyAvatar.motorVelocity} and related
2177  * properties instead.
2178  */
2179  glm::vec3 getThrust() { return _thrust; };
2180 
2181  /*@jsdoc
2182  * Sets the thrust to be applied to your avatar for a short while.
2183  * @function MyAvatar.setThrust
2184  * @param {Vec3} thrust - The thrust direction and magnitude.
2185  * @deprecated This function is deprecated and will be removed. Use {@link MyAvatar|MyAvatar.motorVelocity} and related
2186  * properties instead.
2187  */
2188  void setThrust(glm::vec3 newThrust) { _thrust = newThrust; }
2189 
2190 
2191  /*@jsdoc
2192  * Updates avatar motion behavior from the Developer &gt; Avatar &gt; Enable Default Motor Control and Enable Scripted
2193  * Motor Control menu items.
2194  * @function MyAvatar.updateMotionBehaviorFromMenu
2195  */
2196  Q_INVOKABLE void updateMotionBehaviorFromMenu();
2197 
2198  /*@jsdoc
2199  * @function MyAvatar.setToggleHips
2200  * @param {boolean} enabled - Enabled.
2201  * @deprecated This function is deprecated and will be removed.
2202  */
2203  void setToggleHips(bool followHead);
2204 
2205  /*@jsdoc
2206  * Displays the base of support area debug graphics if in HMD mode. If your head goes outside this area your avatar's hips
2207  * are moved to counterbalance your avatar, and if your head moves too far then your avatar's position is moved (i.e., a
2208  * step happens).
2209  * @function MyAvatar.setEnableDebugDrawBaseOfSupport
2210  * @param {boolean} enabled - <code>true</code> to show the debug graphics, <code>false</code> to hide.
2211  */
2212  void setEnableDebugDrawBaseOfSupport(bool isEnabled);
2213 
2214  /*@jsdoc
2215  * Displays default pose debug graphics.
2216  * @function MyAvatar.setEnableDebugDrawDefaultPose
2217  * @param {boolean} enabled - <code>true</code> to show the debug graphics, <code>false</code> to hide.
2218  */
2219  void setEnableDebugDrawDefaultPose(bool isEnabled);
2220 
2221  /*@jsdoc
2222  * Displays animation debug graphics. By default, the animation poses used for rendering are displayed. However,
2223  * {@link MyAvatar.setDebugDrawAnimPoseName} can be used to set a specific animation node to display.
2224  * @function MyAvatar.setEnableDebugDrawAnimPose
2225  * @param {boolean} enabled - <code>true</code> to show the debug graphics, <code>false</code> to hide.
2226  */
2227  void setEnableDebugDrawAnimPose(bool isEnabled);
2228 
2229  /*@jsdoc
2230  * Sets the animation node to display when animation debug graphics are enabled with
2231  * {@link MyAvatar.setEnableDebugDrawAnimPose}.
2232  * @function MyAvatar.setDebugDrawAnimPoseName
2233  * @param {string} poseName - The name of the animation node to display debug graphics for. Use <code>""</code> to reset to
2234  * default.
2235  */
2236  void setDebugDrawAnimPoseName(QString poseName);
2237 
2238  /*@jsdoc
2239  * Displays position debug graphics.
2240  * @function MyAvatar.setEnableDebugDrawPosition
2241  * @param {boolean} enabled - <code>true</code> to show the debug graphics, <code>false</code> to hide.
2242  */
2243  void setEnableDebugDrawPosition(bool isEnabled);
2244 
2245  /*@jsdoc
2246  * Displays controller hand target debug graphics.
2247  * @function MyAvatar.setEnableDebugDrawHandControllers
2248  * @param {boolean} enabled - <code>true</code> to show the debug graphics, <code>false</code> to hide.
2249  */
2250  void setEnableDebugDrawHandControllers(bool isEnabled);
2251 
2252  /*@jsdoc
2253  * Displays sensor-to-world matrix debug graphics.
2254  * @function MyAvatar.setEnableDebugDrawSensorToWorldMatrix
2255  * @param {boolean} enable - <code>true</code> to show the debug graphics, <code>false</code> to hide.
2256  */
2257  void setEnableDebugDrawSensorToWorldMatrix(bool isEnabled);
2258 
2259  /*@jsdoc
2260  * Displays inverse kinematics targets debug graphics.
2261  * @function MyAvatar.setEnableDebugDrawIKTargets
2262  * @param {boolean} enabled - <code>true</code> to show the debug graphics, <code>false</code> to hide.
2263  */
2264  void setEnableDebugDrawIKTargets(bool isEnabled);
2265 
2266  /*@jsdoc
2267  * Displays inverse kinematics constraints debug graphics.
2268  * @function MyAvatar.setEnableDebugDrawIKConstraints
2269  * @param {boolean} enabled - <code>true</code> to show the debug graphics, <code>false</code> to hide.
2270  */
2271  void setEnableDebugDrawIKConstraints(bool isEnabled);
2272 
2273  /*@jsdoc
2274  * Displays inverse kinematics chains debug graphics.
2275  * @function MyAvatar.setEnableDebugDrawIKChains
2276  * @param {boolean} enabled - <code>true</code> to show the debug graphics, <code>false</code> to hide.
2277  */
2278  void setEnableDebugDrawIKChains(bool isEnabled);
2279 
2280  /*@jsdoc
2281  * Displays detailed collision debug graphics.
2282  * @function MyAvatar.setEnableDebugDrawDetailedCollision
2283  * @param {boolean} enabled - <code>true</code> to show the debug graphics, <code>false</code> to hide.
2284  */
2285  void setEnableDebugDrawDetailedCollision(bool isEnabled);
2286 
2287  /*@jsdoc
2288  * Gets whether your avatar mesh is visible.
2289  * @function MyAvatar.getEnableMeshVisible
2290  * @returns {boolean} <code>true</code> if your avatar's mesh is visible, otherwise <code>false</code>.
2291  */
2292  bool getEnableMeshVisible() const override;
2293 
2294  /*@jsdoc
2295  * @comment Uses the base class's JSDoc.
2296  */
2297  void clearAvatarEntity(const QUuid& entityID, bool requiresRemovalFromTree = true) override;
2298 
2299  /*@jsdoc
2300  * Sets whether your avatar mesh is visible to you.
2301  * @function MyAvatar.setEnableMeshVisible
2302  * @param {boolean} enabled - <code>true</code> to show your avatar mesh, <code>false</code> to hide.
2303  * @example <caption>Make your avatar invisible for 10s.</caption>
2304  * MyAvatar.setEnableMeshVisible(false);
2305  * Script.setTimeout(function () {
2306  * MyAvatar.setEnableMeshVisible(true);
2307  * }, 10000);
2308  */
2309  virtual void setEnableMeshVisible(bool isEnabled) override;
2310 
2311  /*@jsdoc
2312  * Sets whether inverse kinematics (IK) is enabled for your avatar.
2313  * @function MyAvatar.setEnableInverseKinematics
2314  * @param {boolean} enabled - <code>true</code> to enable IK, <code>false</code> to disable.
2315  */
2316  void setEnableInverseKinematics(bool isEnabled);
2317 
2318 
2319  /*@jsdoc
2320  * Gets the URL of the override animation graph.
2321  * <p>See {@link https://docs.overte.org/create/avatars/custom-animations.html|Custom Avatar Animations} for
2322  * information on animation graphs.</p>
2323  * @function MyAvatar.getAnimGraphOverrideUrl
2324  * @returns {string} The URL of the override animation graph JSON file. <code>""</code> if there is no override animation
2325  * graph.
2326  */
2327  QUrl getAnimGraphOverrideUrl() const; // thread-safe
2328 
2329  /*@jsdoc
2330  * Sets the animation graph to use in preference to the default animation graph.
2331  * <p>See {@link https://docs.overte.org/create/avatars/custom-animations.html|Custom Avatar Animations} for
2332  * information on animation graphs.</p>
2333  * @function MyAvatar.setAnimGraphOverrideUrl
2334  * @param {string} url - The URL of the animation graph JSON file to use. Set to <code>""</code> to clear an override.
2335  */
2336  void setAnimGraphOverrideUrl(QUrl value); // thread-safe
2337 
2338  /*@jsdoc
2339  * Gets the URL of animation graph (i.e., the avatar animation JSON) that's currently being used for avatar animations.
2340  * <p>See {@link https://docs.overte.org/create/avatars/custom-animations.html|Custom Avatar Animations} for
2341  * information on animation graphs.</p>
2342  * @function MyAvatar.getAnimGraphUrl
2343  * @returns {string} The URL of the current animation graph JSON file.
2344  * @Example <caption>Report the current avatar animation JSON being used.</caption>
2345  * print(MyAvatar.getAnimGraphUrl());
2346  */
2347  QUrl getAnimGraphUrl() const; // thread-safe
2348 
2349  /*@jsdoc
2350  * Sets the current animation graph (i.e., the avatar animation JSON) to use for avatar animations and makes it the default.
2351  * <p>See {@link https://docs.overte.org/create/avatars/custom-animations.html|Custom Avatar Animations} for
2352  * information on animation graphs.</p>
2353  * @function MyAvatar.setAnimGraphUrl
2354  * @param {string} url - The URL of the animation graph JSON file to use.
2355  */
2356  void setAnimGraphUrl(const QUrl& url); // thread-safe
2357 
2358  /*@jsdoc
2359  * Gets your listening position for spatialized audio. The position depends on the value of the
2360  * {@link Myavatar|audioListenerMode} property.
2361  * @function MyAvatar.getPositionForAudio
2362  * @returns {Vec3} Your listening position.
2363  */
2364  glm::vec3 getPositionForAudio();
2365 
2366  /*@jsdoc
2367  * Gets the orientation of your listening position for spatialized audio. The orientation depends on the value of the
2368  * {@link Myavatar|audioListenerMode} property.
2369  * @function MyAvatar.getOrientationForAudio
2370  * @returns {Quat} The orientation of your listening position.
2371  */
2372  glm::quat getOrientationForAudio();
2373 
2374  /*@jsdoc
2375  * @function MyAvatar.setModelScale
2376  * @param {number} scale - The scale.
2377  * @deprecated This function is deprecated and will be removed.
2378  */
2379  virtual void setModelScale(float scale) override;
2380 
2381  /*@jsdoc
2382  * Gets the list of reactions names that can be triggered using {@link MyAvatar.triggerReaction}.
2383  * <p>See also: {@link MyAvatar.getBeginEndReactions}.
2384  * @function MyAvatar.getTriggerReactions
2385  * @returns {string[]} List of reaction names that can be triggered using {@link MyAvatar.triggerReaction}.
2386  * @example <caption>List the available trigger reactions.</caption>
2387  * print("Trigger reactions:", JSON.stringify(MyAvatar.getTriggerReactions()));
2388  */
2389  QStringList getTriggerReactions() const;
2390 
2391 
2392  /*@jsdoc
2393  * Gets the list of reactions names that can be enabled using {@link MyAvatar.beginReaction} and
2394  * {@link MyAvatar.endReaction}.
2395  * <p>See also: {@link MyAvatar.getTriggerReactions}.
2396  * @function MyAvatar.getBeginEndReactions
2397  * @returns {string[]} List of reaction names that can be enabled using {@link MyAvatar.beginReaction} and
2398  * {@link MyAvatar.endReaction}.
2399  * @example <caption>List the available begin-end reactions.</caption>
2400  * print("Begin-end reactions:", JSON.stringify(MyAvatar.getBeginEndReactions()));
2401  */
2402  QStringList getBeginEndReactions() const;
2403 
2404  /*@jsdoc
2405  * Plays a reaction on the avatar. Once the reaction is complete it will stop playing.
2406  * <p>Only reaction names returned by {@link MyAvatar.getTriggerReactions} are available.</p>
2407  * @function MyAvatar.triggerReaction
2408  * @param {string} reactionName - The reaction to trigger.
2409  * @returns {boolean} <code>true</code> if the reaction was played, <code>false</code> if the reaction is not supported.
2410  */
2411  bool triggerReaction(QString reactionName);
2412 
2413  /*@jsdoc
2414  * Starts playing a reaction on the avatar. The reaction will continue to play until stopped using
2415  * {@link MyAvatar.endReaction} or superseded by another reaction.
2416  * <p>Only reactions returned by {@link MyAvatar.getBeginEndReactions} are available.</p>
2417  * @function MyAvatar.beginReaction
2418  * @param {string} reactionName - The reaction to start playing.
2419  * @returns {boolean} <code>true</code> if the reaction was started, <code>false</code> if the reaction is not supported.
2420  */
2421  bool beginReaction(QString reactionName);
2422 
2423  /*@jsdoc
2424  * Stops playing a reaction that was started using {@link MyAvatar.beginReaction}.
2425  * @function MyAvatar.endReaction
2426  * @param {string} reactionName - The reaction to stop playing.
2427  * @returns {boolean} <code>true</code> if the reaction was stopped, <code>false</code> if the reaction is not supported.
2428  */
2429  bool endReaction(QString reactionName);
2430 
2431 signals:
2432 
2433  /*@jsdoc
2434  * Triggered when the {@link MyAvatar|audioListenerMode} property value changes.
2435  * @function MyAvatar.audioListenerModeChanged
2436  * @returns {Signal}
2437  */
2438  void audioListenerModeChanged();
2439 
2440  /*@jsdoc
2441  * Triggered when the walk speed set for the "AnalogPlus" control scheme changes.
2442  * @function MyAvatar.analogPlusWalkSpeedChanged
2443  * @param {number} speed - The new walk speed set for the "AnalogPlus" control scheme.
2444  * @returns {Signal}
2445  */
2446  void analogPlusWalkSpeedChanged(float value);
2447 
2448  /*@jsdoc
2449  * Triggered when the sprint (run) speed set for the "AnalogPlus" control scheme changes.
2450  * @function MyAvatar.analogPlusSprintSpeedChanged
2451  * @param {number} speed - The new sprint speed set for the "AnalogPlus" control scheme.
2452  * @returns {Signal}
2453  */
2454  void analogPlusSprintSpeedChanged(float value);
2455 
2456  /*@jsdoc
2457  * Triggered when the sprint (run) speed set for the current control scheme (see
2458  * {@link MyAvatar.getControlScheme|getControlScheme}) changes.
2459  * @function MyAvatar.sprintSpeedChanged
2460  * @param {number} speed -The new sprint speed set for the current control scheme.
2461  * @returns {Signal}
2462  */
2463  void sprintSpeedChanged(float value);
2464 
2465  /*@jsdoc
2466  * Triggered when the walk backward speed set for the current control scheme (see
2467  * {@link MyAvatar.getControlScheme|getControlScheme}) changes.
2468  * @function MyAvatar.walkBackwardSpeedChanged
2469  * @param {number} speed - The new walk backward speed set for the current control scheme.
2470  * @returns {Signal}
2471  */
2472  void walkBackwardSpeedChanged(float value);
2473 
2474  /*@jsdoc
2475  * @function MyAvatar.transformChanged
2476  * @returns {Signal}
2477  * @deprecated This signal is deprecated and will be removed.
2478  */
2479  void transformChanged();
2480 
2481  /*@jsdoc
2482  * Triggered when the {@link MyAvatar|collisionSoundURL} property value changes.
2483  * @function MyAvatar.newCollisionSoundURL
2484  * @param {string} url - The URL of the new collision sound.
2485  * @returns {Signal}
2486  */
2487  void newCollisionSoundURL(const QUrl& url);
2488 
2489  /*@jsdoc
2490  * Triggered when the avatar collides with an entity.
2491  * @function MyAvatar.collisionWithEntity
2492  * @param {Collision} collision - Details of the collision.
2493  * @returns {Signal}
2494  * @example <caption>Report each time your avatar collides with an entity.</caption>
2495  * MyAvatar.collisionWithEntity.connect(function (collision) {
2496  * print("Your avatar collided with an entity.");
2497  * });
2498  */
2499  void collisionWithEntity(const Collision& collision);
2500 
2501  /*@jsdoc
2502  * Triggered when collisions with the environment are enabled or disabled.
2503  * @function MyAvatar.collisionsEnabledChanged
2504  * @param {boolean} enabled - <code>true</code> if collisions with the environment are enabled, <code>false</code> if
2505  * they're not.
2506  * @returns {Signal}
2507  */
2508  void collisionsEnabledChanged(bool enabled);
2509 
2510  /*@jsdoc
2511  * Triggered when collisions with other avatars are enabled or disabled.
2512  * @function MyAvatar.otherAvatarsCollisionsEnabledChanged
2513  * @param {boolean} enabled - <code>true</code> if collisions with other avatars are enabled, <code>false</code> if they're
2514  * not.
2515  * @returns {Signal}
2516  */
2517  void otherAvatarsCollisionsEnabledChanged(bool enabled);
2518 
2519  /*@jsdoc
2520  * Triggered when the avatar's animation graph being used changes.
2521  * @function MyAvatar.animGraphUrlChanged
2522  * @param {string} url - The URL of the new animation graph JSON file.
2523  * @returns {Signal}
2524  * @example <caption>Report when the current avatar animation JSON being used changes.</caption>
2525  * MyAvatar.animGraphUrlChanged.connect(function (url) {
2526  * print("Avatar animation JSON changed to: " + url);
2527  * }); */
2528  void animGraphUrlChanged(const QUrl& url);
2529 
2530  /*@jsdoc
2531  * @function MyAvatar.energyChanged
2532  * @param {number} energy - Avatar energy.
2533  * @returns {Signal}
2534  * @deprecated This signal is deprecated and will be removed.
2535  */
2536  void energyChanged(float newEnergy);
2537 
2538  /*@jsdoc
2539  * Triggered when the avatar has been moved to a new position by one of the MyAvatar "goTo" functions.
2540  * @function MyAvatar.positionGoneTo
2541  * @returns {Signal}
2542  */
2543  // FIXME: Better name would be goneToLocation().
2544  void positionGoneTo();
2545 
2546  /*@jsdoc
2547  * Triggered when the avatar's model finishes loading.
2548  * @function MyAvatar.onLoadComplete
2549  * @returns {Signal}
2550  */
2551  void onLoadComplete();
2552 
2553  /*@jsdoc
2554  * Triggered when the avatar's model has failed to load.
2555  * @function MyAvatar.onLoadFailed
2556  * @returns {Signal}
2557  */
2558  void onLoadFailed();
2559 
2560  /*@jsdoc
2561  * Triggered when your avatar changes from being active to being away.
2562  * @function MyAvatar.wentAway
2563  * @returns {Signal}
2564  * @example <caption>Report when your avatar goes away.</caption>
2565  * MyAvatar.wentAway.connect(function () {
2566  * print("My avatar went away");
2567  * });
2568  * // In desktop mode, pres the Esc key to go away.
2569  */
2570  void wentAway();
2571 
2572  /*@jsdoc
2573  * Triggered when your avatar changes from being away to being active.
2574  * @function MyAvatar.wentActive
2575  * @returns {Signal}
2576  */
2577  void wentActive();
2578 
2579  /*@jsdoc
2580  * Triggered when the avatar's model (i.e., {@link MyAvatar|skeletonModelURL} property value) is changed.
2581  * <p>Synonym of {@link MyAvatar.skeletonModelURLChanged|skeletonModelURLChanged}.</p>
2582  * @function MyAvatar.skeletonChanged
2583  * @returns {Signal}
2584  */
2585  void skeletonChanged();
2586 
2587  /*@jsdoc
2588  * Triggered when the avatar's dominant hand changes.
2589  * @function MyAvatar.dominantHandChanged
2590  * @param {string} hand - The dominant hand: <code>"left"</code> for the left hand, <code>"right"</code> for the right hand.
2591  * @returns {Signal}
2592  */
2593  void dominantHandChanged(const QString& hand);
2594 
2595  /*@jsdoc
2596  * Triggered when the HMD alignment for your avatar changes.
2597  * @function MyAvatar.hmdAvatarAlignmentTypeChanged
2598  * @param {string} type - <code>"head"</code> if aligning your head and your avatar's head, <code>"eyes"</code> if aligning
2599  * your eyes and your avatar's eyes.
2600  * @returns {Signal}
2601  */
2602  void hmdAvatarAlignmentTypeChanged(const QString& type);
2603 
2604  /*@jsdoc
2605  * Triggered when the avatar's <code>sensorToWorldScale</code> property value changes.
2606  * @function MyAvatar.sensorToWorldScaleChanged
2607  * @param {number} scale - The scale that transforms dimensions in the user's real world to the avatar's size in the virtual
2608  * world.
2609  * @returns {Signal}
2610  */
2611  void sensorToWorldScaleChanged(float sensorToWorldScale);
2612 
2613  /*@jsdoc
2614  * Triggered when the a model is attached to or detached from one of the avatar's joints using one of
2615  * {@link MyAvatar.attach|attach}, {@link MyAvatar.detachOne|detachOne}, {@link MyAvatar.detachAll|detachAll}, or
2616  * {@link MyAvatar.setAttachmentData|setAttachmentData}.
2617  * @function MyAvatar.attachmentsChanged
2618  * @returns {Signal}
2619  * @deprecated This signal is deprecated and will be removed. Use avatar entities instead.
2620  */
2621  void attachmentsChanged();
2622 
2623  /*@jsdoc
2624  * Triggered when the avatar's size changes. This can be due to the user changing the size of their avatar or the domain
2625  * limiting the size of their avatar.
2626  * @function MyAvatar.scaleChanged
2627  * @returns {Signal}
2628  */
2629  void scaleChanged();
2630 
2631  /*@jsdoc
2632  * Triggered when the hand touch effect is enabled or disabled for the avatar.
2633  * <p>The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that
2634  * it is really touching that object.</p>
2635  * @function MyAvatar.shouldDisableHandTouchChanged
2636  * @param {boolean} disabled - <code>true</code> if the hand touch effect is disabled for the avatar,
2637  * <code>false</code> if it isn't disabled.
2638  * @returns {Signal}
2639  */
2640  void shouldDisableHandTouchChanged(bool shouldDisable);
2641 
2642  /*@jsdoc
2643  * Triggered when the hand touch is enabled or disabled on a specific entity.
2644  * <p>The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that
2645  * it is really touching that object.</p>
2646  * @function MyAvatar.disableHandTouchForIDChanged
2647  * @param {Uuid} entityID - The entity that the hand touch effect has been enabled or disabled for.
2648  * @param {boolean} disabled - <code>true</code> if the hand touch effect is disabled for the entity,
2649  * <code>false</code> if it isn't disabled.
2650  * @returns {Signal}
2651  */
2652  void disableHandTouchForIDChanged(const QUuid& entityID, bool disable);
2653 
2654 private slots:
2655  void leaveDomain();
2656  void updateCollisionCapsuleCache();
2657 
2658 protected:
2659  void handleChangedAvatarEntityData();
2660  void handleCanRezAvatarEntitiesChanged(bool canRezAvatarEntities);
2661  virtual void beParentOfChild(SpatiallyNestablePointer newChild) const override;
2662  virtual void forgetChild(SpatiallyNestablePointer newChild) const override;
2663  virtual void recalculateChildCauterization() const override;
2664 
2665 private:
2666  bool updateStaleAvatarEntityBlobs() const;
2667 
2668  bool requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& positionOut);
2669 
2670  virtual QByteArray toByteArrayStateful(AvatarDataDetail dataDetail, bool dropFaceTracking) override;
2671 
2672  void simulate(float deltaTime, bool inView) override;
2673  void saveAvatarUrl();
2674  virtual void render(RenderArgs* renderArgs) override;
2675  virtual bool shouldRenderHead(const RenderArgs* renderArgs) const override;
2676  void setShouldRenderLocally(bool shouldRender) { _shouldRender = shouldRender; setEnableMeshVisible(shouldRender); }
2677  bool getShouldRenderLocally() const { return _shouldRender; }
2678  void setRotationRecenterFilterLength(float length);
2679  float getRotationRecenterFilterLength() const { return _rotationRecenterFilterLength; }
2680  void setRotationThreshold(float angleRadians);
2681  float getRotationThreshold() const { return _rotationThreshold; }
2682  void setEnableStepResetRotation(bool stepReset) { _stepResetRotationEnabled = stepReset; }
2683  bool getEnableStepResetRotation() const { return _stepResetRotationEnabled; }
2684  void setEnableDrawAverageFacing(bool drawAverage) { _drawAverageFacingEnabled = drawAverage; }
2685  bool getEnableDrawAverageFacing() const { return _drawAverageFacingEnabled; }
2686  virtual bool isMyAvatar() const override { return true; }
2687  virtual bool isMyAvatarURLProtected() const override;
2688  virtual int parseDataFromBuffer(const QByteArray& buffer) override;
2689  virtual glm::vec3 getSkeletonPosition() const override;
2690  int _skeletonModelChangeCount { 0 };
2691  void sanitizeAvatarEntityProperties(EntityItemProperties& properties) const;
2692 
2693  void saveAvatarScale();
2694 
2695  glm::vec3 getScriptedMotorVelocity() const { return _scriptedMotorVelocity; }
2696  float getScriptedMotorTimescale() const { return _scriptedMotorTimescale; }
2697  QString getScriptedMotorFrame() const;
2698  QString getScriptedMotorMode() const;
2699  void setScriptedMotorVelocity(const glm::vec3& velocity);
2700  void setScriptedMotorTimescale(float timescale);
2701  void setScriptedMotorFrame(QString frame);
2702  void setScriptedMotorMode(QString mode);
2703 
2704  // Attachments
2705  virtual void attach(const QString& modelURL, const QString& jointName = QString(),
2706  const glm::vec3& translation = glm::vec3(), const glm::quat& rotation = glm::quat(),
2707  float scale = 1.0f, bool isSoft = false,
2708  bool allowDuplicates = false, bool useSaved = true) override;
2709 
2710  virtual void detachOne(const QString& modelURL, const QString& jointName = QString()) override;
2711  virtual void detachAll(const QString& modelURL, const QString& jointName = QString()) override;
2712 
2713  // Attachments/Avatar Entity
2714  void attachmentDataToEntityProperties(const AttachmentData& data, EntityItemProperties& properties);
2715  AttachmentData entityPropertiesToAttachmentData(const EntityItemProperties& properties) const;
2716  bool findAvatarEntity(const QString& modelURL, const QString& jointName, QUuid& entityID);
2717  void addAvatarEntitiesToTree();
2718 
2719  // FIXME: Rename to clearAvatarEntity() once the API call is removed.
2720  void clearAvatarEntityInternal(const QUuid& entityID) override;
2721 
2722  bool cameraInsideHead(const glm::vec3& cameraPosition) const;
2723 
2724  void updateEyeContactTarget(float deltaTime);
2725 
2726  // These are made private for MyAvatar so that you will use the "use" methods instead
2727  /*@jsdoc
2728  * @comment Borrows the base class's JSDoc.
2729  */
2730  Q_INVOKABLE virtual void setSkeletonModelURL(const QUrl& skeletonModelURL) override;
2731 
2732  virtual void updatePalms() override {}
2733  void lateUpdatePalms();
2734  void setSitDriveKeysStatus(bool enabled);
2735 
2736  void clampTargetScaleToDomainLimits();
2737  void clampScaleChangeToDomainLimits(float desiredScale);
2738  glm::mat4 computeCameraRelativeHandControllerMatrix(const glm::mat4& controllerSensorMatrix) const;
2739 
2740  std::array<float, MAX_DRIVE_KEYS> _driveKeys;
2741  std::bitset<MAX_DRIVE_KEYS> _disabledDriveKeys;
2742 
2743  bool _enableFlying { false };
2744  bool _flyingPrefDesktop { true };
2745  bool _flyingPrefHMD { true };
2746  bool _wasPushing { false };
2747  bool _isPushing { false };
2748  bool _isBeingPushed { false };
2749  bool _isBraking { false };
2750  bool _isAway { false };
2751 
2752  // Indicates which parts of the body are under direct control (tracked).
2753  struct {
2754  bool _feet { false }; // Left or right foot.
2755  bool _feetPreviousUpdate{ false };// Value of _feet on the previous update.
2756  bool _hips{ false };
2757  bool _leftHand{ false };
2758  bool _rightHand{ false };
2759  bool _head{ false };
2760  } _isBodyPartTracked;
2761 
2762  float _boomLength { ZOOM_DEFAULT };
2763  float _yawSpeed; // degrees/sec
2764  float _hmdYawSpeed; // degrees/sec
2765  float _pitchSpeed; // degrees/sec
2766  float _driveGear1 { DEFAULT_GEAR_1 };
2767  float _driveGear2 { DEFAULT_GEAR_2 };
2768  float _driveGear3 { DEFAULT_GEAR_3 };
2769  float _driveGear4 { DEFAULT_GEAR_4 };
2770  float _driveGear5 { DEFAULT_GEAR_5 };
2771  int _controlSchemeIndex { CONTROLS_ANALOG };
2772  int _movementReference{ 0 };
2773 
2774  glm::vec3 _thrust { 0.0f }; // impulse accumulator for outside sources
2775 
2776  glm::vec3 _actionMotorVelocity; // target local-frame velocity of avatar (default controller actions)
2777  glm::vec3 _scriptedMotorVelocity; // target local-frame velocity of avatar (analog script)
2778  float _scriptedMotorTimescale; // timescale for avatar to achieve its target velocity
2779  int _scriptedMotorFrame;
2780  int _scriptedMotorMode;
2781  quint32 _motionBehaviors;
2782  QString _collisionSoundURL;
2783 
2784  SharedSoundPointer _collisionSound;
2785 
2786  MyCharacterController _characterController;
2787  int32_t _previousCollisionMask { BULLET_COLLISION_MASK_MY_AVATAR };
2788 
2789  AvatarWeakPointer _lookAtTargetAvatar;
2790  glm::vec3 _targetAvatarPosition;
2791  bool _shouldRender { true };
2792  float _oculusYawOffset;
2793 
2794  eyeContactTarget _eyeContactTarget;
2795  float _eyeContactTargetTimer { 0.0f };
2796  ThreadSafeValueCache<glm::vec3> _eyesLookAtTarget { glm::vec3() };
2797  bool _scriptControlsEyesLookAt{ false };
2798  float _scriptEyesControlTimer{ 0.0f };
2799 
2800  glm::vec3 _trackedHeadPosition;
2801 
2802  const float MAX_LOOK_AT_TIME_SCRIPT_CONTROL = 2.0f;
2803  glm::quat _lookAtPitch;
2804  glm::quat _lookAtYaw;
2805  float _lookAtYawSpeed { 0.0f };
2806  glm::vec3 _lookAtCameraTarget;
2807  glm::vec3 _lookAtScriptTarget;
2808  bool _headLookAtActive { false };
2809  bool _shouldTurnToFaceCamera { false };
2810  bool _scriptControlsHeadLookAt { false };
2811  float _scriptHeadControlTimer { 0.0f };
2812  float _firstPersonSteadyHeadTimer { 0.0f };
2813  bool _pointAtActive { false };
2814  bool _isPointTargetValid { true };
2815 
2816  Setting::Handle<float> _realWorldFieldOfView;
2817  Setting::Handle<bool> _useAdvancedMovementControls;
2818  Setting::Handle<bool> _showPlayArea;
2819 
2820  // Smoothing.
2821  const float SMOOTH_TIME_ORIENTATION = 0.5f;
2822 
2823  // Smoothing data for blending from one position/orientation to another on remote agents.
2824  float _smoothOrientationTimer;
2825  glm::quat _smoothOrientationInitial;
2826  glm::quat _smoothOrientationTarget;
2827 
2828  // private methods
2829  void updateOrientation(float deltaTime);
2830  glm::vec3 calculateScaledDirection();
2831  float calculateGearedSpeed(const float driveKey);
2832  glm::vec3 scaleMotorSpeed(const glm::vec3 forward, const glm::vec3 right);
2833  void updateActionMotor(float deltaTime);
2834  void updatePosition(float deltaTime);
2835  void updateViewBoom();
2836  void updateCollisionSound(const glm::vec3& penetration, float deltaTime, float frequency);
2837  void initHeadBones();
2838  void initAnimGraph();
2839  void initFlowFromFST();
2840  void updateHeadLookAt(float deltaTime);
2841  void resetHeadLookAt();
2842  void resetLookAtRotation(const glm::vec3& avatarPosition, const glm::quat& avatarOrientation);
2843  void resetPointAt();
2844  static glm::vec3 aimToBlendValues(const glm::vec3& aimVector, const glm::quat& frameOrientation);
2845  void centerBodyInternal(const bool forceFollowYPos = false);
2846 
2847  // Avatar Preferences
2848  QUrl _fullAvatarURLFromPreferences;
2849  QString _fullAvatarModelName;
2850  ThreadSafeValueCache<QUrl> _currentAnimGraphUrl;
2851  ThreadSafeValueCache<QUrl> _prefOverrideAnimGraphUrl;
2852  QUrl _fstAnimGraphOverrideUrl;
2853  bool _useSnapTurn { true };
2854  bool _hoverWhenUnsupported{ false };
2855  ThreadSafeValueCache<QString> _dominantHand { DOMINANT_RIGHT_HAND };
2856  ThreadSafeValueCache<QString> _hmdAvatarAlignmentType { DEFAULT_HMD_AVATAR_ALIGNMENT_TYPE };
2857  ThreadSafeValueCache<bool> _strafeEnabled{ DEFAULT_STRAFE_ENABLED };
2858 
2859  const float ROLL_CONTROL_DEAD_ZONE_DEFAULT = 8.0f; // degrees
2860  const float ROLL_CONTROL_RATE_DEFAULT = 114.0f; // degrees / sec
2861 
2862  bool _hmdRollControlEnabled { true };
2863  float _hmdRollControlDeadZone { ROLL_CONTROL_DEAD_ZONE_DEFAULT };
2864  float _hmdRollControlRate { ROLL_CONTROL_RATE_DEFAULT };
2865  std::atomic<bool> _hasScriptedBlendShapes { false };
2866  std::atomic<float> _rotationRecenterFilterLength { 4.0f };
2867  std::atomic<float> _rotationThreshold { 0.5235f }; // 30 degrees in radians
2868  std::atomic<bool> _stepResetRotationEnabled { true };
2869  std::atomic<bool> _drawAverageFacingEnabled { false };
2870 
2871  // working copy -- see AvatarData for thread-safe _sensorToWorldMatrixCache, used for outward facing access
2872  glm::mat4 _sensorToWorldMatrix { glm::mat4() };
2873 
2874  // cache of the current HMD sensor position and orientation in sensor space.
2875  glm::mat4 _hmdSensorMatrix;
2876  glm::quat _hmdSensorOrientation;
2877  glm::vec3 _hmdSensorPosition;
2878  // cache head controller pose in sensor space
2879  glm::vec2 _headControllerFacing; // facing vector in xz plane (sensor space)
2880  glm::vec2 _headControllerFacingMovingAverage { 0.0f, 0.0f }; // facing vector in xz plane (sensor space)
2881  glm::quat _averageHeadRotation { 0.0f, 0.0f, 0.0f, 1.0f };
2882 
2883  glm::vec2 _hipToHandController { 0.0f, 1.0f }; // spine2 facing vector in xz plane (spine2 space)
2884 
2885  float _currentStandingHeight { 0.0f };
2886  bool _resetMode { true };
2887  RingBufferHistory<int> _recentModeReadings;
2888 
2889  // cache of the current body position and orientation of the avatar's body,
2890  // in sensor space.
2891  glm::mat4 _bodySensorMatrix;
2892 
2893  struct FollowHelper {
2894  FollowHelper();
2895 
2896  CharacterController::FollowTimePerType _timeRemaining;
2897 
2898  void deactivate();
2899  void deactivate(CharacterController::FollowType type);
2900  void activate(CharacterController::FollowType type, const bool snapFollow);
2901  bool isActive() const;
2902  bool isActive(CharacterController::FollowType followType) const;
2903  void decrementTimeRemaining(float dt);
2904  bool shouldActivateRotation(const MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix, bool& shouldSnapOut) const;
2905  bool shouldActivateVertical(const MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix) const;
2906  bool shouldActivateHorizontal(const MyAvatar& myAvatar,
2907  const glm::mat4& desiredBodyMatrix,
2908  const glm::mat4& currentBodyMatrix,
2909  bool& resetModeOut,
2910  bool& goToWalkingStateOut) const;
2911  void prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat4& bodySensorMatrix, const glm::mat4& currentBodyMatrix, bool hasDriveInput);
2912  glm::mat4 postPhysicsUpdate(MyAvatar& myAvatar, const glm::mat4& currentBodyMatrix);
2913  bool getForceActivateRotation() const;
2914  void setForceActivateRotation(bool val);
2915  bool getForceActivateVertical() const;
2916  void setForceActivateVertical(bool val);
2917  bool getForceActivateHorizontal() const;
2918  void setForceActivateHorizontal(bool val);
2919  std::atomic<bool> _forceActivateRotation { false };
2920  std::atomic<bool> _forceActivateVertical { false };
2921  std::atomic<bool> _forceActivateHorizontal { false };
2922  std::atomic<bool> _toggleHipsFollowing { true };
2923 
2924  private:
2925  bool shouldActivateHorizontal_userSitting(const MyAvatar& myAvatar,
2926  const glm::mat4& desiredBodyMatrix,
2927  const glm::mat4& currentBodyMatrix) const;
2928  bool shouldActivateHorizontal_userStanding(const MyAvatar& myAvatar,
2929  bool& resetModeOut,
2930  bool& goToWalkingStateOut) const;
2931  };
2932 
2933  FollowHelper _follow;
2934 
2935  bool isFollowActive(CharacterController::FollowType followType) const;
2936 
2937  bool _goToPending { false };
2938  bool _physicsSafetyPending { false };
2939  bool _goToSafe { true };
2940  bool _goToFeetAjustment { false };
2941  glm::vec3 _goToPosition;
2942  glm::quat _goToOrientation;
2943 
2944  std::unordered_set<int> _headBoneSet;
2945  std::unordered_set<SpatiallyNestablePointer> _cauterizedChildrenOfHead;
2946  bool _prevShouldDrawHead;
2947  bool _rigEnabled { true };
2948 
2949  bool _enableDebugDrawBaseOfSupport { false };
2950  bool _enableDebugDrawDefaultPose { false };
2951  bool _enableDebugDrawAnimPose { false };
2952  bool _enableDebugDrawHandControllers { false };
2953  bool _enableDebugDrawSensorToWorldMatrix { false };
2954  bool _enableDebugDrawIKTargets { false };
2955  bool _enableDebugDrawIKConstraints { false };
2956  bool _enableDebugDrawIKChains { false };
2957  bool _enableDebugDrawDetailedCollision { false };
2958 
2959  ThreadSafeValueCache<QString> _debugDrawAnimPoseName;
2960 
2961  mutable bool _cauterizationNeedsUpdate { false }; // do we need to scan children and update their "cauterized" state?
2962 
2963  AudioListenerMode _audioListenerMode;
2964  glm::vec3 _customListenPosition;
2965  glm::quat _customListenOrientation;
2966 
2967  AtRestDetector _leftHandAtRestDetector;
2968  AtRestDetector _rightHandAtRestDetector;
2969 
2970  // all poses are in sensor-frame
2971  std::map<controller::Action, controller::Pose> _controllerPoseMap;
2972  mutable std::mutex _controllerPoseMapMutex;
2973  mutable std::mutex _disableHandTouchMutex;
2974 
2975  bool _centerOfGravityModelEnabled { true };
2976  bool _hmdLeanRecenterEnabled { true };
2977  bool _hmdCrouchRecenterEnabled {
2978  true
2979  }; // Is MyAvatar allowed to recenter vertically (stand) when the user is sitting in the real world.
2980  bool _sprint { false };
2981 
2982  AnimPose _prePhysicsRoomPose;
2983  std::mutex _holdActionsMutex;
2984  std::vector<AvatarActionHold*> _holdActions;
2985 
2986  float AVATAR_MOVEMENT_ENERGY_CONSTANT { 0.001f };
2987  float AUDIO_ENERGY_CONSTANT { 0.000001f };
2988  float MAX_AVATAR_MOVEMENT_PER_FRAME { 30.0f };
2989  float currentEnergy { 0.0f };
2990  float energyChargeRate { 0.003f };
2991  glm::vec3 priorVelocity;
2992  glm::vec3 lastPosition;
2993  float getAudioEnergy();
2994  float getAccelerationEnergy();
2995  float getEnergy();
2996  void setEnergy(float value);
2997  bool didTeleport();
2998  bool getIsAway() const { return _isAway; }
2999  void setAway(bool value);
3000  void sendPacket(const QUuid& entityID) const override;
3001 
3002  std::mutex _pinnedJointsMutex;
3003  std::vector<int> _pinnedJoints;
3004 
3005  void updateChildCauterization(SpatiallyNestablePointer object, bool cauterize);
3006 
3007  // height of user in sensor space, when standing erect.
3008  ThreadSafeValueCache<float> _userHeight { DEFAULT_AVATAR_HEIGHT };
3009  float _averageUserHeightSensorSpace { _userHeight.get() };
3010  bool _sitStandStateChange { false };
3011 
3012  // max unscaled forward movement speed
3013  ThreadSafeValueCache<float> _defaultWalkSpeed { DEFAULT_AVATAR_MAX_WALKING_SPEED };
3014  ThreadSafeValueCache<float> _defaultWalkBackwardSpeed { DEFAULT_AVATAR_MAX_WALKING_BACKWARD_SPEED };
3015  ThreadSafeValueCache<float> _defaultSprintSpeed { DEFAULT_AVATAR_MAX_SPRINT_SPEED };
3016  ThreadSafeValueCache<float> _analogWalkSpeed { ANALOG_AVATAR_MAX_WALKING_SPEED };
3017  ThreadSafeValueCache<float> _analogWalkBackwardSpeed { ANALOG_AVATAR_MAX_WALKING_BACKWARD_SPEED };
3018  ThreadSafeValueCache<float> _analogSprintSpeed { ANALOG_AVATAR_MAX_SPRINT_SPEED };
3019  ThreadSafeValueCache<float> _analogPlusWalkSpeed { ANALOG_PLUS_AVATAR_MAX_WALKING_SPEED };
3020  ThreadSafeValueCache<float> _analogPlusWalkBackwardSpeed { ANALOG_PLUS_AVATAR_MAX_WALKING_BACKWARD_SPEED };
3021  ThreadSafeValueCache<float> _analogPlusSprintSpeed { ANALOG_PLUS_AVATAR_MAX_SPRINT_SPEED };
3022 
3023  float _walkSpeedScalar { AVATAR_WALK_SPEED_SCALAR };
3024  bool _isInWalkingState { false };
3025  ThreadSafeValueCache<bool> _isInSittingState { false };
3026  ThreadSafeValueCache<MyAvatar::AllowAvatarStandingPreference> _allowAvatarStandingPreference{
3027  MyAvatar::AllowAvatarStandingPreference::Default
3028  }; // The user preference of when MyAvatar may stand.
3029  ThreadSafeValueCache<MyAvatar::AllowAvatarLeaningPreference> _allowAvatarLeaningPreference{
3030  MyAvatar::AllowAvatarLeaningPreference::Default
3031  }; // The user preference of when MyAvatar may lean.
3032  float _sitStandStateTimer { 0.0f };
3033  float _tippingPoint { _userHeight.get() };
3034 
3035  // load avatar scripts once when rig is ready
3036  bool _shouldLoadScripts { false };
3037 
3038  bool _haveReceivedHeightLimitsFromDomain { false };
3039  int _disableHandTouchCount { 0 };
3040  bool _reloadAvatarEntityDataFromSettings { true };
3041 
3042  TimePoint _nextTraitsSendWindow;
3043 
3044  Setting::Handle<QString> _dominantHandSetting;
3045  Setting::Handle<bool> _strafeEnabledSetting;
3046  Setting::Handle<QString> _hmdAvatarAlignmentTypeSetting;
3047  Setting::Handle<float> _headPitchSetting;
3048  Setting::Handle<float> _scaleSetting;
3049  Setting::Handle<float> _yawSpeedSetting;
3050  Setting::Handle<float> _hmdYawSpeedSetting;
3051  Setting::Handle<float> _pitchSpeedSetting;
3052  Setting::Handle<QUrl> _fullAvatarURLSetting;
3053  Setting::Handle<QUrl> _fullAvatarModelNameSetting;
3054  Setting::Handle<QUrl> _animGraphURLSetting;
3055  Setting::Handle<QString> _displayNameSetting;
3056  Setting::Handle<QUrl> _collisionSoundURLSetting;
3057  Setting::Handle<bool> _useSnapTurnSetting;
3058  Setting::Handle<bool> _hoverWhenUnsupportedSetting;
3059  Setting::Handle<float> _userHeightSetting;
3060  Setting::Handle<bool> _flyingHMDSetting;
3061  Setting::Handle<int> _movementReferenceSetting;
3062  Setting::Handle<int> _avatarEntityCountSetting;
3063  Setting::Handle<bool> _allowTeleportingSetting { "allowTeleporting", true };
3064  Setting::Handle<float> _driveGear1Setting;
3065  Setting::Handle<float> _driveGear2Setting;
3066  Setting::Handle<float> _driveGear3Setting;
3067  Setting::Handle<float> _driveGear4Setting;
3068  Setting::Handle<float> _driveGear5Setting;
3069  Setting::Handle<float> _analogWalkSpeedSetting;
3070  Setting::Handle<float> _analogPlusWalkSpeedSetting;
3071  Setting::Handle<int> _controlSchemeIndexSetting;
3072  std::vector<Setting::Handle<QUuid>> _avatarEntityIDSettings;
3073  std::vector<Setting::Handle<QByteArray>> _avatarEntityDataSettings;
3074  Setting::Handle<QString> _allowAvatarStandingPreferenceSetting;
3075  Setting::Handle<QString> _allowAvatarLeaningPreferenceSetting;
3076 
3077  // AvatarEntities stuff:
3078  // We cache the "map of unfortunately-formatted-binary-blobs" because they are expensive to compute
3079  // Do not confuse these with AvatarData::_packedAvatarEntityData which are in wire-format.
3080  mutable AvatarEntityMap _cachedAvatarEntityBlobs;
3081 
3082  // We collect changes to AvatarEntities and then handle them all in one spot per frame: updateAvatarEntities().
3083  // Basically this is a "transaction pattern" with an extra complication: these changes can come from two
3084  // "directions" and the "authoritative source" of each direction is different, so maintain two distinct sets of
3085  // transaction lists;
3086  //
3087  // The _entitiesToDelete/Add/Update lists are for changes whose "authoritative sources" are already
3088  // correctly stored in _cachedAvatarEntityBlobs. These come from loadAvatarEntityDataFromSettings() and
3089  // setAvatarEntityData(). These changes need to be extracted from _cachedAvatarEntityBlobs and applied to
3090  // real EntityItems.
3091  std::vector<EntityItemID> _entitiesToDelete;
3092  std::vector<EntityItemID> _entitiesToAdd;
3093  std::vector<EntityItemID> _entitiesToUpdate;
3094  //
3095  // The _cachedAvatarEntityBlobsToDelete/Add/Update lists are for changes whose "authoritative sources" are
3096  // already reflected in real EntityItems. These changes need to be propagated to _cachedAvatarEntityBlobs
3097  // and eventually to settings.
3098  std::vector<EntityItemID> _cachedAvatarEntityBlobsToDelete;
3099  std::vector<EntityItemID> _cachedAvatarEntityBlobsToAddOrUpdate;
3100  std::vector<EntityItemID> _cachedAvatarEntityBlobUpdatesToSkip;
3101  //
3102  // Also these lists for tracking delayed changes to blobs and Settings
3103  mutable std::set<EntityItemID> _staleCachedAvatarEntityBlobs;
3104  //
3105  // keep a ScriptEngine around so we don't have to instantiate on the fly (these are very slow to create/delete)
3106  // TODO: profile if it performs better when script engine is on avatar thread or on its own thread
3107  // Own thread is safer from deadlocks
3108  mutable HelperScriptEngine _helperScriptEngine;
3109 
3110  bool _needToSaveAvatarEntitySettings { false };
3111 
3112  bool _reactionTriggers[NUM_AVATAR_TRIGGER_REACTIONS] { false, false };
3113  int _reactionEnabledRefCounts[NUM_AVATAR_BEGIN_END_REACTIONS] { 0, 0, 0 };
3114 
3115  mutable std::mutex _reactionLock;
3116 
3117  // used to prevent character from jumping after endSit is called.
3118  bool _endSitKeyPressComplete { false };
3119 
3120  glm::vec3 _cameraEyesOffset;
3121  float _landingAfterJumpTime { 0.0f };
3122 
3123  QTimer _addAvatarEntitiesToTreeTimer;
3124 };
3125 
3126 Q_DECLARE_METATYPE(MyAvatar::DriveKeys)
3127 
3128 ScriptValue audioListenModeToScriptValue(ScriptEngine* engine, const AudioListenerMode& audioListenerMode);
3129 bool audioListenModeFromScriptValue(const ScriptValue& object, AudioListenerMode& audioListenerMode);
3130 
3131 ScriptValue driveKeysToScriptValue(ScriptEngine* engine, const MyAvatar::DriveKeys& driveKeys);
3132 bool driveKeysFromScriptValue(const ScriptValue& object, MyAvatar::DriveKeys& driveKeys);
3133 
3134 bool isWearableEntity(const EntityItemPointer& entity);
3135 
3136 #endif // hifi_MyAvatar_h
Abstract ID for editing model items. Used in EntityItem JS API.
Definition: EntityItemID.h:28
Definition: EntityItemProperties.h:106
Provides a wrapper around script engine that does not have ScriptManager.
Definition: HelperScriptEngine.h:31
Provides an engine-independent interface for a scripting engine.
Definition: ScriptEngine.h:93
[ScriptInterface] Provides an engine-independent interface for QScriptValue
Definition: ScriptValue.h:40