mirror of
https://github.com/overte-org/overte.git
synced 2025-04-15 06:28:48 +02:00
PR feedback
This commit is contained in:
parent
7b90d71205
commit
171440f70b
4 changed files with 13 additions and 22 deletions
|
@ -17,9 +17,8 @@ const AnimPose AnimPose::identity = AnimPose(glm::vec3(1.0f),
|
|||
glm::quat(),
|
||||
glm::vec3(0.0f));
|
||||
|
||||
AnimPose::AnimPose(const glm::mat4& mat) : _dirty(false) {
|
||||
AnimPose::AnimPose(const glm::mat4& mat) {
|
||||
static const float EPSILON = 0.0001f;
|
||||
_mat = mat;
|
||||
_scale = extractScale(mat);
|
||||
// quat_cast doesn't work so well with scaled matrices, so cancel it out.
|
||||
glm::mat4 tmp = glm::scale(mat, 1.0f / _scale);
|
||||
|
@ -60,7 +59,6 @@ AnimPose AnimPose::operator*(const AnimPose& rhs) const {
|
|||
#else
|
||||
return AnimPose(static_cast<glm::mat4>(*this) * static_cast<glm::mat4>(rhs));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
AnimPose AnimPose::inverse() const {
|
||||
|
@ -72,14 +70,10 @@ AnimPose AnimPose::mirror() const {
|
|||
return AnimPose(_scale, glm::quat(_rot.w, _rot.x, -_rot.y, -_rot.z), glm::vec3(-_trans.x, _trans.y, _trans.z));
|
||||
}
|
||||
|
||||
AnimPose::operator const glm::mat4&() const {
|
||||
if (_dirty) {
|
||||
glm::vec3 xAxis = _rot * glm::vec3(_scale.x, 0.0f, 0.0f);
|
||||
glm::vec3 yAxis = _rot * glm::vec3(0.0f, _scale.y, 0.0f);
|
||||
glm::vec3 zAxis = _rot * glm::vec3(0.0f, 0.0f, _scale.z);
|
||||
_mat = glm::mat4(glm::vec4(xAxis, 0.0f), glm::vec4(yAxis, 0.0f),
|
||||
glm::vec4(zAxis, 0.0f), glm::vec4(_trans, 1.0f));
|
||||
_dirty = false;
|
||||
}
|
||||
return _mat;
|
||||
AnimPose::operator glm::mat4() const {
|
||||
glm::vec3 xAxis = _rot * glm::vec3(_scale.x, 0.0f, 0.0f);
|
||||
glm::vec3 yAxis = _rot * glm::vec3(0.0f, _scale.y, 0.0f);
|
||||
glm::vec3 zAxis = _rot * glm::vec3(0.0f, 0.0f, _scale.z);
|
||||
return glm::mat4(glm::vec4(xAxis, 0.0f), glm::vec4(yAxis, 0.0f),
|
||||
glm::vec4(zAxis, 0.0f), glm::vec4(_trans, 1.0f));
|
||||
}
|
||||
|
|
|
@ -32,22 +32,19 @@ public:
|
|||
|
||||
AnimPose inverse() const;
|
||||
AnimPose mirror() const;
|
||||
operator const glm::mat4&() const;
|
||||
operator glm::mat4() const;
|
||||
|
||||
const glm::vec3& scale() const { return _scale; }
|
||||
glm::vec3& scale() { _dirty = true; return _scale; }
|
||||
glm::vec3& scale() { return _scale; }
|
||||
|
||||
const glm::quat& rot() const { return _rot; }
|
||||
glm::quat& rot() { _dirty = true; return _rot; }
|
||||
glm::quat& rot() { return _rot; }
|
||||
|
||||
const glm::vec3& trans() const { return _trans; }
|
||||
glm::vec3& trans() { _dirty = true; return _trans; }
|
||||
glm::vec3& trans() { return _trans; }
|
||||
|
||||
private:
|
||||
friend QDebug operator<<(QDebug debug, const AnimPose& pose);
|
||||
|
||||
mutable bool _dirty { true };
|
||||
mutable glm::mat4 _mat;
|
||||
glm::vec3 _scale { 1.0f };
|
||||
glm::quat _rot;
|
||||
glm::vec3 _trans;
|
||||
|
|
|
@ -1233,7 +1233,7 @@ void Rig::buildAbsoluteRigPoses(const AnimPoseVec& relativePoses, AnimPoseVec& a
|
|||
}
|
||||
}
|
||||
|
||||
const glm::mat4& Rig::getJointTransform(int jointIndex) const {
|
||||
glm::mat4 Rig::getJointTransform(int jointIndex) const {
|
||||
static const glm::mat4 IDENTITY;
|
||||
if (isIndexValid(jointIndex)) {
|
||||
return _internalPoseSet._absolutePoses[jointIndex];
|
||||
|
|
|
@ -141,7 +141,7 @@ public:
|
|||
bool getJointCombinedRotation(int jointIndex, glm::quat& result, const glm::quat& rotation) const;
|
||||
|
||||
// rig space
|
||||
const glm::mat4& getJointTransform(int jointIndex) const;
|
||||
glm::mat4 getJointTransform(int jointIndex) const;
|
||||
|
||||
// Start or stop animations as needed.
|
||||
void computeMotionAnimationState(float deltaTime, const glm::vec3& worldPosition, const glm::vec3& worldVelocity, const glm::quat& worldRotation, CharacterControllerState ccState);
|
||||
|
|
Loading…
Reference in a new issue