Showing the changes to interface/src/avatar/SkeletonModel.cpp (1 of 4 files). Show all
Unified · Split
| @@ -243,7 +243,7 @@ void SkeletonModel::updateJointState(int index) { · 242 unmodified lines | ||
| 243 | 243 | const JointState& parentState = _jointStates.at(joint.parentIndex); |
| 244 | 244 | const FBXGeometry& geometry = _geometry->getFBXGeometry(); |
| 245 | 245 | if (index == geometry.leanJointIndex) { |
| 246 | − maybeUpdateLeanRotation(parentState, joint, state); | |
| 246 | + maybeUpdateLeanRotation(parentState, state); | |
| 247 | 247 | |
| 248 | 248 | } else if (index == geometry.neckJointIndex) { |
| 249 | 249 | maybeUpdateNeckRotation(parentState, joint, state); |
| @@ -260,17 +260,18 @@ void SkeletonModel::updateJointState(int index) { · 10 unmodified lines | ||
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | −void SkeletonModel::maybeUpdateLeanRotation(const JointState& parentState, const FBXJoint& joint, JointState& state) { | |
| 263 | +void SkeletonModel::maybeUpdateLeanRotation(const JointState& parentState, JointState& state) { | |
| 264 | 264 | if (!_owningAvatar->isMyAvatar() || Application::getInstance()->getPrioVR()->isActive()) { |
| 265 | 265 | return; |
| 266 | 266 | } |
| 267 | 267 | // get the rotation axes in joint space and use them to adjust the rotation |
| 268 | − glm::mat3 axes = glm::mat3_cast(glm::quat()); | |
| 269 | − glm::mat3 inverse = glm::mat3(glm::inverse(parentState.getTransform() * glm::translate(state.getDefaultTranslationInConstrainedFrame()) * | |
| 270 | − joint.preTransform * glm::mat4_cast(joint.preRotation * joint.rotation))); | |
| 271 | − state.setRotationInConstrainedFrame(glm::angleAxis(- RADIANS_PER_DEGREE * _owningAvatar->getHead()->getFinalLeanSideways(), | |
| 272 | − glm::normalize(inverse * axes[2])) * glm::angleAxis(- RADIANS_PER_DEGREE * _owningAvatar->getHead()->getFinalLeanForward(), | |
| 273 | − glm::normalize(inverse * axes[0])) * joint.rotation); | |
| 268 | + glm::vec3 xAxis(1.0f, 0.0f, 0.0f); | |
| 269 | + glm::vec3 zAxis(0.0f, 0.0f, 1.0f); | |
| 270 | + glm::quat inverse = glm::inverse(parentState.getRotation() * state.getDefaultRotationInParentFrame()); | |
| 271 | + state.setRotationInConstrainedFrame( | |
| 272 | + glm::angleAxis(- RADIANS_PER_DEGREE * _owningAvatar->getHead()->getFinalLeanSideways(), inverse * zAxis) | |
| 273 | + * glm::angleAxis(- RADIANS_PER_DEGREE * _owningAvatar->getHead()->getFinalLeanForward(), inverse * xAxis) | |
| 274 | + * state.getFBXJoint().rotation); | |
| 274 | 275 | } |
| 275 | 276 | |
| 276 | 277 | void SkeletonModel::maybeUpdateNeckRotation(const JointState& parentState, const FBXJoint& joint, JointState& state) { |