浏览代码

[csharp] Minor: port of commit 877e705, moved common subexpression part out. See commit b17595d.

Harald Csaszar 1 年之前
父节点
当前提交
94d26d2b52
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      spine-csharp/src/IkConstraint.cs

+ 3 - 2
spine-csharp/src/IkConstraint.cs

@@ -328,8 +328,9 @@ namespace Spine {
 					q = -(c1 + q) * 0.5f;
 					q = -(c1 + q) * 0.5f;
 					float r0 = q / c2, r1 = c / q;
 					float r0 = q / c2, r1 = c / q;
 					float r = Math.Abs(r0) < Math.Abs(r1) ? r0 : r1;
 					float r = Math.Abs(r0) < Math.Abs(r1) ? r0 : r1;
-					if (dd - r * r >= 0) {
-						y = (float)Math.Sqrt(dd - r * r) * bendDir;
+					r0 = dd - r * r;
+					if (r0 >= 0) {
+						y = (float)Math.Sqrt(r0) * bendDir;
 						a1 = ta - (float)Math.Atan2(y, r);
 						a1 = ta - (float)Math.Atan2(y, r);
 						a2 = (float)Math.Atan2(y / psy, (r - l1) / psx);
 						a2 = (float)Math.Atan2(y / psy, (r - l1) / psx);
 						goto break_outer; // break outer;
 						goto break_outer; // break outer;