Skip to content

Commit

Permalink
Replace glm gtx functions with gtc variants
Browse files Browse the repository at this point in the history
  • Loading branch information
Eli2 committed Nov 23, 2016
1 parent ef2f801 commit 38acc9d
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/animation/AnimationRender.cpp
Expand Up @@ -1446,7 +1446,7 @@ static void Cedric_TransformVerts(EERIE_3DOBJ * eobj, const Vec3f & pos) {
for(size_t i = 0; i != rig.bones.size(); i++) {
Bone & bone = rig.bones[i];

glm::mat4x4 matrix = glm::toMat4(bone.anim.quat);
glm::mat4x4 matrix = glm::mat4_cast(bone.anim.quat);

// Apply Scale
matrix[0][0] *= bone.anim.scale.x;
Expand Down Expand Up @@ -1592,7 +1592,7 @@ void EERIEDrawAnimQuatUpdate(EERIE_3DOBJ * eobj,
bool isNpc = io && (io->ioflags & IO_NPC);
if(!isNpc) {
// To correct invalid angle in Animated FIX/ITEMS
rotation = glm::toQuat(toRotationMatrix(angle));
rotation = glm::quat_cast(toRotationMatrix(angle));
} else {
rotation = QuatFromAngles(angle);
}
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/Math.cpp
Expand Up @@ -601,7 +601,7 @@ glm::quat angleToQuatForArrow(const Anglef & angle) {

glm::mat4x4 tmat;
MatrixSetByVectors(tmat, front, up);
return glm::toQuat(tmat);
return glm::quat_cast(tmat);
}

glm::quat angleToQuatForExtraRotation(const Anglef & angle) {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/Cursor.cpp
Expand Up @@ -247,7 +247,7 @@ bool Manage3DCursor(Entity * io, bool simulate) {

io->gameFlags &= ~GFLAG_NOCOMPUTATION;

glm::quat rotation = glm::toQuat(toRotationMatrix(angle));
glm::quat rotation = glm::quat_cast(toRotationMatrix(angle));

if(SPECIAL_DRAGINTER_RENDER) {
if(glm::abs(lastanything) > glm::abs(height)) {
Expand Down
6 changes: 3 additions & 3 deletions src/gui/book/Necklace.cpp
Expand Up @@ -153,7 +153,7 @@ void ARX_INTERFACE_ManageOpenedBook_Finish(const Vec2f & mousePos)

if(player.hasRune((Rune)i)) {

TransformInfo t1(pos, glm::toQuat(toRotationMatrix(angle)));
TransformInfo t1(pos, glm::quat_cast(toRotationMatrix(angle)));
DrawEERIEInter(gui::necklace.lacet, t1, NULL, false, 0.f);

if(rune->angle.getYaw() != 0.f) {
Expand All @@ -172,7 +172,7 @@ void ARX_INTERFACE_ManageOpenedBook_Finish(const Vec2f & mousePos)
GRenderer->SetRenderState(Renderer::AlphaBlending, false);

// Now draw the rune
TransformInfo t2(pos, glm::toQuat(toRotationMatrix(angle)));
TransformInfo t2(pos, glm::quat_cast(toRotationMatrix(angle)));
DrawEERIEInter(rune, t2, NULL, false, 0.f);

Rectf runeBox = UpdateBbox2d(*rune).toRect();
Expand Down Expand Up @@ -203,7 +203,7 @@ void ARX_INTERFACE_ManageOpenedBook_Finish(const Vec2f & mousePos)
GRenderer->SetRenderState(Renderer::AlphaBlending, true);
GRenderer->SetBlendFunc(BlendOne, BlendOne);

TransformInfo t(pos, glm::toQuat(toRotationMatrix(angle)));
TransformInfo t(pos, glm::quat_cast(toRotationMatrix(angle)));
DrawEERIEInter(rune, t, NULL, false, 0.f);

rune->angle.setYaw(rune->angle.getYaw() + g_framedelay*2.f);
Expand Down
4 changes: 2 additions & 2 deletions src/scene/Interactive.cpp
Expand Up @@ -2496,15 +2496,15 @@ void RenderInter() {

if(io->obj->pbox && io->obj->pbox->active) {
glm::mat4x4 mat = convertToMatrixForDrawEERIEInter(*io->obj->pbox);
glm::quat rotation = glm::toQuat(mat);
glm::quat rotation = glm::quat_cast(mat);

TransformInfo t(io->pos, rotation, io->scale, io->obj->pbox->vert[0].initpos);

float invisibility = Cedric_GetInvisibility(io);

DrawEERIEInter(io->obj, t, io, false, invisibility);
} else {
glm::quat rotation = glm::toQuat(toRotationMatrix(temp));
glm::quat rotation = glm::quat_cast(toRotationMatrix(temp));

TransformInfo t(io->pos, rotation, io->scale);

Expand Down
2 changes: 1 addition & 1 deletion tests/math/LegacyMath.h
Expand Up @@ -229,7 +229,7 @@ inline glm::quat toNonNpcRotation(const Anglef & src) {
up = VRotateX(up, ang.getPitch());
up = VRotateZ(up, ang.getRoll());
MatrixSetByVectors(mat, vect, up);
return glm::toQuat(mat);
return glm::quat_cast(mat);
}

inline Vec3f camEE_RT(const Vec3f & in, const EERIE_TRANSFORM & trans) {
Expand Down
12 changes: 6 additions & 6 deletions tests/math/LegacyMathTest.cpp
Expand Up @@ -100,8 +100,8 @@ void LegacyMathTest::rotationTestDataTest() {
typedef std::vector<TestRotation>::iterator Itr;
for(Itr i = rotations.begin(); i != rotations.end(); ++i) {

CPPUNIT_ASSERT_EQUAL(i->quat, glm::toQuat(i->mat));
CPPUNIT_ASSERT_EQUAL(glm::toMat4(i->quat), glm::mat4(i->mat));
CPPUNIT_ASSERT_EQUAL(i->quat, glm::quat_cast(i->mat));
CPPUNIT_ASSERT_EQUAL(glm::mat4_cast(i->quat), glm::mat4(i->mat));
}
}

Expand Down Expand Up @@ -129,7 +129,7 @@ void LegacyMathTest::quaternionTests() {
glm::mat4x4 matrixA;
MatrixFromQuat(matrixA, A);

glm::mat4x4 matrixB = glm::toMat4(B);
glm::mat4x4 matrixB = glm::mat4_cast(B);

CPPUNIT_ASSERT_EQUAL(matrixA, matrixB);
}
Expand Down Expand Up @@ -184,11 +184,11 @@ void LegacyMathTest::quatMatrixConversionTest() {
typedef std::vector<TestRotation>::iterator Itr;

for(Itr it = rotations.begin(); it != rotations.end(); ++it) {
CPPUNIT_ASSERT_EQUAL(glm::toMat4(it->quat), glm::mat4(it->mat));
CPPUNIT_ASSERT_EQUAL(glm::mat4_cast(it->quat), glm::mat4(it->mat));

glm::quat q;
QuatFromMatrix(q, glm::mat4(it->mat));
CPPUNIT_ASSERT_EQUAL(glm::toQuat(it->mat), q);
CPPUNIT_ASSERT_EQUAL(glm::quat_cast(it->mat), q);
}
}

Expand Down Expand Up @@ -239,7 +239,7 @@ void LegacyMathTest::angleConversionTest()

glm::quat q = toNonNpcRotation(it->angle);

glm::quat q2 = glm::toQuat(toRotationMatrix(it->angle));
glm::quat q2 = glm::quat_cast(toRotationMatrix(it->angle));

CPPUNIT_ASSERT_EQUAL(q, q2);
}
Expand Down

0 comments on commit 38acc9d

Please sign in to comment.