Fix compilation warnings

This commit is contained in:
Wojtek Figat
2021-02-17 10:59:08 +01:00
parent 25f61e931e
commit 7cc5560adf
3 changed files with 19 additions and 19 deletions

View File

@@ -11,21 +11,21 @@ namespace Utilities
template<typename T>
FORCE_INLINE T RoundTo1DecimalPlace(T value)
{
return round(value * 10) / 10;
return (T)round((double)value * 10) / (T)10;
}
// Round floating point value up to 2 decimal places
template<typename T>
FORCE_INLINE T RoundTo2DecimalPlaces(T value)
{
return round(value * 100) / 100;
return (T)round((double)value * 100.0) / (T)100;
}
// Round floating point value up to 3 decimal places
template<typename T>
FORCE_INLINE T RoundTo3DecimalPlaces(T value)
{
return round(value * 1000) / 1000;
return (T)round((double)value * 1000.0) / (T)1000;
}
// Converts size of the file (in bytes) to the best fitting string

View File

@@ -313,10 +313,10 @@ bool DebugDrawService::Init()
for (float a = 0.0f; a < TWO_PI; a += step)
{
// Calculate sines and cosines
float sinA = sin(a);
float cosA = cos(a);
float sinB = sin(a + step);
float cosB = cos(a + step);
float sinA = Math::Sin(a);
float cosA = Math::Cos(a);
float sinB = Math::Sin(a + step);
float cosB = Math::Cos(a + step);
// XY loop
SphereCache[index++] = Vector3(cosA, sinA, 0.0f);
@@ -337,10 +337,10 @@ bool DebugDrawService::Init()
for (float a = 0.0f; a < TWO_PI; a += step)
{
// Calculate sines and cosines
float sinA = sin(a);
float cosA = cos(a);
float sinB = sin(a + step);
float cosB = cos(a + step);
float sinA = Math::Sin(a);
float cosA = Math::Cos(a);
float sinB = Math::Sin(a + step);
float cosB = Math::Cos(a + step);
CircleCache[index++] = Vector3(cosA, sinA, 0.0f);
CircleCache[index++] = Vector3(cosB, sinB, 0.0f);
@@ -1049,10 +1049,10 @@ void DebugDraw::DrawWireTube(const Vector3& position, const Quaternion& orientat
{
// Calculate sines and cosines
// TODO: optimize this stuff
float sinA = sin(a) * radius;
float cosA = cos(a) * radius;
float sinB = sin(a + step) * radius;
float cosB = cos(a + step) * radius;
float sinA = Math::Sin(a) * radius;
float cosA = Math::Cos(a) * radius;
float sinB = Math::Sin(a + step) * radius;
float cosB = Math::Cos(a + step) * radius;
// First XY loop
DRAW_WIRE_BOX_LINE(cosA, sinA, -halfLength, cosB, sinB, -halfLength);
@@ -1098,8 +1098,8 @@ void DebugDraw::DrawWireCylinder(const Vector3& position, const Quaternion& orie
{
// Cache data
float theta = i * angleBetweenFacets;
float x = cos(theta) * radius;
float z = sin(theta) * radius;
float x = Math::Cos(theta) * radius;
float z = Math::Sin(theta) * radius;
// Top cap
CylinderCache[index++] = Vector3(x, verticalOffset, z);

View File

@@ -198,8 +198,8 @@ void SpotLight::OnDebugDrawSelected()
Vector3 up = _transform.GetUp();
Vector3 forward = GetDirection();
float radius = GetScaledRadius();
float discRadius = radius * tan(_outerConeAngle * DegreesToRadians);
float falloffDiscRadius = radius * tan(_innerConeAngle * DegreesToRadians);
float discRadius = radius * Math::Tan(_outerConeAngle * DegreesToRadians);
float falloffDiscRadius = radius * Math::Tan(_innerConeAngle * DegreesToRadians);
Vector3 position = GetPosition();
DEBUG_DRAW_LINE(position, position + forward * radius + up * discRadius, color, 0, true);