void iteration() { iteration(i1, i2, i3, i4, i5, i6); Vector3 posForearmR, posHandR; float d1, d2; if (absPos) { posForearmR = rightForearm.position; posHandR = rightHand.position; } else { posForearmR = rightHand.InverseTransformPoint(rightForearm.position); posHandR = rightHand.position; } d1 = Vector3.Distance(rightForearmPos, posForearmR); // 肘部位置与目标的距离 var rela = rightHandTarget.position - rightUpperarm.position; rightHandTarget.position = rightUpperarm.position + rela.normalized * handTargetDistance; d2 = Vector3.Distance(rightHandTarget.position, posHandR); // 手掌位置与目标的距离 var dis = d1 + d2; if (dis < bestDistance) // 出现新的理想值 { bestDistance = dis; // 更新(保存)相应数值 i1.SaveBest(); } }
internal void SaveBest() { best = value; if (child != null) { child.SaveBest(); } }