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
243243 const JointState& parentState = _jointStates.at(joint.parentIndex);
244244 const FBXGeometry& geometry = _geometry->getFBXGeometry();
245245 if (index == geometry.leanJointIndex) {
246− maybeUpdateLeanRotation(parentState, joint, state);
246+ maybeUpdateLeanRotation(parentState, state);
247247
248248 } else if (index == geometry.neckJointIndex) {
249249 maybeUpdateNeckRotation(parentState, joint, state);
@@ -260,17 +260,18 @@ void SkeletonModel::updateJointState(int index) { · 10 unmodified lines
260260 }
261261 }
262262
263−void SkeletonModel::maybeUpdateLeanRotation(const JointState& parentState, const FBXJoint& joint, JointState& state) {
263+void SkeletonModel::maybeUpdateLeanRotation(const JointState& parentState, JointState& state) {
264264 if (!_owningAvatar->isMyAvatar() || Application::getInstance()->getPrioVR()->isActive()) {
265265 return;
266266 }
267267 // 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);
274275 }
275276
276277 void 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