From 70448abcdc2bfa874d57e8fbb4d856a07cfde1bb Mon Sep 17 00:00:00 2001 From: pharan Date: Tue, 14 Aug 2018 23:51:33 +0800 Subject: [PATCH] [csharp] Update formatting and docs. --- spine-csharp/src/IkConstraint.cs | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/spine-csharp/src/IkConstraint.cs b/spine-csharp/src/IkConstraint.cs index 721d5e617..127b51a42 100644 --- a/spine-csharp/src/IkConstraint.cs +++ b/spine-csharp/src/IkConstraint.cs @@ -41,9 +41,23 @@ namespace Spine { public IkConstraintData Data { get { return data; } } public int Order { get { return data.order; } } - public ExposedList Bones { get { return bones; } } - public Bone Target { get { return target; } set { target = value; } } - public int BendDirection { get { return bendDirection; } set { bendDirection = value; } } + + /// The bones that will be modified by this IK constraint. + public ExposedList Bones { + get { return bones; } + } + + /// The bone that is the IK target. + public Bone Target { + get { return target; } + set { target = value; } + } + + /// Controls the bend direction of the IK bones, either 1 or -1. + public int BendDirection { + get { return bendDirection; } + set { bendDirection = value; } + } /// /// When true, if the target is out of range, the parent bone is scaled on the X axis to reach it. @@ -53,7 +67,11 @@ namespace Spine { set { stretch = value; } } - public float Mix { get { return mix; } set { mix = value; } } + /// A percentage (0-1) that controls the mix between the constrained and unconstrained rotations. + public float Mix { + get { return mix; } + set { mix = value; } + } public IkConstraint (IkConstraintData data, Skeleton skeleton) { if (data == null) throw new ArgumentNullException("data", "data cannot be null."); @@ -103,14 +121,13 @@ namespace Spine { if (bone.ascaleX < 0) rotationIK += 180; if (rotationIK > 180) rotationIK -= 360; - else if (rotationIK < -180) rotationIK += 360; - + else if (rotationIK < -180) + rotationIK += 360; float sx = bone.ascaleX; if (stretch) { float b = bone.data.length * sx, dd = (float)Math.Sqrt(tx * tx + ty * ty); if (dd > b && b > 0.0001f) sx *= (dd / b - 1) * alpha + 1; } - bone.UpdateWorldTransform(bone.ax, bone.ay, bone.arotation + rotationIK * alpha, sx, bone.ascaleY, bone.ashearX, bone.ashearY); }