Bump CMake version, fix warnings
This commit is contained in:
@@ -107,8 +107,8 @@ void Matrix2::rotate(float angle) {
|
||||
|
||||
Matrix2 newMatrix; // Create new identity matrix
|
||||
newMatrix.init();
|
||||
newMatrix.c[0] = cos(angle);
|
||||
newMatrix.c[1] = -sin(angle);
|
||||
newMatrix.c[0] = cosf(angle);
|
||||
newMatrix.c[1] = -sinf(angle);
|
||||
newMatrix.c[2] = -newMatrix.c[1];
|
||||
newMatrix.c[3] = newMatrix.c[0];
|
||||
|
||||
|
||||
@@ -127,8 +127,8 @@ void Matrix2x3::translate(const Vector2 &v)
|
||||
void Matrix2x3::rotate(float angle) {
|
||||
Matrix2x3 newMatrix;
|
||||
newMatrix.init();
|
||||
newMatrix.c[0] = cos(angle);
|
||||
newMatrix.c[1] = -sin(angle);
|
||||
newMatrix.c[0] = cosf(angle);
|
||||
newMatrix.c[1] = -sinf(angle);
|
||||
newMatrix.c[2] = -newMatrix.c[1];
|
||||
newMatrix.c[3] = newMatrix.c[0];
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ void Matrix4::perspective(float fov, float aspect, float nearz, float farz) {
|
||||
|
||||
memset(c, 0, sizeof(float) * 16);
|
||||
|
||||
float range= tan(fov * 0.5f) * nearz;
|
||||
float range= tanf(fov * 0.5f) * nearz;
|
||||
c[0] = (2 * nearz) / ((range * aspect) - (-range * aspect));
|
||||
c[5] = (2 * nearz) / (2 * range);
|
||||
c[10] = -(farz + nearz) / (farz - nearz);
|
||||
@@ -199,10 +199,11 @@ void Matrix4::rotate(float angle, AXIS axis) {
|
||||
Matrix4 newMatrix; // Create new identity matrix
|
||||
newMatrix.init();
|
||||
|
||||
newMatrix.c[cos1[axis]] = cos(angle);
|
||||
newMatrix.c[sin1[axis]] = -sin(angle);
|
||||
newMatrix.c[sin2[axis]] = -newMatrix.c[sin1[axis]];
|
||||
newMatrix.c[cos2[axis]] = newMatrix.c[cos1[axis]];
|
||||
uint8_t index = static_cast<uint8_t>(axis);
|
||||
newMatrix.c[cos1[index]] = cosf(angle);
|
||||
newMatrix.c[sin1[index]] = -sinf(angle);
|
||||
newMatrix.c[sin2[index]] = -newMatrix.c[sin1[index]];
|
||||
newMatrix.c[cos2[index]] = newMatrix.c[cos1[index]];
|
||||
|
||||
*this *= newMatrix;
|
||||
}
|
||||
@@ -441,9 +442,9 @@ Matrix4 Matrix4::Rotation(const Vector3 &v)
|
||||
{
|
||||
Matrix4 m;
|
||||
m.init();
|
||||
m.rotate(v.x, X_AXIS);
|
||||
m.rotate(v.y, Y_AXIS);
|
||||
m.rotate(v.z, Z_AXIS);
|
||||
m.rotate(v.x, AXIS::X_AXIS);
|
||||
m.rotate(v.y, AXIS::Y_AXIS);
|
||||
m.rotate(v.z, AXIS::Z_AXIS);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ void Quaternion::init(const Vector3 &from_vector, const Vector3 &to_vector) {
|
||||
c[0] = a[0];
|
||||
c[1] = a[1];
|
||||
c[2] = a[2];
|
||||
c[3] = sqrt(from_vector.sqrMagnitude() * to_vector.sqrMagnitude()) + Vector3::Dot(from_vector, to_vector);
|
||||
c[3] = sqrtf(from_vector.sqrMagnitude() * to_vector.sqrMagnitude()) + Vector3::Dot(from_vector, to_vector);
|
||||
normalize();
|
||||
}
|
||||
|
||||
@@ -114,12 +114,12 @@ void Quaternion::setEulerXYZ(const Vector3 &euler)
|
||||
|
||||
void Quaternion::setEulerZYX(const Vector3 &euler) {
|
||||
// ZYX Order!
|
||||
float c1 = cos(euler[0] * 0.5f);
|
||||
float c2 = cos(euler[1] * 0.5f);
|
||||
float c3 = cos(euler[2] * 0.5f);
|
||||
float s1 = sin(euler[0] * 0.5f);
|
||||
float s2 = sin(euler[1] * 0.5f);
|
||||
float s3 = sin(euler[2] * 0.5f);
|
||||
float c1 = cosf(euler[0] * 0.5f);
|
||||
float c2 = cosf(euler[1] * 0.5f);
|
||||
float c3 = cosf(euler[2] * 0.5f);
|
||||
float s1 = sinf(euler[0] * 0.5f);
|
||||
float s2 = sinf(euler[1] * 0.5f);
|
||||
float s3 = sinf(euler[2] * 0.5f);
|
||||
|
||||
c[0] = c1 * c2 * c3 + s1 * s2 * s3;
|
||||
c[1] = s1 * c2 * c3 - c1 * s2 * s3;
|
||||
@@ -139,13 +139,13 @@ Vector3 Quaternion::eulerXYZ() const {
|
||||
float a2 = 2 * (c[0] * c[2] - c[1] * c[3]);
|
||||
if(a2 <= -0.99999) {
|
||||
return Vector3::Create(
|
||||
2.0f * atan2(c[1], c[0]),
|
||||
2.0f * atan2f(c[1], c[0]),
|
||||
-PI * 0.5f,
|
||||
0
|
||||
);
|
||||
} else if(a2 >= 0.99999) {
|
||||
return Vector3::Create(
|
||||
2.0f * atan2(c[1], c[0]),
|
||||
2.0f * atan2f(c[1], c[0]),
|
||||
PI * 0.5f,
|
||||
0
|
||||
);
|
||||
@@ -345,8 +345,8 @@ Matrix4 Quaternion::rotationMatrix() const {
|
||||
Quaternion Quaternion::FromAngleAxis(const Vector3 &axis, float angle)
|
||||
{
|
||||
float ha = angle * 0.5f;
|
||||
float sha = sin(ha);
|
||||
return Quaternion::Create(cos(ha), axis.x * sha, axis.y * sha, axis.z * sha);
|
||||
float sha = sinf(ha);
|
||||
return Quaternion::Create(cosf(ha), axis.x * sha, axis.y * sha, axis.z * sha);
|
||||
}
|
||||
|
||||
Quaternion Quaternion::FromRotationMatrix(const Matrix4 &m)
|
||||
@@ -355,25 +355,25 @@ Quaternion Quaternion::FromRotationMatrix(const Matrix4 &m)
|
||||
const float trace = m[0] + m[5] + m[10];
|
||||
float w, x, y, z;
|
||||
if (trace > 0.0) {
|
||||
const float s = 0.5f / sqrt(trace + 1.0f);
|
||||
const float s = 0.5f / sqrtf(trace + 1.0f);
|
||||
w = 0.25f / s;
|
||||
x = (m[9] - m[6]) * s;
|
||||
y = (m[2] - m[8]) * s;
|
||||
z = (m[4] - m[1]) * s;
|
||||
} else if (m[0] > m[5] && m[0] > m[10]) {
|
||||
const float s = 2.0f * sqrt(1.0f + m[0] - m[5] - m[10]);
|
||||
const float s = 2.0f * sqrtf(1.0f + m[0] - m[5] - m[10]);
|
||||
w = (m[9] - m[6]) / s;
|
||||
x = 0.25f * s;
|
||||
y = (m[1] + m[4]) / s;
|
||||
z = (m[2] + m[8]) / s;
|
||||
} else if (m[5] > m[10]) {
|
||||
const float s = 2.0f * sqrt(1.0f + m[5] - m[0] - m[10]);
|
||||
const float s = 2.0f * sqrtf(1.0f + m[5] - m[0] - m[10]);
|
||||
w = (m[2] - m[8]) / s;
|
||||
x = (m[1] + m[4]) / s;
|
||||
y = 0.25f * s;
|
||||
z = (m[6] + m[9]) / s;
|
||||
} else {
|
||||
const float s = 2.0f * sqrt(1.0f + m[10] - m[0] - m[5]);
|
||||
const float s = 2.0f * sqrtf(1.0f + m[10] - m[0] - m[5]);
|
||||
w = (m[4] - m[1]) / s;
|
||||
x = (m[2] + m[8]) / s;
|
||||
y = (m[6] + m[9]) / s;
|
||||
@@ -423,9 +423,9 @@ Quaternion Quaternion::Slerp(const Quaternion &a, const Quaternion &b, float t)
|
||||
return Lerp(c, b, t);
|
||||
}
|
||||
|
||||
float halftheta = acos(coshalftheta);
|
||||
float halftheta = acosf(coshalftheta);
|
||||
|
||||
return (c * sin((1.0f - t) * halftheta) + b * sin(t * halftheta)) / sin(halftheta);
|
||||
return (c * sinf((1.0f - t) * halftheta) + b * sinf(t * halftheta)) / sinf(halftheta);
|
||||
}
|
||||
|
||||
} // namespace kraken
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace {
|
||||
|
||||
// Return the distance to the [first] intersecting point
|
||||
|
||||
distance = v - sqrt(d);
|
||||
distance = v - sqrtf(d);
|
||||
if (distance < 0.0f) {
|
||||
return false;
|
||||
}
|
||||
@@ -175,7 +175,7 @@ bool Triangle3::rayCast(const Vector3 &start, const Vector3 &dir, Vector3 &hit_p
|
||||
|
||||
// get intersect point of ray with triangle plane
|
||||
r = a / b;
|
||||
if (r < 0.0) // ray goes away from triangle
|
||||
if (r < 0.0f) // ray goes away from triangle
|
||||
return false; // => no intersect
|
||||
// for a segment, also test if (r > 1.0) => no intersect
|
||||
|
||||
@@ -195,10 +195,10 @@ bool Triangle3::rayCast(const Vector3 &start, const Vector3 &dir, Vector3 &hit_p
|
||||
// get and test parametric coords
|
||||
float s, t;
|
||||
s = (uv * wv - vv * wu) / D;
|
||||
if (s < 0.0 || s > 1.0) // plane_hit_point is outside triangle
|
||||
if (s < 0.0f || s > 1.0f) // plane_hit_point is outside triangle
|
||||
return false;
|
||||
t = (uv * wu - uu * wv) / D;
|
||||
if (t < 0.0 || (s + t) > 1.0) // plane_hit_point is outside triangle
|
||||
if (t < 0.0f || (s + t) > 1.0f) // plane_hit_point is outside triangle
|
||||
return false;
|
||||
|
||||
// plane_hit_point is inside the triangle
|
||||
|
||||
@@ -278,11 +278,11 @@ Vector3 Vector3::Slerp(const Vector3 &v1, const Vector3 &v2, float d) {
|
||||
// Acos(dot) returns the angle between start and end,
|
||||
// And multiplying that by percent returns the angle between
|
||||
// start and the final result.
|
||||
float theta = acos(dot)*d;
|
||||
float theta = acosf(dot)*d;
|
||||
Vector3 RelativeVec = v2 - v1*dot;
|
||||
RelativeVec.normalize(); // Orthonormal basis
|
||||
// The final result.
|
||||
return ((v1*cos(theta)) + (RelativeVec*sin(theta)));
|
||||
return ((v1*cosf(theta)) + (RelativeVec*sinf(theta)));
|
||||
}
|
||||
|
||||
void Vector3::OrthoNormalize(Vector3 &normal, Vector3 &tangent) {
|
||||
|
||||
@@ -175,11 +175,11 @@ Vector4 Vector4::Slerp(const Vector4 &v1, const Vector4 &v2, float d) {
|
||||
// Acos(dot) returns the angle between start and end,
|
||||
// And multiplying that by percent returns the angle between
|
||||
// start and the final result.
|
||||
float theta = acos(dot)*d;
|
||||
float theta = acosf(dot)*d;
|
||||
Vector4 RelativeVec = v2 - v1*dot;
|
||||
RelativeVec.normalize(); // Orthonormal basis
|
||||
// The final result.
|
||||
return ((v1*cos(theta)) + (RelativeVec*sin(theta)));
|
||||
return ((v1*cosf(theta)) + (RelativeVec*sinf(theta)));
|
||||
}
|
||||
|
||||
void Vector4::OrthoNormalize(Vector4 &normal, Vector4 &tangent) {
|
||||
|
||||
Reference in New Issue
Block a user