|
@@ -38,6 +38,7 @@ namespace Spine {
|
|
internal ExposedList<IkConstraint> ikConstraints;
|
|
internal ExposedList<IkConstraint> ikConstraints;
|
|
internal ExposedList<TransformConstraint> transformConstraints;
|
|
internal ExposedList<TransformConstraint> transformConstraints;
|
|
internal ExposedList<PathConstraint> pathConstraints;
|
|
internal ExposedList<PathConstraint> pathConstraints;
|
|
|
|
+ internal ExposedList<SpringConstraint> springConstraints;
|
|
internal ExposedList<IUpdatable> updateCache = new ExposedList<IUpdatable>();
|
|
internal 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;
|
|
@@ -51,6 +52,7 @@ namespace Spine {
|
|
public ExposedList<Slot> DrawOrder { get { return drawOrder; } }
|
|
public ExposedList<Slot> DrawOrder { get { return drawOrder; } }
|
|
public ExposedList<IkConstraint> IkConstraints { get { return ikConstraints; } }
|
|
public ExposedList<IkConstraint> IkConstraints { get { return ikConstraints; } }
|
|
public ExposedList<PathConstraint> PathConstraints { get { return pathConstraints; } }
|
|
public ExposedList<PathConstraint> PathConstraints { get { return pathConstraints; } }
|
|
|
|
+ public ExposedList<SpringConstraint> SpringConstraints { get { return springConstraints; } }
|
|
public ExposedList<TransformConstraint> TransformConstraints { get { return transformConstraints; } }
|
|
public ExposedList<TransformConstraint> TransformConstraints { get { return transformConstraints; } }
|
|
|
|
|
|
public Skin Skin {
|
|
public Skin Skin {
|
|
@@ -118,6 +120,10 @@ namespace Spine {
|
|
foreach (PathConstraintData pathConstraintData in data.pathConstraints)
|
|
foreach (PathConstraintData pathConstraintData in data.pathConstraints)
|
|
pathConstraints.Add(new PathConstraint(pathConstraintData, this));
|
|
pathConstraints.Add(new PathConstraint(pathConstraintData, this));
|
|
|
|
|
|
|
|
+ springConstraints = new ExposedList<SpringConstraint>(data.springConstraints.Count);
|
|
|
|
+ foreach (SpringConstraintData springConstraintData in data.springConstraints)
|
|
|
|
+ springConstraints.Add(new SpringConstraint(springConstraintData, this));
|
|
|
|
+
|
|
UpdateCache();
|
|
UpdateCache();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -163,6 +169,10 @@ namespace Spine {
|
|
foreach (PathConstraint pathConstraint in skeleton.pathConstraints)
|
|
foreach (PathConstraint pathConstraint in skeleton.pathConstraints)
|
|
pathConstraints.Add(new PathConstraint(pathConstraint, this));
|
|
pathConstraints.Add(new PathConstraint(pathConstraint, this));
|
|
|
|
|
|
|
|
+ springConstraints = new ExposedList<SpringConstraint>(skeleton.springConstraints.Count);
|
|
|
|
+ foreach (SpringConstraint springConstraint in skeleton.springConstraints)
|
|
|
|
+ springConstraints.Add(new SpringConstraint(springConstraint, this));
|
|
|
|
+
|
|
skin = skeleton.skin;
|
|
skin = skeleton.skin;
|
|
r = skeleton.r;
|
|
r = skeleton.r;
|
|
g = skeleton.g;
|
|
g = skeleton.g;
|
|
@@ -199,11 +209,13 @@ namespace Spine {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- int ikCount = this.ikConstraints.Count, transformCount = this.transformConstraints.Count, pathCount = this.pathConstraints.Count;
|
|
|
|
|
|
+ int ikCount = this.ikConstraints.Count, transformCount = this.transformConstraints.Count, pathCount = this.pathConstraints.Count,
|
|
|
|
+ springCount = this.springConstraints.Count;
|
|
IkConstraint[] ikConstraints = this.ikConstraints.Items;
|
|
IkConstraint[] ikConstraints = this.ikConstraints.Items;
|
|
TransformConstraint[] transformConstraints = this.transformConstraints.Items;
|
|
TransformConstraint[] transformConstraints = this.transformConstraints.Items;
|
|
PathConstraint[] pathConstraints = this.pathConstraints.Items;
|
|
PathConstraint[] pathConstraints = this.pathConstraints.Items;
|
|
- int constraintCount = ikCount + transformCount + pathCount;
|
|
|
|
|
|
+ SpringConstraint[] springConstraints = this.springConstraints.Items;
|
|
|
|
+ int constraintCount = ikCount + transformCount + pathCount + springCount;
|
|
for (int i = 0; i < constraintCount; i++) {
|
|
for (int i = 0; i < constraintCount; i++) {
|
|
for (int ii = 0; ii < ikCount; ii++) {
|
|
for (int ii = 0; ii < ikCount; ii++) {
|
|
IkConstraint constraint = ikConstraints[ii];
|
|
IkConstraint constraint = ikConstraints[ii];
|
|
@@ -226,6 +238,13 @@ namespace Spine {
|
|
goto continue_outer;
|
|
goto continue_outer;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ for (int ii = 0; ii < springCount; ii++) {
|
|
|
|
+ SpringConstraint constraint = springConstraints[ii];
|
|
|
|
+ if (constraint.data.order == i) {
|
|
|
|
+ SortSpringConstraint(constraint);
|
|
|
|
+ goto continue_outer;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
continue_outer: { }
|
|
continue_outer: { }
|
|
}
|
|
}
|
|
|
|
|
|
@@ -336,6 +355,23 @@ namespace Spine {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void SortSpringConstraint (SpringConstraint constraint) {
|
|
|
|
+ constraint.active = !constraint.data.skinRequired || (skin != null && skin.constraints.Contains(constraint.data));
|
|
|
|
+ if (!constraint.active) return;
|
|
|
|
+
|
|
|
|
+ Object[] constrained = constraint.bones.Items;
|
|
|
|
+ int boneCount = constraint.bones.Count;
|
|
|
|
+ for (int i = 0; i < boneCount; i++)
|
|
|
|
+ SortBone((Bone)constrained[i]);
|
|
|
|
+
|
|
|
|
+ updateCache.Add(constraint);
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < boneCount; i++)
|
|
|
|
+ SortReset(((Bone)constrained[i]).children);
|
|
|
|
+ for (int i = 0; i < boneCount; i++)
|
|
|
|
+ ((Bone)constrained[i]).sorted = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
private void SortBone (Bone bone) {
|
|
private void SortBone (Bone bone) {
|
|
if (bone.sorted) return;
|
|
if (bone.sorted) return;
|
|
Bone parent = bone.parent;
|
|
Bone parent = bone.parent;
|
|
@@ -454,6 +490,20 @@ namespace Spine {
|
|
constraint.mixX = data.mixX;
|
|
constraint.mixX = data.mixX;
|
|
constraint.mixY = data.mixY;
|
|
constraint.mixY = data.mixY;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ SpringConstraint[] springConstraints = this.springConstraints.Items;
|
|
|
|
+ for (int i = 0, n = this.springConstraints.Count; i < n; i++) {
|
|
|
|
+ SpringConstraint constraint = springConstraints[i];
|
|
|
|
+ SpringConstraintData data = constraint.data;
|
|
|
|
+ constraint.mix = data.mix;
|
|
|
|
+ constraint.friction = data.friction;
|
|
|
|
+ constraint.gravity = data.gravity;
|
|
|
|
+ constraint.wind = data.wind;
|
|
|
|
+ constraint.stiffness = data.stiffness;
|
|
|
|
+ constraint.damping = data.damping;
|
|
|
|
+ constraint.rope = data.rope;
|
|
|
|
+ constraint.stretch = data.stretch;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
public void SetSlotsToSetupPose () {
|
|
public void SetSlotsToSetupPose () {
|
|
@@ -607,6 +657,19 @@ namespace Spine {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>Finds a spring constraint by comparing each spring constraint's name. It is more efficient to cache the results of this
|
|
|
|
+ /// method than to call it repeatedly.</summary>
|
|
|
|
+ /// <returns>May be null.</returns>
|
|
|
|
+ public SpringConstraint FindSpringConstraint (String constraintName) {
|
|
|
|
+ if (constraintName == null) throw new ArgumentNullException("constraintName", "constraintName cannot be null.");
|
|
|
|
+ SpringConstraint[] springConstraints = this.springConstraints.Items;
|
|
|
|
+ for (int i = 0, n = this.springConstraints.Count; i < n; i++) {
|
|
|
|
+ SpringConstraint constraint = springConstraints[i];
|
|
|
|
+ if (constraint.data.name.Equals(constraintName)) return constraint;
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>Returns the axis aligned bounding box (AABB) of the region and mesh attachments for the current pose.</summary>
|
|
/// <summary>Returns the axis aligned bounding box (AABB) of the region and mesh attachments for the current pose.</summary>
|
|
/// <param name="x">The horizontal distance between the skeleton origin and the left side of the AABB.</param>
|
|
/// <param name="x">The horizontal distance between the skeleton origin and the left side of the AABB.</param>
|
|
/// <param name="y">The vertical distance between the skeleton origin and the bottom side of the AABB.</param>
|
|
/// <param name="y">The vertical distance between the skeleton origin and the bottom side of the AABB.</param>
|