mirror of
https://github.com/overte-org/overte.git
synced 2025-04-30 00:42:46 +02:00
remove JointState::_combinedRotation
instead use JointState::_rotationInModelFrame
This commit is contained in:
parent
19f0f453a5
commit
d46a90d763
2 changed files with 7 additions and 12 deletions
|
@ -201,13 +201,12 @@ QVector<JointState> Model::createJointStates(const FBXGeometry& geometry) {
|
||||||
if (parentIndex == -1) {
|
if (parentIndex == -1) {
|
||||||
_rootIndex = i;
|
_rootIndex = i;
|
||||||
glm::mat4 baseTransform = glm::mat4_cast(_rotation) * glm::scale(_scale) * glm::translate(_offset) * geometry.offset;
|
glm::mat4 baseTransform = glm::mat4_cast(_rotation) * glm::scale(_scale) * glm::translate(_offset) * geometry.offset;
|
||||||
state.computeTransforms(baseTransform, _rotation);
|
state.computeTransforms(baseTransform);
|
||||||
++numJointsSet;
|
++numJointsSet;
|
||||||
jointIsSet[i] = true;
|
jointIsSet[i] = true;
|
||||||
} else if (jointIsSet[parentIndex]) {
|
} else if (jointIsSet[parentIndex]) {
|
||||||
const JointState& parentState = jointStates.at(parentIndex);
|
const JointState& parentState = jointStates.at(parentIndex);
|
||||||
glm::quat parentRotation = _rotation * parentState.getRotationInModelFrame();
|
state.computeTransforms(parentState.getHybridTransform());
|
||||||
state.computeTransforms(parentState.getHybridTransform(), parentRotation);
|
|
||||||
++numJointsSet;
|
++numJointsSet;
|
||||||
jointIsSet[i] = true;
|
jointIsSet[i] = true;
|
||||||
}
|
}
|
||||||
|
@ -1280,11 +1279,10 @@ void Model::updateJointState(int index) {
|
||||||
if (parentIndex == -1) {
|
if (parentIndex == -1) {
|
||||||
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
||||||
glm::mat4 baseTransform = glm::mat4_cast(_rotation) * glm::scale(_scale) * glm::translate(_offset) * geometry.offset;
|
glm::mat4 baseTransform = glm::mat4_cast(_rotation) * glm::scale(_scale) * glm::translate(_offset) * geometry.offset;
|
||||||
state.computeTransforms(baseTransform, _rotation);
|
state.computeTransforms(baseTransform);
|
||||||
} else {
|
} else {
|
||||||
const JointState& parentState = _jointStates.at(parentIndex);
|
const JointState& parentState = _jointStates.at(parentIndex);
|
||||||
glm::quat parentRotation = _rotation * parentState.getRotationInModelFrame();
|
state.computeTransforms(parentState.getHybridTransform());
|
||||||
state.computeTransforms(parentState.getHybridTransform(), parentRotation);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2039,7 +2037,6 @@ void JointState::copyState(const JointState& state) {
|
||||||
|
|
||||||
_transformInModelFrame = state._transformInModelFrame;
|
_transformInModelFrame = state._transformInModelFrame;
|
||||||
_rotationInModelFrame = extractRotation(_transformInModelFrame);
|
_rotationInModelFrame = extractRotation(_transformInModelFrame);
|
||||||
_combinedRotation = state._combinedRotation;
|
|
||||||
_transform = state._transform;
|
_transform = state._transform;
|
||||||
|
|
||||||
_animationPriority = state._animationPriority;
|
_animationPriority = state._animationPriority;
|
||||||
|
@ -2053,13 +2050,12 @@ void JointState::computeTransformInModelFrame(const glm::mat4& parentTransform)
|
||||||
_rotationInModelFrame = extractRotation(_transformInModelFrame);
|
_rotationInModelFrame = extractRotation(_transformInModelFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JointState::computeTransforms(const glm::mat4& parentTransform, const glm::quat& baseRotation) {
|
void JointState::computeTransforms(const glm::mat4& parentTransform) {
|
||||||
assert(_fbxJoint != NULL);
|
assert(_fbxJoint != NULL);
|
||||||
|
|
||||||
glm::quat modifiedRotation = _fbxJoint->preRotation * _rotation * _fbxJoint->postRotation;
|
glm::quat modifiedRotation = _fbxJoint->preRotation * _rotation * _fbxJoint->postRotation;
|
||||||
glm::mat4 modifiedTransform = _fbxJoint->preTransform * glm::mat4_cast(modifiedRotation) * _fbxJoint->postTransform;
|
glm::mat4 modifiedTransform = _fbxJoint->preTransform * glm::mat4_cast(modifiedRotation) * _fbxJoint->postTransform;
|
||||||
_transform = parentTransform * glm::translate(_fbxJoint->translation) * modifiedTransform;
|
_transform = parentTransform * glm::translate(_fbxJoint->translation) * modifiedTransform;
|
||||||
_combinedRotation = baseRotation * modifiedRotation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat JointState::getRotationFromBindToModelFrame() const {
|
glm::quat JointState::getRotationFromBindToModelFrame() const {
|
||||||
|
|
|
@ -46,8 +46,8 @@ public:
|
||||||
glm::quat getRotationInModelFrame() const { return _rotationInModelFrame; }
|
glm::quat getRotationInModelFrame() const { return _rotationInModelFrame; }
|
||||||
glm::vec3 getPositionInModelFrame() const { return extractTranslation(_transformInModelFrame); }
|
glm::vec3 getPositionInModelFrame() const { return extractTranslation(_transformInModelFrame); }
|
||||||
|
|
||||||
/// computes new _transform and _combinedRotation
|
/// computes new _transform
|
||||||
void computeTransforms(const glm::mat4& baseTransform, const glm::quat& baseRotation);
|
void computeTransforms(const glm::mat4& baseTransform);
|
||||||
|
|
||||||
/// \return rotation from bind to model frame
|
/// \return rotation from bind to model frame
|
||||||
glm::quat getRotationFromBindToModelFrame() const;
|
glm::quat getRotationFromBindToModelFrame() const;
|
||||||
|
@ -72,7 +72,6 @@ public:
|
||||||
private:
|
private:
|
||||||
glm::mat4 _transformInModelFrame;
|
glm::mat4 _transformInModelFrame;
|
||||||
glm::quat _rotationInModelFrame;
|
glm::quat _rotationInModelFrame;
|
||||||
glm::quat _combinedRotation; // rotation from joint local to world frame
|
|
||||||
glm::mat4 _transform; // rotation to world frame + translation in model frame
|
glm::mat4 _transform; // rotation to world frame + translation in model frame
|
||||||
|
|
||||||
const FBXJoint* _fbxJoint; // JointState does NOT own its FBXJoint
|
const FBXJoint* _fbxJoint; // JointState does NOT own its FBXJoint
|
||||||
|
|
Loading…
Reference in a new issue