[haxe] Port of commit 7facce3: Draw order folder timeline property ID per slot with "all" special case.

This commit is contained in:
Davide Tantillo 2026-03-18 15:23:02 +01:00
parent a056f01029
commit 9df5f9e4de
3 changed files with 28 additions and 9 deletions

View File

@ -283,7 +283,7 @@ class AnimationState {
for (ii in 0...timelineCount) {
var timeline:Timeline = timelines[ii];
var timelineBlend:MixBlend = timelineMode[ii] == SUBSEQUENT ? current.mixBlendblend : MixBlend.setup;
var timelineBlend:MixBlend = timelineMode[ii] == SUBSEQUENT ? current.mixBlend : MixBlend.setup;
if (!shortestRotation && Std.isOfType(timeline, RotateTimeline)) {
this.applyRotateTimeline(cast(timeline, RotateTimeline), skeleton, applyTime, alpha, timelineBlend, current.timelinesRotation,
ii << 1, firstFrame);
@ -875,7 +875,10 @@ class AnimationState {
if (to != null && to.holdPrevious) {
for (i in 0...timelinesCount) {
timelineMode[i] = propertyIDs.addAll(timelines[i].propertyIds) ? HOLD_FIRST : HOLD_SUBSEQUENT;
var first = propertyIDs.addAll(timelines[i].propertyIds);
if (first && Std.isOfType(timelines[i], DrawOrderFolderTimeline) && propertyIDs.contains(DrawOrderTimeline.propertyID))
first = false; // DrawOrderTimeline changed.
timelineMode[i] = first ? HOLD_FIRST : HOLD_SUBSEQUENT;
}
return;
}
@ -885,9 +888,11 @@ class AnimationState {
continueOuter = false;
var timeline:Timeline = timelines[i];
var ids:Array<String> = timeline.propertyIds;
if (!propertyIDs.addAll(ids)) {
if (!propertyIDs.addAll(ids))
timelineMode[i] = SUBSEQUENT;
} else if (to == null
else if (Std.isOfType(timeline, DrawOrderFolderTimeline) && propertyIDs.contains(DrawOrderTimeline.propertyID))
timelineMode[i] = SUBSEQUENT; // DrawOrderTimeline changed.
else if (to == null
|| Std.isOfType(timeline, AttachmentTimeline)
|| Std.isOfType(timeline, DrawOrderTimeline)
|| Std.isOfType(timeline, DrawOrderFolderTimeline)

View File

@ -42,7 +42,7 @@ class DrawOrderFolderTimeline extends Timeline {
/** @param slots spine.Skeleton.slots indices controlled by this timeline, in setup order.
* @param slotCount The maximum number of slots in the skeleton. */
public function new(frameCount:Int, slots:Array<Int>, slotCount:Int) {
super(frameCount, Property.drawOrder);
super(frameCount, ...DrawOrderFolderTimeline.getPropertyIds(slots));
this.slots = slots;
drawOrders = new Array<Array<Int>>();
drawOrders.resize(frameCount);
@ -54,6 +54,14 @@ class DrawOrderFolderTimeline extends Timeline {
inFolder[i] = true;
}
private static function getPropertyIds(slots:Array<Int>):Array<String> {
var n = slots.length;
var ids = new Array();
for (i in 0...n)
ids[i] = "d" + slots[i];
return ids;
}
public var frameCount(get, never):Int;
private function get_frameCount():Int {
@ -82,9 +90,11 @@ class DrawOrderFolderTimeline extends Timeline {
public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend, direction:MixDirection,
appliedPose:Bool) {
if (direction == MixDirection.mixOut) {
if (blend == MixBlend.setup) setupApply(skeleton);
if (blend == MixBlend.setup)
setupApply(skeleton);
} else if (time < frames[0]) {
if (blend == MixBlend.setup || blend == MixBlend.first) setupApply(skeleton);
if (blend == MixBlend.setup || blend == MixBlend.first)
setupApply(skeleton);
} else {
var order = drawOrders[Timeline.search1(frames, time)];
if (order == null)
@ -103,7 +113,8 @@ class DrawOrderFolderTimeline extends Timeline {
if (inFolder[drawOrder[i].data.index]) {
drawOrder[i] = allSlots[slots[found]];
found++;
if (found == done) break;
if (found == done)
break;
}
i++;
}
@ -118,7 +129,8 @@ class DrawOrderFolderTimeline extends Timeline {
if (inFolder[drawOrder[i].data.index]) {
drawOrder[i] = allSlots[slots[order[found]]];
found++;
if (found == done) break;
if (found == done)
break;
}
i++;
}

View File

@ -35,6 +35,8 @@ import spine.Slot;
/** Changes a skeleton's Skeleton#drawOrder. */
class DrawOrderTimeline extends Timeline {
public static final propertyID = Property.drawOrder;
/** The draw order for each frame. See setFrame(). */
public var drawOrders:Array<Array<Int>>;