From 49881b5ea24f8cae93d60cd4323e00a9d94f6b79 Mon Sep 17 00:00:00 2001 From: trent Date: Tue, 2 May 2017 13:55:32 -0400 Subject: [PATCH] Actually the full set of changes. Kids: don't forget to pop your stash. --- interface/src/avatar/MyAvatar.cpp | 11 +++++++++++ interface/src/avatar/MyAvatar.h | 2 ++ libraries/avatars/src/AvatarData.cpp | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 2043a6b9b6..98afdb56c0 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -268,6 +268,17 @@ QVariant MyAvatar::getOrientationVar() const { return quatToVariant(Avatar::getOrientation()); } +glm::quat MyAvatar::getOrientationOutbound() const { + // Allows MyAvatar to send out smoothed data to remote agents if required. + if (_smoothOrientationTimer > _smoothOrientationTime) { + return (getLocalOrientation()); + } + + // Smooth the remote avatar movement. + float t = _smoothOrientationTimer / _smoothOrientationTime; + float l = easeInOutQuad(glm::clamp(t, 0.0f, 1.0f)); + return (slerp(_smoothOrientationInitial, _smoothOrientationTarget, l)); +} // virtual void MyAvatar::simulateAttachments(float deltaTime) { diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 1d26a2f3f9..c69359cc4c 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -187,6 +187,8 @@ public: Q_INVOKABLE void setOrientationVar(const QVariant& newOrientationVar); Q_INVOKABLE QVariant getOrientationVar() const; + // A method intended to be overriden by MyAvatar for polling orientation for network transmission. + virtual glm::quat getOrientationOutbound() const override; // Pass a recent sample of the HMD to the avatar. // This can also update the avatar's position to follow the HMD diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 3c88ee0749..7eedbcd216 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -312,7 +312,7 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent if (hasAvatarOrientation) { auto startSection = destinationBuffer; - auto localOrientation = getLocalOrientation(); + auto localOrientation = getOrientationOutbound(); destinationBuffer += packOrientationQuatToSixBytes(destinationBuffer, localOrientation); int numBytes = destinationBuffer - startSection;