From 9b6ec34f092d1ab80f765050f0f088a510513080 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 1 Dec 2015 20:50:03 -0800 Subject: [PATCH] Fixing avatar orientation in recordings --- libraries/avatars/src/AvatarData.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index e25e4f243f..597c4c5986 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -116,7 +116,7 @@ void AvatarData::setOrientation(const glm::quat& orientation, bool overideRefere glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(orientation)); _bodyPitch = eulerAngles.x; _bodyYaw = eulerAngles.y; - _bodyRoll = eulerAngles.z; + _bodyRoll = eulerAngles.z; } } @@ -1529,6 +1529,17 @@ QJsonObject AvatarData::toJson() const { } void AvatarData::fromJson(const QJsonObject& json) { + // The head setOrientation likes to overwrite the avatar orientation, + // so lets do the head first + // Most head data is relative to the avatar, and needs no basis correction, + // but the lookat vector does need correction + if (json.contains(JSON_AVATAR_HEAD)) { + if (!_headData) { + _headData = new HeadData(this); + } + _headData->fromJson(json[JSON_AVATAR_HEAD].toObject()); + } + if (json.contains(JSON_AVATAR_HEAD_MODEL)) { auto faceModelURL = json[JSON_AVATAR_HEAD_MODEL].toString(); if (faceModelURL != getFaceModelURL().toString()) { @@ -1600,15 +1611,6 @@ void AvatarData::fromJson(const QJsonObject& json) { } setRawJointData(jointArray); } - - // Most head data is relative to the avatar, and needs no basis correction, - // but the lookat vector does need correction - if (json.contains(JSON_AVATAR_HEAD)) { - if (!_headData) { - _headData = new HeadData(this); - } - _headData->fromJson(json[JSON_AVATAR_HEAD].toObject()); - } } // Every frame will store both a basis for the recording and a relative transform