mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
Fixed constraint copy constructors references the wrong bones.
ref #2511
This commit is contained in:
parent
c65f73e873
commit
cb4873702d
@ -54,25 +54,24 @@ public class IkConstraint implements Updatable {
|
||||
if (data == null) throw new IllegalArgumentException("data cannot be null.");
|
||||
if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");
|
||||
this.data = data;
|
||||
mix = data.mix;
|
||||
softness = data.softness;
|
||||
bendDirection = data.bendDirection;
|
||||
compress = data.compress;
|
||||
stretch = data.stretch;
|
||||
|
||||
bones = new Array(data.bones.size);
|
||||
for (BoneData boneData : data.bones)
|
||||
bones.add(skeleton.bones.get(boneData.index));
|
||||
|
||||
target = skeleton.bones.get(data.target.index);
|
||||
|
||||
mix = data.mix;
|
||||
softness = data.softness;
|
||||
bendDirection = data.bendDirection;
|
||||
compress = data.compress;
|
||||
stretch = data.stretch;
|
||||
}
|
||||
|
||||
/** Copy constructor. */
|
||||
public IkConstraint (IkConstraint constraint) {
|
||||
if (constraint == null) throw new IllegalArgumentException("constraint cannot be null.");
|
||||
data = constraint.data;
|
||||
bones = new Array(constraint.bones);
|
||||
target = constraint.target;
|
||||
public IkConstraint (IkConstraint constraint, Skeleton skeleton) {
|
||||
this(constraint.data, skeleton);
|
||||
|
||||
mix = constraint.mix;
|
||||
softness = constraint.softness;
|
||||
bendDirection = constraint.bendDirection;
|
||||
|
||||
@ -72,6 +72,7 @@ public class PathConstraint implements Updatable {
|
||||
bones.add(skeleton.bones.get(boneData.index));
|
||||
|
||||
target = skeleton.slots.get(data.target.index);
|
||||
|
||||
position = data.position;
|
||||
spacing = data.spacing;
|
||||
mixRotate = data.mixRotate;
|
||||
@ -80,11 +81,9 @@ public class PathConstraint implements Updatable {
|
||||
}
|
||||
|
||||
/** Copy constructor. */
|
||||
public PathConstraint (PathConstraint constraint) {
|
||||
if (constraint == null) throw new IllegalArgumentException("constraint cannot be null.");
|
||||
data = constraint.data;
|
||||
bones = new Array(constraint.bones);
|
||||
target = constraint.target;
|
||||
public PathConstraint (PathConstraint constraint, Skeleton skeleton) {
|
||||
this(constraint.data, skeleton);
|
||||
|
||||
position = constraint.position;
|
||||
spacing = constraint.spacing;
|
||||
mixRotate = constraint.mixRotate;
|
||||
|
||||
@ -58,7 +58,9 @@ public class PhysicsConstraint implements Updatable {
|
||||
if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");
|
||||
this.data = data;
|
||||
this.skeleton = skeleton;
|
||||
|
||||
bone = skeleton.bones.get(data.bone.index);
|
||||
|
||||
inertia = data.inertia;
|
||||
strength = data.strength;
|
||||
damping = data.damping;
|
||||
@ -69,11 +71,9 @@ public class PhysicsConstraint implements Updatable {
|
||||
}
|
||||
|
||||
/** Copy constructor. */
|
||||
public PhysicsConstraint (PhysicsConstraint constraint) {
|
||||
if (constraint == null) throw new IllegalArgumentException("constraint cannot be null.");
|
||||
data = constraint.data;
|
||||
skeleton = constraint.skeleton;
|
||||
bone = constraint.bone;
|
||||
public PhysicsConstraint (PhysicsConstraint constraint, Skeleton skeleton) {
|
||||
this(constraint.data, skeleton);
|
||||
|
||||
inertia = constraint.inertia;
|
||||
strength = constraint.strength;
|
||||
damping = constraint.damping;
|
||||
|
||||
@ -139,19 +139,19 @@ public class Skeleton {
|
||||
|
||||
ikConstraints = new Array(skeleton.ikConstraints.size);
|
||||
for (IkConstraint ikConstraint : skeleton.ikConstraints)
|
||||
ikConstraints.add(new IkConstraint(ikConstraint));
|
||||
ikConstraints.add(new IkConstraint(ikConstraint, skeleton));
|
||||
|
||||
transformConstraints = new Array(skeleton.transformConstraints.size);
|
||||
for (TransformConstraint transformConstraint : skeleton.transformConstraints)
|
||||
transformConstraints.add(new TransformConstraint(transformConstraint));
|
||||
transformConstraints.add(new TransformConstraint(transformConstraint, skeleton));
|
||||
|
||||
pathConstraints = new Array(skeleton.pathConstraints.size);
|
||||
for (PathConstraint pathConstraint : skeleton.pathConstraints)
|
||||
pathConstraints.add(new PathConstraint(pathConstraint));
|
||||
pathConstraints.add(new PathConstraint(pathConstraint, skeleton));
|
||||
|
||||
physicsConstraints = new Array(skeleton.physicsConstraints.size);
|
||||
for (PhysicsConstraint physicsConstraint : skeleton.physicsConstraints)
|
||||
physicsConstraints.add(new PhysicsConstraint(physicsConstraint));
|
||||
physicsConstraints.add(new PhysicsConstraint(physicsConstraint, skeleton));
|
||||
|
||||
skin = skeleton.skin;
|
||||
color = new Color(skeleton.color);
|
||||
|
||||
@ -53,26 +53,25 @@ public class TransformConstraint implements Updatable {
|
||||
if (data == null) throw new IllegalArgumentException("data cannot be null.");
|
||||
if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");
|
||||
this.data = data;
|
||||
mixRotate = data.mixRotate;
|
||||
mixX = data.mixX;
|
||||
mixY = data.mixY;
|
||||
mixScaleX = data.mixScaleX;
|
||||
mixScaleY = data.mixScaleY;
|
||||
mixShearY = data.mixShearY;
|
||||
|
||||
bones = new Array(data.bones.size);
|
||||
for (BoneData boneData : data.bones)
|
||||
bones.add(skeleton.bones.get(boneData.index));
|
||||
|
||||
target = skeleton.bones.get(data.target.index);
|
||||
|
||||
mixRotate = data.mixRotate;
|
||||
mixX = data.mixX;
|
||||
mixY = data.mixY;
|
||||
mixScaleX = data.mixScaleX;
|
||||
mixScaleY = data.mixScaleY;
|
||||
mixShearY = data.mixShearY;
|
||||
}
|
||||
|
||||
/** Copy constructor. */
|
||||
public TransformConstraint (TransformConstraint constraint) {
|
||||
if (constraint == null) throw new IllegalArgumentException("constraint cannot be null.");
|
||||
data = constraint.data;
|
||||
bones = new Array(constraint.bones);
|
||||
target = constraint.target;
|
||||
public TransformConstraint (TransformConstraint constraint, Skeleton skeleton) {
|
||||
this(constraint.data, skeleton);
|
||||
|
||||
mixRotate = constraint.mixRotate;
|
||||
mixX = constraint.mixX;
|
||||
mixY = constraint.mixY;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user