mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 21:29:33 +02:00
Merge pull request #15143 from amantley/bugShadowNames2
loading jointRotationOffset2 from FST and deal with the shadow joints
This commit is contained in:
commit
aa3b27d89e
1 changed files with 46 additions and 7 deletions
|
@ -29,8 +29,14 @@ QMap<QString, QString> getJointNameMapping(const QVariantHash& mapping) {
|
||||||
QMap<QString, glm::quat> getJointRotationOffsets(const QVariantHash& mapping) {
|
QMap<QString, glm::quat> getJointRotationOffsets(const QVariantHash& mapping) {
|
||||||
QMap<QString, glm::quat> jointRotationOffsets;
|
QMap<QString, glm::quat> jointRotationOffsets;
|
||||||
static const QString JOINT_ROTATION_OFFSET_FIELD = "jointRotationOffset";
|
static const QString JOINT_ROTATION_OFFSET_FIELD = "jointRotationOffset";
|
||||||
if (!mapping.isEmpty() && mapping.contains(JOINT_ROTATION_OFFSET_FIELD) && mapping[JOINT_ROTATION_OFFSET_FIELD].type() == QVariant::Hash) {
|
static const QString JOINT_ROTATION_OFFSET2_FIELD = "jointRotationOffset2";
|
||||||
auto offsets = mapping[JOINT_ROTATION_OFFSET_FIELD].toHash();
|
if (!mapping.isEmpty() && ((mapping.contains(JOINT_ROTATION_OFFSET_FIELD) && mapping[JOINT_ROTATION_OFFSET_FIELD].type() == QVariant::Hash) || (mapping.contains(JOINT_ROTATION_OFFSET2_FIELD) && mapping[JOINT_ROTATION_OFFSET2_FIELD].type() == QVariant::Hash))) {
|
||||||
|
QHash<QString, QVariant> offsets;
|
||||||
|
if (mapping.contains(JOINT_ROTATION_OFFSET_FIELD)) {
|
||||||
|
offsets = mapping[JOINT_ROTATION_OFFSET_FIELD].toHash();
|
||||||
|
} else {
|
||||||
|
offsets = mapping[JOINT_ROTATION_OFFSET2_FIELD].toHash();
|
||||||
|
}
|
||||||
for (auto itr = offsets.begin(); itr != offsets.end(); itr++) {
|
for (auto itr = offsets.begin(); itr != offsets.end(); itr++) {
|
||||||
QString jointName = itr.key();
|
QString jointName = itr.key();
|
||||||
QString line = itr.value().toString();
|
QString line = itr.value().toString();
|
||||||
|
@ -57,6 +63,15 @@ void PrepareJointsTask::run(const baker::BakeContextPointer& context, const Inpu
|
||||||
auto& jointRotationOffsets = output.edit1();
|
auto& jointRotationOffsets = output.edit1();
|
||||||
auto& jointIndices = output.edit2();
|
auto& jointIndices = output.edit2();
|
||||||
|
|
||||||
|
bool newJointRot = false;
|
||||||
|
static const QString JOINT_ROTATION_OFFSET2_FIELD = "jointRotationOffset2";
|
||||||
|
QVariantHash fstHashMap = mapping.second;
|
||||||
|
if (fstHashMap.contains(JOINT_ROTATION_OFFSET2_FIELD)) {
|
||||||
|
newJointRot = true;
|
||||||
|
} else {
|
||||||
|
newJointRot = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Get joint renames
|
// Get joint renames
|
||||||
auto jointNameMapping = getJointNameMapping(mapping.second);
|
auto jointNameMapping = getJointNameMapping(mapping.second);
|
||||||
// Apply joint metadata from FST file mappings
|
// Apply joint metadata from FST file mappings
|
||||||
|
@ -64,11 +79,12 @@ void PrepareJointsTask::run(const baker::BakeContextPointer& context, const Inpu
|
||||||
jointsOut.push_back(jointIn);
|
jointsOut.push_back(jointIn);
|
||||||
auto& jointOut = jointsOut.back();
|
auto& jointOut = jointsOut.back();
|
||||||
|
|
||||||
auto jointNameMapKey = jointNameMapping.key(jointIn.name);
|
if (!newJointRot) {
|
||||||
if (jointNameMapping.contains(jointNameMapKey)) {
|
auto jointNameMapKey = jointNameMapping.key(jointIn.name);
|
||||||
jointOut.name = jointNameMapKey;
|
if (jointNameMapping.contains(jointNameMapKey)) {
|
||||||
|
jointOut.name = jointNameMapKey;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jointIndices.insert(jointOut.name, (int)jointsOut.size());
|
jointIndices.insert(jointOut.name, (int)jointsOut.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,10 +93,33 @@ void PrepareJointsTask::run(const baker::BakeContextPointer& context, const Inpu
|
||||||
for (auto itr = offsets.begin(); itr != offsets.end(); itr++) {
|
for (auto itr = offsets.begin(); itr != offsets.end(); itr++) {
|
||||||
QString jointName = itr.key();
|
QString jointName = itr.key();
|
||||||
int jointIndex = jointIndices.value(jointName) - 1;
|
int jointIndex = jointIndices.value(jointName) - 1;
|
||||||
if (jointIndex != -1) {
|
if (jointIndex >= 0) {
|
||||||
glm::quat rotationOffset = itr.value();
|
glm::quat rotationOffset = itr.value();
|
||||||
jointRotationOffsets.insert(jointIndex, rotationOffset);
|
jointRotationOffsets.insert(jointIndex, rotationOffset);
|
||||||
qCDebug(model_baker) << "Joint Rotation Offset added to Rig._jointRotationOffsets : " << " jointName: " << jointName << " jointIndex: " << jointIndex << " rotation offset: " << rotationOffset;
|
qCDebug(model_baker) << "Joint Rotation Offset added to Rig._jointRotationOffsets : " << " jointName: " << jointName << " jointIndex: " << jointIndex << " rotation offset: " << rotationOffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newJointRot) {
|
||||||
|
for (const auto& jointIn : jointsIn) {
|
||||||
|
|
||||||
|
auto jointNameMapKey = jointNameMapping.key(jointIn.name);
|
||||||
|
int mappedIndex = jointIndices.value(jointIn.name);
|
||||||
|
if (jointNameMapping.contains(jointNameMapKey)) {
|
||||||
|
|
||||||
|
// delete and replace with hifi name
|
||||||
|
jointIndices.remove(jointIn.name);
|
||||||
|
jointIndices.insert(jointNameMapKey, mappedIndex);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// nothing mapped to this fbx joint name
|
||||||
|
if (jointNameMapping.contains(jointIn.name)) {
|
||||||
|
// but the name is in the list of hifi names is mapped to a different joint
|
||||||
|
int extraIndex = jointIndices.value(jointIn.name);
|
||||||
|
jointIndices.remove(jointIn.name);
|
||||||
|
jointIndices.insert("", extraIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue