mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 18:13:29 +02:00
add JointState::getDistanceToParent()
This commit is contained in:
parent
b62f04e9fe
commit
72c7498454
2 changed files with 6 additions and 0 deletions
|
@ -20,6 +20,7 @@
|
|||
JointState::JointState() :
|
||||
_animationPriority(0.0f),
|
||||
_positionInParentFrame(0.0f),
|
||||
_distanceToParent(0.0f),
|
||||
_fbxJoint(NULL),
|
||||
_constraint(NULL) {
|
||||
}
|
||||
|
@ -29,6 +30,7 @@ JointState::JointState(const JointState& other) : _constraint(NULL) {
|
|||
_rotation = other._rotation;
|
||||
_rotationInConstrainedFrame = other._rotationInConstrainedFrame;
|
||||
_positionInParentFrame = other._positionInParentFrame;
|
||||
_distanceToParent = other._distanceToParent;
|
||||
_animationPriority = other._animationPriority;
|
||||
_fbxJoint = other._fbxJoint;
|
||||
// DO NOT copy _constraint
|
||||
|
@ -72,6 +74,7 @@ void JointState::copyState(const JointState& state) {
|
|||
_rotation = extractRotation(_transform);
|
||||
_rotationInConstrainedFrame = state._rotationInConstrainedFrame;
|
||||
_positionInParentFrame = state._positionInParentFrame;
|
||||
_distanceToParent = state._distanceToParent;
|
||||
|
||||
_visibleTransform = state._visibleTransform;
|
||||
_visibleRotation = extractRotation(_visibleTransform);
|
||||
|
@ -82,6 +85,7 @@ void JointState::copyState(const JointState& state) {
|
|||
void JointState::initTransform(const glm::mat4& parentTransform) {
|
||||
computeTransform(parentTransform);
|
||||
_positionInParentFrame = glm::inverse(extractRotation(parentTransform)) * (extractTranslation(_transform) - extractTranslation(parentTransform));
|
||||
_distanceToParent = glm::length(_positionInParentFrame);
|
||||
}
|
||||
|
||||
void JointState::computeTransform(const glm::mat4& parentTransform) {
|
||||
|
|
|
@ -51,6 +51,7 @@ public:
|
|||
glm::quat getRotationInParentFrame() const;
|
||||
glm::quat getVisibleRotationInParentFrame() const;
|
||||
const glm::vec3& getPositionInParentFrame() const { return _positionInParentFrame; }
|
||||
float getDistanceToParent() const { return _distanceToParent; }
|
||||
|
||||
int getParentIndex() const { return _fbxJoint->parentIndex; }
|
||||
|
||||
|
@ -104,6 +105,7 @@ private:
|
|||
glm::quat _rotation; // joint- to model-frame
|
||||
glm::quat _rotationInConstrainedFrame; // rotation in frame where angular constraints would be applied
|
||||
glm::vec3 _positionInParentFrame; // only changes when the Model is scaled
|
||||
float _distanceToParent;
|
||||
|
||||
glm::mat4 _visibleTransform;
|
||||
glm::quat _visibleRotation;
|
||||
|
|
Loading…
Reference in a new issue