| 109 | } |
| 110 | |
| 111 | bool IKController::Update(double applicationTime) |
| 112 | { |
| 113 | if (!Controller::Update(applicationTime)) |
| 114 | { |
| 115 | return false; |
| 116 | } |
| 117 | |
| 118 | // Make sure effectors are all current in world space. It is assumed |
| 119 | // that the joints form a chain, so the world transforms of joint I |
| 120 | // are the parent transforms for the joint I+1. |
| 121 | for (auto& joint : mJoints) |
| 122 | { |
| 123 | joint.UpdateWorldSRT(); |
| 124 | } |
| 125 | |
| 126 | // Update joints one-at-a-time to meet goals. As each joint is updated, |
| 127 | // the nodes occurring in the chain after that joint must be made current |
| 128 | // in world space. |
| 129 | int32_t numJoints = static_cast<int32_t>(mJoints.size()); |
| 130 | if (mOrderEndToRoot) |
| 131 | { |
| 132 | for (size_t iter = 0; iter < mNumIterations; ++iter) |
| 133 | { |
| 134 | for (int32_t k = 0; k < numJoints; ++k) |
| 135 | { |
| 136 | int32_t r = numJoints - 1 - k; |
| 137 | auto& joint = mJoints[r]; |
| 138 | |
| 139 | for (int32_t axis = 0; axis < 3; ++axis) |
| 140 | { |
| 141 | if (joint.allowTranslation[axis]) |
| 142 | { |
| 143 | if (joint.UpdateLocalT(axis, mGoals)) |
| 144 | { |
| 145 | for (int32_t j = r; j < numJoints; ++j) |
| 146 | { |
| 147 | mJoints[j].UpdateWorldRT(); |
| 148 | } |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | for (int32_t axis = 0; axis < 3; ++axis) |
| 154 | { |
| 155 | if (joint.allowRotation[axis]) |
| 156 | { |
| 157 | if (joint.UpdateLocalR(axis, mGoals)) |
| 158 | { |
| 159 | for (int32_t j = r; j < numJoints; ++j) |
| 160 | { |
| 161 | mJoints[j].UpdateWorldRT(); |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | } |
nothing calls this directly
no test coverage detected