This commit is contained in:
ZappoMan 2017-09-29 09:52:30 -07:00
parent be7729b276
commit 9c81bc5479

View file

@ -404,18 +404,16 @@ void ModelOverlay::animate() {
float deltaTime = (float)interval / (float)USECS_PER_SECOND; float deltaTime = (float)interval / (float)USECS_PER_SECOND;
_animationCurrentFrame += (deltaTime * _animationFPS); _animationCurrentFrame += (deltaTime * _animationFPS);
{ int animationCurrentFrame = (int)(glm::floor(_animationCurrentFrame)) % frameCount;
int animationCurrentFrame = (int)(glm::floor(_animationCurrentFrame)) % frameCount; if (animationCurrentFrame < 0 || animationCurrentFrame > frameCount) {
if (animationCurrentFrame < 0 || animationCurrentFrame > frameCount) { animationCurrentFrame = 0;
animationCurrentFrame = 0;
}
if (animationCurrentFrame == _lastKnownCurrentFrame) {
return;
}
_lastKnownCurrentFrame = animationCurrentFrame;
} }
if (animationCurrentFrame == _lastKnownCurrentFrame) {
return;
}
_lastKnownCurrentFrame = animationCurrentFrame;
if (_jointMapping.size() != _model->getJointStateCount()) { if (_jointMapping.size() != _model->getJointStateCount()) {
return; return;
} }
@ -440,12 +438,11 @@ void ModelOverlay::animate() {
if (index < translations.size()) { if (index < translations.size()) {
translationMat = glm::translate(translations[index]); translationMat = glm::translate(translations[index]);
} }
} } else if (index < animationJointNames.size()) {
else if (index < animationJointNames.size()) {
QString jointName = fbxJoints[index].name; QString jointName = fbxJoints[index].name;
if (originalFbxIndices.contains(jointName)) { 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. // Making sure the joint names exist in the original model the animation is trying to apply onto. If they do, then remap and get its translation.
int remappedIndex = originalFbxIndices[jointName] - 1; // JointIndeces seem to always start from 1 and the found index is always 1 higher than actual. 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); translationMat = glm::translate(originalFbxJoints[remappedIndex].translation);
} }
@ -453,8 +450,7 @@ void ModelOverlay::animate() {
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);
} } else {
else {
rotationMat = glm::mat4_cast(fbxJoints[index].preRotation * fbxJoints[index].postRotation); rotationMat = glm::mat4_cast(fbxJoints[index].preRotation * fbxJoints[index].postRotation);
} }