Merge pull request #482 from LostPolygon/animator-fix

[Spine-Unity] Fix occasional broken frame at the moment node transition happened
This commit is contained in:
John 2015-12-15 16:15:28 +08:00
commit c28d6442ff

View File

@ -102,7 +102,8 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation {
if (mode == MixMode.AlwaysMix) { if (mode == MixMode.AlwaysMix) {
//always use Mix instead of Applying the first non-zero weighted clip //always use Mix instead of Applying the first non-zero weighted clip
foreach (var info in clipInfo) { for (int c = 0; c < clipInfo.Length; c++) {
var info = clipInfo[c];
float weight = info.weight * layerWeight; float weight = info.weight * layerWeight;
if (weight == 0) if (weight == 0)
continue; continue;
@ -111,7 +112,9 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation {
animationTable[GetAnimationClipNameHashCode(info.clip)].Mix(skeleton, Mathf.Max(0, time - deltaTime), time, stateInfo.loop, null, weight); animationTable[GetAnimationClipNameHashCode(info.clip)].Mix(skeleton, Mathf.Max(0, time - deltaTime), time, stateInfo.loop, null, weight);
} }
foreach (var info in nextClipInfo) { if (nextStateInfo.fullPathHash != 0) {
for (int c = 0; c < nextClipInfo.Length; c++) {
var info = nextClipInfo[c];
float weight = info.weight * layerWeight; float weight = info.weight * layerWeight;
if (weight == 0) if (weight == 0)
continue; continue;
@ -119,6 +122,7 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation {
float time = nextStateInfo.normalizedTime * info.clip.length; float time = nextStateInfo.normalizedTime * info.clip.length;
animationTable[GetAnimationClipNameHashCode(info.clip)].Mix(skeleton, Mathf.Max(0, time - deltaTime), time, nextStateInfo.loop, null, weight); animationTable[GetAnimationClipNameHashCode(info.clip)].Mix(skeleton, Mathf.Max(0, time - deltaTime), time, nextStateInfo.loop, null, weight);
} }
}
} else if (mode >= MixMode.MixNext) { } else if (mode >= MixMode.MixNext) {
//apply first non-zero weighted clip //apply first non-zero weighted clip
int c = 0; int c = 0;
@ -147,6 +151,7 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation {
c = 0; c = 0;
if (nextStateInfo.fullPathHash != 0) {
//apply next clip directly instead of mixing (ie: no crossfade, ignores mecanim transition weights) //apply next clip directly instead of mixing (ie: no crossfade, ignores mecanim transition weights)
if (mode == MixMode.SpineStyle) { if (mode == MixMode.SpineStyle) {
for (; c < nextClipInfo.Length; c++) { for (; c < nextClipInfo.Length; c++) {
@ -173,6 +178,7 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation {
} }
} }
} }
}
if (_UpdateLocal != null) if (_UpdateLocal != null)
_UpdateLocal(this); _UpdateLocal(this);