mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[csharp][unity] Cleanup refactoring of TranslateTimeline.Evaluate code, see previous commit 91f7969c. See #1676.
This commit is contained in:
parent
f4021177f9
commit
cd8064774f
@ -546,7 +546,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float x, y;
|
float x, y;
|
||||||
EvaluateCurve(out x, out y, time); // note: reference implementation has code inlined
|
GetCurveValue(out x, out y, time); // note: reference implementation has code inlined
|
||||||
|
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case MixBlend.Setup:
|
case MixBlend.Setup:
|
||||||
@ -565,7 +565,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void EvaluateCurve (out float x, out float y, float time) {
|
public void GetCurveValue (out float x, out float y, float time) {
|
||||||
int i = Search(frames, time, ENTRIES), curveType = (int)curves[i / ENTRIES];
|
int i = Search(frames, time, ENTRIES), curveType = (int)curves[i / ENTRIES];
|
||||||
switch (curveType) {
|
switch (curveType) {
|
||||||
case LINEAR:
|
case LINEAR:
|
||||||
@ -586,27 +586,6 @@ namespace Spine {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Evaluates the resulting value of a TranslateTimeline at a given time.
|
|
||||||
/// If no SkeletonData is given, values are returned as difference to setup pose
|
|
||||||
/// instead of absolute values.</summary>
|
|
||||||
public void Evaluate (out float outX, out float outY, float time, SkeletonData skeletonData) {
|
|
||||||
outX = outY = 0;
|
|
||||||
if (time < frames[0]) return;
|
|
||||||
|
|
||||||
float x, y;
|
|
||||||
EvaluateCurve(out x, out y, time);
|
|
||||||
|
|
||||||
if (skeletonData == null) {
|
|
||||||
outX = x;
|
|
||||||
outY = y;
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
var boneData = skeletonData.bones.Items[boneIndex];
|
|
||||||
outX = x + boneData.x;
|
|
||||||
outY = y + boneData.y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Changes a bone's local <see cref"Bone.X"/>.</summary>
|
/// <summary>Changes a bone's local <see cref"Bone.X"/>.</summary>
|
||||||
|
|||||||
@ -39,9 +39,17 @@ namespace Spine.Unity.AnimationTools {
|
|||||||
/// If no SkeletonData is given, values are returned as difference to setup pose
|
/// If no SkeletonData is given, values are returned as difference to setup pose
|
||||||
/// instead of absolute values.</summary>
|
/// instead of absolute values.</summary>
|
||||||
public static Vector2 Evaluate (this TranslateTimeline timeline, float time, SkeletonData skeletonData = null) {
|
public static Vector2 Evaluate (this TranslateTimeline timeline, float time, SkeletonData skeletonData = null) {
|
||||||
|
if (time < timeline.Frames[0]) return Vector2.zero;
|
||||||
|
|
||||||
float x, y;
|
float x, y;
|
||||||
timeline.Evaluate(out x, out y, time, skeletonData);
|
timeline.GetCurveValue(out x, out y, time);
|
||||||
return new Vector2(x, y);
|
|
||||||
|
if (skeletonData == null) {
|
||||||
|
return new Vector2(x, y);
|
||||||
|
} else {
|
||||||
|
BoneData boneData = skeletonData.Bones.Items[timeline.BoneIndex];
|
||||||
|
return new Vector2(boneData.X + x, boneData.Y + y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Gets the translate timeline for a given boneIndex.
|
/// <summary>Gets the translate timeline for a given boneIndex.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user