mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-05 23:42:58 +02:00
Revert "AnimPose::inverse() optimization"
This reverts commit 5c7e81584c
.
This commit is contained in:
parent
75901a1e37
commit
f0e163b4df
3 changed files with 1 additions and 59 deletions
|
@ -51,10 +51,7 @@ AnimPose AnimPose::operator*(const AnimPose& rhs) const {
|
|||
}
|
||||
|
||||
AnimPose AnimPose::inverse() const {
|
||||
float invScale = 1.0f / _scale;
|
||||
glm::quat invRot = glm::inverse(_rot);
|
||||
glm::vec3 invTrans = invScale * (invRot * -_trans);
|
||||
return AnimPose(invScale, invRot, invTrans);
|
||||
return AnimPose(glm::inverse(static_cast<glm::mat4>(*this)));
|
||||
}
|
||||
|
||||
// mirror about x-axis without applying negative scale.
|
||||
|
|
|
@ -526,60 +526,6 @@ void AnimTests::testAnimPoseMultiply() {
|
|||
}
|
||||
}
|
||||
|
||||
void AnimTests::testAnimPoseInverse() {
|
||||
const float PI = (float)M_PI;
|
||||
const glm::quat ROT_X_90 = glm::angleAxis(PI / 2.0f, glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
const glm::quat ROT_Y_180 = glm::angleAxis(PI, glm::vec3(0.0f, 1.0, 0.0f));
|
||||
const glm::quat ROT_Z_30 = glm::angleAxis(PI / 6.0f, glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
|
||||
std::vector<float> scaleVec = {
|
||||
1.0f,
|
||||
2.0f,
|
||||
0.5f
|
||||
};
|
||||
|
||||
std::vector<glm::quat> rotVec = {
|
||||
glm::quat(),
|
||||
ROT_X_90,
|
||||
ROT_Y_180,
|
||||
ROT_Z_30,
|
||||
ROT_X_90 * ROT_Y_180 * ROT_Z_30,
|
||||
-ROT_Y_180
|
||||
};
|
||||
|
||||
std::vector<glm::vec3> transVec = {
|
||||
glm::vec3(),
|
||||
glm::vec3(10.0f, 0.0f, 0.0f),
|
||||
glm::vec3(0.0f, 5.0f, 0.0f),
|
||||
glm::vec3(0.0f, 0.0f, 7.5f),
|
||||
glm::vec3(10.0f, 5.0f, 7.5f),
|
||||
glm::vec3(-10.0f, 5.0f, 7.5f),
|
||||
glm::vec3(10.0f, -5.0f, 7.5f),
|
||||
glm::vec3(10.0f, 5.0f, -7.5f)
|
||||
};
|
||||
|
||||
const float TEST_EPSILON = 0.001f;
|
||||
|
||||
for (auto& scale : scaleVec) {
|
||||
for (auto& rot : rotVec) {
|
||||
for (auto& trans : transVec) {
|
||||
|
||||
// build a matrix the old fashioned way.
|
||||
glm::mat4 scaleMat = glm::scale(glm::mat4(), glm::vec3(scale));
|
||||
glm::mat4 rotTransMat = createMatFromQuatAndPos(rot, trans);
|
||||
glm::mat4 rawMat = glm::inverse(rotTransMat * scaleMat);
|
||||
|
||||
// use an anim pose to build a matrix by parts.
|
||||
AnimPose pose(scale, rot, trans);
|
||||
glm::mat4 poseMat = pose.inverse();
|
||||
|
||||
QCOMPARE_WITH_ABS_ERROR(rawMat, poseMat, TEST_EPSILON);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AnimTests::testExpressionTokenizer() {
|
||||
QString str = "(10 + x) >= 20.1 && (y != !z)";
|
||||
AnimExpression e("x");
|
||||
|
|
|
@ -28,7 +28,6 @@ private slots:
|
|||
void testAccumulateTime();
|
||||
void testAnimPose();
|
||||
void testAnimPoseMultiply();
|
||||
void testAnimPoseInverse();
|
||||
void testExpressionTokenizer();
|
||||
void testExpressionParser();
|
||||
void testExpressionEvaluator();
|
||||
|
|
Loading…
Reference in a new issue