| 75 | } |
| 76 | |
| 77 | void CPHCapture::PullingUpdate() |
| 78 | { |
| 79 | if (!m_taget_element->isActive() || Device.dwTimeGlobal - m_time_start > m_capture_time) |
| 80 | { |
| 81 | Release(); |
| 82 | return; |
| 83 | } |
| 84 | |
| 85 | Fvector dir; |
| 86 | Fvector capture_bone_position = GetCapturePosition(); |
| 87 | m_taget_element->GetGlobalPositionDynamic(&dir); |
| 88 | dir.sub(capture_bone_position, dir); |
| 89 | float dist = dir.magnitude(); |
| 90 | if (dist > m_pull_distance) |
| 91 | { |
| 92 | Release(); |
| 93 | return; |
| 94 | } |
| 95 | dir.mul(1.f / dist); |
| 96 | if (dist < m_capture_distance) |
| 97 | { |
| 98 | m_back_force = 0.f; |
| 99 | |
| 100 | m_joint = dJointCreateBall(0, 0); |
| 101 | m_island.AddJoint(m_joint); |
| 102 | m_ajoint = dJointCreateAMotor(0, 0); |
| 103 | m_island.AddJoint(m_ajoint); |
| 104 | dJointSetAMotorMode(m_ajoint, dAMotorEuler); |
| 105 | dJointSetAMotorNumAxes(m_ajoint, 3); |
| 106 | |
| 107 | CreateBody(); |
| 108 | dBodySetPosition(m_body, capture_bone_position.x, capture_bone_position.y, capture_bone_position.z); |
| 109 | dJointAttach(m_joint, m_body, m_taget_element->get_body()); |
| 110 | dJointAttach(m_ajoint, m_body, m_taget_element->get_body()); |
| 111 | dJointSetFeedback(m_joint, &m_joint_feedback); |
| 112 | dJointSetFeedback(m_ajoint, &m_joint_feedback); |
| 113 | dJointSetBallAnchor(m_joint, capture_bone_position.x, capture_bone_position.y, capture_bone_position.z); |
| 114 | |
| 115 | dJointSetAMotorAxis(m_ajoint, 0, 1, dir.x, dir.y, dir.z); |
| 116 | |
| 117 | if (dir.x > EPS) |
| 118 | { |
| 119 | if (dir.y > EPS) |
| 120 | { |
| 121 | float mag = dir.x * dir.x + dir.y * dir.y; |
| 122 | dJointSetAMotorAxis(m_ajoint, 2, 2, -dir.y / mag, dir.x / mag, 0.f); |
| 123 | } |
| 124 | else if (dir.z > EPS) |
| 125 | { |
| 126 | float mag = dir.x * dir.x + dir.z * dir.z; |
| 127 | dJointSetAMotorAxis(m_ajoint, 2, 2, -dir.z / mag, 0.f, dir.x / mag); |
| 128 | } |
| 129 | else |
| 130 | { |
| 131 | dJointSetAMotorAxis(m_ajoint, 2, 2, 1.f, 0.f, 0.f); |
| 132 | } |
| 133 | } |
| 134 | else |
nothing calls this directly
no test coverage detected