[as3] Fixed AnimationState not respecting MixBlend.first for rotate timelines. See #1274.

This commit is contained in:
badlogic 2019-02-12 14:14:53 +01:00
parent 19e5edc94b
commit fd51eee47f
4 changed files with 27 additions and 20 deletions

View File

@ -300,12 +300,19 @@ package spine.animation {
var rotateTimeline : RotateTimeline = RotateTimeline(timeline);
var frames : Vector.<Number> = rotateTimeline.frames;
var bone : Bone = skeleton.bones[rotateTimeline.boneIndex];
var r1 : Number, r2 : Number;
if (time < frames[0]) {
if (blend == MixBlend.setup) bone.rotation = bone.data.rotation;
switch (blend) {
case MixBlend.setup:
bone.rotation = bone.data.rotation;
default:
return;
case MixBlend.first:
r1 = bone.rotation;
r2 = bone.data.rotation;
}
var r2 : Number;
} else {
r1 = blend == MixBlend.setup ? bone.data.rotation : bone.rotation;
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) // Time is after last frame.
r2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION];
else {
@ -320,9 +327,9 @@ package spine.animation {
r2 = prevRotation + r2 * percent + bone.data.rotation;
r2 -= (16384 - int((16384.499999999996 - r2 / 360))) * 360;
}
}
// Mix between rotations using the direction of the shortest route on the first frame while detecting crosses.
var r1 : Number = blend == MixBlend.setup ? bone.data.rotation : bone.rotation;
var total : Number, diff : Number = r2 - r1;
diff -= (16384 - int((16384.499999999996 - diff / 360))) * 360;
if (diff == 0) {