mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-29 12:25:59 +02:00
Merge pull request #12877 from hyperlogic/bug-fix/avatar-recording-mtu-overflow
Fix for avatar recording playback on avatars with many joints
This commit is contained in:
commit
f2c38a77a6
1 changed files with 20 additions and 10 deletions
|
@ -2058,32 +2058,42 @@ static const QString JSON_AVATAR_ENTITIES = QStringLiteral("attachedEntities");
|
||||||
static const QString JSON_AVATAR_SCALE = QStringLiteral("scale");
|
static const QString JSON_AVATAR_SCALE = QStringLiteral("scale");
|
||||||
static const QString JSON_AVATAR_VERSION = QStringLiteral("version");
|
static const QString JSON_AVATAR_VERSION = QStringLiteral("version");
|
||||||
|
|
||||||
static const int JSON_AVATAR_JOINT_ROTATIONS_IN_RELATIVE_FRAME_VERSION = 0;
|
enum class JsonAvatarFrameVersion : int {
|
||||||
static const int JSON_AVATAR_JOINT_ROTATIONS_IN_ABSOLUTE_FRAME_VERSION = 1;
|
JointRotationsInRelativeFrame = 0,
|
||||||
|
JointRotationsInAbsoluteFrame,
|
||||||
|
JointDefaultPoseBits
|
||||||
|
};
|
||||||
|
|
||||||
QJsonValue toJsonValue(const JointData& joint) {
|
QJsonValue toJsonValue(const JointData& joint) {
|
||||||
QJsonArray result;
|
QJsonArray result;
|
||||||
result.push_back(toJsonValue(joint.rotation));
|
result.push_back(toJsonValue(joint.rotation));
|
||||||
result.push_back(toJsonValue(joint.translation));
|
result.push_back(toJsonValue(joint.translation));
|
||||||
|
result.push_back(QJsonValue(joint.rotationIsDefaultPose));
|
||||||
|
result.push_back(QJsonValue(joint.translationIsDefaultPose));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
JointData jointDataFromJsonValue(const QJsonValue& json) {
|
JointData jointDataFromJsonValue(int version, const QJsonValue& json) {
|
||||||
JointData result;
|
JointData result;
|
||||||
if (json.isArray()) {
|
if (json.isArray()) {
|
||||||
QJsonArray array = json.toArray();
|
QJsonArray array = json.toArray();
|
||||||
result.rotation = quatFromJsonValue(array[0]);
|
result.rotation = quatFromJsonValue(array[0]);
|
||||||
result.rotationIsDefaultPose = false;
|
|
||||||
result.translation = vec3FromJsonValue(array[1]);
|
result.translation = vec3FromJsonValue(array[1]);
|
||||||
|
if (version >= (int)JsonAvatarFrameVersion::JointDefaultPoseBits) {
|
||||||
|
result.rotationIsDefaultPose = array[2].toBool();
|
||||||
|
result.translationIsDefaultPose = array[3].toBool();
|
||||||
|
} else {
|
||||||
|
result.rotationIsDefaultPose = false;
|
||||||
result.translationIsDefaultPose = false;
|
result.translationIsDefaultPose = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject AvatarData::toJson() const {
|
QJsonObject AvatarData::toJson() const {
|
||||||
QJsonObject root;
|
QJsonObject root;
|
||||||
|
|
||||||
root[JSON_AVATAR_VERSION] = JSON_AVATAR_JOINT_ROTATIONS_IN_ABSOLUTE_FRAME_VERSION;
|
root[JSON_AVATAR_VERSION] = (int)JsonAvatarFrameVersion::JointDefaultPoseBits;
|
||||||
|
|
||||||
if (!getSkeletonModelURL().isEmpty()) {
|
if (!getSkeletonModelURL().isEmpty()) {
|
||||||
root[JSON_AVATAR_BODY_MODEL] = getSkeletonModelURL().toString();
|
root[JSON_AVATAR_BODY_MODEL] = getSkeletonModelURL().toString();
|
||||||
|
@ -2158,7 +2168,7 @@ void AvatarData::fromJson(const QJsonObject& json, bool useFrameSkeleton) {
|
||||||
version = json[JSON_AVATAR_VERSION].toInt();
|
version = json[JSON_AVATAR_VERSION].toInt();
|
||||||
} else {
|
} else {
|
||||||
// initial data did not have a version field.
|
// initial data did not have a version field.
|
||||||
version = JSON_AVATAR_JOINT_ROTATIONS_IN_RELATIVE_FRAME_VERSION;
|
version = (int)JsonAvatarFrameVersion::JointRotationsInRelativeFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json.contains(JSON_AVATAR_BODY_MODEL)) {
|
if (json.contains(JSON_AVATAR_BODY_MODEL)) {
|
||||||
|
@ -2235,7 +2245,7 @@ void AvatarData::fromJson(const QJsonObject& json, bool useFrameSkeleton) {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (json.contains(JSON_AVATAR_JOINT_ARRAY)) {
|
if (json.contains(JSON_AVATAR_JOINT_ARRAY)) {
|
||||||
if (version == JSON_AVATAR_JOINT_ROTATIONS_IN_RELATIVE_FRAME_VERSION) {
|
if (version == (int)JsonAvatarFrameVersion::JointRotationsInRelativeFrame) {
|
||||||
// because we don't have the full joint hierarchy skeleton of the model,
|
// because we don't have the full joint hierarchy skeleton of the model,
|
||||||
// we can't properly convert from relative rotations into absolute rotations.
|
// we can't properly convert from relative rotations into absolute rotations.
|
||||||
quint64 now = usecTimestampNow();
|
quint64 now = usecTimestampNow();
|
||||||
|
@ -2247,7 +2257,7 @@ void AvatarData::fromJson(const QJsonObject& json, bool useFrameSkeleton) {
|
||||||
QJsonArray jointArrayJson = json[JSON_AVATAR_JOINT_ARRAY].toArray();
|
QJsonArray jointArrayJson = json[JSON_AVATAR_JOINT_ARRAY].toArray();
|
||||||
jointArray.reserve(jointArrayJson.size());
|
jointArray.reserve(jointArrayJson.size());
|
||||||
for (const auto& jointJson : jointArrayJson) {
|
for (const auto& jointJson : jointArrayJson) {
|
||||||
auto joint = jointDataFromJsonValue(jointJson);
|
auto joint = jointDataFromJsonValue(version, jointJson);
|
||||||
jointArray.push_back(joint);
|
jointArray.push_back(joint);
|
||||||
}
|
}
|
||||||
setRawJointData(jointArray);
|
setRawJointData(jointArray);
|
||||||
|
|
Loading…
Reference in a new issue