[c] Fixed rotation timeline handling in AnimationState. Fixed main.cpp missing a break

This commit is contained in:
badlogic 2016-11-29 13:27:15 +01:00
parent 1e7a31747d
commit 6fe1e8fa68
2 changed files with 7 additions and 5 deletions

View File

@ -433,6 +433,8 @@ void _spAnimationState_applyRotateTimeline (spAnimationState* self, spTimeline*
float total, diff;
int /*boolean*/ current, dir;
if (firstFrame) timelinesRotation[i] = 0;
if (alpha == 1) {
spTimeline_apply(timeline, skeleton, 0, time, 0, 0, 1, setupPose, 0);
return;
@ -468,11 +470,7 @@ void _spAnimationState_applyRotateTimeline (spAnimationState* self, spTimeline*
r1 = setupPose ? bone->data->rotation : bone->rotation;
diff = r2 - r1;
if (diff == 0) {
if (firstFrame) {
timelinesRotation[i] = 0;
total = 0;
} else
total = timelinesRotation[i];
total = timelinesRotation[i];
} else {
float lastTotal, lastDiff;
diff -= (16384 - (int)(16384.499999999996 - diff / 360)) * 360;
@ -581,6 +579,8 @@ void _spAnimationState_setCurrent (spAnimationState* self, int index, spTrackEnt
current->mixingFrom = from;
current->mixTime = 0;
from->timelinesRotationCount = 0;
/* If not completely mixed in, set mixAlpha so mixing out happens from current mix to zero. */
if (from->mixingFrom) current->mixAlpha *= MIN(from->mixTime / from->mixDuration, 1);
}

View File

@ -48,6 +48,7 @@ void callback (AnimationState* state, EventType type, TrackEntry* entry, Event*
break;
case ANIMATION_INTERRUPT:
printf("%d interrupt: %s\n", entry->trackIndex, animationName);
break;
case ANIMATION_END:
printf("%d end: %s\n", entry->trackIndex, animationName);
break;
@ -56,6 +57,7 @@ void callback (AnimationState* state, EventType type, TrackEntry* entry, Event*
break;
case ANIMATION_DISPOSE:
printf("%d dispose: %s\n", entry->trackIndex, animationName);
break;
case ANIMATION_EVENT:
printf("%d event: %s, %s: %d, %f, %s\n", entry->trackIndex, animationName, event->data->name, event->intValue, event->floatValue,
event->stringValue);