mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-26 19:51:47 +08:00
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:
commit
c28d6442ff
@ -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,13 +112,16 @@ 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) {
|
||||||
float weight = info.weight * layerWeight;
|
for (int c = 0; c < nextClipInfo.Length; c++) {
|
||||||
if (weight == 0)
|
var info = nextClipInfo[c];
|
||||||
continue;
|
float weight = info.weight * layerWeight;
|
||||||
|
if (weight == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
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
|
||||||
@ -147,8 +151,22 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation {
|
|||||||
|
|
||||||
c = 0;
|
c = 0;
|
||||||
|
|
||||||
//apply next clip directly instead of mixing (ie: no crossfade, ignores mecanim transition weights)
|
if (nextStateInfo.fullPathHash != 0) {
|
||||||
if (mode == MixMode.SpineStyle) {
|
//apply next clip directly instead of mixing (ie: no crossfade, ignores mecanim transition weights)
|
||||||
|
if (mode == MixMode.SpineStyle) {
|
||||||
|
for (; c < nextClipInfo.Length; c++) {
|
||||||
|
var info = nextClipInfo[c];
|
||||||
|
float weight = info.weight * layerWeight;
|
||||||
|
if (weight == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
float time = nextStateInfo.normalizedTime * info.clip.length;
|
||||||
|
animationTable[GetAnimationClipNameHashCode(info.clip)].Apply(skeleton, Mathf.Max(0, time - deltaTime), time, nextStateInfo.loop, null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//mix the rest
|
||||||
for (; c < nextClipInfo.Length; c++) {
|
for (; c < nextClipInfo.Length; c++) {
|
||||||
var info = nextClipInfo[c];
|
var info = nextClipInfo[c];
|
||||||
float weight = info.weight * layerWeight;
|
float weight = info.weight * layerWeight;
|
||||||
@ -156,21 +174,9 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
float time = nextStateInfo.normalizedTime * info.clip.length;
|
float time = nextStateInfo.normalizedTime * info.clip.length;
|
||||||
animationTable[GetAnimationClipNameHashCode(info.clip)].Apply(skeleton, Mathf.Max(0, time - deltaTime), time, nextStateInfo.loop, null);
|
animationTable[GetAnimationClipNameHashCode(info.clip)].Mix(skeleton, Mathf.Max(0, time - deltaTime), time, nextStateInfo.loop, null, weight);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//mix the rest
|
|
||||||
for (; c < nextClipInfo.Length; c++) {
|
|
||||||
var info = nextClipInfo[c];
|
|
||||||
float weight = info.weight * layerWeight;
|
|
||||||
if (weight == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
float time = nextStateInfo.normalizedTime * info.clip.length;
|
|
||||||
animationTable[GetAnimationClipNameHashCode(info.clip)].Mix(skeleton, Mathf.Max(0, time - deltaTime), time, nextStateInfo.loop, null, weight);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user