mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
Merge branch '3.8-beta' of https://github.com/EsotericSoftware/spine-runtimes into 3.8-beta
This commit is contained in:
commit
942e1c722a
@ -150,7 +150,7 @@ namespace Spine {
|
||||
|
||||
Bone parent = this.parent;
|
||||
if (parent == null) { // Root bone.
|
||||
float rotationY = rotation + 90 + shearY, sx = skeleton.scaleX, sy = skeleton.scaleY;
|
||||
float rotationY = rotation + 90 + shearY, sx = skeleton.ScaleX, sy = skeleton.ScaleY;
|
||||
a = MathUtils.CosDeg(rotation + shearX) * scaleX * sx;
|
||||
b = MathUtils.CosDeg(rotationY) * scaleY * sx;
|
||||
c = MathUtils.SinDeg(rotation + shearX) * scaleX * sy;
|
||||
@ -212,15 +212,15 @@ namespace Spine {
|
||||
case TransformMode.NoScale:
|
||||
case TransformMode.NoScaleOrReflection: {
|
||||
float cos = MathUtils.CosDeg(rotation), sin = MathUtils.SinDeg(rotation);
|
||||
float za = (pa * cos + pb * sin) / skeleton.scaleX;
|
||||
float zc = (pc * cos + pd * sin) / skeleton.scaleY;
|
||||
float za = (pa * cos + pb * sin) / skeleton.ScaleX;
|
||||
float zc = (pc * cos + pd * sin) / skeleton.ScaleY;
|
||||
float s = (float)Math.Sqrt(za * za + zc * zc);
|
||||
if (s > 0.00001f) s = 1 / s;
|
||||
za *= s;
|
||||
zc *= s;
|
||||
s = (float)Math.Sqrt(za * za + zc * zc);
|
||||
if (data.transformMode == TransformMode.NoScale
|
||||
&& (pa * pd - pb * pc < 0) != (skeleton.scaleX < 0 != skeleton.scaleY < 0)) s = -s;
|
||||
&& (pa * pd - pb * pc < 0) != (skeleton.ScaleX < 0 != skeleton.ScaleY < 0)) s = -s;
|
||||
|
||||
float r = MathUtils.PI / 2 + MathUtils.Atan2(zc, za);
|
||||
float zb = MathUtils.Cos(r) * s;
|
||||
@ -237,10 +237,10 @@ namespace Spine {
|
||||
}
|
||||
}
|
||||
|
||||
a *= skeleton.scaleX;
|
||||
b *= skeleton.scaleX;
|
||||
c *= skeleton.scaleY;
|
||||
d *= skeleton.scaleY;
|
||||
a *= skeleton.ScaleX;
|
||||
b *= skeleton.ScaleX;
|
||||
c *= skeleton.ScaleY;
|
||||
d *= skeleton.ScaleY;
|
||||
}
|
||||
|
||||
public void SetToSetupPose () {
|
||||
|
||||
@ -44,7 +44,7 @@ namespace Spine {
|
||||
internal Skin skin;
|
||||
internal float r = 1, g = 1, b = 1, a = 1;
|
||||
internal float time;
|
||||
internal float scaleX = 1, scaleY = 1;
|
||||
private float scaleX = 1, scaleY = 1;
|
||||
internal float x, y;
|
||||
|
||||
public SkeletonData Data { get { return data; } }
|
||||
@ -64,7 +64,7 @@ namespace Spine {
|
||||
public float X { get { return x; } set { x = value; } }
|
||||
public float Y { get { return y; } set { y = value; } }
|
||||
public float ScaleX { get { return scaleX; } set { scaleX = value; } }
|
||||
public float ScaleY { get { return scaleY; } set { scaleY = value; } }
|
||||
public float ScaleY { get { return scaleY * (Bone.yDown ? -1 : 1); } set { scaleY = value; } }
|
||||
|
||||
[Obsolete("Use ScaleX instead. FlipX is when ScaleX is negative.")]
|
||||
public bool FlipX { get { return scaleX < 0; } set { scaleX = value ? -1f : 1f; } }
|
||||
|
||||
@ -77,8 +77,7 @@ namespace Spine {
|
||||
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
|
||||
state = new AnimationState(stateData);
|
||||
|
||||
// Flip the skeleton on the y-axis and center it within the viewport
|
||||
skeleton.ScaleY = -1;
|
||||
// Center within the viewport
|
||||
skeleton.X = game.GraphicsDevice.Viewport.Width / 2;
|
||||
skeleton.Y = game.GraphicsDevice.Viewport.Height;
|
||||
|
||||
@ -135,7 +134,6 @@ namespace Spine {
|
||||
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
|
||||
state = new AnimationState(stateData);
|
||||
|
||||
skeleton.ScaleY = -1;
|
||||
skeleton.X = game.GraphicsDevice.Viewport.Width / 2 + 200;
|
||||
skeleton.Y = game.GraphicsDevice.Viewport.Height;
|
||||
|
||||
@ -182,7 +180,6 @@ namespace Spine {
|
||||
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
|
||||
state = new AnimationState(stateData);
|
||||
|
||||
skeleton.ScaleY = -1;
|
||||
skeleton.X = game.GraphicsDevice.Viewport.Width / 2;
|
||||
skeleton.Y = game.GraphicsDevice.Viewport.Height;
|
||||
|
||||
@ -237,7 +234,6 @@ namespace Spine {
|
||||
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
|
||||
state = new AnimationState(stateData);
|
||||
|
||||
skeleton.ScaleY = -1;
|
||||
skeleton.X = game.GraphicsDevice.Viewport.Width / 2;
|
||||
skeleton.Y = game.GraphicsDevice.Viewport.Height;
|
||||
|
||||
|
||||
@ -177,7 +177,7 @@ namespace Spine.Unity {
|
||||
}
|
||||
|
||||
Vector3 localScale = followLocalScale ? new Vector3(bone.scaleX, bone.scaleY, 1f) : new Vector3(1f, 1f, 1f);
|
||||
if (followSkeletonFlip) localScale.y *= Mathf.Sign(bone.skeleton.scaleX * bone.skeleton.scaleY);
|
||||
if (followSkeletonFlip) localScale.y *= Mathf.Sign(bone.skeleton.ScaleX * bone.skeleton.ScaleY);
|
||||
thisTransform.localScale = localScale;
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ namespace Spine.Unity {
|
||||
|
||||
if (followSkeletonFlip) {
|
||||
Vector3 localScale = thisTransform.localScale;
|
||||
localScale.y = Mathf.Abs(localScale.y) * Mathf.Sign(bone.skeleton.scaleX * bone.skeleton.scaleY);
|
||||
localScale.y = Mathf.Abs(localScale.y) * Mathf.Sign(bone.skeleton.ScaleX * bone.skeleton.ScaleY);
|
||||
thisTransform.localScale = localScale;
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,8 +291,8 @@ namespace Spine.Unity {
|
||||
rendererBuffers.Initialize();
|
||||
|
||||
skeleton = new Skeleton(skeletonData) {
|
||||
scaleX = initialFlipX ? -1 : 1,
|
||||
scaleY = initialFlipY ? -1 : 1
|
||||
ScaleX = initialFlipX ? -1 : 1,
|
||||
ScaleY = initialFlipY ? -1 : 1
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(initialSkinName) && !string.Equals(initialSkinName, "default", System.StringComparison.Ordinal))
|
||||
|
||||
@ -159,7 +159,7 @@ namespace Spine.Unity {
|
||||
}
|
||||
|
||||
Vector3 localScale = followLocalScale ? new Vector3(bone.scaleX, bone.scaleY, 1f) : new Vector3(1f, 1f, 1f);
|
||||
if (followSkeletonFlip) localScale.y *= Mathf.Sign(bone.skeleton.scaleX * bone.skeleton.scaleY);
|
||||
if (followSkeletonFlip) localScale.y *= Mathf.Sign(bone.skeleton.ScaleX * bone.skeleton.ScaleY);
|
||||
thisTransform.localScale = localScale;
|
||||
}
|
||||
|
||||
|
||||
@ -89,8 +89,8 @@ namespace Spine.Unity {
|
||||
|
||||
// Only provide visual feedback to inspector changes in Unity Editor Edit mode.
|
||||
if (!Application.isPlaying) {
|
||||
skeleton.scaleX = this.initialFlipX ? -1 : 1;
|
||||
skeleton.scaleY = this.initialFlipY ? -1 : 1;
|
||||
skeleton.ScaleX = this.initialFlipX ? -1 : 1;
|
||||
skeleton.ScaleY = this.initialFlipY ? -1 : 1;
|
||||
|
||||
state.ClearTrack(0);
|
||||
skeleton.SetToSetupPose();
|
||||
@ -267,8 +267,8 @@ namespace Spine.Unity {
|
||||
}
|
||||
|
||||
this.skeleton = new Skeleton(skeletonData) {
|
||||
scaleX = this.initialFlipX ? -1 : 1,
|
||||
scaleY = this.initialFlipY ? -1 : 1
|
||||
ScaleX = this.initialFlipX ? -1 : 1,
|
||||
ScaleY = this.initialFlipY ? -1 : 1
|
||||
};
|
||||
|
||||
meshBuffers = new DoubleBuffered<MeshRendererBuffers.SmartMesh>();
|
||||
|
||||
@ -82,14 +82,14 @@ namespace Spine.Unity.Playables {
|
||||
}
|
||||
|
||||
if (currentInputs != 1 && 1f - totalWeight > greatestWeight) {
|
||||
skeleton.scaleX = originalScaleX;
|
||||
skeleton.scaleY = originalScaleY;
|
||||
skeleton.ScaleX = originalScaleX;
|
||||
skeleton.ScaleY = originalScaleY;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSkeletonScaleFromFlip (Skeleton skeleton, bool flipX, bool flipY) {
|
||||
skeleton.scaleX = flipX ? -baseScaleX : baseScaleX;
|
||||
skeleton.scaleY = flipY ? -baseScaleY : baseScaleY;
|
||||
skeleton.ScaleX = flipX ? -baseScaleX : baseScaleX;
|
||||
skeleton.ScaleY = flipY ? -baseScaleY : baseScaleY;
|
||||
}
|
||||
|
||||
public override void OnGraphStop (Playable playable) {
|
||||
@ -99,8 +99,8 @@ namespace Spine.Unity.Playables {
|
||||
return;
|
||||
|
||||
var skeleton = playableHandle.Skeleton;
|
||||
skeleton.scaleX = originalScaleX;
|
||||
skeleton.scaleY = originalScaleY;
|
||||
skeleton.ScaleX = originalScaleX;
|
||||
skeleton.ScaleY = originalScaleY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -100,8 +100,8 @@ namespace Spine.Unity {
|
||||
#region Skeleton
|
||||
/// <summary>Sets the Skeleton's local scale using a UnityEngine.Vector2. If only individual components need to be set, set Skeleton.ScaleX or Skeleton.ScaleY.</summary>
|
||||
public static void SetLocalScale (this Skeleton skeleton, Vector2 scale) {
|
||||
skeleton.scaleX = scale.x;
|
||||
skeleton.scaleY = scale.y;
|
||||
skeleton.ScaleX = scale.x;
|
||||
skeleton.ScaleY = scale.y;
|
||||
}
|
||||
|
||||
/// <summary>Gets the internal bone matrix as a Unity bonespace-to-skeletonspace transformation matrix.</summary>
|
||||
@ -171,7 +171,7 @@ namespace Spine.Unity {
|
||||
|
||||
/// <summary>Returns the Skeleton's local scale as a UnityEngine.Vector2. If only individual components are needed, use Skeleton.ScaleX or Skeleton.ScaleY.</summary>
|
||||
public static Vector2 GetLocalScale (this Skeleton skeleton) {
|
||||
return new Vector2(skeleton.scaleX, skeleton.scaleY);
|
||||
return new Vector2(skeleton.ScaleX, skeleton.ScaleY);
|
||||
}
|
||||
|
||||
/// <summary>Calculates a 2x2 Transformation Matrix that can convert a skeleton-space position to a bone-local position.</summary>
|
||||
|
||||
@ -128,7 +128,7 @@ namespace Spine.Unity {
|
||||
void Update () {
|
||||
var skeleton = skeletonRenderer.skeleton;
|
||||
if (skeleton != null && boneRoot != null) {
|
||||
boneRoot.localScale = new Vector3(skeleton.scaleX, skeleton.scaleY, 1f);
|
||||
boneRoot.localScale = new Vector3(skeleton.ScaleX, skeleton.ScaleY, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -121,7 +121,7 @@ namespace Spine.Unity {
|
||||
}
|
||||
|
||||
var thisTransform = cachedTransform;
|
||||
float skeletonFlipRotation = Mathf.Sign(skeleton.scaleX * skeleton.scaleY);
|
||||
float skeletonFlipRotation = Mathf.Sign(skeleton.ScaleX * skeleton.ScaleY);
|
||||
if (mode == Mode.Follow) {
|
||||
switch (phase) {
|
||||
case UpdatePhase.Local:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user