mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[as3] Store timeline ids inside set in Animation for O(1) lookup. See #1462.
This commit is contained in:
parent
18eb242df6
commit
06089630fb
Binary file not shown.
@ -30,10 +30,12 @@
|
|||||||
package spine.animation {
|
package spine.animation {
|
||||||
import spine.Event;
|
import spine.Event;
|
||||||
import spine.Skeleton;
|
import spine.Skeleton;
|
||||||
|
import flash.utils.Dictionary;
|
||||||
|
|
||||||
public class Animation {
|
public class Animation {
|
||||||
internal var _name : String;
|
internal var _name : String;
|
||||||
public var _timelines : Vector.<Timeline>;
|
public var _timelines : Vector.<Timeline>;
|
||||||
|
internal var _timelineIds : Dictionary = new Dictionary();
|
||||||
public var duration : Number;
|
public var duration : Number;
|
||||||
|
|
||||||
public function Animation(name : String, timelines : Vector.<Timeline>, duration : Number) {
|
public function Animation(name : String, timelines : Vector.<Timeline>, duration : Number) {
|
||||||
@ -41,9 +43,15 @@ package spine.animation {
|
|||||||
if (timelines == null) throw new ArgumentError("timelines cannot be null.");
|
if (timelines == null) throw new ArgumentError("timelines cannot be null.");
|
||||||
_name = name;
|
_name = name;
|
||||||
_timelines = timelines;
|
_timelines = timelines;
|
||||||
|
for (var i : Number = 0; i < timelines.length; i++)
|
||||||
|
_timelineIds[timelines[i].getPropertyId()] = true;
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasTimeline(id: Number) : Boolean {
|
||||||
|
return _timelineIds[id] == true;
|
||||||
|
}
|
||||||
|
|
||||||
public function get timelines() : Vector.<Timeline> {
|
public function get timelines() : Vector.<Timeline> {
|
||||||
return _timelines;
|
return _timelines;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -664,11 +664,11 @@ package spine.animation {
|
|||||||
if (contained != null) {
|
if (contained != null) {
|
||||||
timelineMode[i] = AnimationState.SUBSEQUENT;
|
timelineMode[i] = AnimationState.SUBSEQUENT;
|
||||||
} else if (to == null || timeline is AttachmentTimeline || timeline is DrawOrderTimeline
|
} else if (to == null || timeline is AttachmentTimeline || timeline is DrawOrderTimeline
|
||||||
|| timeline is EventTimeline || !hasTimeline(to, intId)) {
|
|| timeline is EventTimeline || !to.animation.hasTimeline(intId)) {
|
||||||
timelineMode[i] = AnimationState.FIRST;
|
timelineMode[i] = AnimationState.FIRST;
|
||||||
} else {
|
} else {
|
||||||
for (var next : TrackEntry = to.mixingTo; next != null; next = next.mixingTo) {
|
for (var next : TrackEntry = to.mixingTo; next != null; next = next.mixingTo) {
|
||||||
if (hasTimeline(next, intId)) continue;
|
if (next.animation.hasTimeline(intId)) continue;
|
||||||
if (entry.mixDuration > 0) {
|
if (entry.mixDuration > 0) {
|
||||||
timelineMode[i] = AnimationState.HOLD_MIX;
|
timelineMode[i] = AnimationState.HOLD_MIX;
|
||||||
timelineHoldMix[i] = entry;
|
timelineHoldMix[i] = entry;
|
||||||
@ -681,13 +681,6 @@ package spine.animation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function hasTimeline (entry: TrackEntry, id : int) : Boolean {
|
|
||||||
var timelines : Vector.<Timeline> = entry.animation.timelines;
|
|
||||||
for (var i : int = 0, n : int = entry.animation.timelines.length; i < n; i++)
|
|
||||||
if (timelines[i].getPropertyId() == id) return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCurrent(trackIndex : int) : TrackEntry {
|
public function getCurrent(trackIndex : int) : TrackEntry {
|
||||||
if (trackIndex >= tracks.length) return null;
|
if (trackIndex >= tracks.length) return null;
|
||||||
return tracks[trackIndex];
|
return tracks[trackIndex];
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user