From 40d339a8318e7b014c60da12a6817aa684d44a9b Mon Sep 17 00:00:00 2001 From: Menithal Date: Mon, 11 Sep 2017 20:33:54 +0300 Subject: [PATCH] 21484: Updated code to go with PR feedback --- .../src/RenderableModelEntityItem.cpp | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index cc9dcf8ac5..c6bad008e4 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -909,13 +909,6 @@ void ModelEntityRenderer::animate(const TypedEntityPointer& entity) { QVector jointsData; const QVector& frames = _animation->getFramesReference(); // NOTE: getFrames() is too heavy - QStringList animationJointNames = _animation->getGeometry().getJointNames(); - auto& fbxJoints = _animation->getGeometry().joints; - - auto& originalFbxJoints = _model->getFBXGeometry().joints; - auto& originalFbxIndices = _model->getFBXGeometry().jointIndices; - - bool allowTranslation = entity->getAnimationAllowTranslation(); int frameCount = frames.size(); if (frameCount <= 0) { return; @@ -950,6 +943,14 @@ void ModelEntityRenderer::animate(const TypedEntityPointer& entity) { 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& rotations = frames[_lastKnownCurrentFrame].rotations; const QVector& translations = frames[_lastKnownCurrentFrame].translations; @@ -960,9 +961,11 @@ void ModelEntityRenderer::animate(const TypedEntityPointer& entity) { if (index >= 0) { glm::mat4 translationMat; - if (allowTranslation && index < translations.size()) { - translationMat = glm::translate(translations[index]); - } else if (!allowTranslation && index < animationJointNames.size()){ + if (allowTranslation) { + if(index < translations.size()){ + 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)) {