Fix color timeline mixing when animation is after the last frame.

This commit is contained in:
NathanSweet 2014-04-27 22:02:08 +02:00
parent 1306384a8c
commit afe0817811

View File

@ -406,15 +406,14 @@ void _spColorTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, f
slot = skeleton->slots[self->slotIndex]; slot = skeleton->slots[self->slotIndex];
if (time >= self->frames[self->framesLength - 5]) { /* Time is after last frame. */ if (time >= self->frames[self->framesLength - 5]) {
/* Time is after last frame. */
int i = self->framesLength - 1; int i = self->framesLength - 1;
slot->r = self->frames[i - 3]; r = self->frames[i - 3];
slot->g = self->frames[i - 2]; g = self->frames[i - 2];
slot->b = self->frames[i - 1]; b = self->frames[i - 1];
slot->a = self->frames[i]; a = self->frames[i];
return; } else {
}
/* Interpolate between the last frame and the current frame. */ /* Interpolate between the last frame and the current frame. */
frameIndex = binarySearch(self->frames, self->framesLength, time, 5); frameIndex = binarySearch(self->frames, self->framesLength, time, 5);
lastFrameR = self->frames[frameIndex - 4]; lastFrameR = self->frames[frameIndex - 4];
@ -429,6 +428,7 @@ void _spColorTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, f
g = lastFrameG + (self->frames[frameIndex + COLOR_FRAME_G] - lastFrameG) * percent; g = lastFrameG + (self->frames[frameIndex + COLOR_FRAME_G] - lastFrameG) * percent;
b = lastFrameB + (self->frames[frameIndex + COLOR_FRAME_B] - lastFrameB) * percent; b = lastFrameB + (self->frames[frameIndex + COLOR_FRAME_B] - lastFrameB) * percent;
a = lastFrameA + (self->frames[frameIndex + COLOR_FRAME_A] - lastFrameA) * percent; a = lastFrameA + (self->frames[frameIndex + COLOR_FRAME_A] - lastFrameA) * percent;
}
if (alpha < 1) { if (alpha < 1) {
slot->r += (r - slot->r) * alpha; slot->r += (r - slot->r) * alpha;
slot->g += (g - slot->g) * alpha; slot->g += (g - slot->g) * alpha;