mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:17:45 +02:00
Merge pull request #8010 from hyperlogic/feature/hmd-lean-recenter-property
Added MyAvatar.hmdLeanRecenterEnabled property
This commit is contained in:
commit
3c5af56421
13 changed files with 47 additions and 133 deletions
|
@ -84,7 +84,6 @@ Avatar::Avatar(RigPointer rig) :
|
||||||
_acceleration(0.0f),
|
_acceleration(0.0f),
|
||||||
_lastAngularVelocity(0.0f),
|
_lastAngularVelocity(0.0f),
|
||||||
_lastOrientation(),
|
_lastOrientation(),
|
||||||
_leanScale(0.5f),
|
|
||||||
_worldUpDirection(DEFAULT_UP_DIRECTION),
|
_worldUpDirection(DEFAULT_UP_DIRECTION),
|
||||||
_moving(false),
|
_moving(false),
|
||||||
_initialized(false),
|
_initialized(false),
|
||||||
|
|
|
@ -210,7 +210,6 @@ protected:
|
||||||
glm::vec3 _angularAcceleration;
|
glm::vec3 _angularAcceleration;
|
||||||
glm::quat _lastOrientation;
|
glm::quat _lastOrientation;
|
||||||
|
|
||||||
float _leanScale;
|
|
||||||
glm::vec3 _worldUpDirection;
|
glm::vec3 _worldUpDirection;
|
||||||
float _stringLength;
|
float _stringLength;
|
||||||
bool _moving; ///< set when position is changing
|
bool _moving; ///< set when position is changing
|
||||||
|
|
|
@ -54,8 +54,6 @@ Head::Head(Avatar* owningAvatar) :
|
||||||
_deltaPitch(0.0f),
|
_deltaPitch(0.0f),
|
||||||
_deltaYaw(0.0f),
|
_deltaYaw(0.0f),
|
||||||
_deltaRoll(0.0f),
|
_deltaRoll(0.0f),
|
||||||
_deltaLeanSideways(0.0f),
|
|
||||||
_deltaLeanForward(0.0f),
|
|
||||||
_isCameraMoving(false),
|
_isCameraMoving(false),
|
||||||
_isLookingAtMe(false),
|
_isLookingAtMe(false),
|
||||||
_lookingAtMeStarted(0),
|
_lookingAtMeStarted(0),
|
||||||
|
@ -70,7 +68,6 @@ void Head::init() {
|
||||||
|
|
||||||
void Head::reset() {
|
void Head::reset() {
|
||||||
_baseYaw = _basePitch = _baseRoll = 0.0f;
|
_baseYaw = _basePitch = _baseRoll = 0.0f;
|
||||||
_leanForward = _leanSideways = 0.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
||||||
|
@ -118,13 +115,6 @@ void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
||||||
auto eyeTracker = DependencyManager::get<EyeTracker>();
|
auto eyeTracker = DependencyManager::get<EyeTracker>();
|
||||||
_isEyeTrackerConnected = eyeTracker->isTracking();
|
_isEyeTrackerConnected = eyeTracker->isTracking();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Twist the upper body to follow the rotation of the head, but only do this with my avatar,
|
|
||||||
// since everyone else will see the full joint rotations for other people.
|
|
||||||
const float BODY_FOLLOW_HEAD_YAW_RATE = 0.1f;
|
|
||||||
const float BODY_FOLLOW_HEAD_FACTOR = 0.66f;
|
|
||||||
float currentTwist = getTorsoTwist();
|
|
||||||
setTorsoTwist(currentTwist + (getFinalYaw() * BODY_FOLLOW_HEAD_FACTOR - currentTwist) * BODY_FOLLOW_HEAD_YAW_RATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(_isFaceTrackerConnected || billboard)) {
|
if (!(_isFaceTrackerConnected || billboard)) {
|
||||||
|
@ -301,17 +291,13 @@ void Head::applyEyelidOffset(glm::quat headOrientation) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Head::relaxLean(float deltaTime) {
|
void Head::relax(float deltaTime) {
|
||||||
// restore rotation, lean to neutral positions
|
// restore rotation, lean to neutral positions
|
||||||
const float LEAN_RELAXATION_PERIOD = 0.25f; // seconds
|
const float LEAN_RELAXATION_PERIOD = 0.25f; // seconds
|
||||||
float relaxationFactor = 1.0f - glm::min(deltaTime / LEAN_RELAXATION_PERIOD, 1.0f);
|
float relaxationFactor = 1.0f - glm::min(deltaTime / LEAN_RELAXATION_PERIOD, 1.0f);
|
||||||
_deltaYaw *= relaxationFactor;
|
_deltaYaw *= relaxationFactor;
|
||||||
_deltaPitch *= relaxationFactor;
|
_deltaPitch *= relaxationFactor;
|
||||||
_deltaRoll *= relaxationFactor;
|
_deltaRoll *= relaxationFactor;
|
||||||
_leanSideways *= relaxationFactor;
|
|
||||||
_leanForward *= relaxationFactor;
|
|
||||||
_deltaLeanSideways *= relaxationFactor;
|
|
||||||
_deltaLeanForward *= relaxationFactor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Head::setScale (float scale) {
|
void Head::setScale (float scale) {
|
||||||
|
@ -419,8 +405,3 @@ float Head::getFinalPitch() const {
|
||||||
float Head::getFinalRoll() const {
|
float Head::getFinalRoll() const {
|
||||||
return glm::clamp(_baseRoll + _deltaRoll, MIN_HEAD_ROLL, MAX_HEAD_ROLL);
|
return glm::clamp(_baseRoll + _deltaRoll, MIN_HEAD_ROLL, MAX_HEAD_ROLL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Head::addLeanDeltas(float sideways, float forward) {
|
|
||||||
_deltaLeanSideways += sideways;
|
|
||||||
_deltaLeanForward += forward;
|
|
||||||
}
|
|
||||||
|
|
|
@ -59,8 +59,6 @@ public:
|
||||||
glm::vec3 getRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }
|
glm::vec3 getRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }
|
||||||
glm::vec3 getUpDirection() const { return getOrientation() * IDENTITY_UP; }
|
glm::vec3 getUpDirection() const { return getOrientation() * IDENTITY_UP; }
|
||||||
glm::vec3 getFrontDirection() const { return getOrientation() * IDENTITY_FRONT; }
|
glm::vec3 getFrontDirection() const { return getOrientation() * IDENTITY_FRONT; }
|
||||||
float getFinalLeanSideways() const { return _leanSideways + _deltaLeanSideways; }
|
|
||||||
float getFinalLeanForward() const { return _leanForward + _deltaLeanForward; }
|
|
||||||
|
|
||||||
glm::quat getEyeRotation(const glm::vec3& eyePosition) const;
|
glm::quat getEyeRotation(const glm::vec3& eyePosition) const;
|
||||||
|
|
||||||
|
@ -91,8 +89,7 @@ public:
|
||||||
virtual float getFinalYaw() const;
|
virtual float getFinalYaw() const;
|
||||||
virtual float getFinalRoll() const;
|
virtual float getFinalRoll() const;
|
||||||
|
|
||||||
void relaxLean(float deltaTime);
|
void relax(float deltaTime);
|
||||||
void addLeanDeltas(float sideways, float forward);
|
|
||||||
|
|
||||||
float getTimeWithoutTalking() const { return _timeWithoutTalking; }
|
float getTimeWithoutTalking() const { return _timeWithoutTalking; }
|
||||||
|
|
||||||
|
@ -132,10 +129,6 @@ private:
|
||||||
float _deltaYaw;
|
float _deltaYaw;
|
||||||
float _deltaRoll;
|
float _deltaRoll;
|
||||||
|
|
||||||
// delta lean angles for lean perturbations (driven by collisions)
|
|
||||||
float _deltaLeanSideways;
|
|
||||||
float _deltaLeanForward;
|
|
||||||
|
|
||||||
bool _isCameraMoving;
|
bool _isCameraMoving;
|
||||||
bool _isLookingAtMe;
|
bool _isLookingAtMe;
|
||||||
quint64 _lookingAtMeStarted;
|
quint64 _lookingAtMeStarted;
|
||||||
|
|
|
@ -190,9 +190,6 @@ MyAvatar::MyAvatar(RigPointer rig) :
|
||||||
if (!headData->getBlendshapeCoefficients().isEmpty()) {
|
if (!headData->getBlendshapeCoefficients().isEmpty()) {
|
||||||
_headData->setBlendshapeCoefficients(headData->getBlendshapeCoefficients());
|
_headData->setBlendshapeCoefficients(headData->getBlendshapeCoefficients());
|
||||||
}
|
}
|
||||||
// head lean
|
|
||||||
_headData->setLeanForward(headData->getLeanForward());
|
|
||||||
_headData->setLeanSideways(headData->getLeanSideways());
|
|
||||||
// head orientation
|
// head orientation
|
||||||
_headData->setLookAtPosition(headData->getLookAtPosition());
|
_headData->setLookAtPosition(headData->getLookAtPosition());
|
||||||
}
|
}
|
||||||
|
@ -237,7 +234,7 @@ QByteArray MyAvatar::toByteArray(bool cullSmallChanges, bool sendAll) {
|
||||||
void MyAvatar::reset(bool andRecenter, bool andReload, bool andHead) {
|
void MyAvatar::reset(bool andRecenter, bool andReload, bool andHead) {
|
||||||
|
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "reset", Q_ARG(bool, andRecenter));
|
QMetaObject::invokeMethod(this, "reset", Q_ARG(bool, andRecenter), Q_ARG(bool, andReload), Q_ARG(bool, andHead));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +303,7 @@ void MyAvatar::update(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Head* head = getHead();
|
Head* head = getHead();
|
||||||
head->relaxLean(deltaTime);
|
head->relax(deltaTime);
|
||||||
updateFromTrackers(deltaTime);
|
updateFromTrackers(deltaTime);
|
||||||
|
|
||||||
// Get audio loudness data from audio input device
|
// Get audio loudness data from audio input device
|
||||||
|
@ -574,16 +571,6 @@ void MyAvatar::updateFromTrackers(float deltaTime) {
|
||||||
head->setDeltaYaw(estimatedRotation.y * magnifyFieldOfView);
|
head->setDeltaYaw(estimatedRotation.y * magnifyFieldOfView);
|
||||||
head->setDeltaRoll(estimatedRotation.z);
|
head->setDeltaRoll(estimatedRotation.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update torso lean distance based on accelerometer data
|
|
||||||
const float TORSO_LENGTH = 0.5f;
|
|
||||||
glm::vec3 relativePosition = estimatedPosition - glm::vec3(0.0f, -TORSO_LENGTH, 0.0f);
|
|
||||||
|
|
||||||
const float MAX_LEAN = 45.0f;
|
|
||||||
head->setLeanSideways(glm::clamp(glm::degrees(atanf(relativePosition.x * _leanScale / TORSO_LENGTH)),
|
|
||||||
-MAX_LEAN, MAX_LEAN));
|
|
||||||
head->setLeanForward(glm::clamp(glm::degrees(atanf(relativePosition.z * _leanScale / TORSO_LENGTH)),
|
|
||||||
-MAX_LEAN, MAX_LEAN));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 MyAvatar::getLeftHandPosition() const {
|
glm::vec3 MyAvatar::getLeftHandPosition() const {
|
||||||
|
@ -692,7 +679,6 @@ void MyAvatar::saveData() {
|
||||||
|
|
||||||
settings.setValue("headPitch", getHead()->getBasePitch());
|
settings.setValue("headPitch", getHead()->getBasePitch());
|
||||||
|
|
||||||
settings.setValue("leanScale", _leanScale);
|
|
||||||
settings.setValue("scale", _targetScale);
|
settings.setValue("scale", _targetScale);
|
||||||
|
|
||||||
settings.setValue("fullAvatarURL",
|
settings.setValue("fullAvatarURL",
|
||||||
|
@ -809,7 +795,6 @@ void MyAvatar::loadData() {
|
||||||
|
|
||||||
getHead()->setBasePitch(loadSetting(settings, "headPitch", 0.0f));
|
getHead()->setBasePitch(loadSetting(settings, "headPitch", 0.0f));
|
||||||
|
|
||||||
_leanScale = loadSetting(settings, "leanScale", 0.05f);
|
|
||||||
_targetScale = loadSetting(settings, "scale", 1.0f);
|
_targetScale = loadSetting(settings, "scale", 1.0f);
|
||||||
setScale(glm::vec3(_targetScale));
|
setScale(glm::vec3(_targetScale));
|
||||||
|
|
||||||
|
@ -1271,13 +1256,13 @@ void MyAvatar::prepareForPhysicsSimulation() {
|
||||||
void MyAvatar::harvestResultsFromPhysicsSimulation(float deltaTime) {
|
void MyAvatar::harvestResultsFromPhysicsSimulation(float deltaTime) {
|
||||||
glm::vec3 position = getPosition();
|
glm::vec3 position = getPosition();
|
||||||
glm::quat orientation = getOrientation();
|
glm::quat orientation = getOrientation();
|
||||||
if (_characterController.isEnabled()) {
|
if (_characterController.isEnabledAndReady()) {
|
||||||
_characterController.getPositionAndOrientation(position, orientation);
|
_characterController.getPositionAndOrientation(position, orientation);
|
||||||
}
|
}
|
||||||
nextAttitude(position, orientation);
|
nextAttitude(position, orientation);
|
||||||
_bodySensorMatrix = _follow.postPhysicsUpdate(*this, _bodySensorMatrix);
|
_bodySensorMatrix = _follow.postPhysicsUpdate(*this, _bodySensorMatrix);
|
||||||
|
|
||||||
if (_characterController.isEnabled()) {
|
if (_characterController.isEnabledAndReady()) {
|
||||||
setVelocity(_characterController.getLinearVelocity() + _characterController.getFollowVelocity());
|
setVelocity(_characterController.getLinearVelocity() + _characterController.getFollowVelocity());
|
||||||
} else {
|
} else {
|
||||||
setVelocity(getVelocity() + _characterController.getFollowVelocity());
|
setVelocity(getVelocity() + _characterController.getFollowVelocity());
|
||||||
|
@ -1660,7 +1645,7 @@ void MyAvatar::updatePosition(float deltaTime) {
|
||||||
|
|
||||||
vec3 velocity = getVelocity();
|
vec3 velocity = getVelocity();
|
||||||
const float MOVING_SPEED_THRESHOLD_SQUARED = 0.0001f; // 0.01 m/s
|
const float MOVING_SPEED_THRESHOLD_SQUARED = 0.0001f; // 0.01 m/s
|
||||||
if (!_characterController.isEnabled()) {
|
if (!_characterController.isEnabledAndReady()) {
|
||||||
// _characterController is not in physics simulation but it can still compute its target velocity
|
// _characterController is not in physics simulation but it can still compute its target velocity
|
||||||
updateMotors();
|
updateMotors();
|
||||||
_characterController.computeNewVelocity(deltaTime, velocity);
|
_characterController.computeNewVelocity(deltaTime, velocity);
|
||||||
|
@ -1834,6 +1819,16 @@ void MyAvatar::updateMotionBehaviorFromMenu() {
|
||||||
_motionBehaviors &= ~AVATAR_MOTION_SCRIPTED_MOTOR_ENABLED;
|
_motionBehaviors &= ~AVATAR_MOTION_SCRIPTED_MOTOR_ENABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setCharacterControllerEnabled(menu->isOptionChecked(MenuOption::EnableCharacterController));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyAvatar::setCharacterControllerEnabled(bool enabled) {
|
||||||
|
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
QMetaObject::invokeMethod(this, "setCharacterControllerEnabled", Q_ARG(bool, enabled));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bool ghostingAllowed = true;
|
bool ghostingAllowed = true;
|
||||||
EntityTreeRenderer* entityTreeRenderer = qApp->getEntities();
|
EntityTreeRenderer* entityTreeRenderer = qApp->getEntities();
|
||||||
if (entityTreeRenderer) {
|
if (entityTreeRenderer) {
|
||||||
|
@ -1842,12 +1837,11 @@ void MyAvatar::updateMotionBehaviorFromMenu() {
|
||||||
ghostingAllowed = zone->getGhostingAllowed();
|
ghostingAllowed = zone->getGhostingAllowed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool checked = menu->isOptionChecked(MenuOption::EnableCharacterController);
|
_characterController.setEnabled(ghostingAllowed ? enabled : true);
|
||||||
if (!ghostingAllowed) {
|
}
|
||||||
checked = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
_characterController.setEnabled(checked);
|
bool MyAvatar::getCharacterControllerEnabled() {
|
||||||
|
return _characterController.isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::clearDriveKeys() {
|
void MyAvatar::clearDriveKeys() {
|
||||||
|
@ -2055,14 +2049,17 @@ bool MyAvatar::FollowHelper::shouldActivateVertical(const MyAvatar& myAvatar, co
|
||||||
|
|
||||||
void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix, bool hasDriveInput) {
|
void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix, bool hasDriveInput) {
|
||||||
_desiredBodyMatrix = desiredBodyMatrix;
|
_desiredBodyMatrix = desiredBodyMatrix;
|
||||||
if (!isActive(Rotation) && shouldActivateRotation(myAvatar, desiredBodyMatrix, currentBodyMatrix)) {
|
|
||||||
activate(Rotation);
|
if (myAvatar.getHMDLeanRecenterEnabled()) {
|
||||||
}
|
if (!isActive(Rotation) && shouldActivateRotation(myAvatar, desiredBodyMatrix, currentBodyMatrix)) {
|
||||||
if (!isActive(Horizontal) && shouldActivateHorizontal(myAvatar, desiredBodyMatrix, currentBodyMatrix)) {
|
activate(Rotation);
|
||||||
activate(Horizontal);
|
}
|
||||||
}
|
if (!isActive(Horizontal) && shouldActivateHorizontal(myAvatar, desiredBodyMatrix, currentBodyMatrix)) {
|
||||||
if (!isActive(Vertical) && (shouldActivateVertical(myAvatar, desiredBodyMatrix, currentBodyMatrix) || hasDriveInput)) {
|
activate(Horizontal);
|
||||||
activate(Vertical);
|
}
|
||||||
|
if (!isActive(Vertical) && (shouldActivateVertical(myAvatar, desiredBodyMatrix, currentBodyMatrix) || hasDriveInput)) {
|
||||||
|
activate(Vertical);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 desiredWorldMatrix = myAvatar.getSensorToWorldMatrix() * _desiredBodyMatrix;
|
glm::mat4 desiredWorldMatrix = myAvatar.getSensorToWorldMatrix() * _desiredBodyMatrix;
|
||||||
|
|
|
@ -69,7 +69,6 @@ class MyAvatar : public Avatar {
|
||||||
Q_PROPERTY(AudioListenerMode audioListenerModeCustom READ getAudioListenerModeCustom)
|
Q_PROPERTY(AudioListenerMode audioListenerModeCustom READ getAudioListenerModeCustom)
|
||||||
//TODO: make gravity feature work Q_PROPERTY(glm::vec3 gravity READ getGravity WRITE setGravity)
|
//TODO: make gravity feature work Q_PROPERTY(glm::vec3 gravity READ getGravity WRITE setGravity)
|
||||||
|
|
||||||
|
|
||||||
Q_PROPERTY(glm::vec3 leftHandPosition READ getLeftHandPosition)
|
Q_PROPERTY(glm::vec3 leftHandPosition READ getLeftHandPosition)
|
||||||
Q_PROPERTY(glm::vec3 rightHandPosition READ getRightHandPosition)
|
Q_PROPERTY(glm::vec3 rightHandPosition READ getRightHandPosition)
|
||||||
Q_PROPERTY(glm::vec3 leftHandTipPosition READ getLeftHandTipPosition)
|
Q_PROPERTY(glm::vec3 leftHandTipPosition READ getLeftHandTipPosition)
|
||||||
|
@ -84,6 +83,9 @@ class MyAvatar : public Avatar {
|
||||||
|
|
||||||
Q_PROPERTY(float energy READ getEnergy WRITE setEnergy)
|
Q_PROPERTY(float energy READ getEnergy WRITE setEnergy)
|
||||||
|
|
||||||
|
Q_PROPERTY(bool hmdLeanRecenterEnabled READ getHMDLeanRecenterEnabled WRITE setHMDLeanRecenterEnabled)
|
||||||
|
Q_PROPERTY(bool characterControllerEnabled READ getCharacterControllerEnabled WRITE setCharacterControllerEnabled)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MyAvatar(RigPointer rig);
|
explicit MyAvatar(RigPointer rig);
|
||||||
~MyAvatar();
|
~MyAvatar();
|
||||||
|
@ -123,9 +125,6 @@ public:
|
||||||
|
|
||||||
void setRealWorldFieldOfView(float realWorldFov) { _realWorldFieldOfView.set(realWorldFov); }
|
void setRealWorldFieldOfView(float realWorldFov) { _realWorldFieldOfView.set(realWorldFov); }
|
||||||
|
|
||||||
void setLeanScale(float scale) { _leanScale = scale; }
|
|
||||||
float getLeanScale() const { return _leanScale; }
|
|
||||||
|
|
||||||
Q_INVOKABLE glm::vec3 getDefaultEyePosition() const;
|
Q_INVOKABLE glm::vec3 getDefaultEyePosition() const;
|
||||||
|
|
||||||
float getRealWorldFieldOfView() { return _realWorldFieldOfView.get(); }
|
float getRealWorldFieldOfView() { return _realWorldFieldOfView.get(); }
|
||||||
|
@ -163,6 +162,9 @@ public:
|
||||||
Q_INVOKABLE bool getClearOverlayWhenDriving() const { return _clearOverlayWhenDriving; }
|
Q_INVOKABLE bool getClearOverlayWhenDriving() const { return _clearOverlayWhenDriving; }
|
||||||
Q_INVOKABLE void setClearOverlayWhenDriving(bool on) { _clearOverlayWhenDriving = on; }
|
Q_INVOKABLE void setClearOverlayWhenDriving(bool on) { _clearOverlayWhenDriving = on; }
|
||||||
|
|
||||||
|
Q_INVOKABLE void setHMDLeanRecenterEnabled(bool value) { _hmdLeanRecenterEnabled = value; }
|
||||||
|
Q_INVOKABLE bool getHMDLeanRecenterEnabled() const { return _hmdLeanRecenterEnabled; }
|
||||||
|
|
||||||
// get/set avatar data
|
// get/set avatar data
|
||||||
void saveData();
|
void saveData();
|
||||||
void loadData();
|
void loadData();
|
||||||
|
@ -264,6 +266,9 @@ public:
|
||||||
controller::Pose getLeftHandControllerPoseInAvatarFrame() const;
|
controller::Pose getLeftHandControllerPoseInAvatarFrame() const;
|
||||||
controller::Pose getRightHandControllerPoseInAvatarFrame() const;
|
controller::Pose getRightHandControllerPoseInAvatarFrame() const;
|
||||||
|
|
||||||
|
Q_INVOKABLE void setCharacterControllerEnabled(bool enabled);
|
||||||
|
Q_INVOKABLE bool getCharacterControllerEnabled();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void increaseSize();
|
void increaseSize();
|
||||||
void decreaseSize();
|
void decreaseSize();
|
||||||
|
@ -470,6 +475,8 @@ private:
|
||||||
ThreadSafeValueCache<controller::Pose> _leftHandControllerPoseInSensorFrameCache { controller::Pose() };
|
ThreadSafeValueCache<controller::Pose> _leftHandControllerPoseInSensorFrameCache { controller::Pose() };
|
||||||
ThreadSafeValueCache<controller::Pose> _rightHandControllerPoseInSensorFrameCache { controller::Pose() };
|
ThreadSafeValueCache<controller::Pose> _rightHandControllerPoseInSensorFrameCache { controller::Pose() };
|
||||||
|
|
||||||
|
bool _hmdLeanRecenterEnabled = true;
|
||||||
|
|
||||||
float AVATAR_MOVEMENT_ENERGY_CONSTANT { 0.001f };
|
float AVATAR_MOVEMENT_ENERGY_CONSTANT { 0.001f };
|
||||||
float AUDIO_ENERGY_CONSTANT { 0.000001f };
|
float AUDIO_ENERGY_CONSTANT { 0.000001f };
|
||||||
float MAX_AVATAR_MOVEMENT_PER_FRAME { 30.0f };
|
float MAX_AVATAR_MOVEMENT_PER_FRAME { 30.0f };
|
||||||
|
|
|
@ -106,10 +106,6 @@ void SkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
||||||
MyAvatar* myAvatar = static_cast<MyAvatar*>(_owningAvatar);
|
MyAvatar* myAvatar = static_cast<MyAvatar*>(_owningAvatar);
|
||||||
|
|
||||||
Rig::HeadParameters headParams;
|
Rig::HeadParameters headParams;
|
||||||
headParams.enableLean = qApp->isHMDMode();
|
|
||||||
headParams.leanSideways = head->getFinalLeanSideways();
|
|
||||||
headParams.leanForward = head->getFinalLeanForward();
|
|
||||||
headParams.torsoTwist = head->getTorsoTwist();
|
|
||||||
|
|
||||||
if (qApp->isHMDMode()) {
|
if (qApp->isHMDMode()) {
|
||||||
headParams.isInHMD = true;
|
headParams.isInHMD = true;
|
||||||
|
@ -131,7 +127,6 @@ void SkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
||||||
headParams.worldHeadOrientation = head->getFinalOrientationInWorldFrame();
|
headParams.worldHeadOrientation = head->getFinalOrientationInWorldFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
headParams.leanJointIndex = geometry.leanJointIndex;
|
|
||||||
headParams.neckJointIndex = geometry.neckJointIndex;
|
headParams.neckJointIndex = geometry.neckJointIndex;
|
||||||
headParams.isTalking = head->getTimeWithoutTalking() <= 1.5f;
|
headParams.isTalking = head->getTimeWithoutTalking() <= 1.5f;
|
||||||
|
|
||||||
|
|
|
@ -129,16 +129,6 @@ void setupPreferences() {
|
||||||
preference->setStep(1);
|
preference->setStep(1);
|
||||||
preferences->addPreference(preference);
|
preferences->addPreference(preference);
|
||||||
}
|
}
|
||||||
{
|
|
||||||
auto getter = [=]()->float { return myAvatar->getLeanScale(); };
|
|
||||||
auto setter = [=](float value) { myAvatar->setLeanScale(value); };
|
|
||||||
auto preference = new SpinnerPreference(AVATAR_TUNING, "Lean scale (applies to Faceshift users)", getter, setter);
|
|
||||||
preference->setMin(0);
|
|
||||||
preference->setMax(99.9f);
|
|
||||||
preference->setDecimals(2);
|
|
||||||
preference->setStep(1);
|
|
||||||
preferences->addPreference(preference);
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
auto getter = [=]()->float { return myAvatar->getUniformScale(); };
|
auto getter = [=]()->float { return myAvatar->getUniformScale(); };
|
||||||
auto setter = [=](float value) { myAvatar->setTargetScaleVerbose(value); }; // The hell?
|
auto setter = [=](float value) { myAvatar->setTargetScaleVerbose(value); }; // The hell?
|
||||||
|
|
|
@ -931,11 +931,6 @@ glm::quat Rig::getJointDefaultRotationInParentFrame(int jointIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rig::updateFromHeadParameters(const HeadParameters& params, float dt) {
|
void Rig::updateFromHeadParameters(const HeadParameters& params, float dt) {
|
||||||
if (params.enableLean) {
|
|
||||||
updateLeanJoint(params.leanJointIndex, params.leanSideways, params.leanForward, params.torsoTwist);
|
|
||||||
} else {
|
|
||||||
_animVars.unset("lean");
|
|
||||||
}
|
|
||||||
updateNeckJoint(params.neckJointIndex, params);
|
updateNeckJoint(params.neckJointIndex, params);
|
||||||
|
|
||||||
_animVars.set("isTalking", params.isTalking);
|
_animVars.set("isTalking", params.isTalking);
|
||||||
|
@ -953,15 +948,6 @@ static const glm::vec3 X_AXIS(1.0f, 0.0f, 0.0f);
|
||||||
static const glm::vec3 Y_AXIS(0.0f, 1.0f, 0.0f);
|
static const glm::vec3 Y_AXIS(0.0f, 1.0f, 0.0f);
|
||||||
static const glm::vec3 Z_AXIS(0.0f, 0.0f, 1.0f);
|
static const glm::vec3 Z_AXIS(0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
void Rig::updateLeanJoint(int index, float leanSideways, float leanForward, float torsoTwist) {
|
|
||||||
if (isIndexValid(index)) {
|
|
||||||
glm::quat absRot = (glm::angleAxis(-RADIANS_PER_DEGREE * leanSideways, Z_AXIS) *
|
|
||||||
glm::angleAxis(-RADIANS_PER_DEGREE * leanForward, X_AXIS) *
|
|
||||||
glm::angleAxis(RADIANS_PER_DEGREE * torsoTwist, Y_AXIS));
|
|
||||||
_animVars.set("lean", absRot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rig::computeHeadNeckAnimVars(const AnimPose& hmdPose, glm::vec3& headPositionOut, glm::quat& headOrientationOut,
|
void Rig::computeHeadNeckAnimVars(const AnimPose& hmdPose, glm::vec3& headPositionOut, glm::quat& headOrientationOut,
|
||||||
glm::vec3& neckPositionOut, glm::quat& neckOrientationOut) const {
|
glm::vec3& neckPositionOut, glm::quat& neckOrientationOut) const {
|
||||||
|
|
||||||
|
|
|
@ -42,15 +42,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HeadParameters {
|
struct HeadParameters {
|
||||||
float leanSideways = 0.0f; // degrees
|
|
||||||
float leanForward = 0.0f; // degrees
|
|
||||||
float torsoTwist = 0.0f; // degrees
|
|
||||||
bool enableLean = false;
|
|
||||||
glm::quat worldHeadOrientation = glm::quat(); // world space (-z forward)
|
glm::quat worldHeadOrientation = glm::quat(); // world space (-z forward)
|
||||||
glm::quat rigHeadOrientation = glm::quat(); // rig space (-z forward)
|
glm::quat rigHeadOrientation = glm::quat(); // rig space (-z forward)
|
||||||
glm::vec3 rigHeadPosition = glm::vec3(); // rig space
|
glm::vec3 rigHeadPosition = glm::vec3(); // rig space
|
||||||
bool isInHMD = false;
|
bool isInHMD = false;
|
||||||
int leanJointIndex = -1;
|
|
||||||
int neckJointIndex = -1;
|
int neckJointIndex = -1;
|
||||||
bool isTalking = false;
|
bool isTalking = false;
|
||||||
};
|
};
|
||||||
|
@ -222,7 +217,6 @@ protected:
|
||||||
void applyOverridePoses();
|
void applyOverridePoses();
|
||||||
void buildAbsoluteRigPoses(const AnimPoseVec& relativePoses, AnimPoseVec& absolutePosesOut);
|
void buildAbsoluteRigPoses(const AnimPoseVec& relativePoses, AnimPoseVec& absolutePosesOut);
|
||||||
|
|
||||||
void updateLeanJoint(int index, float leanSideways, float leanForward, float torsoTwist);
|
|
||||||
void updateNeckJoint(int index, const HeadParameters& params);
|
void updateNeckJoint(int index, const HeadParameters& params);
|
||||||
void computeHeadNeckAnimVars(const AnimPose& hmdPose, glm::vec3& headPositionOut, glm::quat& headOrientationOut,
|
void computeHeadNeckAnimVars(const AnimPose& hmdPose, glm::vec3& headPositionOut, glm::quat& headOrientationOut,
|
||||||
glm::vec3& neckPositionOut, glm::quat& neckOrientationOut) const;
|
glm::vec3& neckPositionOut, glm::quat& neckOrientationOut) const;
|
||||||
|
|
|
@ -31,9 +31,6 @@ HeadData::HeadData(AvatarData* owningAvatar) :
|
||||||
_baseYaw(0.0f),
|
_baseYaw(0.0f),
|
||||||
_basePitch(0.0f),
|
_basePitch(0.0f),
|
||||||
_baseRoll(0.0f),
|
_baseRoll(0.0f),
|
||||||
_leanSideways(0.0f),
|
|
||||||
_leanForward(0.0f),
|
|
||||||
_torsoTwist(0.0f),
|
|
||||||
_lookAtPosition(0.0f, 0.0f, 0.0f),
|
_lookAtPosition(0.0f, 0.0f, 0.0f),
|
||||||
_audioLoudness(0.0f),
|
_audioLoudness(0.0f),
|
||||||
_isFaceTrackerConnected(false),
|
_isFaceTrackerConnected(false),
|
||||||
|
@ -132,12 +129,6 @@ QJsonObject HeadData::toJson() const {
|
||||||
if (getRawOrientation() != quat()) {
|
if (getRawOrientation() != quat()) {
|
||||||
headJson[JSON_AVATAR_HEAD_ROTATION] = toJsonValue(getRawOrientation());
|
headJson[JSON_AVATAR_HEAD_ROTATION] = toJsonValue(getRawOrientation());
|
||||||
}
|
}
|
||||||
if (getLeanForward() != 0.0f) {
|
|
||||||
headJson[JSON_AVATAR_HEAD_LEAN_FORWARD] = getLeanForward();
|
|
||||||
}
|
|
||||||
if (getLeanSideways() != 0.0f) {
|
|
||||||
headJson[JSON_AVATAR_HEAD_LEAN_SIDEWAYS] = getLeanSideways();
|
|
||||||
}
|
|
||||||
auto lookat = getLookAtPosition();
|
auto lookat = getLookAtPosition();
|
||||||
if (lookat != vec3()) {
|
if (lookat != vec3()) {
|
||||||
vec3 relativeLookAt = glm::inverse(_owningAvatar->getOrientation()) *
|
vec3 relativeLookAt = glm::inverse(_owningAvatar->getOrientation()) *
|
||||||
|
@ -171,12 +162,6 @@ void HeadData::fromJson(const QJsonObject& json) {
|
||||||
if (json.contains(JSON_AVATAR_HEAD_ROTATION)) {
|
if (json.contains(JSON_AVATAR_HEAD_ROTATION)) {
|
||||||
setOrientation(quatFromJsonValue(json[JSON_AVATAR_HEAD_ROTATION]));
|
setOrientation(quatFromJsonValue(json[JSON_AVATAR_HEAD_ROTATION]));
|
||||||
}
|
}
|
||||||
if (json.contains(JSON_AVATAR_HEAD_LEAN_FORWARD)) {
|
|
||||||
setLeanForward((float)json[JSON_AVATAR_HEAD_LEAN_FORWARD].toDouble());
|
|
||||||
}
|
|
||||||
if (json.contains(JSON_AVATAR_HEAD_LEAN_SIDEWAYS)) {
|
|
||||||
setLeanSideways((float)json[JSON_AVATAR_HEAD_LEAN_SIDEWAYS].toDouble());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (json.contains(JSON_AVATAR_HEAD_LOOKAT)) {
|
if (json.contains(JSON_AVATAR_HEAD_LOOKAT)) {
|
||||||
auto relativeLookAt = vec3FromJsonValue(json[JSON_AVATAR_HEAD_LOOKAT]);
|
auto relativeLookAt = vec3FromJsonValue(json[JSON_AVATAR_HEAD_LOOKAT]);
|
||||||
|
|
|
@ -68,17 +68,6 @@ public:
|
||||||
const glm::vec3& getLookAtPosition() const { return _lookAtPosition; }
|
const glm::vec3& getLookAtPosition() const { return _lookAtPosition; }
|
||||||
void setLookAtPosition(const glm::vec3& lookAtPosition) { _lookAtPosition = lookAtPosition; }
|
void setLookAtPosition(const glm::vec3& lookAtPosition) { _lookAtPosition = lookAtPosition; }
|
||||||
|
|
||||||
|
|
||||||
float getLeanSideways() const { return _leanSideways; }
|
|
||||||
float getLeanForward() const { return _leanForward; }
|
|
||||||
float getTorsoTwist() const { return _torsoTwist; }
|
|
||||||
virtual float getFinalLeanSideways() const { return _leanSideways; }
|
|
||||||
virtual float getFinalLeanForward() const { return _leanForward; }
|
|
||||||
|
|
||||||
void setLeanSideways(float leanSideways) { _leanSideways = leanSideways; }
|
|
||||||
void setLeanForward(float leanForward) { _leanForward = leanForward; }
|
|
||||||
void setTorsoTwist(float torsoTwist) { _torsoTwist = torsoTwist; }
|
|
||||||
|
|
||||||
friend class AvatarData;
|
friend class AvatarData;
|
||||||
|
|
||||||
QJsonObject toJson() const;
|
QJsonObject toJson() const;
|
||||||
|
@ -89,9 +78,6 @@ protected:
|
||||||
float _baseYaw;
|
float _baseYaw;
|
||||||
float _basePitch;
|
float _basePitch;
|
||||||
float _baseRoll;
|
float _baseRoll;
|
||||||
float _leanSideways;
|
|
||||||
float _leanForward;
|
|
||||||
float _torsoTwist;
|
|
||||||
|
|
||||||
glm::vec3 _lookAtPosition;
|
glm::vec3 _lookAtPosition;
|
||||||
float _audioLoudness;
|
float _audioLoudness;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <atomic>
|
||||||
#include <btBulletDynamicsCommon.h>
|
#include <btBulletDynamicsCommon.h>
|
||||||
#include <BulletDynamics/Character/btCharacterControllerInterface.h>
|
#include <BulletDynamics/Character/btCharacterControllerInterface.h>
|
||||||
|
|
||||||
|
@ -105,8 +106,9 @@ public:
|
||||||
|
|
||||||
void setLocalBoundingBox(const glm::vec3& corner, const glm::vec3& scale);
|
void setLocalBoundingBox(const glm::vec3& corner, const glm::vec3& scale);
|
||||||
|
|
||||||
|
bool isEnabled() const { return _enabled; } // thread-safe
|
||||||
void setEnabled(bool enabled);
|
void setEnabled(bool enabled);
|
||||||
bool isEnabled() const { return _enabled && _dynamicsWorld; }
|
bool isEnabledAndReady() const { return _enabled && _dynamicsWorld; }
|
||||||
|
|
||||||
bool getRigidBodyLocation(glm::vec3& avatarRigidBodyPosition, glm::quat& avatarRigidBodyRotation);
|
bool getRigidBodyLocation(glm::vec3& avatarRigidBodyPosition, glm::quat& avatarRigidBodyRotation);
|
||||||
|
|
||||||
|
@ -167,7 +169,7 @@ protected:
|
||||||
btQuaternion _followAngularDisplacement;
|
btQuaternion _followAngularDisplacement;
|
||||||
btVector3 _linearAcceleration;
|
btVector3 _linearAcceleration;
|
||||||
|
|
||||||
bool _enabled;
|
std::atomic_bool _enabled;
|
||||||
State _state;
|
State _state;
|
||||||
bool _isPushingUp;
|
bool _isPushingUp;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue