mirror of
https://github.com/overte-org/overte.git
synced 2025-06-26 03:29:50 +02:00
Merge pull request #11301 from Menithal/21484-Fix
WL21484 _- Hotfix - Solve Joint array issues with Similar, but not same Skeletons
This commit is contained in:
commit
5741699bab
1 changed files with 23 additions and 9 deletions
|
@ -909,9 +909,6 @@ void ModelEntityRenderer::animate(const TypedEntityPointer& entity) {
|
||||||
QVector<JointData> jointsData;
|
QVector<JointData> jointsData;
|
||||||
|
|
||||||
const QVector<FBXAnimationFrame>& frames = _animation->getFramesReference(); // NOTE: getFrames() is too heavy
|
const QVector<FBXAnimationFrame>& frames = _animation->getFramesReference(); // NOTE: getFrames() is too heavy
|
||||||
auto& fbxJoints = _animation->getGeometry().joints;
|
|
||||||
auto& originalFbxJoints = _model->getFBXGeometry().joints;
|
|
||||||
bool allowTranslation = entity->getAnimationAllowTranslation();
|
|
||||||
int frameCount = frames.size();
|
int frameCount = frames.size();
|
||||||
if (frameCount <= 0) {
|
if (frameCount <= 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -946,19 +943,37 @@ void ModelEntityRenderer::animate(const TypedEntityPointer& entity) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList animationJointNames = _animation->getGeometry().getJointNames();
|
||||||
|
auto& fbxJoints = _animation->getGeometry().joints;
|
||||||
|
|
||||||
|
auto& originalFbxJoints = _model->getFBXGeometry().joints;
|
||||||
|
auto& originalFbxIndices = _model->getFBXGeometry().jointIndices;
|
||||||
|
|
||||||
|
bool allowTranslation = entity->getAnimationAllowTranslation();
|
||||||
|
|
||||||
const QVector<glm::quat>& rotations = frames[_lastKnownCurrentFrame].rotations;
|
const QVector<glm::quat>& rotations = frames[_lastKnownCurrentFrame].rotations;
|
||||||
const QVector<glm::vec3>& translations = frames[_lastKnownCurrentFrame].translations;
|
const QVector<glm::vec3>& translations = frames[_lastKnownCurrentFrame].translations;
|
||||||
|
|
||||||
jointsData.resize(_jointMapping.size());
|
jointsData.resize(_jointMapping.size());
|
||||||
for (int j = 0; j < _jointMapping.size(); j++) {
|
for (int j = 0; j < _jointMapping.size(); j++) {
|
||||||
int index = _jointMapping[j];
|
int index = _jointMapping[j];
|
||||||
|
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
glm::mat4 translationMat;
|
glm::mat4 translationMat;
|
||||||
if (!allowTranslation){
|
|
||||||
translationMat = glm::translate(originalFbxJoints[index].translation);
|
if (allowTranslation) {
|
||||||
} else if (index < translations.size()) {
|
if(index < translations.size()){
|
||||||
translationMat = glm::translate(translations[index]);
|
translationMat = glm::translate(translations[index]);
|
||||||
}
|
}
|
||||||
|
} else if (index < animationJointNames.size()){
|
||||||
|
QString jointName = fbxJoints[index].name; // Pushing this here so its not done on every entity, with the exceptions of those allowing for translation
|
||||||
|
|
||||||
|
if (originalFbxIndices.contains(jointName)) {
|
||||||
|
// Making sure the joint names exist in the original model the animation is trying to apply onto. If they do, then remap and get it's translation.
|
||||||
|
int remappedIndex = originalFbxIndices[jointName] - 1; // JointIndeces seem to always start from 1 and the found index is always 1 higher than actual.
|
||||||
|
translationMat = glm::translate(originalFbxJoints[remappedIndex].translation);
|
||||||
|
}
|
||||||
|
}
|
||||||
glm::mat4 rotationMat;
|
glm::mat4 rotationMat;
|
||||||
if (index < rotations.size()) {
|
if (index < rotations.size()) {
|
||||||
rotationMat = glm::mat4_cast(fbxJoints[index].preRotation * rotations[index] * fbxJoints[index].postRotation);
|
rotationMat = glm::mat4_cast(fbxJoints[index].preRotation * rotations[index] * fbxJoints[index].postRotation);
|
||||||
|
@ -975,7 +990,6 @@ void ModelEntityRenderer::animate(const TypedEntityPointer& entity) {
|
||||||
jointData.rotationSet = true;
|
jointData.rotationSet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the data in the entity
|
// Set the data in the entity
|
||||||
entity->setAnimationJointsData(jointsData);
|
entity->setAnimationJointsData(jointsData);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue