mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[haxe] Port of commit 29bf262: Fix track 0 dip mixing to animation with key > frame 0.
This commit is contained in:
parent
161780fcac
commit
a056f01029
@ -238,12 +238,14 @@ class AnimationState {
|
|||||||
if (current == null || current.delay > 0)
|
if (current == null || current.delay > 0)
|
||||||
continue;
|
continue;
|
||||||
applied = true;
|
applied = true;
|
||||||
|
|
||||||
|
// Track 0 animations aren't for layering, so never use current values before the first key.
|
||||||
var blend:MixBlend = i == 0 ? MixBlend.first : current.mixBlend;
|
var blend:MixBlend = i == 0 ? MixBlend.first : current.mixBlend;
|
||||||
|
|
||||||
// Apply mixing from entries first.
|
// Apply mixing from entries first.
|
||||||
var alpha:Float = current.alpha;
|
var alpha:Float = current.alpha;
|
||||||
if (current.mixingFrom != null) {
|
if (current.mixingFrom != null) {
|
||||||
alpha *= applyMixingFrom(current, skeleton, blend);
|
alpha *= applyMixingFrom(current, skeleton);
|
||||||
} else if (current.trackTime >= current.trackEnd && current.next == null) {
|
} else if (current.trackTime >= current.trackEnd && current.next == null) {
|
||||||
alpha = 0;
|
alpha = 0;
|
||||||
}
|
}
|
||||||
@ -281,7 +283,7 @@ class AnimationState {
|
|||||||
|
|
||||||
for (ii in 0...timelineCount) {
|
for (ii in 0...timelineCount) {
|
||||||
var timeline:Timeline = timelines[ii];
|
var timeline:Timeline = timelines[ii];
|
||||||
var timelineBlend:MixBlend = timelineMode[ii] == SUBSEQUENT ? blend : MixBlend.setup;
|
var timelineBlend:MixBlend = timelineMode[ii] == SUBSEQUENT ? current.mixBlendblend : MixBlend.setup;
|
||||||
if (!shortestRotation && Std.isOfType(timeline, RotateTimeline)) {
|
if (!shortestRotation && Std.isOfType(timeline, RotateTimeline)) {
|
||||||
this.applyRotateTimeline(cast(timeline, RotateTimeline), skeleton, applyTime, alpha, timelineBlend, current.timelinesRotation,
|
this.applyRotateTimeline(cast(timeline, RotateTimeline), skeleton, applyTime, alpha, timelineBlend, current.timelinesRotation,
|
||||||
ii << 1, firstFrame);
|
ii << 1, firstFrame);
|
||||||
@ -314,23 +316,18 @@ class AnimationState {
|
|||||||
return applied;
|
return applied;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function applyMixingFrom(to:TrackEntry, skeleton:Skeleton, blend:MixBlend):Float {
|
private function applyMixingFrom(to:TrackEntry, skeleton:Skeleton):Float {
|
||||||
var from:TrackEntry = to.mixingFrom;
|
var from:TrackEntry = to.mixingFrom;
|
||||||
if (from.mixingFrom != null)
|
if (from.mixingFrom != null)
|
||||||
applyMixingFrom(from, skeleton, blend);
|
applyMixingFrom(from, skeleton);
|
||||||
|
|
||||||
var mix:Float = 0;
|
var mix:Float = 0;
|
||||||
if (to.mixDuration == 0) // Single frame mix to undo mixingFrom changes.
|
if (to.mixDuration == 0) // Single frame mix to undo mixingFrom changes.
|
||||||
{
|
|
||||||
mix = 1;
|
mix = 1;
|
||||||
if (blend == MixBlend.first)
|
else {
|
||||||
blend = MixBlend.setup;
|
|
||||||
} else {
|
|
||||||
mix = to.mixTime / to.mixDuration;
|
mix = to.mixTime / to.mixDuration;
|
||||||
if (mix > 1)
|
if (mix > 1)
|
||||||
mix = 1;
|
mix = 1;
|
||||||
if (blend != MixBlend.first)
|
|
||||||
blend = from.mixBlend;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var attachments:Bool = mix < from.mixAttachmentThreshold,
|
var attachments:Bool = mix < from.mixAttachmentThreshold,
|
||||||
@ -349,6 +346,7 @@ class AnimationState {
|
|||||||
applyEvents = events;
|
applyEvents = events;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var blend = from.mixBlend;
|
||||||
if (blend == MixBlend.add) {
|
if (blend == MixBlend.add) {
|
||||||
for (timeline in timelines) {
|
for (timeline in timelines) {
|
||||||
timeline.apply(skeleton, animationLast, applyTime, applyEvents, alphaMix, blend, MixDirection.mixOut, false);
|
timeline.apply(skeleton, animationLast, applyTime, applyEvents, alphaMix, blend, MixDirection.mixOut, false);
|
||||||
@ -393,8 +391,8 @@ class AnimationState {
|
|||||||
if (!shortestRotation && Std.isOfType(timeline, RotateTimeline)) {
|
if (!shortestRotation && Std.isOfType(timeline, RotateTimeline)) {
|
||||||
applyRotateTimeline(cast(timeline, RotateTimeline), skeleton, applyTime, alpha, timelineBlend, from.timelinesRotation, i << 1, firstFrame);
|
applyRotateTimeline(cast(timeline, RotateTimeline), skeleton, applyTime, alpha, timelineBlend, from.timelinesRotation, i << 1, firstFrame);
|
||||||
} else if (Std.isOfType(timeline, AttachmentTimeline)) {
|
} else if (Std.isOfType(timeline, AttachmentTimeline)) {
|
||||||
applyAttachmentTimeline(cast(timeline, AttachmentTimeline), skeleton, applyTime,
|
applyAttachmentTimeline(cast(timeline, AttachmentTimeline), skeleton, applyTime, timelineBlend,
|
||||||
timelineBlend, true, attachments && alpha >= from.alphaAttachmentThreshold);
|
true, attachments && alpha >= from.alphaAttachmentThreshold);
|
||||||
} else {
|
} else {
|
||||||
var direction = MixDirection.mixOut;
|
var direction = MixDirection.mixOut;
|
||||||
if (drawOrder && Std.isOfType(timeline, DrawOrderTimeline) && timelineBlend == MixBlend.setup)
|
if (drawOrder && Std.isOfType(timeline, DrawOrderTimeline) && timelineBlend == MixBlend.setup)
|
||||||
@ -425,7 +423,8 @@ class AnimationState {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (out) {
|
if (out) {
|
||||||
if (blend == MixBlend.setup) this.setAttachment(skeleton, slot, slot.data.attachmentName, attachments);
|
if (blend == MixBlend.setup)
|
||||||
|
this.setAttachment(skeleton, slot, slot.data.attachmentName, attachments);
|
||||||
} else if (time < timeline.frames[0]) { // Time is before first frame.
|
} else if (time < timeline.frames[0]) { // Time is before first frame.
|
||||||
if (blend == MixBlend.setup || blend == MixBlend.first)
|
if (blend == MixBlend.setup || blend == MixBlend.first)
|
||||||
this.setAttachment(skeleton, slot, slot.data.attachmentName, attachments);
|
this.setAttachment(skeleton, slot, slot.data.attachmentName, attachments);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user