mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[as3] Ported last minute AnimationState changes
This commit is contained in:
parent
a05ee4130f
commit
ab0ff1d963
Binary file not shown.
@ -307,7 +307,7 @@ public class Bone implements Updatable {
|
|||||||
* the applied transform after the world transform has been modified directly (eg, by a constraint).
|
* the applied transform after the world transform has been modified directly (eg, by a constraint).
|
||||||
* <p>
|
* <p>
|
||||||
* Some information is ambiguous in the world transform, such as -1,-1 scale versus 180 rotation. */
|
* Some information is ambiguous in the world transform, such as -1,-1 scale versus 180 rotation. */
|
||||||
public function updateAppliedTransform () : void {
|
function updateAppliedTransform () : void {
|
||||||
appliedValid = true;
|
appliedValid = true;
|
||||||
var parent:Bone = this.parent;
|
var parent:Bone = this.parent;
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
|
|||||||
@ -68,7 +68,14 @@ public class SkeletonBounds {
|
|||||||
boundingBox.computeWorldVertices(slot, polygon.vertices);
|
boundingBox.computeWorldVertices(slot, polygon.vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updateAabb) aabbCompute();
|
if (updateAabb)
|
||||||
|
aabbCompute();
|
||||||
|
else {
|
||||||
|
minX = Number.MIN_VALUE;
|
||||||
|
minY = Number.MIN_VALUE;
|
||||||
|
maxX = Number.MAX_VALUE;
|
||||||
|
maxY = Number.MAX_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function aabbCompute () : void {
|
private function aabbCompute () : void {
|
||||||
|
|||||||
@ -253,7 +253,7 @@ public class SkeletonJson {
|
|||||||
var eventData:EventData = new EventData(eventName);
|
var eventData:EventData = new EventData(eventName);
|
||||||
eventData.intValue = eventMap["int"] || 0;
|
eventData.intValue = eventMap["int"] || 0;
|
||||||
eventData.floatValue = eventMap["float"] || 0;
|
eventData.floatValue = eventMap["float"] || 0;
|
||||||
eventData.stringValue = eventMap["string"] || null;
|
eventData.stringValue = eventMap["string"] || "";
|
||||||
skeletonData.events.push(eventData);
|
skeletonData.events.push(eventData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -149,7 +149,7 @@ public class AnimationState {
|
|||||||
|
|
||||||
// Apply mixing from entries first.
|
// Apply mixing from entries first.
|
||||||
var mix:Number = current.alpha;
|
var mix:Number = current.alpha;
|
||||||
if (current.mixingFrom != null) mix = applyMixingFrom(current, skeleton, mix);
|
if (current.mixingFrom != null) mix *= applyMixingFrom(current, skeleton);
|
||||||
|
|
||||||
// Apply current entry.
|
// Apply current entry.
|
||||||
var animationLast:Number = current.animationLast, animationTime:Number = current.getAnimationTime();
|
var animationLast:Number = current.animationLast, animationTime:Number = current.getAnimationTime();
|
||||||
@ -182,9 +182,9 @@ public class AnimationState {
|
|||||||
queue.drain();
|
queue.drain();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function applyMixingFrom (entry:TrackEntry, skeleton:Skeleton, alpha:Number):Number {
|
private function applyMixingFrom (entry:TrackEntry, skeleton:Skeleton):Number {
|
||||||
var from:TrackEntry = entry.mixingFrom;
|
var from:TrackEntry = entry.mixingFrom;
|
||||||
if (from.mixingFrom != null) applyMixingFrom(from, skeleton, alpha);
|
if (from.mixingFrom != null) applyMixingFrom(from, skeleton);
|
||||||
|
|
||||||
var mix:Number = 0;
|
var mix:Number = 0;
|
||||||
if (entry.mixDuration == 0) // Single frame mix to undo mixingFrom changes.
|
if (entry.mixDuration == 0) // Single frame mix to undo mixingFrom changes.
|
||||||
@ -192,16 +192,15 @@ public class AnimationState {
|
|||||||
else {
|
else {
|
||||||
mix = entry.mixTime / entry.mixDuration;
|
mix = entry.mixTime / entry.mixDuration;
|
||||||
if (mix > 1) mix = 1;
|
if (mix > 1) mix = 1;
|
||||||
mix *= alpha;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var events:Vector.<Event> = mix < from.eventThreshold ? this.events : null;
|
var events:Vector.<Event> = mix < from.eventThreshold ? this.events : null;
|
||||||
var attachments:Boolean = mix < from.attachmentThreshold, drawOrder:Boolean = mix < from.drawOrderThreshold;
|
var attachments:Boolean = mix < from.attachmentThreshold, drawOrder:Boolean = mix < from.drawOrderThreshold;
|
||||||
var animationLast:Number = from.animationLast, animationTime:Number = from.getAnimationTime();
|
var animationLast:Number = from.animationLast, animationTime:Number = from.getAnimationTime();
|
||||||
alpha = from.alpha * (1 - mix);
|
|
||||||
var timelineCount:int = from.animation.timelines.length;
|
var timelineCount:int = from.animation.timelines.length;
|
||||||
var timelines:Vector.<Timeline> = from.animation.timelines;
|
var timelines:Vector.<Timeline> = from.animation.timelines;
|
||||||
var timelinesFirst:Vector.<Boolean> = from.timelinesFirst;
|
var timelinesFirst:Vector.<Boolean> = from.timelinesFirst;
|
||||||
|
var alpha:Number = from.alpha * entry.mixAlpha * (1 - mix);
|
||||||
|
|
||||||
var firstFrame:Boolean = from.timelinesRotation.length == 0;
|
var firstFrame:Boolean = from.timelinesRotation.length == 0;
|
||||||
if (firstFrame) from.timelinesRotation.length = timelineCount << 1;
|
if (firstFrame) from.timelinesRotation.length = timelineCount << 1;
|
||||||
@ -368,8 +367,8 @@ public class AnimationState {
|
|||||||
|
|
||||||
from.timelinesRotation.length = 0;
|
from.timelinesRotation.length = 0;
|
||||||
|
|
||||||
// If not completely mixed in, set alpha so mixing out happens from current mix to zero.
|
// If not completely mixed in, set mixAlpha so mixing out happens from current mix to zero.
|
||||||
if (from.mixingFrom != null) from.alpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
if (from.mixingFrom != null) current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
queue.start(current);
|
queue.start(current);
|
||||||
@ -490,6 +489,7 @@ public class AnimationState {
|
|||||||
entry.timeScale = 1;
|
entry.timeScale = 1;
|
||||||
|
|
||||||
entry.alpha = 1;
|
entry.alpha = 1;
|
||||||
|
entry.mixAlpha = 1;
|
||||||
entry.mixTime = 0;
|
entry.mixTime = 0;
|
||||||
entry.mixDuration = last == null ? 0 : data.getMix(last.animation, animation);
|
entry.mixDuration = last == null ? 0 : data.getMix(last.animation, animation);
|
||||||
return entry;
|
return entry;
|
||||||
|
|||||||
@ -71,5 +71,9 @@ public class TrackEntry implements Poolable {
|
|||||||
timelinesFirst.length = 0;
|
timelinesFirst.length = 0;
|
||||||
timelinesRotation.length = 0;
|
timelinesRotation.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function resetRotationDirection ():void {
|
||||||
|
timelinesRotation.length = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user