Daniele Bartolini vor 10 Jahren
Ursprung
Commit
ffb88914a7

+ 1 - 1
src/core/math/intersection.cpp

@@ -39,7 +39,7 @@ float ray_sphere_intersection(const Vector3& from, const Vector3& dir, const Sph
 		return -1.0f;
 	}
 
-	return b - sqrt(det);
+	return b - sqrtf(det);
 }
 
 // http://www.opengl-tutorial.org/miscellaneous/clicking-on-objects/picking-with-custom-ray-obb-function/

+ 1 - 61
src/core/math/math_utils.h

@@ -71,66 +71,6 @@ inline bool is_pow_2(uint32_t x)
 	return !(x & (x - 1)) && x;
 }
 
-inline float ceil(float x)
-{
-	return ceilf(x);
-}
-
-inline float floor(float x)
-{
-	return floorf(x);
-}
-
-inline float sqrt(float x)
-{
-	return sqrtf(x);
-}
-
-inline float inv_sqrt(float x)
-{
-	return 1.0f / sqrt(x);
-}
-
-inline float sin(float x)
-{
-	return sinf(x);
-}
-
-inline float cos(float x)
-{
-	return cosf(x);
-}
-
-inline float asin(float x)
-{
-	return asinf(x);
-}
-
-inline float acos(float x)
-{
-	return acosf(x);
-}
-
-inline float tan(float x)
-{
-	return tanf(x);
-}
-
-inline float atan2(float y, float x)
-{
-	return atan2f(y, x);
-}
-
-inline float abs(float x)
-{
-	return fabs(x);
-}
-
-inline float fmod(float n, float d)
-{
-	return ::fmod(n, d);
-}
-
 /// Returns the linear interpolated value between @a p0 and @a p1 at time @a t
 template <typename T>
 inline T linear(const T& p0, const T& p1, float t)
@@ -143,7 +83,7 @@ template <typename T>
 inline T cosine(const T& p0, const T& p1, float t)
 {
 	const float f = t * PI;
-	const float g = (1.0f - cos(f)) * 0.5f;
+	const float g = (1.0f - cosf(f)) * 0.5f;
 
 	return p0 + (g * (p1 - p0));
 }

+ 1 - 1
src/core/math/matrix3x3.h

@@ -263,7 +263,7 @@ inline Quaternion rotation(const Matrix3x3& m)
 		index = 3;
 	}
 
-	const float biggest = sqrt(max + 1.0f) * 0.5f;
+	const float biggest = sqrtf(max + 1.0f) * 0.5f;
 	const float mult = 0.25f / biggest;
 
 	Quaternion tmp;

+ 1 - 1
src/core/math/matrix4x4.h

@@ -276,7 +276,7 @@ inline Matrix4x4 operator*(Matrix4x4 a, const Matrix4x4& b)
 /// Sets the matrix @a m to perspective.
 inline void set_perspective(Matrix4x4& m, float fovy, float aspect, float near, float far)
 {
-	const float height = 1.0f / tan(fovy * ((float) PI / 180.0f) * 0.5f);
+	const float height = 1.0f / tanf(fovy * ((float) PI / 180.0f) * 0.5f);
 	const float width = height * 1.0f / aspect;
 	const float aa = far / (far - near);
 	const float bb = -near * aa;

+ 8 - 8
src/core/math/quaternion.h

@@ -29,10 +29,10 @@ inline Quaternion quaternion(float x, float y, float z, float w)
 inline Quaternion quaternion(const Vector3& axis, float angle)
 {
 	Quaternion q;
-	q.x = axis.x * sin(angle * 0.5f);
-	q.y = axis.y * sin(angle * 0.5f);
-	q.z = axis.z * sin(angle * 0.5f);
-	q.w = cos(angle * 0.5f);
+	q.x = axis.x * sinf(angle * 0.5f);
+	q.y = axis.y * sinf(angle * 0.5f);
+	q.z = axis.z * sinf(angle * 0.5f);
+	q.w = cosf(angle * 0.5f);
 	return q;
 }
 
@@ -87,7 +87,7 @@ inline float dot(const Quaternion& a, const Quaternion& b)
 /// Returns the length of @a q.
 inline float length(const Quaternion& q)
 {
-	return sqrt(q.w * q.w + q.x * q.x + q.y * q.y + q.z * q.z);
+	return sqrtf(q.w * q.w + q.x * q.x + q.y * q.y + q.z * q.z);
 }
 
 /// Normalizes the quaternion @a q and returns the result.
@@ -121,13 +121,13 @@ inline Quaternion inverse(const Quaternion& q)
 /// Returns the quaternion @a q raised to the power of @a exp.
 inline Quaternion power(const Quaternion& q, float exp)
 {
-	if (abs(q.w) < 0.9999)
+	if (fabs(q.w) < 0.9999)
 	{
 		float alpha = acos(q.w); // alpha = theta/2
 		float new_alpha = alpha * exp;
-		float mult = sin(new_alpha) / sin(alpha);
+		float mult = sinf(new_alpha) / sinf(alpha);
 		Quaternion tmp;
-		tmp.w = cos(new_alpha);
+		tmp.w = cosf(new_alpha);
 		tmp.x = q.x * mult;
 		tmp.y = q.y * mult;
 		tmp.z = q.z * mult;

+ 2 - 2
src/core/math/sphere.h

@@ -51,7 +51,7 @@ namespace sphere
 
 			const float dist = squared_length(*p - s.c);
 			if (dist > s.r*s.r)
-				s.r = sqrt(dist);
+				s.r = sqrtf(dist);
 
 			points = (const void*)((const char*)points + stride);
 		}
@@ -71,7 +71,7 @@ namespace sphere
 			if (dist < (spheres[i].r + s.r) * (spheres[i].r + s.r))
 			{
 				if (spheres[i].r * spheres[i].r > s.r * s.r)
-					s.r = sqrt(dist + spheres[i].r * spheres[i].r);
+					s.r = sqrtf(dist + spheres[i].r * spheres[i].r);
 			}
 		}
 	}

+ 1 - 1
src/core/math/vector2.h

@@ -113,7 +113,7 @@ inline float dot(const Vector2& a, const Vector2& b)
 /// Returns the lenght of @a a.
 inline float length(const Vector2& a)
 {
-	return sqrt(a.x * a.x + a.y * a.y);
+	return sqrtf(a.x * a.x + a.y * a.y);
 }
 
 /// Returns the squared length of @a a.

+ 1 - 1
src/core/math/vector3.h

@@ -135,7 +135,7 @@ inline Vector3 cross(const Vector3& a, const Vector3& b)
 /// Returns the lenght of @a a.
 inline float length(const Vector3& a)
 {
-	return sqrt(a.x * a.x + a.y * a.y + a.z * a.z);
+	return sqrtf(a.x * a.x + a.y * a.y + a.z * a.z);
 }
 
 /// Returns the squared length of @a a.

+ 1 - 1
src/core/math/vector4.h

@@ -146,7 +146,7 @@ inline float dot(const Vector4& a, const Vector4& b)
 /// Returns the lenght of @a a.
 inline float length(const Vector4& a)
 {
-	return sqrt(a.x * a.x + a.y * a.y + a.z * a.z + a.w * a.w);
+	return sqrtf(a.x * a.x + a.y * a.y + a.z * a.z + a.w * a.w);
 }
 
 /// Returns the squared length of @a a.

+ 1 - 1
src/physics/controller.cpp

@@ -39,7 +39,7 @@ Controller::Controller(const ControllerResource* cr, SceneGraph& sg, UnitId id,
 	desc.nonWalkableMode = PxCCTNonWalkableMode::eFORCE_SLIDING;
 	desc.radius = cr->radius;
 	desc.height = cr->height;
-	desc.slopeLimit = cos(cr->slope_limit);
+	desc.slopeLimit = cosf(cr->slope_limit);
 	desc.stepOffset = cr->step_offset;
 	desc.contactOffset = cr->contact_offset;
 	desc.upDirection = PxVec3(0.0, 1.0, 0.0);

+ 6 - 6
src/renderers/debug_line.cpp

@@ -186,18 +186,18 @@ void DebugLine::add_sphere(const Vector3& center, const float radius, const Colo
 		const float rad1 = to_rad(float(deg + deg_step));
 
 		// XZ plane
-		const Vector3 start0 = vector3(cos(rad0)*radius, 0.0f, -sin(rad0)*radius);
-		const Vector3 end0   = vector3(cos(rad1)*radius, 0.0f, -sin(rad1)*radius);
+		const Vector3 start0 = vector3(cosf(rad0)*radius, 0.0f, -sinf(rad0)*radius);
+		const Vector3 end0   = vector3(cosf(rad1)*radius, 0.0f, -sinf(rad1)*radius);
 		add_line(center + start0, center + end0, color);
 
 		// XY plane
-		const Vector3 start1 = vector3(cos(rad0)*radius, sin(rad0)*radius, 0.0f);
-		const Vector3 end1   = vector3(cos(rad1)*radius, sin(rad1)*radius, 0.0f);
+		const Vector3 start1 = vector3(cosf(rad0)*radius, sinf(rad0)*radius, 0.0f);
+		const Vector3 end1   = vector3(cosf(rad1)*radius, sinf(rad1)*radius, 0.0f);
 		add_line(center + start1, center + end1, color);
 
 		// YZ plane
-		const Vector3 start2 = vector3(0.0f, sin(rad0)*radius, -cos(rad0)*radius);
-		const Vector3 end2   = vector3(0.0f, sin(rad1)*radius, -cos(rad1)*radius);
+		const Vector3 start2 = vector3(0.0f, sinf(rad0)*radius, -cosf(rad0)*radius);
+		const Vector3 end2   = vector3(0.0f, sinf(rad1)*radius, -cosf(rad1)*radius);
 		add_line(center + start2, center + end2, color);
 	}
 }