Moto Clean-up: double-promotion warnings

This commit is contained in:
Jorge Bernal 2015-12-13 02:50:30 +01:00
parent 6329e20cbb
commit 0dcca69589
12 changed files with 84 additions and 84 deletions

View File

@ -132,14 +132,14 @@ public:
void setRotation(const MT_Quaternion& q) {
MT_Scalar d = q.length2();
MT_assert(!MT_fuzzyZero2(d));
MT_Scalar s = MT_Scalar(2.0) / d;
MT_Scalar s = MT_Scalar(2.0f) / d;
MT_Scalar xs = q[0] * s, ys = q[1] * s, zs = q[2] * s;
MT_Scalar wx = q[3] * xs, wy = q[3] * ys, wz = q[3] * zs;
MT_Scalar xx = q[0] * xs, xy = q[0] * ys, xz = q[0] * zs;
MT_Scalar yy = q[1] * ys, yz = q[1] * zs, zz = q[2] * zs;
setValue(MT_Scalar(1.0) - (yy + zz), xy - wz , xz + wy,
xy + wz , MT_Scalar(1.0) - (xx + zz), yz - wx,
xz - wy , yz + wx, MT_Scalar(1.0) - (xx + yy));
setValue(MT_Scalar(1.0f) - (yy + zz), xy - wz , xz + wy,
xy + wz , MT_Scalar(1.0f) - (xx + zz), yz - wx,
xz - wy , yz + wx, MT_Scalar(1.0f) - (xx + yy));
}
/**
@ -169,19 +169,19 @@ public:
void getEuler(MT_Scalar& yaw, MT_Scalar& pitch, MT_Scalar& roll) const
{
if (m_el[2][0] != -1.0 && m_el[2][0] != 1.0) {
if (m_el[2][0] != -1.0f && m_el[2][0] != 1.0f) {
pitch = MT_Scalar(-asin(m_el[2][0]));
yaw = MT_Scalar(atan2(m_el[2][1] / cos(pitch), m_el[2][2] / cos(pitch)));
roll = MT_Scalar(atan2(m_el[1][0] / cos(pitch), m_el[0][0] / cos(pitch)));
}
else {
roll = MT_Scalar(0);
if (m_el[2][0] == -1.0) {
pitch = MT_PI / 2.0;
if (m_el[2][0] == -1.0f) {
pitch = (float)MT_PI / 2.0f;
yaw = MT_Scalar(atan2(m_el[0][1], m_el[0][2]));
}
else {
pitch = - MT_PI / 2.0;
pitch = (float)-MT_PI / 2.0f;
yaw = MT_Scalar(atan2(m_el[0][1], m_el[0][2]));
}
}
@ -200,15 +200,15 @@ public:
}
void setIdentity() {
setValue(MT_Scalar(1.0), MT_Scalar(0.0), MT_Scalar(0.0),
MT_Scalar(0.0), MT_Scalar(1.0), MT_Scalar(0.0),
MT_Scalar(0.0), MT_Scalar(0.0), MT_Scalar(1.0));
setValue(MT_Scalar(1.0f), MT_Scalar(0.0f), MT_Scalar(0.0f),
MT_Scalar(0.0f), MT_Scalar(1.0f), MT_Scalar(0.0f),
MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(1.0f));
}
void getValue(float *m) const {
*m++ = (float) m_el[0][0]; *m++ = (float) m_el[1][0]; *m++ = (float) m_el[2][0]; *m++ = (float) 0.0;
*m++ = (float) m_el[0][1]; *m++ = (float) m_el[1][1]; *m++ = (float) m_el[2][1]; *m++ = (float) 0.0;
*m++ = (float) m_el[0][2]; *m++ = (float) m_el[1][2]; *m++ = (float) m_el[2][2]; *m = (float) 0.0;
*m++ = (float) m_el[0][0]; *m++ = (float) m_el[1][0]; *m++ = (float) m_el[2][0]; *m++ = (float) 0.0f;
*m++ = (float) m_el[0][1]; *m++ = (float) m_el[1][1]; *m++ = (float) m_el[2][1]; *m++ = (float) 0.0f;
*m++ = (float) m_el[0][2]; *m++ = (float) m_el[1][2]; *m++ = (float) m_el[2][2]; *m = (float) 0.0f;
}
void getValue(double *m) const {

View File

@ -7,11 +7,11 @@ GEN_INLINE MT_Quaternion MT_Matrix3x3::getRotation() const {
MT_Scalar trace = m_el[0][0] + m_el[1][1] + m_el[2][2];
if (trace > 0.0)
if (trace > 0.0f)
{
MT_Scalar s = sqrt(trace + MT_Scalar(1.0));
result[3] = s * MT_Scalar(0.5);
s = MT_Scalar(0.5) / s;
MT_Scalar s = sqrt(trace + MT_Scalar(1.0f));
result[3] = s * MT_Scalar(0.5f);
s = MT_Scalar(0.5f) / s;
result[0] = (m_el[2][1] - m_el[1][2]) * s;
result[1] = (m_el[0][2] - m_el[2][0]) * s;
@ -28,11 +28,11 @@ GEN_INLINE MT_Quaternion MT_Matrix3x3::getRotation() const {
int j = next[i];
int k = next[j];
MT_Scalar s = sqrt(m_el[i][i] - m_el[j][j] - m_el[k][k] + MT_Scalar(1.0));
MT_Scalar s = sqrt(m_el[i][i] - m_el[j][j] - m_el[k][k] + MT_Scalar(1.0f));
result[i] = s * MT_Scalar(0.5);
result[i] = s * MT_Scalar(0.5f);
s = MT_Scalar(0.5) / s;
s = MT_Scalar(0.5f) / s;
result[3] = (m_el[k][j] - m_el[j][k]) * s;
result[j] = (m_el[j][i] + m_el[i][j]) * s;
@ -80,7 +80,7 @@ GEN_INLINE MT_Matrix3x3 MT_Matrix3x3::inverse() const {
MT_Vector3 co(cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1));
MT_Scalar det = MT_dot((*this)[0], co);
MT_assert(!MT_fuzzyZero2(det));
MT_Scalar s = MT_Scalar(1.0) / det;
MT_Scalar s = MT_Scalar(1.0f) / det;
return
MT_Matrix3x3(co[0] * s, cofac(0, 2, 2, 1) * s, cofac(0, 1, 1, 2) * s,
co[1] * s, cofac(0, 0, 2, 2) * s, cofac(0, 2, 1, 0) * s,

View File

@ -86,7 +86,7 @@ public:
basis[0][0],basis[0][1],basis[0][2],origin[0],
basis[1][0],basis[1][1],basis[1][2],origin[1],
basis[2][0],basis[2][1],basis[2][2],origin[2],
MT_Scalar(0),MT_Scalar(0),MT_Scalar(0),MT_Scalar(1)
MT_Scalar(0.0f),MT_Scalar(0.0f),MT_Scalar(0.0f),MT_Scalar(1.0f)
);
}
@ -157,10 +157,10 @@ public:
* Set this matrix to I.
*/
void setIdentity() {
setValue(MT_Scalar(1.0), MT_Scalar(0.0), MT_Scalar(0.0), MT_Scalar(0.0),
MT_Scalar(0.0), MT_Scalar(1.0), MT_Scalar(0.0), MT_Scalar(0.0),
MT_Scalar(0.0), MT_Scalar(0.0), MT_Scalar(1.0), MT_Scalar(0.0),
MT_Scalar(0.0), MT_Scalar(0.0), MT_Scalar(0.0), MT_Scalar(1.0));
setValue(MT_Scalar(1.0f), MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(0.0f),
MT_Scalar(0.0f), MT_Scalar(1.0f), MT_Scalar(0.0f), MT_Scalar(0.0f),
MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(1.0f), MT_Scalar(0.0f),
MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(1.0f));
}
/**

View File

@ -11,14 +11,14 @@ GEN_INLINE void MT_Matrix4x4::invert() {
for (i=1; i < 4; i++) m_el[0][i] /= m_el[0][0];
for (i=1; i < 4; i++) {
for (j=i; j < 4; j++) { // do a column of L
MT_Scalar sum = 0.0;
MT_Scalar sum = 0.0f;
for (k = 0; k < i; k++)
sum += m_el[j][k] * m_el[k][i];
m_el[j][i] -= sum;
}
if (i == 3) continue;
for (j=i+1; j < 4; j++) { // do a row of U
MT_Scalar sum = 0.0;
MT_Scalar sum = 0.0f;
for (k = 0; k < i; k++)
sum += m_el[i][k]*m_el[k][j];
m_el[i][j] =
@ -27,9 +27,9 @@ GEN_INLINE void MT_Matrix4x4::invert() {
}
for (i = 0; i < 4; i++ ) // invert L
for (j = i; j < 4; j++ ) {
MT_Scalar x = 1.0;
MT_Scalar x = 1.0f;
if ( i != j ) {
x = 0.0;
x = 0.0f;
for (k = i; k < j; k++ )
x -= m_el[j][k]*m_el[k][i];
}
@ -38,16 +38,16 @@ GEN_INLINE void MT_Matrix4x4::invert() {
for (i = 0; i < 4; i++ ) // invert U
for (j = i; j < 4; j++ ) {
if ( i == j ) continue;
MT_Scalar sum = 0.0;
MT_Scalar sum = 0.0f;
for (k = i; k < j; k++ )
sum += m_el[k][j]*( (i==k) ? 1.0 : m_el[i][k] );
sum += m_el[k][j]*( (i==k) ? 1.0f : m_el[i][k] );
m_el[i][j] = -sum;
}
for (i = 0; i < 4; i++ ) // final inversion
for (j = 0; j < 4; j++ ) {
MT_Scalar sum = 0.0;
MT_Scalar sum = 0.0f;
for (k = ((i>j)?i:j); k < 4; k++ )
sum += ((j==k)?1.0:m_el[j][k])*m_el[k][i];
sum += ((j==k)?1.0f:m_el[j][k])*m_el[k][i];
m_el[j][i] = sum;
}
}

View File

@ -70,18 +70,18 @@ public:
void setRotation(const MT_Vector3& axis, MT_Scalar mt_angle) {
MT_Scalar d = axis.length();
MT_assert(!MT_fuzzyZero(d));
MT_Scalar s = sin(mt_angle * MT_Scalar(0.5)) / d;
MT_Scalar s = sin(mt_angle * MT_Scalar(0.5f)) / d;
setValue(axis[0] * s, axis[1] * s, axis[2] * s,
cos(mt_angle * MT_Scalar(0.5)));
cos(mt_angle * MT_Scalar(0.5f)));
}
void setEuler(MT_Scalar yaw, MT_Scalar pitch, MT_Scalar roll) {
MT_Scalar cosYaw = cos(yaw * MT_Scalar(0.5));
MT_Scalar sinYaw = sin(yaw * MT_Scalar(0.5));
MT_Scalar cosPitch = cos(pitch * MT_Scalar(0.5));
MT_Scalar sinPitch = sin(pitch * MT_Scalar(0.5));
MT_Scalar cosRoll = cos(roll * MT_Scalar(0.5));
MT_Scalar sinRoll = sin(roll * MT_Scalar(0.5));
MT_Scalar cosYaw = cos(yaw * MT_Scalar(0.5f));
MT_Scalar sinYaw = sin(yaw * MT_Scalar(0.5f));
MT_Scalar cosPitch = cos(pitch * MT_Scalar(0.5f));
MT_Scalar sinPitch = sin(pitch * MT_Scalar(0.5f));
MT_Scalar cosRoll = cos(roll * MT_Scalar(0.5f));
MT_Scalar sinRoll = sin(roll * MT_Scalar(0.5f));
setValue(cosRoll * sinPitch * cosYaw + sinRoll * cosPitch * sinYaw,
cosRoll * cosPitch * sinYaw - sinRoll * sinPitch * cosYaw,
sinRoll * cosPitch * cosYaw - cosRoll * sinPitch * sinYaw,

View File

@ -29,8 +29,8 @@ GEN_INLINE MT_Quaternion MT_Quaternion::inverse() const {
// pg. 124-132
GEN_INLINE MT_Quaternion MT_Quaternion::random() {
MT_Scalar x0 = MT_random();
MT_Scalar r1 = sqrt(MT_Scalar(1.0) - x0), r2 = sqrt(x0);
MT_Scalar t1 = MT_2_PI * MT_random(), t2 = MT_2_PI * MT_random();
MT_Scalar r1 = sqrt(MT_Scalar(1.0f) - x0), r2 = sqrt(x0);
MT_Scalar t1 = (float)MT_2_PI * MT_random(), t2 = (float)MT_2_PI * MT_random();
MT_Scalar c1 = cos(t1), s1 = sin(t1);
MT_Scalar c2 = cos(t2), s2 = sin(t2);
return MT_Quaternion(s1 * r1, c1 * r1, s2 * r2, c2 * r2);
@ -63,11 +63,11 @@ GEN_INLINE MT_Quaternion operator*(const MT_Vector3& w, const MT_Quaternion& q)
GEN_INLINE MT_Scalar MT_Quaternion::angle(const MT_Quaternion& q) const
{
MT_Scalar s = sqrt(length2() * q.length2());
assert(s != MT_Scalar(0.0));
assert(s != MT_Scalar(0.0f));
s = dot(q) / s;
s = MT_clamp(s, -1.0, 1.0);
s = MT_clamp(s, -1.0f, 1.0f);
return acos(s);
}
@ -76,21 +76,21 @@ GEN_INLINE MT_Quaternion MT_Quaternion::slerp(const MT_Quaternion& q, const MT_S
{
MT_Scalar d, s0, s1;
MT_Scalar s = dot(q);
bool neg = (s < 0.0);
bool neg = (s < 0.0f);
if (neg)
s = -s;
if ((1.0 - s) > 0.0001)
if ((1.0f - s) > 0.0001f)
{
MT_Scalar theta = acos(s);
d = MT_Scalar(1.0) / sin(theta);
s0 = sin((MT_Scalar(1.0) - t) * theta);
d = MT_Scalar(1.0f) / sin(theta);
s0 = sin((MT_Scalar(1.0f) - t) * theta);
s1 = sin(t * theta);
}
else
{
d = MT_Scalar(1.0);
s0 = MT_Scalar(1.0) - t;
d = MT_Scalar(1.0f);
s0 = MT_Scalar(1.0f) - t;
s1 = t;
}
if (neg)

View File

@ -64,20 +64,20 @@ const MT_Scalar MT_EPSILON2(1.0e-20);
const MT_Scalar MT_INFINITY(1.0e50);
inline int MT_sign(MT_Scalar x) {
return x < 0.0 ? -1 : x > 0.0 ? 1 : 0;
return x < 0.0f ? -1 : x > 0.0f ? 1 : 0;
}
inline MT_Scalar MT_abs(MT_Scalar x) { return fabs(x); }
inline bool MT_fuzzyZero(MT_Scalar x) { return MT_abs(x) < MT_EPSILON; }
inline bool MT_fuzzyZero2(MT_Scalar x) { return MT_abs(x) < MT_EPSILON2; }
inline bool MT_fuzzyZero(MT_Scalar x) { return MT_abs(x) < (float)MT_EPSILON; }
inline bool MT_fuzzyZero2(MT_Scalar x) { return MT_abs(x) < (float)MT_EPSILON2; }
inline MT_Scalar MT_radians(MT_Scalar x) {
return x * MT_RADS_PER_DEG;
return x * (float)MT_RADS_PER_DEG;
}
inline MT_Scalar MT_degrees(MT_Scalar x) {
return x * MT_DEGS_PER_RAD;
return x * (float)MT_DEGS_PER_RAD;
}
inline MT_Scalar MT_random() {

View File

@ -17,7 +17,7 @@ GEN_INLINE MT_Vector2& MT_Vector2::operator*=(MT_Scalar s) {
GEN_INLINE MT_Vector2& MT_Vector2::operator/=(MT_Scalar s) {
MT_assert(!MT_fuzzyZero(s));
return *this *= 1.0 / s;
return *this *= 1.0f / s;
}
GEN_INLINE MT_Vector2 operator+(const MT_Vector2& v1, const MT_Vector2& v2) {
@ -40,7 +40,7 @@ GEN_INLINE MT_Vector2 operator*(MT_Scalar s, const MT_Vector2& v) { return v * s
GEN_INLINE MT_Vector2 operator/(const MT_Vector2& v, MT_Scalar s) {
MT_assert(!MT_fuzzyZero(s));
return v * (1.0 / s);
return v * (1.0f / s);
}
GEN_INLINE MT_Scalar MT_Vector2::dot(const MT_Vector2& vv) const {

View File

@ -17,7 +17,7 @@ GEN_INLINE MT_Vector3& MT_Vector3::operator*=(MT_Scalar s) {
GEN_INLINE MT_Vector3& MT_Vector3::operator/=(MT_Scalar s) {
MT_assert(!MT_fuzzyZero(s));
return *this *= MT_Scalar(1.0) / s;
return *this *= MT_Scalar(1.0f) / s;
}
GEN_INLINE MT_Vector3 operator+(const MT_Vector3& v1, const MT_Vector3& v2) {
@ -40,7 +40,7 @@ GEN_INLINE MT_Vector3 operator*(MT_Scalar s, const MT_Vector3& v) { return v * s
GEN_INLINE MT_Vector3 operator/(const MT_Vector3& v, MT_Scalar s) {
MT_assert(!MT_fuzzyZero(s));
return v * (MT_Scalar(1.0) / s);
return v * (MT_Scalar(1.0f) / s);
}
GEN_INLINE MT_Vector3 operator*(const MT_Vector3& v1, const MT_Vector3& v2) {
@ -64,7 +64,7 @@ GEN_INLINE bool MT_Vector3::fuzzyZero() const {
GEN_INLINE void MT_Vector3::noiseGate(MT_Scalar threshold) {
if (length2() < threshold) {
setValue(MT_Scalar(0.0), MT_Scalar(0.0), MT_Scalar(0.0));
setValue(MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(0.0f));
}
}
@ -73,7 +73,7 @@ GEN_INLINE MT_Vector3 MT_Vector3::normalized() const { return *this / length();
GEN_INLINE MT_Vector3 MT_Vector3::safe_normalized() const {
MT_Scalar len = length();
return MT_fuzzyZero(len) ?
MT_Vector3(MT_Scalar(1.0), MT_Scalar(0.0), MT_Scalar(0.0)) :
MT_Vector3(MT_Scalar(1.0f), MT_Scalar(0.0f), MT_Scalar(0.0f)) :
*this / len;
}
@ -116,9 +116,9 @@ GEN_INLINE int MT_Vector3::closestAxis() const {
}
GEN_INLINE MT_Vector3 MT_Vector3::random() {
MT_Scalar z = MT_Scalar(2.0) * MT_random() - MT_Scalar(1.0);
MT_Scalar r = sqrt(MT_Scalar(1.0) - z * z);
MT_Scalar t = MT_2_PI * MT_random();
MT_Scalar z = MT_Scalar(2.0f) * MT_random() - MT_Scalar(1.0f);
MT_Scalar r = sqrt(MT_Scalar(1.0f) - z * z);
MT_Scalar t = (float)MT_2_PI * MT_random();
return MT_Vector3(r * cos(t), r * sin(t), z);
}

View File

@ -17,7 +17,7 @@ GEN_INLINE MT_Vector4& MT_Vector4::operator*=(MT_Scalar s) {
GEN_INLINE MT_Vector4& MT_Vector4::operator/=(MT_Scalar s) {
MT_assert(!MT_fuzzyZero(s));
return *this *= MT_Scalar(1.0) / s;
return *this *= MT_Scalar(1.0f) / s;
}
GEN_INLINE MT_Vector4 operator+(const MT_Vector4& v1, const MT_Vector4& v2) {
@ -40,7 +40,7 @@ GEN_INLINE MT_Vector4 operator*(MT_Scalar s, const MT_Vector4& v) { return v * s
GEN_INLINE MT_Vector4 operator/(const MT_Vector4& v, MT_Scalar s) {
MT_assert(!MT_fuzzyZero(s));
return v * (MT_Scalar(1.0) / s);
return v * (MT_Scalar(1.0f) / s);
}
GEN_INLINE MT_Scalar MT_Vector4::dot(const MT_Vector4& v) const {

View File

@ -179,28 +179,28 @@ MT_CmMatrix4x4 MT_CmMatrix4x4::Perspective(
MT_CmMatrix4x4 mat;
// Column 0
mat(0, 0) = -(2.0*inNear) / (inRight-inLeft);
mat(1, 0) = 0;
mat(2, 0) = 0;
mat(3, 0) = 0;
mat(0, 0) = -(2.0f*inNear) / (inRight-inLeft);
mat(1, 0) = 0.0f;
mat(2, 0) = 0.0f;
mat(3, 0) = 0.0f;
// Column 1
mat(0, 1) = 0;
mat(1, 1) = (2.0*inNear) / (inTop-inBottom);
mat(2, 1) = 0;
mat(3, 1) = 0;
mat(0, 1) = 0.0f;
mat(1, 1) = (2.0f*inNear) / (inTop-inBottom);
mat(2, 1) = 0.0f;
mat(3, 1) = 0.0f;
// Column 2
mat(0, 2) = (inRight+inLeft) / (inRight-inLeft);
mat(1, 2) = (inTop+inBottom) / (inTop-inBottom);
mat(2, 2) = -(inFar+inNear) / (inFar-inNear);
mat(3, 2) = -1;
mat(3, 2) = -1.0f;
// Column 3
mat(0, 3) = 0;
mat(1, 3) = 0;
mat(2, 3) = -(2.0*inFar*inNear) / (inFar-inNear);
mat(3, 3) = 0;
mat(0, 3) = 0.0f;
mat(1, 3) = 0.0f;
mat(2, 3) = -(2.0f*inFar*inNear) / (inFar-inNear);
mat(3, 3) = 0.0f;
return mat;
}

View File

@ -68,7 +68,7 @@ void MT_Transform::setValue(const double *m) {
void MT_Transform::getValue(float *m) const {
m_basis.getValue(m);
m_origin.getValue(&m[12]);
m[15] = 1.0;
m[15] = 1.0f;
}
void MT_Transform::getValue(double *m) const {
@ -101,7 +101,7 @@ void MT_Transform::scale(MT_Scalar x, MT_Scalar y, MT_Scalar z) {
void MT_Transform::setIdentity() {
m_basis.setIdentity();
m_origin.setValue(MT_Scalar(0.0), MT_Scalar(0.0), MT_Scalar(0.0));
m_origin.setValue(MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(0.0f));
m_type = IDENTITY;
}