[as3] Ported last minute AnimationState changes

This commit is contained in:
badlogic 2016-11-02 11:12:46 +01:00
parent a05ee4130f
commit ab0ff1d963
8 changed files with 22 additions and 11 deletions

View File

@ -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) {

View File

@ -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 {

View File

@ -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);
} }
} }

View File

@ -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;

View File

@ -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;
}
} }
} }