mirror of
https://github.com/overte-org/overte.git
synced 2025-07-24 01:03:58 +02:00
Prototype blend. Just equal weighting for now.
This commit is contained in:
parent
6ad3cdd402
commit
78a900c866
6 changed files with 15 additions and 7 deletions
|
@ -176,7 +176,9 @@ void AnimationHandle::applyFrame(float frameIndex) {
|
||||||
safeMix(floorFrame.rotations.at(i),
|
safeMix(floorFrame.rotations.at(i),
|
||||||
ceilFrame.rotations.at(i),
|
ceilFrame.rotations.at(i),
|
||||||
frameFraction),
|
frameFraction),
|
||||||
_priority);
|
_priority,
|
||||||
|
false,
|
||||||
|
_mix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
|
|
||||||
void setPriority(float priority);
|
void setPriority(float priority);
|
||||||
float getPriority() const { return _priority; }
|
float getPriority() const { return _priority; }
|
||||||
|
void setMix(float mix) { _mix = mix; }
|
||||||
|
|
||||||
void setMaskedJoints(const QStringList& maskedJoints);
|
void setMaskedJoints(const QStringList& maskedJoints);
|
||||||
const QStringList& getMaskedJoints() const { return _maskedJoints; }
|
const QStringList& getMaskedJoints() const { return _maskedJoints; }
|
||||||
|
@ -119,6 +120,7 @@ private:
|
||||||
QString _role;
|
QString _role;
|
||||||
QUrl _url;
|
QUrl _url;
|
||||||
float _priority;
|
float _priority;
|
||||||
|
float _mix;
|
||||||
|
|
||||||
QStringList _maskedJoints;
|
QStringList _maskedJoints;
|
||||||
QVector<int> _jointMappings;
|
QVector<int> _jointMappings;
|
||||||
|
|
|
@ -232,12 +232,13 @@ glm::quat JointState::computeVisibleParentRotation() const {
|
||||||
return _visibleRotation * glm::inverse(_fbxJoint->preRotation * _visibleRotationInConstrainedFrame * _fbxJoint->postRotation);
|
return _visibleRotation * glm::inverse(_fbxJoint->preRotation * _visibleRotationInConstrainedFrame * _fbxJoint->postRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JointState::setRotationInConstrainedFrame(glm::quat targetRotation, float priority, bool constrain) {
|
void JointState::setRotationInConstrainedFrame(glm::quat targetRotation, float priority, bool constrain, float mix) {
|
||||||
if (priority >= _animationPriority || _animationPriority == 0.0f) {
|
if (priority >= _animationPriority || _animationPriority == 0.0f) {
|
||||||
if (constrain && _constraint) {
|
if (constrain && _constraint) {
|
||||||
_constraint->softClamp(targetRotation, _rotationInConstrainedFrame, 0.5f);
|
_constraint->softClamp(targetRotation, _rotationInConstrainedFrame, 0.5f);
|
||||||
}
|
}
|
||||||
setRotationInConstrainedFrameInternal(targetRotation);
|
auto rotation = (mix == 1.0f) ? targetRotation : safeMix(getRotationInConstrainedFrame(), targetRotation, mix);
|
||||||
|
setRotationInConstrainedFrameInternal(rotation);
|
||||||
_animationPriority = priority;
|
_animationPriority = priority;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ public:
|
||||||
/// NOTE: the JointState's model-frame transform/rotation are NOT updated!
|
/// NOTE: the JointState's model-frame transform/rotation are NOT updated!
|
||||||
void setRotationInBindFrame(const glm::quat& rotation, float priority, bool constrain = false);
|
void setRotationInBindFrame(const glm::quat& rotation, float priority, bool constrain = false);
|
||||||
|
|
||||||
void setRotationInConstrainedFrame(glm::quat targetRotation, float priority, bool constrain = false);
|
void setRotationInConstrainedFrame(glm::quat targetRotation, float priority, bool constrain = false, float mix = 1.0f);
|
||||||
void setVisibleRotationInConstrainedFrame(const glm::quat& targetRotation);
|
void setVisibleRotationInConstrainedFrame(const glm::quat& targetRotation);
|
||||||
const glm::quat& getRotationInConstrainedFrame() const { return _rotationInConstrainedFrame; }
|
const glm::quat& getRotationInConstrainedFrame() const { return _rotationInConstrainedFrame; }
|
||||||
const glm::quat& getVisibleRotationInConstrainedFrame() const { return _visibleRotationInConstrainedFrame; }
|
const glm::quat& getVisibleRotationInConstrainedFrame() const { return _visibleRotationInConstrainedFrame; }
|
||||||
|
|
|
@ -390,7 +390,10 @@ void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPos
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rig::updateAnimations(float deltaTime, glm::mat4 parentTransform) {
|
void Rig::updateAnimations(float deltaTime, glm::mat4 parentTransform) {
|
||||||
|
int nAnimationsSoFar = 0;
|
||||||
foreach (const AnimationHandlePointer& handle, _runningAnimations) {
|
foreach (const AnimationHandlePointer& handle, _runningAnimations) {
|
||||||
|
handle->setMix(1.0f / ++nAnimationsSoFar);
|
||||||
|
handle->setPriority(1.0);
|
||||||
handle->simulate(deltaTime);
|
handle->simulate(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,13 +643,13 @@ glm::vec3 Rig::getJointDefaultTranslationInConstrainedFrame(int jointIndex) {
|
||||||
return _jointStates[jointIndex].getDefaultTranslationInConstrainedFrame();
|
return _jointStates[jointIndex].getDefaultTranslationInConstrainedFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat Rig::setJointRotationInConstrainedFrame(int jointIndex, glm::quat targetRotation, float priority, bool constrain) {
|
glm::quat Rig::setJointRotationInConstrainedFrame(int jointIndex, glm::quat targetRotation, float priority, bool constrain, float mix) {
|
||||||
glm::quat endRotation;
|
glm::quat endRotation;
|
||||||
if (jointIndex == -1 || _jointStates.isEmpty()) {
|
if (jointIndex == -1 || _jointStates.isEmpty()) {
|
||||||
return endRotation;
|
return endRotation;
|
||||||
}
|
}
|
||||||
JointState& state = _jointStates[jointIndex];
|
JointState& state = _jointStates[jointIndex];
|
||||||
state.setRotationInConstrainedFrame(targetRotation, priority, constrain);
|
state.setRotationInConstrainedFrame(targetRotation, priority, constrain, mix);
|
||||||
endRotation = state.getRotationInConstrainedFrame();
|
endRotation = state.getRotationInConstrainedFrame();
|
||||||
return endRotation;
|
return endRotation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,7 @@ public:
|
||||||
glm::quat setJointRotationInBindFrame(int jointIndex, const glm::quat& rotation, float priority, bool constrain = false);
|
glm::quat setJointRotationInBindFrame(int jointIndex, const glm::quat& rotation, float priority, bool constrain = false);
|
||||||
glm::vec3 getJointDefaultTranslationInConstrainedFrame(int jointIndex);
|
glm::vec3 getJointDefaultTranslationInConstrainedFrame(int jointIndex);
|
||||||
glm::quat setJointRotationInConstrainedFrame(int jointIndex, glm::quat targetRotation,
|
glm::quat setJointRotationInConstrainedFrame(int jointIndex, glm::quat targetRotation,
|
||||||
float priority, bool constrain = false);
|
float priority, bool constrain = false, float mix = 1.0f);
|
||||||
glm::quat getJointDefaultRotationInParentFrame(int jointIndex);
|
glm::quat getJointDefaultRotationInParentFrame(int jointIndex);
|
||||||
void updateVisibleJointStates();
|
void updateVisibleJointStates();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue