History

simplified SkeletonModel::maybeUpdateLeanRotation()

Andrew Meadows committed 12 years ago

Commit a01d3781 parent c76afe74 files · +16 −9Browse files

Showing the changes to interface/src/avatar/SkeletonModel.cpp (1 of 4 files). Show all

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t