Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
LegacyMathTest: Don't rely on GLM default constructors
  • Loading branch information
dscharrer committed Aug 7, 2018
1 parent 4bcea76 commit 0653d12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
13 changes: 5 additions & 8 deletions tests/math/LegacyMath.h
Expand Up @@ -72,7 +72,8 @@ inline void Quat_Divide(glm::quat * dest, const glm::quat * q1, const glm::quat

//! Inverts a Quaternion
inline void Quat_Reverse(glm::quat * q) {
glm::quat qw, qr;
glm::quat qw = quat_identity();
glm::quat qr;
Quat_Divide(&qr, q, &qw);
*q = qr;
}
Expand Down Expand Up @@ -219,7 +220,7 @@ inline glm::quat toNonNpcRotation(const Anglef & src) {
Anglef ang = src;
ang.setPitch(360 - ang.getPitch());

glm::mat4x4 mat;
glm::mat4x4 mat(1.f);
Vec3f vect(0, 0, 1);
Vec3f up(0, 1, 0);
vect = VRotateY(vect, ang.getYaw());
Expand Down Expand Up @@ -272,14 +273,10 @@ inline Vec2s inventorySizeFromTextureSize_1(u32 m_dwWidth, u32 m_dwHeight) {
}

inline Vec2s inventorySizeFromTextureSize_2(u32 m_dwWidth, u32 m_dwHeight) {
Vec2s m_inventorySize;

unsigned long w = m_dwWidth >> 5;
unsigned long h = m_dwHeight >> 5;
m_inventorySize.x = char(glm::clamp(((w << 5) != m_dwWidth) ? (w + 1) : w, 1ul, 3ul));
m_inventorySize.y = char(glm::clamp(((h << 5) != m_dwHeight) ? (h + 1) : h, 1ul, 3ul));

return m_inventorySize;
return Vec2s(char(glm::clamp(((w << 5) != m_dwWidth) ? (w + 1) : w, 1ul, 3ul)),
char(glm::clamp(((h << 5) != m_dwHeight) ? (h + 1) : h, 1ul, 3ul)));
}

inline float focalToFovLegacy(float focal) {
Expand Down
4 changes: 2 additions & 2 deletions tests/math/LegacyMathTest.cpp
Expand Up @@ -126,7 +126,7 @@ void LegacyMathTest::quaternionTests() {

CPPUNIT_ASSERT_EQUAL(vecA, vecB);

glm::mat4x4 matrixA;
glm::mat4x4 matrixA(1.f);
MatrixFromQuat(matrixA, A);

glm::mat4x4 matrixB = glm::mat4_cast(B);
Expand Down Expand Up @@ -203,7 +203,7 @@ void LegacyMathTest::vecMatrixConversionTest() {
front = it->quat * front;
up = it->quat * up;

glm::mat4 mat;
glm::mat4 mat(1.f);
MatrixSetByVectors(mat, front, up);

CPPUNIT_ASSERT_EQUAL(glm::mat4(it->mat), mat);
Expand Down

0 comments on commit 0653d12

Please sign in to comment.