Smooth pose sheet

Simple smooth algorithm: average the frame transform with neiboring frames.
master
Jeremy Hu 2018-11-09 23:42:20 +08:00
parent bbe36fde68
commit 8a2298bfcb
1 changed files with 12 additions and 11 deletions

View File

@ -187,18 +187,19 @@ void MotionsGenerator::generateMotion(const QUuid &motionId, std::set<QUuid> &vi
int frame = clipLocalProgress * frames->size() / clipDuration; int frame = clipLocalProgress * frames->size() / clipDuration;
if (frame >= (int)frames->size()) if (frame >= (int)frames->size())
frame = frames->size() - 1; frame = frames->size() - 1;
//int nextFrame = frame + 1; int previousFrame = frame - 1;
//if (nextFrame >= (int)frames->size()) if (previousFrame < 0)
// nextFrame = frames->size() - 1; previousFrame = 0;
//float offset = clipLocalProgress / clipDuration; int nextFrame = frame + 1;
//qDebug() << "frame:" << frame << "clipLocalProgress:" << clipLocalProgress << "clipDuration:" << clipDuration; if (nextFrame >= (int)frames->size())
if (frame >= 0 && frame < (int)frames->size()/* && nextFrame = frames->size() - 1;
nextFrame >= 0 && nextFrame < (int)frames->size()*/) { if (frame >= 0 && frame < (int)frames->size()) {
const JointNodeTree previousJointNodeTree = poseJointNodeTree(progressClip.linkToId, previousFrame);
const JointNodeTree jointNodeTree = poseJointNodeTree(progressClip.linkToId, frame); const JointNodeTree jointNodeTree = poseJointNodeTree(progressClip.linkToId, frame);
//const JointNodeTree nextJointNodeTree = poseJointNodeTree(progressClip.linkToId, nextFrame); const JointNodeTree nextJointNodeTree = poseJointNodeTree(progressClip.linkToId, nextFrame);
//outcomes.push_back({progress - lastProgress, const JointNodeTree middleJointNodeTree = generateInterpolation(InterpolationType::Linear, previousJointNodeTree, nextJointNodeTree, 0.5);
// generateInterpolation(progressClip.interpolationType, jointNodeTree, nextJointNodeTree, offset)}); outcomes.push_back({progress - lastProgress,
outcomes.push_back({progress - lastProgress, jointNodeTree}); generateInterpolation(InterpolationType::Linear, jointNodeTree, middleJointNodeTree, 0.5)});
lastProgress = progress; lastProgress = progress;
} }
progress += interval; progress += interval;