mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-10 10:34:56 +02:00
Bug fixes for avatarData protocol
Two issues were recently discovered after they were introduced by PR #14733 1) The Avatar Mixer would sometimes have incorrect translation scale when splitting BulkAvatarData across multiple MTUs 2) Old avatar recordings would no longer work properly. This PR should fix both of these issues.
This commit is contained in:
parent
3ec9290dca
commit
77fb20801f
1 changed files with 13 additions and 3 deletions
|
@ -639,7 +639,7 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
|
|||
|
||||
// compute maxTranslationDimension before we send any joint data.
|
||||
float maxTranslationDimension = 0.001f;
|
||||
for (int i = sendStatus.rotationsSent; i < numJoints; ++i) {
|
||||
for (int i = sendStatus.translationsSent; i < numJoints; ++i) {
|
||||
const JointData& data = jointData[i];
|
||||
if (!data.translationIsDefaultPose) {
|
||||
maxTranslationDimension = glm::max(fabsf(data.translation.x), maxTranslationDimension);
|
||||
|
@ -2428,7 +2428,8 @@ static const QString JSON_AVATAR_VERSION = QStringLiteral("version");
|
|||
enum class JsonAvatarFrameVersion : int {
|
||||
JointRotationsInRelativeFrame = 0,
|
||||
JointRotationsInAbsoluteFrame,
|
||||
JointDefaultPoseBits
|
||||
JointDefaultPoseBits,
|
||||
JointUnscaledTranslations,
|
||||
};
|
||||
|
||||
QJsonValue toJsonValue(const JointData& joint) {
|
||||
|
@ -2445,7 +2446,16 @@ JointData jointDataFromJsonValue(int version, const QJsonValue& json) {
|
|||
if (json.isArray()) {
|
||||
QJsonArray array = json.toArray();
|
||||
result.rotation = quatFromJsonValue(array[0]);
|
||||
|
||||
result.translation = vec3FromJsonValue(array[1]);
|
||||
|
||||
// In old recordings, translations are scaled by _geometryOffset. Undo that scaling.
|
||||
if (version < (int)JsonAvatarFrameVersion::JointUnscaledTranslations) {
|
||||
// because we don't have access to the actual _geometryOffset used. we have to guess.
|
||||
// most avatar FBX files were authored in centimeters.
|
||||
const float METERS_TO_CENTIMETERS = 100.0f;
|
||||
result.translation *= METERS_TO_CENTIMETERS;
|
||||
}
|
||||
if (version >= (int)JsonAvatarFrameVersion::JointDefaultPoseBits) {
|
||||
result.rotationIsDefaultPose = array[2].toBool();
|
||||
result.translationIsDefaultPose = array[3].toBool();
|
||||
|
@ -2464,7 +2474,7 @@ void AvatarData::avatarEntityDataToJson(QJsonObject& root) const {
|
|||
QJsonObject AvatarData::toJson() const {
|
||||
QJsonObject root;
|
||||
|
||||
root[JSON_AVATAR_VERSION] = (int)JsonAvatarFrameVersion::JointDefaultPoseBits;
|
||||
root[JSON_AVATAR_VERSION] = (int)JsonAvatarFrameVersion::JointUnscaledTranslations;
|
||||
|
||||
if (!getSkeletonModelURL().isEmpty()) {
|
||||
root[JSON_AVATAR_BODY_MODEL] = getSkeletonModelURL().toString();
|
||||
|
|
Loading…
Reference in a new issue