From 557d7d428bd450a7dc0ac6964af7f7f9129fe480 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 30 May 2014 08:28:15 -0700 Subject: [PATCH] minor rename and formatting --- interface/src/renderer/Model.cpp | 24 +++++++++++++++--------- interface/src/renderer/Model.h | 3 ++- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index b716c48603..d5006e76bc 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -42,7 +42,7 @@ Model::Model(QObject* parent) : _rootIndex(-1), _shapesAreDirty(true), _boundingRadius(0.0f), - _boundingShape(), + _boundingShape(), _boundingShapeLocalOffset(0.0f), _lodDistance(0.0f), _pupilDilation(0.0f), @@ -104,7 +104,7 @@ void Model::setScale(const glm::vec3& scale) { void Model::setScaleInternal(const glm::vec3& scale) { float scaleLength = glm::length(_scale); float relativeDeltaScale = glm::length(_scale - scale) / scaleLength; - + const float ONE_PERCENT = 0.01f; if (relativeDeltaScale > ONE_PERCENT || scaleLength < EPSILON) { _scale = scale; @@ -1068,13 +1068,14 @@ void Model::simulate(float deltaTime, bool fullUpdate) { } void Model::simulateInternal(float deltaTime) { + // NOTE: this is a recursive call that walks all attachments, and their attachments + // update the world space transforms for all joints + // update animations foreach (const AnimationHandlePointer& handle, _runningAnimations) { handle->simulate(deltaTime); } - // NOTE: this is a recursive call that walks all attachments, and their attachments - // update the world space transforms for all joints for (int i = 0; i < _jointStates.size(); i++) { updateJointState(i); } @@ -1847,7 +1848,7 @@ JointState::JointState() : _fbxJoint(NULL) { } -void JointState::setFBXJoint(const FBXJoint* joint) { +void JointState::setFBXJoint(const FBXJoint* joint) { assert(joint != NULL); _rotation = joint->rotation; // NOTE: JointState does not own the FBXJoint to which it points. @@ -1862,18 +1863,21 @@ void JointState::copyState(const JointState& state) { // DO NOT copy _fbxJoint } -void JointState::computeTransforms(const glm::mat4& baseTransform, const glm::quat& parentRotation) { +void JointState::computeTransforms(const glm::mat4& baseTransform, const glm::quat& baseRotation) { assert(_fbxJoint != NULL); - glm::quat combinedRotation = _fbxJoint->preRotation * _rotation * _fbxJoint->postRotation; - _transform = baseTransform * glm::translate(_fbxJoint->translation) * _fbxJoint->preTransform * glm::mat4_cast(combinedRotation) * _fbxJoint->postTransform; - _combinedRotation = parentRotation * combinedRotation; + glm::quat combinedRotation = _fbxJoint->preRotation * _rotation * _fbxJoint->postRotation; + _transform = baseTransform * glm::translate(_fbxJoint->translation) * _fbxJoint->preTransform + * glm::mat4_cast(combinedRotation) * _fbxJoint->postTransform; + _combinedRotation = baseRotation * combinedRotation; } glm::quat JointState::getJointRotation(bool fromBind) const { + assert(_fbxJoint != NULL); return _combinedRotation * (fromBind ? _fbxJoint->inverseBindRotation : _fbxJoint->inverseDefaultRotation); } void JointState::restoreRotation(float fraction, float priority) { + assert(_fbxJoint != NULL); if (priority == _animationPriority) { _rotation = safeMix(_rotation, _fbxJoint->rotation, fraction); _animationPriority = 0.0f; @@ -1881,6 +1885,7 @@ void JointState::restoreRotation(float fraction, float priority) { } void JointState::applyRotationDelta(const glm::quat& delta, bool constrain, float priority) { + assert(_fbxJoint != NULL); if (priority < _animationPriority) { return; } @@ -1900,5 +1905,6 @@ void JointState::applyRotationDelta(const glm::quat& delta, bool constrain, floa } const glm::vec3& JointState::getDefaultTranslationInParentFrame() const { + assert(_fbxJoint != NULL); return _fbxJoint->translation; } diff --git a/interface/src/renderer/Model.h b/interface/src/renderer/Model.h index deec5aeee9..154b23fe68 100644 --- a/interface/src/renderer/Model.h +++ b/interface/src/renderer/Model.h @@ -40,7 +40,8 @@ public: void copyState(const JointState& state); - void computeTransforms(const glm::mat4& baseTransform, const glm::quat& parentRotation); + /// computes new _transform and _combinedRotation + void computeTransforms(const glm::mat4& baseTransform, const glm::quat& baseRotation); /// \return rotation from the joint's default (or bind) frame to world frame glm::quat getJointRotation(bool fromBind = false) const;