mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-26 11:41:23 +08:00
Fixed whitespace.
C# has such bad tools. :(
This commit is contained in:
parent
337e6c284f
commit
03606717a7
@ -452,7 +452,7 @@ namespace Spine {
|
|||||||
|
|
||||||
String attachmentName = attachmentNames[frameIndex];
|
String attachmentName = attachmentNames[frameIndex];
|
||||||
skeleton.slots.Items[slotIndex].Attachment =
|
skeleton.slots.Items[slotIndex].Attachment =
|
||||||
attachmentName == null ? null : skeleton.GetAttachment(slotIndex, attachmentName);
|
attachmentName == null ? null : skeleton.GetAttachment(slotIndex, attachmentName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine {
|
||||||
/// <summary>Attachment that displays a texture region using a mesh which can be deformed by bones.</summary>
|
/// <summary>Attachment that displays a texture region using a mesh which can be deformed by bones.</summary>
|
||||||
public class WeightedMeshAttachment : Attachment {
|
public class WeightedMeshAttachment : Attachment {
|
||||||
internal int[] bones;
|
internal int[] bones;
|
||||||
internal float[] weights, uvs, regionUVs;
|
internal float[] weights, uvs, regionUVs;
|
||||||
|
|||||||
@ -33,7 +33,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine {
|
||||||
public class Bone : IUpdatable {
|
public class Bone : IUpdatable {
|
||||||
static public bool yDown;
|
static public bool yDown;
|
||||||
|
|
||||||
internal BoneData data;
|
internal BoneData data;
|
||||||
@ -123,44 +123,44 @@ namespace Spine {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
|
float pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
|
||||||
worldX = pa * x + pb * y + parent.worldX;
|
worldX = pa * x + pb * y + parent.worldX;
|
||||||
worldY = pc * x + pd * y + parent.worldY;
|
worldY = pc * x + pd * y + parent.worldY;
|
||||||
worldSignX = parent.worldSignX * Math.Sign(scaleX);
|
worldSignX = parent.worldSignX * Math.Sign(scaleX);
|
||||||
worldSignY = parent.worldSignY * Math.Sign(scaleY);
|
worldSignY = parent.worldSignY * Math.Sign(scaleY);
|
||||||
|
|
||||||
if (data.inheritRotation && data.inheritScale) {
|
if (data.inheritRotation && data.inheritScale) {
|
||||||
a = pa * la + pb * lc;
|
a = pa * la + pb * lc;
|
||||||
b = pa * lb + pb * ld;
|
b = pa * lb + pb * ld;
|
||||||
c = pc * la + pd * lc;
|
c = pc * la + pd * lc;
|
||||||
d = pc * lb + pd * ld;
|
d = pc * lb + pd * ld;
|
||||||
} else if (data.inheritRotation) { // No scale inheritance.
|
} else if (data.inheritRotation) { // No scale inheritance.
|
||||||
Bone p = parent;
|
Bone p = parent;
|
||||||
pa = 1;
|
pa = 1;
|
||||||
pb = 0;
|
pb = 0;
|
||||||
pc = 0;
|
pc = 0;
|
||||||
pd = 1;
|
pd = 1;
|
||||||
while (p != null) {
|
while (p != null) {
|
||||||
cos = MathUtils.CosDeg(p.appliedRotation);
|
cos = MathUtils.CosDeg(p.appliedRotation);
|
||||||
sin = MathUtils.SinDeg(p.appliedRotation);
|
sin = MathUtils.SinDeg(p.appliedRotation);
|
||||||
float ta = pa * cos + pb * sin;
|
float ta = pa * cos + pb * sin;
|
||||||
float tb = pa * -sin + pb * cos;
|
float tb = pa * -sin + pb * cos;
|
||||||
float tc = pc * cos + pd * sin;
|
float tc = pc * cos + pd * sin;
|
||||||
float td = pc * -sin + pd * cos;
|
float td = pc * -sin + pd * cos;
|
||||||
pa = ta;
|
pa = ta;
|
||||||
pb = tb;
|
pb = tb;
|
||||||
pc = tc;
|
pc = tc;
|
||||||
pd = td;
|
pd = td;
|
||||||
p = p.parent;
|
p = p.parent;
|
||||||
}
|
}
|
||||||
if (yDown) {
|
if (yDown) {
|
||||||
pb = -pb;
|
pb = -pb;
|
||||||
pd = -pd;
|
pd = -pd;
|
||||||
}
|
}
|
||||||
a = pa * la + pb * lc;
|
a = pa * la + pb * lc;
|
||||||
b = pa * lb + pb * ld;
|
b = pa * lb + pb * ld;
|
||||||
c = pc * la + pd * lc;
|
c = pc * la + pd * lc;
|
||||||
d = pc * lb + pd * ld;
|
d = pc * lb + pd * ld;
|
||||||
if (skeleton.flipX) {
|
if (skeleton.flipX) {
|
||||||
a = -a;
|
a = -a;
|
||||||
b = -b;
|
b = -b;
|
||||||
@ -169,45 +169,45 @@ namespace Spine {
|
|||||||
c = -c;
|
c = -c;
|
||||||
d = -d;
|
d = -d;
|
||||||
}
|
}
|
||||||
} else if (data.inheritScale) { // No rotation inheritance.
|
} else if (data.inheritScale) { // No rotation inheritance.
|
||||||
Bone p = parent;
|
Bone p = parent;
|
||||||
pa = 1;
|
pa = 1;
|
||||||
pb = 0;
|
pb = 0;
|
||||||
pc = 0;
|
pc = 0;
|
||||||
pd = 1;
|
pd = 1;
|
||||||
while (p != null) {
|
while (p != null) {
|
||||||
float r = p.rotation;
|
float r = p.rotation;
|
||||||
cos = MathUtils.CosDeg(r);
|
cos = MathUtils.CosDeg(r);
|
||||||
sin = MathUtils.SinDeg(r);
|
sin = MathUtils.SinDeg(r);
|
||||||
float psx = p.appliedScaleX, psy = p.appliedScaleY;
|
float psx = p.appliedScaleX, psy = p.appliedScaleY;
|
||||||
float za = cos * psx, zb = -sin * psy, zc = sin * psx, zd = cos * psy;
|
float za = cos * psx, zb = -sin * psy, zc = sin * psx, zd = cos * psy;
|
||||||
float temp = pa * za + pb * zc;
|
float temp = pa * za + pb * zc;
|
||||||
pb = pa * zb + pb * zd;
|
pb = pa * zb + pb * zd;
|
||||||
pa = temp;
|
pa = temp;
|
||||||
temp = pc * za + pd * zc;
|
temp = pc * za + pd * zc;
|
||||||
pd = pc * zb + pd * zd;
|
pd = pc * zb + pd * zd;
|
||||||
pc = temp;
|
pc = temp;
|
||||||
|
|
||||||
if (psx < 0) r = -r;
|
if (psx < 0) r = -r;
|
||||||
cos = MathUtils.CosDeg(-r);
|
cos = MathUtils.CosDeg(-r);
|
||||||
sin = MathUtils.SinDeg(-r);
|
sin = MathUtils.SinDeg(-r);
|
||||||
temp = pa * cos + pb * sin;
|
temp = pa * cos + pb * sin;
|
||||||
pb = pa * -sin + pb * cos;
|
pb = pa * -sin + pb * cos;
|
||||||
pa = temp;
|
pa = temp;
|
||||||
temp = pc * cos + pd * sin;
|
temp = pc * cos + pd * sin;
|
||||||
pd = pc * -sin + pd * cos;
|
pd = pc * -sin + pd * cos;
|
||||||
pc = temp;
|
pc = temp;
|
||||||
|
|
||||||
p = p.parent;
|
p = p.parent;
|
||||||
}
|
}
|
||||||
if (yDown) {
|
if (yDown) {
|
||||||
pb = -pb;
|
pb = -pb;
|
||||||
pd = -pd;
|
pd = -pd;
|
||||||
}
|
}
|
||||||
a = pa * la + pb * lc;
|
a = pa * la + pb * lc;
|
||||||
b = pa * lb + pb * ld;
|
b = pa * lb + pb * ld;
|
||||||
c = pc * la + pd * lc;
|
c = pc * la + pd * lc;
|
||||||
d = pc * lb + pd * ld;
|
d = pc * lb + pd * ld;
|
||||||
if (skeleton.flipX) {
|
if (skeleton.flipX) {
|
||||||
a = -a;
|
a = -a;
|
||||||
b = -b;
|
b = -b;
|
||||||
@ -216,39 +216,39 @@ namespace Spine {
|
|||||||
c = -c;
|
c = -c;
|
||||||
d = -d;
|
d = -d;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
a = la;
|
a = la;
|
||||||
b = lb;
|
b = lb;
|
||||||
c = lc;
|
c = lc;
|
||||||
d = ld;
|
d = ld;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update () {
|
public void Update () {
|
||||||
UpdateWorldTransform(x, y, rotation, scaleX, scaleY);
|
UpdateWorldTransform(x, y, rotation, scaleX, scaleY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetToSetupPose () {
|
public void SetToSetupPose () {
|
||||||
BoneData data = this.data;
|
BoneData data = this.data;
|
||||||
x = data.x;
|
x = data.x;
|
||||||
y = data.y;
|
y = data.y;
|
||||||
rotation = data.rotation;
|
rotation = data.rotation;
|
||||||
scaleX = data.scaleX;
|
scaleX = data.scaleX;
|
||||||
scaleY = data.scaleY;
|
scaleY = data.scaleY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WorldToLocal (float worldX, float worldY, out float localX, out float localY) {
|
public void WorldToLocal (float worldX, float worldY, out float localX, out float localY) {
|
||||||
float x = worldX - this.worldX, y = worldY - this.worldY;
|
float x = worldX - this.worldX, y = worldY - this.worldY;
|
||||||
float a = this.a, b = this.b, c = this.c, d = this.d;
|
float a = this.a, b = this.b, c = this.c, d = this.d;
|
||||||
float invDet = 1 / (a * d - b * c);
|
float invDet = 1 / (a * d - b * c);
|
||||||
localX = (x * a * invDet - y * b * invDet);
|
localX = (x * a * invDet - y * b * invDet);
|
||||||
localY = (y * d * invDet - x * c * invDet);
|
localY = (y * d * invDet - x * c * invDet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LocalToWorld (float localX, float localY, out float worldX, out float worldY) {
|
public void LocalToWorld (float localX, float localY, out float worldX, out float worldY) {
|
||||||
float x = localX, y = localY;
|
float x = localX, y = localY;
|
||||||
worldX = x * a + y * b + this.worldX;
|
worldX = x * a + y * b + this.worldX;
|
||||||
worldY = x * c + y * d + this.worldY;
|
worldY = x * c + y * d + this.worldY;
|
||||||
}
|
}
|
||||||
|
|
||||||
override public String ToString () {
|
override public String ToString () {
|
||||||
|
|||||||
@ -37,41 +37,41 @@ namespace Spine {
|
|||||||
public const float radDeg = 180f / PI;
|
public const float radDeg = 180f / PI;
|
||||||
public const float degRad = PI / 180;
|
public const float degRad = PI / 180;
|
||||||
|
|
||||||
const int SIN_BITS = 14; // 16KB. Adjust for accuracy.
|
const int SIN_BITS = 14; // 16KB. Adjust for accuracy.
|
||||||
const int SIN_MASK = ~(-1 << SIN_BITS);
|
const int SIN_MASK = ~(-1 << SIN_BITS);
|
||||||
const int SIN_COUNT = SIN_MASK + 1;
|
const int SIN_COUNT = SIN_MASK + 1;
|
||||||
const float radFull = PI * 2;
|
const float radFull = PI * 2;
|
||||||
const float degFull = 360;
|
const float degFull = 360;
|
||||||
const float radToIndex = SIN_COUNT / radFull;
|
const float radToIndex = SIN_COUNT / radFull;
|
||||||
const float degToIndex = SIN_COUNT / degFull;
|
const float degToIndex = SIN_COUNT / degFull;
|
||||||
static float[] sin = new float[SIN_COUNT];
|
static float[] sin = new float[SIN_COUNT];
|
||||||
|
|
||||||
static MathUtils () {
|
static MathUtils () {
|
||||||
for (int i = 0; i < SIN_COUNT; i++)
|
for (int i = 0; i < SIN_COUNT; i++)
|
||||||
sin[i] = (float)Math.Sin((i + 0.5f) / SIN_COUNT * radFull);
|
sin[i] = (float)Math.Sin((i + 0.5f) / SIN_COUNT * radFull);
|
||||||
for (int i = 0; i < 360; i += 90)
|
for (int i = 0; i < 360; i += 90)
|
||||||
sin[(int)(i * degToIndex) & SIN_MASK] = (float)Math.Sin(i * degRad);
|
sin[(int)(i * degToIndex) & SIN_MASK] = (float)Math.Sin(i * degRad);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the sine in radians from a lookup table. */
|
/** Returns the sine in radians from a lookup table. */
|
||||||
static public float Sin (float radians) {
|
static public float Sin (float radians) {
|
||||||
return sin[(int)(radians * radToIndex) & SIN_MASK];
|
return sin[(int)(radians * radToIndex) & SIN_MASK];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the cosine in radians from a lookup table. */
|
/** Returns the cosine in radians from a lookup table. */
|
||||||
static public float Cos (float radians) {
|
static public float Cos (float radians) {
|
||||||
return sin[(int)((radians + PI / 2) * radToIndex) & SIN_MASK];
|
return sin[(int)((radians + PI / 2) * radToIndex) & SIN_MASK];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the sine in radians from a lookup table. */
|
/** Returns the sine in radians from a lookup table. */
|
||||||
static public float SinDeg (float degrees) {
|
static public float SinDeg (float degrees) {
|
||||||
return sin[(int)(degrees * degToIndex) & SIN_MASK];
|
return sin[(int)(degrees * degToIndex) & SIN_MASK];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the cosine in radians from a lookup table. */
|
/** Returns the cosine in radians from a lookup table. */
|
||||||
static public float CosDeg (float degrees) {
|
static public float CosDeg (float degrees) {
|
||||||
return sin[(int)((degrees + 90) * degToIndex) & SIN_MASK];
|
return sin[(int)((degrees + 90) * degToIndex) & SIN_MASK];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Returns atan2 in radians, faster but less accurate than Math.Atan2. Average error of 0.00231 radians (0.1323
|
/// <summary>Returns atan2 in radians, faster but less accurate than Math.Atan2. Average error of 0.00231 radians (0.1323
|
||||||
/// degrees), largest error of 0.00488 radians (0.2796 degrees).</summary>
|
/// degrees), largest error of 0.00488 radians (0.2796 degrees).</summary>
|
||||||
|
|||||||
@ -39,8 +39,8 @@ namespace Spine {
|
|||||||
internal ExposedList<Slot> slots;
|
internal ExposedList<Slot> slots;
|
||||||
internal ExposedList<Slot> drawOrder;
|
internal ExposedList<Slot> drawOrder;
|
||||||
internal ExposedList<IkConstraint> ikConstraints;
|
internal ExposedList<IkConstraint> ikConstraints;
|
||||||
internal ExposedList<TransformConstraint> transformConstraints;
|
internal ExposedList<TransformConstraint> transformConstraints;
|
||||||
private ExposedList<IUpdatable> updateCache = new ExposedList<IUpdatable>();
|
private ExposedList<IUpdatable> updateCache = new ExposedList<IUpdatable>();
|
||||||
internal Skin skin;
|
internal Skin skin;
|
||||||
internal float r = 1, g = 1, b = 1, a = 1;
|
internal float r = 1, g = 1, b = 1, a = 1;
|
||||||
internal float time;
|
internal float time;
|
||||||
@ -90,13 +90,13 @@ namespace Spine {
|
|||||||
drawOrder.Add(slot);
|
drawOrder.Add(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
ikConstraints = new ExposedList<IkConstraint>(data.ikConstraints.Count);
|
ikConstraints = new ExposedList<IkConstraint>(data.ikConstraints.Count);
|
||||||
foreach (IkConstraintData ikConstraintData in data.ikConstraints)
|
foreach (IkConstraintData ikConstraintData in data.ikConstraints)
|
||||||
ikConstraints.Add(new IkConstraint(ikConstraintData, this));
|
ikConstraints.Add(new IkConstraint(ikConstraintData, this));
|
||||||
|
|
||||||
transformConstraints = new ExposedList<TransformConstraint>(data.transformConstraints.Count);
|
transformConstraints = new ExposedList<TransformConstraint>(data.transformConstraints.Count);
|
||||||
foreach (TransformConstraintData transformConstraintData in data.transformConstraints)
|
foreach (TransformConstraintData transformConstraintData in data.transformConstraints)
|
||||||
transformConstraints.Add(new TransformConstraint(transformConstraintData, this));
|
transformConstraints.Add(new TransformConstraint(transformConstraintData, this));
|
||||||
|
|
||||||
UpdateCache();
|
UpdateCache();
|
||||||
UpdateWorldTransform();
|
UpdateWorldTransform();
|
||||||
|
|||||||
@ -42,7 +42,7 @@ namespace Spine {
|
|||||||
internal ExposedList<EventData> events = new ExposedList<EventData>();
|
internal ExposedList<EventData> events = new ExposedList<EventData>();
|
||||||
internal ExposedList<Animation> animations = new ExposedList<Animation>();
|
internal ExposedList<Animation> animations = new ExposedList<Animation>();
|
||||||
internal ExposedList<IkConstraintData> ikConstraints = new ExposedList<IkConstraintData>();
|
internal ExposedList<IkConstraintData> ikConstraints = new ExposedList<IkConstraintData>();
|
||||||
internal ExposedList<TransformConstraintData> transformConstraints = new ExposedList<TransformConstraintData>();
|
internal ExposedList<TransformConstraintData> transformConstraints = new ExposedList<TransformConstraintData>();
|
||||||
internal float width, height;
|
internal float width, height;
|
||||||
internal String version, hash, imagesPath;
|
internal String version, hash, imagesPath;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user