|
@@ -154,11 +154,11 @@ void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY
|
|
}
|
|
}
|
|
x = targetX - pp->_worldX;
|
|
x = targetX - pp->_worldX;
|
|
y = targetY - pp->_worldY;
|
|
y = targetY - pp->_worldY;
|
|
- tx = (x * d - y * b) * id - px, ty = (y * a - x * c) * id - py;
|
|
|
|
|
|
+ tx = (x * d - y * b) * id - px; ty = (y * a - x * c) * id - py;
|
|
dd = tx * tx + ty * ty;
|
|
dd = tx * tx + ty * ty;
|
|
if (softness != 0) {
|
|
if (softness != 0) {
|
|
softness *= psx * (csx + 1) * 0.5f;
|
|
softness *= psx * (csx + 1) * 0.5f;
|
|
- td = MathUtil::sqrt(dd), sd = td - l1 - l2 * psx + softness;
|
|
|
|
|
|
+ td = MathUtil::sqrt(dd); sd = td - l1 - l2 * psx + softness;
|
|
if (sd > 0) {
|
|
if (sd > 0) {
|
|
p = MathUtil::min(1.0f, sd / (softness * 2)) - 1;
|
|
p = MathUtil::min(1.0f, sd / (softness * 2)) - 1;
|
|
p = (sd - softness * (1 - p * p)) / td;
|
|
p = (sd - softness * (1 - p * p)) / td;
|
|
@@ -188,7 +188,7 @@ void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY
|
|
b = l2 * MathUtil::sin(a2);
|
|
b = l2 * MathUtil::sin(a2);
|
|
a1 = MathUtil::atan2(ty * a - tx * b, tx * a + ty * b);
|
|
a1 = MathUtil::atan2(ty * a - tx * b, tx * a + ty * b);
|
|
} else {
|
|
} else {
|
|
- a = psx * l2, b = psy * l2;
|
|
|
|
|
|
+ a = psx * l2; b = psy * l2;
|
|
float aa = a * a, bb = b * b, ll = l1 * l1, ta = MathUtil::atan2(ty, tx);
|
|
float aa = a * a, bb = b * b, ll = l1 * l1, ta = MathUtil::atan2(ty, tx);
|
|
float c0 = bb * ll + aa * dd - aa * bb, c1 = -2 * bb * l1, c2 = bb - aa;
|
|
float c0 = bb * ll + aa * dd - aa * bb, c1 = -2 * bb * l1, c2 = bb - aa;
|
|
d = c1 * c1 - 4 * c2 * c0;
|
|
d = c1 * c1 - 4 * c2 * c0;
|