mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Merge branch '3.7-beta' into 3.7-beta-cpp
This commit is contained in:
commit
d6c047359d
@ -56,16 +56,18 @@ struct spTrackEntry {
|
|||||||
spAnimation* animation;
|
spAnimation* animation;
|
||||||
spTrackEntry* next;
|
spTrackEntry* next;
|
||||||
spTrackEntry* mixingFrom;
|
spTrackEntry* mixingFrom;
|
||||||
|
spTrackEntry* mixingTo;
|
||||||
spAnimationStateListener listener;
|
spAnimationStateListener listener;
|
||||||
int trackIndex;
|
int trackIndex;
|
||||||
int /*boolean*/ loop;
|
int /*boolean*/ loop;
|
||||||
|
int /*boolean*/ holdPrevious;
|
||||||
float eventThreshold, attachmentThreshold, drawOrderThreshold;
|
float eventThreshold, attachmentThreshold, drawOrderThreshold;
|
||||||
float animationStart, animationEnd, animationLast, nextAnimationLast;
|
float animationStart, animationEnd, animationLast, nextAnimationLast;
|
||||||
float delay, trackTime, trackLast, nextTrackLast, trackEnd, timeScale;
|
float delay, trackTime, trackLast, nextTrackLast, trackEnd, timeScale;
|
||||||
float alpha, mixTime, mixDuration, interruptAlpha, totalAlpha;
|
float alpha, mixTime, mixDuration, interruptAlpha, totalAlpha;
|
||||||
spMixBlend mixBlend;
|
spMixBlend mixBlend;
|
||||||
spIntArray* timelineData;
|
spIntArray* timelineMode;
|
||||||
spTrackEntryArray* timelineDipMix;
|
spTrackEntryArray* timelineHoldMix;
|
||||||
float* timelinesRotation;
|
float* timelinesRotation;
|
||||||
int timelinesRotationCount;
|
int timelinesRotationCount;
|
||||||
void* rendererObject;
|
void* rendererObject;
|
||||||
@ -74,17 +76,18 @@ struct spTrackEntry {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
spTrackEntry() :
|
spTrackEntry() :
|
||||||
animation(0),
|
animation(0),
|
||||||
next(0), mixingFrom(0),
|
next(0), mixingFrom(0), mixingTo(0),
|
||||||
listener(0),
|
listener(0),
|
||||||
trackIndex(0),
|
trackIndex(0),
|
||||||
loop(0),
|
loop(0),
|
||||||
|
holdPrevious(0),
|
||||||
eventThreshold(0), attachmentThreshold(0), drawOrderThreshold(0),
|
eventThreshold(0), attachmentThreshold(0), drawOrderThreshold(0),
|
||||||
animationStart(0), animationEnd(0), animationLast(0), nextAnimationLast(0),
|
animationStart(0), animationEnd(0), animationLast(0), nextAnimationLast(0),
|
||||||
delay(0), trackTime(0), trackLast(0), nextTrackLast(0), trackEnd(0), timeScale(0),
|
delay(0), trackTime(0), trackLast(0), nextTrackLast(0), trackEnd(0), timeScale(0),
|
||||||
alpha(0), mixTime(0), mixDuration(0), interruptAlpha(0), totalAlpha(0),
|
alpha(0), mixTime(0), mixDuration(0), interruptAlpha(0), totalAlpha(0),
|
||||||
mixBlend(SP_MIX_BLEND_REPLACE),
|
mixBlend(SP_MIX_BLEND_REPLACE),
|
||||||
timelineData(0),
|
timelineMode(0),
|
||||||
timelineDipMix(0),
|
timelineHoldMix(0),
|
||||||
timelinesRotation(0),
|
timelinesRotation(0),
|
||||||
timelinesRotationCount(0),
|
timelinesRotationCount(0),
|
||||||
rendererObject(0), userData(0) {
|
rendererObject(0), userData(0) {
|
||||||
@ -102,8 +105,6 @@ struct spAnimationState {
|
|||||||
|
|
||||||
float timeScale;
|
float timeScale;
|
||||||
|
|
||||||
spTrackEntryArray* mixingTo;
|
|
||||||
|
|
||||||
void* rendererObject;
|
void* rendererObject;
|
||||||
void* userData;
|
void* userData;
|
||||||
|
|
||||||
@ -114,7 +115,6 @@ struct spAnimationState {
|
|||||||
tracks(0),
|
tracks(0),
|
||||||
listener(0),
|
listener(0),
|
||||||
timeScale(0),
|
timeScale(0),
|
||||||
mixingTo(0),
|
|
||||||
rendererObject(0),
|
rendererObject(0),
|
||||||
userData(0) {
|
userData(0) {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,8 +34,8 @@
|
|||||||
|
|
||||||
#define SUBSEQUENT 0
|
#define SUBSEQUENT 0
|
||||||
#define FIRST 1
|
#define FIRST 1
|
||||||
#define DIP 2
|
#define HOLD 2
|
||||||
#define DIP_MIX 3
|
#define HOLD_MIX 3
|
||||||
|
|
||||||
_SP_ARRAY_IMPLEMENT_TYPE(spTrackEntryArray, spTrackEntry*)
|
_SP_ARRAY_IMPLEMENT_TYPE(spTrackEntryArray, spTrackEntry*)
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ float* _spAnimationState_resizeTimelinesRotation(spTrackEntry* entry, int newSiz
|
|||||||
int* _spAnimationState_resizeTimelinesFirst(spTrackEntry* entry, int newSize);
|
int* _spAnimationState_resizeTimelinesFirst(spTrackEntry* entry, int newSize);
|
||||||
void _spAnimationState_ensureCapacityPropertyIDs(spAnimationState* self, int capacity);
|
void _spAnimationState_ensureCapacityPropertyIDs(spAnimationState* self, int capacity);
|
||||||
int _spAnimationState_addPropertyID(spAnimationState* self, int id);
|
int _spAnimationState_addPropertyID(spAnimationState* self, int id);
|
||||||
spTrackEntry* _spTrackEntry_setTimelineData(spTrackEntry* self, spTrackEntry* to, spTrackEntryArray* mixingToArray, spAnimationState* state);
|
void _spTrackEntry_setTimelineData(spTrackEntry* self, spAnimationState* state);
|
||||||
|
|
||||||
|
|
||||||
_spEventQueue* _spEventQueue_create (_spAnimationState* state) {
|
_spEventQueue* _spEventQueue_create (_spAnimationState* state) {
|
||||||
@ -192,8 +192,8 @@ void _spAnimationState_disableQueue(spAnimationState* self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _spAnimationState_disposeTrackEntry (spTrackEntry* entry) {
|
void _spAnimationState_disposeTrackEntry (spTrackEntry* entry) {
|
||||||
spIntArray_dispose(entry->timelineData);
|
spIntArray_dispose(entry->timelineMode);
|
||||||
spTrackEntryArray_dispose(entry->timelineDipMix);
|
spTrackEntryArray_dispose(entry->timelineHoldMix);
|
||||||
FREE(entry->timelinesRotation);
|
FREE(entry->timelinesRotation);
|
||||||
FREE(entry);
|
FREE(entry);
|
||||||
}
|
}
|
||||||
@ -237,8 +237,6 @@ spAnimationState* spAnimationState_create (spAnimationStateData* data) {
|
|||||||
internal->propertyIDs = CALLOC(int, 128);
|
internal->propertyIDs = CALLOC(int, 128);
|
||||||
internal->propertyIDsCapacity = 128;
|
internal->propertyIDsCapacity = 128;
|
||||||
|
|
||||||
self->mixingTo = spTrackEntryArray_create(16);
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +249,6 @@ void spAnimationState_dispose (spAnimationState* self) {
|
|||||||
_spEventQueue_free(internal->queue);
|
_spEventQueue_free(internal->queue);
|
||||||
FREE(internal->events);
|
FREE(internal->events);
|
||||||
FREE(internal->propertyIDs);
|
FREE(internal->propertyIDs);
|
||||||
spTrackEntryArray_dispose(self->mixingTo);
|
|
||||||
FREE(internal);
|
FREE(internal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,6 +302,7 @@ void spAnimationState_update (spAnimationState* self, float delta) {
|
|||||||
/* End mixing from entries once all have completed. */
|
/* End mixing from entries once all have completed. */
|
||||||
spTrackEntry* from = current->mixingFrom;
|
spTrackEntry* from = current->mixingFrom;
|
||||||
current->mixingFrom = 0;
|
current->mixingFrom = 0;
|
||||||
|
if (from != 0) from->mixingTo = 0;
|
||||||
while (from != 0) {
|
while (from != 0) {
|
||||||
_spEventQueue_end(internal->queue, from);
|
_spEventQueue_end(internal->queue, from);
|
||||||
from = from->mixingFrom;
|
from = from->mixingFrom;
|
||||||
@ -333,6 +331,7 @@ int /*boolean*/ _spAnimationState_updateMixingFrom (spAnimationState* self, spTr
|
|||||||
/* Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame). */
|
/* Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame). */
|
||||||
if (from->totalAlpha == 0 || to->mixDuration == 0) {
|
if (from->totalAlpha == 0 || to->mixDuration == 0) {
|
||||||
to->mixingFrom = from->mixingFrom;
|
to->mixingFrom = from->mixingFrom;
|
||||||
|
if (from->mixingFrom != 0) from->mixingFrom->mixingTo = to;
|
||||||
to->interruptAlpha = from->interruptAlpha;
|
to->interruptAlpha = from->interruptAlpha;
|
||||||
_spEventQueue_end(internal->queue, from);
|
_spEventQueue_end(internal->queue, from);
|
||||||
}
|
}
|
||||||
@ -378,11 +377,11 @@ int spAnimationState_apply (spAnimationState* self, spSkeleton* skeleton) {
|
|||||||
animationLast = current->animationLast; animationTime = spTrackEntry_getAnimationTime(current);
|
animationLast = current->animationLast; animationTime = spTrackEntry_getAnimationTime(current);
|
||||||
timelineCount = current->animation->timelinesCount;
|
timelineCount = current->animation->timelinesCount;
|
||||||
timelines = current->animation->timelines;
|
timelines = current->animation->timelines;
|
||||||
if (mix == 1 || blend == SP_MIX_BLEND_ADD) {
|
if (i == 0 && (mix == 1 || blend == SP_MIX_BLEND_ADD)) {
|
||||||
for (ii = 0; ii < timelineCount; ii++)
|
for (ii = 0; ii < timelineCount; ii++)
|
||||||
spTimeline_apply(timelines[ii], skeleton, animationLast, animationTime, internal->events, &internal->eventsCount, mix, blend, SP_MIX_DIRECTION_IN);
|
spTimeline_apply(timelines[ii], skeleton, animationLast, animationTime, internal->events, &internal->eventsCount, mix, blend, SP_MIX_DIRECTION_IN);
|
||||||
} else {
|
} else {
|
||||||
spIntArray* timelineData = current->timelineData;
|
spIntArray* timelineMode = current->timelineMode;
|
||||||
|
|
||||||
firstFrame = current->timelinesRotationCount == 0;
|
firstFrame = current->timelinesRotationCount == 0;
|
||||||
if (firstFrame) _spAnimationState_resizeTimelinesRotation(current, timelineCount << 1);
|
if (firstFrame) _spAnimationState_resizeTimelinesRotation(current, timelineCount << 1);
|
||||||
@ -390,7 +389,7 @@ int spAnimationState_apply (spAnimationState* self, spSkeleton* skeleton) {
|
|||||||
|
|
||||||
for (ii = 0; ii < timelineCount; ii++) {
|
for (ii = 0; ii < timelineCount; ii++) {
|
||||||
timeline = timelines[ii];
|
timeline = timelines[ii];
|
||||||
timelineBlend = timelineData->items[ii] == SUBSEQUENT ? blend : SP_MIX_BLEND_SETUP;
|
timelineBlend = timelineMode->items[ii] == SUBSEQUENT ? blend : SP_MIX_BLEND_SETUP;
|
||||||
if (timeline->type == SP_TIMELINE_ROTATE)
|
if (timeline->type == SP_TIMELINE_ROTATE)
|
||||||
_spAnimationState_applyRotateTimeline(self, timeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii << 1, firstFrame);
|
_spAnimationState_applyRotateTimeline(self, timeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii << 1, firstFrame);
|
||||||
else
|
else
|
||||||
@ -417,16 +416,16 @@ float _spAnimationState_applyMixingFrom (spAnimationState* self, spTrackEntry* t
|
|||||||
float animationTime;
|
float animationTime;
|
||||||
int timelineCount;
|
int timelineCount;
|
||||||
spTimeline** timelines;
|
spTimeline** timelines;
|
||||||
spIntArray* timelineData;
|
spIntArray* timelineMode;
|
||||||
spTrackEntryArray* timelineDipMix;
|
spTrackEntryArray* timelineHoldMix;
|
||||||
spMixBlend timelineBlend;
|
spMixBlend timelineBlend;
|
||||||
float alphaDip;
|
float alphaHold;
|
||||||
float alphaMix;
|
float alphaMix;
|
||||||
float alpha;
|
float alpha;
|
||||||
int /*boolean*/ firstFrame;
|
int /*boolean*/ firstFrame;
|
||||||
float* timelinesRotation;
|
float* timelinesRotation;
|
||||||
int i;
|
int i;
|
||||||
spTrackEntry* dipMix;
|
spTrackEntry* holdMix;
|
||||||
|
|
||||||
spTrackEntry* from = to->mixingFrom;
|
spTrackEntry* from = to->mixingFrom;
|
||||||
if (from->mixingFrom) _spAnimationState_applyMixingFrom(self, from, skeleton, blend);
|
if (from->mixingFrom) _spAnimationState_applyMixingFrom(self, from, skeleton, blend);
|
||||||
@ -447,15 +446,15 @@ float _spAnimationState_applyMixingFrom (spAnimationState* self, spTrackEntry* t
|
|||||||
animationTime = spTrackEntry_getAnimationTime(from);
|
animationTime = spTrackEntry_getAnimationTime(from);
|
||||||
timelineCount = from->animation->timelinesCount;
|
timelineCount = from->animation->timelinesCount;
|
||||||
timelines = from->animation->timelines;
|
timelines = from->animation->timelines;
|
||||||
alphaDip = from->alpha * to->interruptAlpha; alphaMix = alphaDip * (1 - mix);
|
alphaHold = from->alpha * to->interruptAlpha; alphaMix = alphaHold * (1 - mix);
|
||||||
if (blend == SP_MIX_BLEND_ADD) {
|
if (blend == SP_MIX_BLEND_ADD) {
|
||||||
for (i = 0; i < timelineCount; i++) {
|
for (i = 0; i < timelineCount; i++) {
|
||||||
spTimeline *timeline = timelines[i];
|
spTimeline *timeline = timelines[i];
|
||||||
spTimeline_apply(timeline, skeleton, animationLast, animationTime, events, &internal->eventsCount, alphaMix, blend, SP_MIX_DIRECTION_OUT);
|
spTimeline_apply(timeline, skeleton, animationLast, animationTime, events, &internal->eventsCount, alphaMix, blend, SP_MIX_DIRECTION_OUT);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
timelineData = from->timelineData;
|
timelineMode = from->timelineMode;
|
||||||
timelineDipMix = from->timelineDipMix;
|
timelineHoldMix = from->timelineHoldMix;
|
||||||
|
|
||||||
firstFrame = from->timelinesRotationCount == 0;
|
firstFrame = from->timelinesRotationCount == 0;
|
||||||
if (firstFrame) _spAnimationState_resizeTimelinesRotation(from, timelineCount << 1);
|
if (firstFrame) _spAnimationState_resizeTimelinesRotation(from, timelineCount << 1);
|
||||||
@ -464,7 +463,7 @@ float _spAnimationState_applyMixingFrom (spAnimationState* self, spTrackEntry* t
|
|||||||
from->totalAlpha = 0;
|
from->totalAlpha = 0;
|
||||||
for (i = 0; i < timelineCount; i++) {
|
for (i = 0; i < timelineCount; i++) {
|
||||||
spTimeline *timeline = timelines[i];
|
spTimeline *timeline = timelines[i];
|
||||||
switch (timelineData->items[i]) {
|
switch (timelineMode->items[i]) {
|
||||||
case SUBSEQUENT:
|
case SUBSEQUENT:
|
||||||
if (!attachments && timeline->type == SP_TIMELINE_ATTACHMENT) continue;
|
if (!attachments && timeline->type == SP_TIMELINE_ATTACHMENT) continue;
|
||||||
if (!drawOrder && timeline->type == SP_TIMELINE_DRAWORDER) continue;
|
if (!drawOrder && timeline->type == SP_TIMELINE_DRAWORDER) continue;
|
||||||
@ -475,14 +474,14 @@ float _spAnimationState_applyMixingFrom (spAnimationState* self, spTrackEntry* t
|
|||||||
timelineBlend = SP_MIX_BLEND_SETUP;
|
timelineBlend = SP_MIX_BLEND_SETUP;
|
||||||
alpha = alphaMix;
|
alpha = alphaMix;
|
||||||
break;
|
break;
|
||||||
case DIP:
|
case HOLD:
|
||||||
timelineBlend = SP_MIX_BLEND_SETUP;
|
timelineBlend = SP_MIX_BLEND_SETUP;
|
||||||
alpha = alphaDip;
|
alpha = alphaHold;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
timelineBlend = SP_MIX_BLEND_SETUP;
|
timelineBlend = SP_MIX_BLEND_SETUP;
|
||||||
dipMix = timelineDipMix->items[i];
|
holdMix = timelineHoldMix->items[i];
|
||||||
alpha = alphaDip * MAX(0, 1 - dipMix->mixTime / dipMix->mixDuration);
|
alpha = alphaHold * MAX(0, 1 - holdMix->mixTime / holdMix->mixDuration);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
from->totalAlpha += alpha;
|
from->totalAlpha += alpha;
|
||||||
@ -648,6 +647,7 @@ void spAnimationState_clearTrack (spAnimationState* self, int trackIndex) {
|
|||||||
if (!from) break;
|
if (!from) break;
|
||||||
_spEventQueue_end(internal->queue, from);
|
_spEventQueue_end(internal->queue, from);
|
||||||
entry->mixingFrom = 0;
|
entry->mixingFrom = 0;
|
||||||
|
entry->mixingTo = 0;
|
||||||
entry = from;
|
entry = from;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -663,6 +663,7 @@ void _spAnimationState_setCurrent (spAnimationState* self, int index, spTrackEnt
|
|||||||
if (from) {
|
if (from) {
|
||||||
if (interrupt) _spEventQueue_interrupt(internal->queue, from);
|
if (interrupt) _spEventQueue_interrupt(internal->queue, from);
|
||||||
current->mixingFrom = from;
|
current->mixingFrom = from;
|
||||||
|
from->mixingTo = current;
|
||||||
current->mixTime = 0;
|
current->mixTime = 0;
|
||||||
|
|
||||||
/* Store the interrupted mix percentage. */
|
/* Store the interrupted mix percentage. */
|
||||||
@ -794,6 +795,7 @@ spTrackEntry* _spAnimationState_trackEntry (spAnimationState* self, int trackInd
|
|||||||
entry->trackIndex = trackIndex;
|
entry->trackIndex = trackIndex;
|
||||||
entry->animation = animation;
|
entry->animation = animation;
|
||||||
entry->loop = loop;
|
entry->loop = loop;
|
||||||
|
entry->holdPrevious = 0;
|
||||||
|
|
||||||
entry->eventThreshold = 0;
|
entry->eventThreshold = 0;
|
||||||
entry->attachmentThreshold = 0;
|
entry->attachmentThreshold = 0;
|
||||||
@ -817,8 +819,9 @@ spTrackEntry* _spAnimationState_trackEntry (spAnimationState* self, int trackInd
|
|||||||
entry->mixDuration = !last ? 0 : spAnimationStateData_getMix(self->data, last->animation, animation);
|
entry->mixDuration = !last ? 0 : spAnimationStateData_getMix(self->data, last->animation, animation);
|
||||||
entry->mixBlend = SP_MIX_BLEND_REPLACE;
|
entry->mixBlend = SP_MIX_BLEND_REPLACE;
|
||||||
|
|
||||||
entry->timelineData = spIntArray_create(16);
|
entry->timelineMode = spIntArray_create(16);
|
||||||
entry->timelineDipMix = spTrackEntryArray_create(16);
|
entry->timelineHoldMix = spTrackEntryArray_create(16);
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -836,17 +839,19 @@ void _spAnimationState_animationsChanged (spAnimationState* self) {
|
|||||||
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
|
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
|
||||||
int i, n;
|
int i, n;
|
||||||
spTrackEntry* entry;
|
spTrackEntry* entry;
|
||||||
spTrackEntryArray* mixingTo;
|
|
||||||
internal->animationsChanged = 0;
|
internal->animationsChanged = 0;
|
||||||
|
|
||||||
internal->propertyIDsCount = 0;
|
internal->propertyIDsCount = 0;
|
||||||
i = 0; n = self->tracksCount;
|
i = 0; n = self->tracksCount;
|
||||||
|
|
||||||
mixingTo = self->mixingTo;
|
|
||||||
|
|
||||||
for (;i < n; i++) {
|
for (;i < n; i++) {
|
||||||
entry = self->tracks[i];
|
entry = self->tracks[i];
|
||||||
if (entry != 0 && entry->mixBlend != SP_MIX_BLEND_ADD) _spTrackEntry_setTimelineData(entry, 0, mixingTo, self);
|
while (entry->mixingFrom != 0)
|
||||||
|
entry = entry->mixingFrom;
|
||||||
|
do {
|
||||||
|
if (entry->mixingTo == 0 || entry->mixBlend != SP_MIX_BLEND_ADD) _spTrackEntry_setTimelineData(entry, self);
|
||||||
|
entry = entry->mixingTo;
|
||||||
|
} while (entry != 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -912,51 +917,51 @@ int /*boolean*/ _spTrackEntry_hasTimeline(spTrackEntry* self, int id) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
spTrackEntry* _spTrackEntry_setTimelineData(spTrackEntry* self, spTrackEntry* to, spTrackEntryArray* mixingToArray, spAnimationState* state) {
|
void _spTrackEntry_setTimelineData(spTrackEntry* entry, spAnimationState* state) {
|
||||||
spTrackEntry* lastEntry;
|
spTrackEntry* to;
|
||||||
spTrackEntry** mixingTo;
|
|
||||||
int mixingToLast;
|
|
||||||
spTimeline** timelines;
|
spTimeline** timelines;
|
||||||
int timelinesCount;
|
int timelinesCount;
|
||||||
int* timelineData;
|
int* timelineMode;
|
||||||
spTrackEntry** timelineDipMix;
|
spTrackEntry** timelineHoldMix;
|
||||||
int i, ii;
|
spTrackEntry* next;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (to != 0) spTrackEntryArray_add(mixingToArray, to);
|
to = entry->mixingTo;
|
||||||
lastEntry = self->mixingFrom != 0 ? _spTrackEntry_setTimelineData(self->mixingFrom, self, mixingToArray, state) : self;
|
timelines = entry->animation->timelines;
|
||||||
if (to != 0) spTrackEntryArray_pop(mixingToArray);
|
timelinesCount = entry->animation->timelinesCount;
|
||||||
|
timelineMode = spIntArray_setSize(entry->timelineMode, timelinesCount)->items;
|
||||||
|
spTrackEntryArray_clear(entry->timelineHoldMix);
|
||||||
|
timelineHoldMix = spTrackEntryArray_setSize(entry->timelineHoldMix, timelinesCount)->items;
|
||||||
|
|
||||||
mixingTo = mixingToArray->items;
|
if (to != 0 && to->holdPrevious) {
|
||||||
mixingToLast = mixingToArray->size - 1;
|
for (i = 0; i < timelinesCount; i++) {
|
||||||
timelines = self->animation->timelines;
|
int id = spTimeline_getPropertyId(timelines[i]);
|
||||||
timelinesCount = self->animation->timelinesCount;
|
_spAnimationState_addPropertyID(state, id);
|
||||||
timelineData = spIntArray_setSize(self->timelineData, timelinesCount)->items;
|
timelineMode[i] = HOLD;
|
||||||
spTrackEntryArray_clear(self->timelineDipMix);
|
}
|
||||||
timelineDipMix = spTrackEntryArray_setSize(self->timelineDipMix, timelinesCount)->items;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
continue_outer:
|
continue_outer:
|
||||||
for (; i < timelinesCount; i++) {
|
for (; i < timelinesCount; i++) {
|
||||||
int id = spTimeline_getPropertyId(timelines[i]);
|
int id = spTimeline_getPropertyId(timelines[i]);
|
||||||
if (!_spAnimationState_addPropertyID(state, id))
|
if (!_spAnimationState_addPropertyID(state, id))
|
||||||
timelineData[i] = SUBSEQUENT;
|
timelineMode[i] = SUBSEQUENT;
|
||||||
else if (to == 0 || !_spTrackEntry_hasTimeline(to, id))
|
else if (to == 0 || !_spTrackEntry_hasTimeline(to, id))
|
||||||
timelineData[i] = FIRST;
|
timelineMode[i] = FIRST;
|
||||||
else {
|
else {
|
||||||
for (ii = mixingToLast; ii >= 0; ii--) {
|
for (next = to->mixingTo; next != 0; next = next->mixingTo) {
|
||||||
spTrackEntry* entry = mixingTo[ii];
|
if (_spTrackEntry_hasTimeline(next, id)) continue;
|
||||||
if (!_spTrackEntry_hasTimeline(entry, id)) {
|
if (next->mixDuration > 0) {
|
||||||
if (entry->mixDuration > 0) {
|
timelineMode[i] = HOLD_MIX;
|
||||||
timelineData[i] = DIP_MIX;
|
timelineHoldMix[i] = next;
|
||||||
timelineDipMix[i] = entry;
|
i++;
|
||||||
i++;
|
goto continue_outer;
|
||||||
goto continue_outer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
timelineData[i] = DIP;
|
timelineMode[i] = HOLD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lastEntry;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,6 +79,21 @@ namespace spine {
|
|||||||
/// If true, the animation will repeat. If false, it will not, instead its last frame is applied if played beyond its duration.
|
/// If true, the animation will repeat. If false, it will not, instead its last frame is applied if played beyond its duration.
|
||||||
bool getLoop();
|
bool getLoop();
|
||||||
void setLoop(bool inValue);
|
void setLoop(bool inValue);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// If true, when mixing from the previous animation to this animation, the previous animation is applied as normal instead
|
||||||
|
/// of being mixed out.
|
||||||
|
///
|
||||||
|
/// When mixing between animations that key the same property, if a lower track also keys that property then the value will
|
||||||
|
/// briefly dip toward the lower track value during the mix. This happens because the first animation mixes from 100% to 0%
|
||||||
|
/// while the second animation mixes from 0% to 100%. Setting holdPrevious to true applies the first animation
|
||||||
|
/// at 100% during the mix so the lower track value is overwritten. Such dipping does not occur on the lowest track which
|
||||||
|
/// keys the property, only when a higher track also keys the property.
|
||||||
|
///
|
||||||
|
/// Snapping will occur if holdPrevious is true and this animation does not key all the same properties as the
|
||||||
|
/// previous animation.
|
||||||
|
bool getHoldPrevious();
|
||||||
|
void setHoldPrevious(bool inValue);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Seconds to postpone playing the animation. When a track entry is the current track entry, delay postpones incrementing
|
/// Seconds to postpone playing the animation. When a track entry is the current track entry, delay postpones incrementing
|
||||||
@ -206,8 +221,13 @@ namespace spine {
|
|||||||
|
|
||||||
///
|
///
|
||||||
/// The track entry for the previous animation when mixing from the previous animation to this animation, or NULL if no
|
/// The track entry for the previous animation when mixing from the previous animation to this animation, or NULL if no
|
||||||
/// mixing is currently occuring. When mixing from multiple animations, MixingFrom makes up a linked list.
|
/// mixing is currently occuring. When mixing from multiple animations, MixingFrom makes up a double linked list with MixingTo.
|
||||||
TrackEntry* getMixingFrom();
|
TrackEntry* getMixingFrom();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The track entry for the next animation when mixing from this animation, or NULL if no mixing is currently occuring.
|
||||||
|
/// When mixing from multiple animations, MixingTo makes up a double linked list with MixingFrom.
|
||||||
|
TrackEntry* getMixingTo();
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Resets the rotation directions for mixing this entry's rotate timelines. This can be useful to avoid bones rotating the
|
/// Resets the rotation directions for mixing this entry's rotate timelines. This can be useful to avoid bones rotating the
|
||||||
@ -226,25 +246,20 @@ namespace spine {
|
|||||||
|
|
||||||
TrackEntry* _next;
|
TrackEntry* _next;
|
||||||
TrackEntry* _mixingFrom;
|
TrackEntry* _mixingFrom;
|
||||||
|
TrackEntry* _mixingTo;
|
||||||
int _trackIndex;
|
int _trackIndex;
|
||||||
|
|
||||||
bool _loop;
|
bool _loop, _holdPrevious;
|
||||||
float _eventThreshold, _attachmentThreshold, _drawOrderThreshold;
|
float _eventThreshold, _attachmentThreshold, _drawOrderThreshold;
|
||||||
float _animationStart, _animationEnd, _animationLast, _nextAnimationLast;
|
float _animationStart, _animationEnd, _animationLast, _nextAnimationLast;
|
||||||
float _delay, _trackTime, _trackLast, _nextTrackLast, _trackEnd, _timeScale;
|
float _delay, _trackTime, _trackLast, _nextTrackLast, _trackEnd, _timeScale;
|
||||||
float _alpha, _mixTime, _mixDuration, _interruptAlpha, _totalAlpha;
|
float _alpha, _mixTime, _mixDuration, _interruptAlpha, _totalAlpha;
|
||||||
MixBlend _mixBlend;
|
MixBlend _mixBlend;
|
||||||
Vector<int> _timelineData;
|
Vector<int> _timelineMode;
|
||||||
Vector<TrackEntry*> _timelineDipMix;
|
Vector<TrackEntry*> _timelineHoldMix;
|
||||||
Vector<float> _timelinesRotation;
|
Vector<float> _timelinesRotation;
|
||||||
AnimationStateListener _listener;
|
AnimationStateListener _listener;
|
||||||
|
|
||||||
/// Sets the timeline data.
|
|
||||||
/// @param to May be NULL.
|
|
||||||
TrackEntry* setTimelineData(TrackEntry* to, Vector<TrackEntry*>& mixingToArray, Vector<int>& propertyIDs);
|
|
||||||
|
|
||||||
bool hasTimeline(int inId);
|
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -386,7 +401,7 @@ namespace spine {
|
|||||||
void enableQueue();
|
void enableQueue();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int Subsequent, First, Dip, DipMix;
|
static const int Subsequent, First, Hold, HoldMix;
|
||||||
|
|
||||||
AnimationStateData* _data;
|
AnimationStateData* _data;
|
||||||
|
|
||||||
@ -396,7 +411,6 @@ namespace spine {
|
|||||||
EventQueue* _queue;
|
EventQueue* _queue;
|
||||||
|
|
||||||
Vector<int> _propertyIDs;
|
Vector<int> _propertyIDs;
|
||||||
Vector<TrackEntry*> _mixingTo;
|
|
||||||
bool _animationsChanged;
|
bool _animationsChanged;
|
||||||
|
|
||||||
AnimationStateListener _listener;
|
AnimationStateListener _listener;
|
||||||
@ -427,6 +441,10 @@ namespace spine {
|
|||||||
void disposeNext(TrackEntry* entry);
|
void disposeNext(TrackEntry* entry);
|
||||||
|
|
||||||
void animationsChanged();
|
void animationsChanged();
|
||||||
|
|
||||||
|
void setTimelineModes(TrackEntry* entry);
|
||||||
|
|
||||||
|
bool hasTimeline(TrackEntry* entry, int inId);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,7 @@ void dummyOnAnimationEventFunc(AnimationState *state, spine::EventType type, Tra
|
|||||||
SP_UNUSED(event);
|
SP_UNUSED(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry::TrackEntry() : _animation(NULL), _next(NULL), _mixingFrom(NULL), _trackIndex(0), _loop(false),
|
TrackEntry::TrackEntry() : _animation(NULL), _next(NULL), _mixingFrom(NULL), _mixingTo(0), _trackIndex(0), _loop(false), _holdPrevious(false),
|
||||||
_eventThreshold(0), _attachmentThreshold(0), _drawOrderThreshold(0), _animationStart(0),
|
_eventThreshold(0), _attachmentThreshold(0), _drawOrderThreshold(0), _animationStart(0),
|
||||||
_animationEnd(0), _animationLast(0), _nextAnimationLast(0), _delay(0), _trackTime(0),
|
_animationEnd(0), _animationLast(0), _nextAnimationLast(0), _delay(0), _trackTime(0),
|
||||||
_trackLast(0), _nextTrackLast(0), _trackEnd(0), _timeScale(1.0f), _alpha(0), _mixTime(0),
|
_trackLast(0), _nextTrackLast(0), _trackEnd(0), _timeScale(1.0f), _alpha(0), _mixTime(0),
|
||||||
@ -71,6 +71,10 @@ bool TrackEntry::getLoop() { return _loop; }
|
|||||||
|
|
||||||
void TrackEntry::setLoop(bool inValue) { _loop = inValue; }
|
void TrackEntry::setLoop(bool inValue) { _loop = inValue; }
|
||||||
|
|
||||||
|
bool TrackEntry::getHoldPrevious() { return _holdPrevious; }
|
||||||
|
|
||||||
|
void TrackEntry::setHoldPrevious(bool inValue) { _holdPrevious = inValue; }
|
||||||
|
|
||||||
float TrackEntry::getDelay() { return _delay; }
|
float TrackEntry::getDelay() { return _delay; }
|
||||||
|
|
||||||
void TrackEntry::setDelay(float inValue) { _delay = inValue; }
|
void TrackEntry::setDelay(float inValue) { _delay = inValue; }
|
||||||
@ -147,6 +151,8 @@ void TrackEntry::setMixDuration(float inValue) { _mixDuration = inValue; }
|
|||||||
|
|
||||||
TrackEntry *TrackEntry::getMixingFrom() { return _mixingFrom; }
|
TrackEntry *TrackEntry::getMixingFrom() { return _mixingFrom; }
|
||||||
|
|
||||||
|
TrackEntry *TrackEntry::getMixingTo() { return _mixingTo; }
|
||||||
|
|
||||||
void TrackEntry::setMixBlend(MixBlend blend) { _mixBlend = blend; }
|
void TrackEntry::setMixBlend(MixBlend blend) { _mixBlend = blend; }
|
||||||
|
|
||||||
MixBlend TrackEntry::getMixBlend() { return _mixBlend; }
|
MixBlend TrackEntry::getMixBlend() { return _mixBlend; }
|
||||||
@ -159,67 +165,14 @@ void TrackEntry::setListener(AnimationStateListener inValue) {
|
|||||||
_listener = inValue;
|
_listener = inValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry *TrackEntry::setTimelineData(TrackEntry *to, Vector<TrackEntry *> &mixingToArray, Vector<int> &propertyIDs) {
|
|
||||||
if (to != NULL) mixingToArray.add(to);
|
|
||||||
TrackEntry *lastEntry = _mixingFrom != NULL ? _mixingFrom->setTimelineData(this, mixingToArray, propertyIDs) : this;
|
|
||||||
if (to != NULL) mixingToArray.removeAt(mixingToArray.size() - 1);
|
|
||||||
|
|
||||||
size_t mixingToLast = mixingToArray.size() - 1;
|
|
||||||
Vector<Timeline *> &timelines = _animation->_timelines;
|
|
||||||
size_t timelinesCount = timelines.size();
|
|
||||||
_timelineData.setSize(timelinesCount, 0);
|
|
||||||
_timelineDipMix.setSize(timelinesCount, 0);
|
|
||||||
|
|
||||||
// outer:
|
|
||||||
size_t i = 0;
|
|
||||||
continue_outer:
|
|
||||||
for (; i < timelinesCount; ++i) {
|
|
||||||
int id = timelines[i]->getPropertyId();
|
|
||||||
if (propertyIDs.contains(id)) {
|
|
||||||
_timelineData[i] = AnimationState::Subsequent;
|
|
||||||
} else {
|
|
||||||
propertyIDs.add(id);
|
|
||||||
|
|
||||||
if (to == NULL || !to->hasTimeline(id)) {
|
|
||||||
_timelineData[i] = AnimationState::First;
|
|
||||||
} else {
|
|
||||||
for (int ii = mixingToLast; ii >= 0; --ii) {
|
|
||||||
TrackEntry *entry = mixingToArray[ii];
|
|
||||||
if (!entry->hasTimeline(id)) {
|
|
||||||
if (entry->_mixDuration > 0) {
|
|
||||||
_timelineData[i] = AnimationState::DipMix;
|
|
||||||
_timelineDipMix[i] = entry;
|
|
||||||
i++;
|
|
||||||
goto continue_outer; // continue outer;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_timelineData[i] = AnimationState::Dip;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return lastEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TrackEntry::hasTimeline(int inId) {
|
|
||||||
Vector<Timeline *> &timelines = _animation->_timelines;
|
|
||||||
for (size_t i = 0, n = timelines.size(); i < n; ++i) {
|
|
||||||
if (timelines[i]->getPropertyId() == inId) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackEntry::reset() {
|
void TrackEntry::reset() {
|
||||||
_animation = NULL;
|
_animation = NULL;
|
||||||
_next = NULL;
|
_next = NULL;
|
||||||
_mixingFrom = NULL;
|
_mixingFrom = NULL;
|
||||||
|
_mixingTo = NULL;
|
||||||
|
|
||||||
_timelineData.clear();
|
_timelineMode.clear();
|
||||||
_timelineDipMix.clear();
|
_timelineHoldMix.clear();
|
||||||
_timelinesRotation.clear();
|
_timelinesRotation.clear();
|
||||||
|
|
||||||
_listener = dummyOnAnimationEventFunc;
|
_listener = dummyOnAnimationEventFunc;
|
||||||
@ -318,8 +271,8 @@ void EventQueue::drain() {
|
|||||||
|
|
||||||
const int AnimationState::Subsequent = 0;
|
const int AnimationState::Subsequent = 0;
|
||||||
const int AnimationState::First = 1;
|
const int AnimationState::First = 1;
|
||||||
const int AnimationState::Dip = 2;
|
const int AnimationState::Hold = 2;
|
||||||
const int AnimationState::DipMix = 3;
|
const int AnimationState::HoldMix = 3;
|
||||||
|
|
||||||
AnimationState::AnimationState(AnimationStateData *data) :
|
AnimationState::AnimationState(AnimationStateData *data) :
|
||||||
_data(data),
|
_data(data),
|
||||||
@ -403,6 +356,7 @@ void AnimationState::update(float delta) {
|
|||||||
// End mixing from entries once all have completed.
|
// End mixing from entries once all have completed.
|
||||||
TrackEntry *from = current._mixingFrom;
|
TrackEntry *from = current._mixingFrom;
|
||||||
current._mixingFrom = NULL;
|
current._mixingFrom = NULL;
|
||||||
|
if (from != NULL) from->_mixingTo = NULL;
|
||||||
while (from != NULL) {
|
while (from != NULL) {
|
||||||
_queue->end(from);
|
_queue->end(from);
|
||||||
from = from->_mixingFrom;
|
from = from->_mixingFrom;
|
||||||
@ -444,13 +398,13 @@ bool AnimationState::apply(Skeleton &skeleton) {
|
|||||||
float animationLast = current._animationLast, animationTime = current.getAnimationTime();
|
float animationLast = current._animationLast, animationTime = current.getAnimationTime();
|
||||||
size_t timelineCount = current._animation->_timelines.size();
|
size_t timelineCount = current._animation->_timelines.size();
|
||||||
Vector<Timeline *> &timelines = current._animation->_timelines;
|
Vector<Timeline *> &timelines = current._animation->_timelines;
|
||||||
if (mix == 1 || blend == MixBlend_Add) {
|
if (i == 0 && (mix == 1 || blend == MixBlend_Add)) {
|
||||||
for (size_t ii = 0; ii < timelineCount; ++ii) {
|
for (size_t ii = 0; ii < timelineCount; ++ii) {
|
||||||
timelines[ii]->apply(skeleton, animationLast, animationTime, &_events, mix, blend,
|
timelines[ii]->apply(skeleton, animationLast, animationTime, &_events, mix, blend,
|
||||||
MixDirection_In);
|
MixDirection_In);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Vector<int> &timelineData = current._timelineData;
|
Vector<int> &timelineMode = current._timelineMode;
|
||||||
|
|
||||||
bool firstFrame = current._timelinesRotation.size() == 0;
|
bool firstFrame = current._timelinesRotation.size() == 0;
|
||||||
if (firstFrame) {
|
if (firstFrame) {
|
||||||
@ -462,7 +416,7 @@ bool AnimationState::apply(Skeleton &skeleton) {
|
|||||||
Timeline *timeline = timelines[ii];
|
Timeline *timeline = timelines[ii];
|
||||||
assert(timeline);
|
assert(timeline);
|
||||||
|
|
||||||
MixBlend timelineBlend = timelineData[ii] == AnimationState::Subsequent ? blend : MixBlend_Setup;
|
MixBlend timelineBlend = timelineMode[ii] == AnimationState::Subsequent ? blend : MixBlend_Setup;
|
||||||
|
|
||||||
RotateTimeline *rotateTimeline = NULL;
|
RotateTimeline *rotateTimeline = NULL;
|
||||||
if (timeline->getRTTI().isExactly(RotateTimeline::rtti)) {
|
if (timeline->getRTTI().isExactly(RotateTimeline::rtti)) {
|
||||||
@ -522,6 +476,7 @@ void AnimationState::clearTrack(size_t trackIndex) {
|
|||||||
|
|
||||||
_queue->end(from);
|
_queue->end(from);
|
||||||
entry->_mixingFrom = NULL;
|
entry->_mixingFrom = NULL;
|
||||||
|
entry->_mixingTo = NULL;
|
||||||
entry = from;
|
entry = from;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -766,6 +721,7 @@ bool AnimationState::updateMixingFrom(TrackEntry *to, float delta) {
|
|||||||
// Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame).
|
// Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame).
|
||||||
if (from->_totalAlpha == 0 || to->_mixDuration == 0) {
|
if (from->_totalAlpha == 0 || to->_mixDuration == 0) {
|
||||||
to->_mixingFrom = from->_mixingFrom;
|
to->_mixingFrom = from->_mixingFrom;
|
||||||
|
if (from->_mixingFrom != NULL) from->_mixingFrom->_mixingTo = to;
|
||||||
to->_interruptAlpha = from->_interruptAlpha;
|
to->_interruptAlpha = from->_interruptAlpha;
|
||||||
_queue->end(from);
|
_queue->end(from);
|
||||||
}
|
}
|
||||||
@ -802,14 +758,14 @@ float AnimationState::applyMixingFrom(TrackEntry *to, Skeleton &skeleton, MixBle
|
|||||||
float animationLast = from->_animationLast, animationTime = from->getAnimationTime();
|
float animationLast = from->_animationLast, animationTime = from->getAnimationTime();
|
||||||
Vector<Timeline *> &timelines = from->_animation->_timelines;
|
Vector<Timeline *> &timelines = from->_animation->_timelines;
|
||||||
size_t timelineCount = timelines.size();
|
size_t timelineCount = timelines.size();
|
||||||
float alphaDip = from->_alpha * to->_interruptAlpha, alphaMix = alphaDip * (1 - mix);
|
float alphaHold = from->_alpha * to->_interruptAlpha, alphaMix = alphaHold * (1 - mix);
|
||||||
|
|
||||||
if (blend == MixBlend_Add) {
|
if (blend == MixBlend_Add) {
|
||||||
for (size_t i = 0; i < timelineCount; i++)
|
for (size_t i = 0; i < timelineCount; i++)
|
||||||
timelines[i]->apply(skeleton, animationLast, animationTime, eventBuffer, alphaMix, blend, MixDirection_Out);
|
timelines[i]->apply(skeleton, animationLast, animationTime, eventBuffer, alphaMix, blend, MixDirection_Out);
|
||||||
} else {
|
} else {
|
||||||
Vector<int> &timelineData = from->_timelineData;
|
Vector<int> &timelineMode = from->_timelineMode;
|
||||||
Vector<TrackEntry *> &timelineDipMix = from->_timelineDipMix;
|
Vector<TrackEntry *> &timelineHoldMix = from->_timelineHoldMix;
|
||||||
|
|
||||||
bool firstFrame = from->_timelinesRotation.size() == 0;
|
bool firstFrame = from->_timelinesRotation.size() == 0;
|
||||||
if (firstFrame) {
|
if (firstFrame) {
|
||||||
@ -823,7 +779,7 @@ float AnimationState::applyMixingFrom(TrackEntry *to, Skeleton &skeleton, MixBle
|
|||||||
Timeline *timeline = timelines[i];
|
Timeline *timeline = timelines[i];
|
||||||
MixBlend timelineBlend;
|
MixBlend timelineBlend;
|
||||||
float alpha;
|
float alpha;
|
||||||
switch (timelineData[i]) {
|
switch (timelineMode[i]) {
|
||||||
case AnimationState::Subsequent:
|
case AnimationState::Subsequent:
|
||||||
if (!attachments && (timeline->getRTTI().isExactly(AttachmentTimeline::rtti))) continue;
|
if (!attachments && (timeline->getRTTI().isExactly(AttachmentTimeline::rtti))) continue;
|
||||||
if (!drawOrder && (timeline->getRTTI().isExactly(DrawOrderTimeline::rtti))) continue;
|
if (!drawOrder && (timeline->getRTTI().isExactly(DrawOrderTimeline::rtti))) continue;
|
||||||
@ -834,14 +790,14 @@ float AnimationState::applyMixingFrom(TrackEntry *to, Skeleton &skeleton, MixBle
|
|||||||
timelineBlend = MixBlend_Setup;
|
timelineBlend = MixBlend_Setup;
|
||||||
alpha = alphaMix;
|
alpha = alphaMix;
|
||||||
break;
|
break;
|
||||||
case AnimationState::Dip:
|
case AnimationState::Hold:
|
||||||
timelineBlend = MixBlend_Setup;
|
timelineBlend = MixBlend_Setup;
|
||||||
alpha = alphaDip;
|
alpha = alphaHold;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
timelineBlend = MixBlend_Setup;
|
timelineBlend = MixBlend_Setup;
|
||||||
TrackEntry *dipMix = timelineDipMix[i];
|
TrackEntry *holdMix = timelineHoldMix[i];
|
||||||
alpha = alphaDip * MathUtil::max(0.0f, 1.0f - dipMix->_mixTime / dipMix->_mixDuration);
|
alpha = alphaHold * MathUtil::max(0.0f, 1.0f - holdMix->_mixTime / holdMix->_mixDuration);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
from->_totalAlpha += alpha;
|
from->_totalAlpha += alpha;
|
||||||
@ -914,6 +870,7 @@ void AnimationState::setCurrent(size_t index, TrackEntry *current, bool interrup
|
|||||||
}
|
}
|
||||||
|
|
||||||
current->_mixingFrom = from;
|
current->_mixingFrom = from;
|
||||||
|
from->_mixingTo = current;
|
||||||
current->_mixTime = 0;
|
current->_mixTime = 0;
|
||||||
|
|
||||||
// Store interrupted mix percentage.
|
// Store interrupted mix percentage.
|
||||||
@ -946,6 +903,7 @@ TrackEntry *AnimationState::newTrackEntry(size_t trackIndex, Animation *animatio
|
|||||||
entry._trackIndex = trackIndex;
|
entry._trackIndex = trackIndex;
|
||||||
entry._animation = animation;
|
entry._animation = animation;
|
||||||
entry._loop = loop;
|
entry._loop = loop;
|
||||||
|
entry._holdPrevious = 0;
|
||||||
|
|
||||||
entry._eventThreshold = 0;
|
entry._eventThreshold = 0;
|
||||||
entry._attachmentThreshold = 0;
|
entry._attachmentThreshold = 0;
|
||||||
@ -987,8 +945,70 @@ void AnimationState::animationsChanged() {
|
|||||||
|
|
||||||
for (size_t i = 0, n = _tracks.size(); i < n; ++i) {
|
for (size_t i = 0, n = _tracks.size(); i < n; ++i) {
|
||||||
TrackEntry *entry = _tracks[i];
|
TrackEntry *entry = _tracks[i];
|
||||||
if (entry != NULL && (i == 0 ||entry->_mixBlend != MixBlend_Add)) {
|
|
||||||
entry->setTimelineData(NULL, _mixingTo, _propertyIDs);
|
while (entry->_mixingFrom != NULL)
|
||||||
|
entry = entry->_mixingFrom;
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (entry->_mixingTo == NULL || entry->_mixBlend != MixBlend_Add) setTimelineModes(entry);
|
||||||
|
entry = entry->_mixingTo;
|
||||||
|
} while (entry != NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnimationState::setTimelineModes(TrackEntry *entry) {
|
||||||
|
TrackEntry* to = entry->_mixingTo;
|
||||||
|
Vector<Timeline *> &timelines = entry->_animation->_timelines;
|
||||||
|
size_t timelinesCount = timelines.size();
|
||||||
|
Vector<int> &timelineMode = entry->_timelineMode;
|
||||||
|
timelineMode.setSize(timelinesCount, 0);
|
||||||
|
Vector<TrackEntry *> &timelineHoldMix = entry->_timelineHoldMix;
|
||||||
|
timelineHoldMix.setSize(timelinesCount, 0);
|
||||||
|
|
||||||
|
if (to != NULL && to->_holdPrevious) {
|
||||||
|
for (size_t i = 0; i < timelinesCount; i++) {
|
||||||
|
int id = timelines[i]->getPropertyId();
|
||||||
|
if (!_propertyIDs.contains(id)) _propertyIDs.add(id);
|
||||||
|
timelineMode[i] = AnimationState::Hold;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// outer:
|
||||||
|
size_t i = 0;
|
||||||
|
continue_outer:
|
||||||
|
for (; i < timelinesCount; ++i) {
|
||||||
|
int id = timelines[i]->getPropertyId();
|
||||||
|
if (_propertyIDs.contains(id)) {
|
||||||
|
timelineMode[i] = AnimationState::Subsequent;
|
||||||
|
} else {
|
||||||
|
_propertyIDs.add(id);
|
||||||
|
|
||||||
|
if (to == NULL || !hasTimeline(to, id)) {
|
||||||
|
timelineMode[i] = AnimationState::First;
|
||||||
|
} else {
|
||||||
|
for (TrackEntry *next = to->_mixingTo; next != NULL; next = next->_mixingTo) {
|
||||||
|
if (hasTimeline(next, id)) continue;
|
||||||
|
if (entry->_mixDuration > 0) {
|
||||||
|
timelineMode[i] = AnimationState::HoldMix;
|
||||||
|
timelineHoldMix[i] = entry;
|
||||||
|
i++;
|
||||||
|
goto continue_outer; // continue outer;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
timelineMode[i] = AnimationState::Hold;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AnimationState::hasTimeline(TrackEntry* entry, int inId) {
|
||||||
|
Vector<Timeline *> &timelines = entry->_animation->_timelines;
|
||||||
|
for (size_t i = 0, n = timelines.size(); i < n; ++i) {
|
||||||
|
if (timelines[i]->getPropertyId() == inId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user