Showing the changes to interface/src/avatar/SkeletonModel.cpp (1 of 9 files). Show all
Unified · Split
| @@ -123,6 +123,7 @@ void SkeletonModel::applyPalmData(int jointIndex, const QVector<int>& fingerJoin · 122 unmodified lines | ||
| 123 | 123 | return; |
| 124 | 124 | } |
| 125 | 125 | const FBXGeometry& geometry = _geometry->getFBXGeometry(); |
| 126 | + setJointPosition(jointIndex, palm.getPosition()); | |
| 126 | 127 | float sign = (jointIndex == geometry.rightHandJointIndex) ? 1.0f : -1.0f; |
| 127 | 128 | glm::quat palmRotation; |
| 128 | 129 | getJointRotation(jointIndex, palmRotation, true); |
| @@ -154,7 +155,6 @@ void SkeletonModel::applyPalmData(int jointIndex, const QVector<int>& fingerJoin · 25 unmodified lines | ||
| 154 | 155 | |
| 155 | 156 | // no point in continuing if there are no fingers |
| 156 | 157 | if (palm.getNumFingers() == 0 || fingerJointIndices.isEmpty()) { |
| 157 | − stretchArm(jointIndex, palm.getPosition()); | |
| 158 | 158 | return; |
| 159 | 159 | } |
| 160 | 160 | |
| @@ -172,8 +172,6 @@ void SkeletonModel::applyPalmData(int jointIndex, const QVector<int>& fingerJoin · 11 unmodified lines | ||
| 172 | 172 | |
| 173 | 173 | setJointRotation(fingerJointIndex, rotationBetween(palmRotation * jointVector, fingerVector) * palmRotation, true); |
| 174 | 174 | } |
| 175 | − | |
| 176 | − stretchArm(jointIndex, palm.getPosition()); | |
| 177 | 175 | } |
| 178 | 176 | |
| 179 | 177 | void SkeletonModel::updateJointState(int index) { |
| @@ -200,41 +198,3 @@ void SkeletonModel::maybeUpdateLeanRotation(const JointState& parentState, const · 20 unmodified lines | ||
| 200 | 198 | glm::normalize(inverse * axes[0])) * joint.rotation; |
| 201 | 199 | } |
| 202 | 200 | |
| 203 | −void SkeletonModel::stretchArm(int jointIndex, const glm::vec3& position) { | |
| 204 | − // find out where the hand is pointing | |
| 205 | − glm::quat handRotation; | |
| 206 | − getJointRotation(jointIndex, handRotation, true); | |
| 207 | − const FBXGeometry& geometry = _geometry->getFBXGeometry(); | |
| 208 | − glm::vec3 forwardVector(jointIndex == geometry.rightHandJointIndex ? -1.0f : 1.0f, 0.0f, 0.0f); | |
| 209 | − glm::vec3 handVector = handRotation * forwardVector; | |
| 210 | − | |
| 211 | − // align elbow with hand | |
| 212 | − const FBXJoint& joint = geometry.joints.at(jointIndex); | |
| 213 | − if (joint.parentIndex == -1) { | |
| 214 | − return; | |
| 215 | − } | |
| 216 | − glm::quat elbowRotation; | |
| 217 | − getJointRotation(joint.parentIndex, elbowRotation, true); | |
| 218 | − applyRotationDelta(joint.parentIndex, rotationBetween(elbowRotation * forwardVector, handVector), false); | |
| 219 | − | |
| 220 | − // set position according to normal length | |
| 221 | − float scale = extractUniformScale(_scale); | |
| 222 | − glm::vec3 handPosition = position - _translation; | |
| 223 | − glm::vec3 elbowPosition = handPosition - handVector * joint.distanceToParent * scale; | |
| 224 | − | |
| 225 | − // set shoulder orientation to point to elbow | |
| 226 | − const FBXJoint& parentJoint = geometry.joints.at(joint.parentIndex); | |
| 227 | − if (parentJoint.parentIndex == -1) { | |
| 228 | − return; | |
| 229 | − } | |
| 230 | − glm::quat shoulderRotation; | |
| 231 | − getJointRotation(parentJoint.parentIndex, shoulderRotation, true); | |
| 232 | − applyRotationDelta(parentJoint.parentIndex, rotationBetween(shoulderRotation * forwardVector, | |
| 233 | − elbowPosition - extractTranslation(_jointStates.at(parentJoint.parentIndex).transform)), false); | |
| 234 | − | |
| 235 | − // update the shoulder state | |
| 236 | − updateJointState(parentJoint.parentIndex); | |
| 237 | − | |
| 238 | − // adjust the elbow's local translation | |
| 239 | − setJointTranslation(joint.parentIndex, elbowPosition); | |
| 240 | −} | |