1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-01-14 12:16:41 +00:00

Animation editor enhancement: Move/rotate bones across all keyframes

This commit is contained in:
fgenesis 2012-12-23 22:32:19 +01:00
parent 9eb5b9828a
commit f9ce5c0172

View file

@ -1057,6 +1057,9 @@ void AnimationEditor::applyTranslation()
{ {
if (editingBone) if (editingBone)
{ {
if (!core->getShiftState())
{
// one bone mode
BoneKeyframe *b = editSprite->getCurrentAnimation()->getKeyframe(currentKey)->getBoneKeyframe(editingBone->boneIdx); BoneKeyframe *b = editSprite->getCurrentAnimation()->getKeyframe(currentKey)->getBoneKeyframe(editingBone->boneIdx);
if (b) if (b)
{ {
@ -1064,6 +1067,26 @@ void AnimationEditor::applyTranslation()
b->y = editingBone->position.y; b->y = editingBone->position.y;
} }
} }
else
{
BoneKeyframe *bcur = editSprite->getCurrentAnimation()->getKeyframe(currentKey)->getBoneKeyframe(editingBone->boneIdx);
if (bcur)
{
int xdiff = editingBone->position.x - bcur->x;
int ydiff = editingBone->position.y - bcur->y;
// all bones mode
for (int i = 0; i < editSprite->getCurrentAnimation()->getNumKeyframes(); ++i)
{
BoneKeyframe *b = editSprite->getCurrentAnimation()->getKeyframe(i)->getBoneKeyframe(editingBone->boneIdx);
if (b)
{
b->x += xdiff;
b->y += ydiff;
}
}
}
}
}
} }
void AnimationEditor::applyRotation() void AnimationEditor::applyRotation()
@ -1149,12 +1172,32 @@ void AnimationEditor::rmbu()
{ {
if (editingBone) if (editingBone)
{ {
if (!core->getShiftState())
{
// one bone mode
BoneKeyframe *b = editSprite->getCurrentAnimation()->getKeyframe(currentKey)->getBoneKeyframe(editingBone->boneIdx); BoneKeyframe *b = editSprite->getCurrentAnimation()->getKeyframe(currentKey)->getBoneKeyframe(editingBone->boneIdx);
if (b) if (b)
{ {
b->rot = int(editingBone->rotation.z); b->rot = int(editingBone->rotation.z);
} }
} }
else
{
BoneKeyframe *bcur = editSprite->getCurrentAnimation()->getKeyframe(currentKey)->getBoneKeyframe(editingBone->boneIdx);
if (bcur)
{
int rotdiff = editingBone->rotation.z - bcur->rot;
for (int i = 0; i < editSprite->getCurrentAnimation()->getNumKeyframes(); ++i)
{
BoneKeyframe *b = editSprite->getCurrentAnimation()->getKeyframe(i)->getBoneKeyframe(editingBone->boneIdx);
if (b)
{
b->rot += rotdiff;
}
}
}
}
}
} }
break; break;
} }