diff --git a/src/nvimage/ErrorMetric.cpp b/src/nvimage/ErrorMetric.cpp index 3f632ef..b4f0b42 100644 --- a/src/nvimage/ErrorMetric.cpp +++ b/src/nvimage/ErrorMetric.cpp @@ -93,9 +93,9 @@ float nv::averageColorError(const FloatImage * ref, const FloatImage * img, bool float b1 = ref->pixel(i + count * 2); float a1 = ref->pixel(i + count * 3); - float r = fabs(r0 - r1); - float g = fabs(g0 - g1); - float b = fabs(b0 - b1); + float r = fabsf(r0 - r1); + float g = fabsf(g0 - g1); + float b = fabsf(b0 - b1); float a = 1; if (alphaWeight) a = a1; @@ -125,7 +125,7 @@ float nv::averageAlphaError(const FloatImage * ref, const FloatImage * img) float a = a0 - a1; - mae += fabs(a); + mae += fabsf(a); } return float(mae / count); diff --git a/src/nvimage/Filter.cpp b/src/nvimage/Filter.cpp index 183f1fb..e30fefe 100644 --- a/src/nvimage/Filter.cpp +++ b/src/nvimage/Filter.cpp @@ -52,7 +52,7 @@ namespace return 1.0f + x*x*(-1.0f/6.0f + x*x*1.0f/120.0f); } else { - return sin(x) / x; + return sinf(x) / x; } } @@ -157,7 +157,7 @@ BoxFilter::BoxFilter(float width) : Filter(width) {} float BoxFilter::evaluate(float x) const { - if (fabs(x) <= m_width) return 1.0f; + if (fabsf(x) <= m_width) return 1.0f; else return 0.0f; } @@ -167,7 +167,7 @@ TriangleFilter::TriangleFilter(float width) : Filter(width) {} float TriangleFilter::evaluate(float x) const { - x = fabs(x); + x = fabsf(x); if( x < m_width ) return m_width - x; return 0.0f; } @@ -177,7 +177,7 @@ QuadraticFilter::QuadraticFilter() : Filter(1.5f) {} float QuadraticFilter::evaluate(float x) const { - x = fabs(x); + x = fabsf(x); if( x < 0.5f ) return 0.75f - x * x; if( x < 1.5f ) { float t = x - 1.5f; @@ -192,7 +192,7 @@ CubicFilter::CubicFilter() : Filter(1.0f) {} float CubicFilter::evaluate(float x) const { // f(t) = 2|t|^3 - 3|t|^2 + 1, -1 <= t <= 1 - x = fabs(x); + x = fabsf(x); if( x < 1.0f ) return((2.0f * x - 3.0f) * x * x + 1.0f); return 0.0f; } @@ -202,7 +202,7 @@ BSplineFilter::BSplineFilter() : Filter(2.0f) {} float BSplineFilter::evaluate(float x) const { - x = fabs(x); + x = fabsf(x); if( x < 1.0f ) return (4.0f + x * x * (-6.0f + x * 3.0f)) / 6.0f; if( x < 2.0f ) { float t = 2.0f - x; @@ -216,7 +216,7 @@ MitchellFilter::MitchellFilter() : Filter(2.0f) { setParameters(1.0f/3.0f, 1.0f/ float MitchellFilter::evaluate(float x) const { - x = fabs(x); + x = fabsf(x); if( x < 1.0f ) return p0 + x * x * (p2 + x * p3); if( x < 2.0f ) return q0 + x * (q1 + x * (q2 + x * q3)); return 0.0f; @@ -238,7 +238,7 @@ LanczosFilter::LanczosFilter() : Filter(3.0f) {} float LanczosFilter::evaluate(float x) const { - x = fabs(x); + x = fabsf(x); if( x < 3.0f ) return sincf(PI * x) * sincf(PI * x / 3.0f); return 0.0f; } @@ -357,7 +357,7 @@ void Kernel2::normalize() { float total = 0.0f; for(uint i = 0; i < m_windowSize*m_windowSize; i++) { - total += fabs(m_data[i]); + total += fabsf(m_data[i]); } float inv = 1.0f / total; diff --git a/src/nvmath/Matrix.cpp b/src/nvmath/Matrix.cpp index d171d13..75429e5 100644 --- a/src/nvmath/Matrix.cpp +++ b/src/nvmath/Matrix.cpp @@ -57,7 +57,7 @@ static bool ludcmp(float **a, int n, int *indx, float *d) } a[i][j]=sum; - float dum = vv[i]*fabs(sum); + float dum = vv[i]*fabsf(sum); if (dum >= big) { // Is the figure of merit for the pivot better than the best so far? big = dum; @@ -284,8 +284,8 @@ Matrix nv::inverse(const Matrix & m) { for (i=0; i<4; i++) { /* eliminate in column i, below diag */ max = -1.; for (k=i; k<4; k++) /* find pivot for column i */ - if (fabs(A(k, i)) > max) { - max = fabs(A(k, i)); + if (fabsf(A(k, i)) > max) { + max = fabsf(A(k, i)); j = k; } if (max<=0.) return B; /* if no nonzero pivot, PUNT */ @@ -340,7 +340,7 @@ Matrix3 nv::inverse(const Matrix3 & m) { max = -1.; for (k=i; k<3; k++) /* find pivot for column i */ if (fabs(A(k, i)) > max) { - max = fabs(A(k, i)); + max = fabsf(A(k, i)); j = k; } if (max<=0.) return B; /* if no nonzero pivot, PUNT */ diff --git a/src/nvmath/Matrix.inl b/src/nvmath/Matrix.inl index f742656..54c998f 100644 --- a/src/nvmath/Matrix.inl +++ b/src/nvmath/Matrix.inl @@ -729,7 +729,7 @@ namespace nv // Get perspective matrix. inline Matrix perspective(float fovy, float aspect, float zNear, float zFar) { - float xmax = zNear * tan(fovy / 2); + float xmax = zNear * tanf(fovy / 2); float xmin = -xmax; float ymax = xmax / aspect; @@ -741,7 +741,7 @@ namespace nv // Get inverse perspective matrix. inline Matrix perspectiveInverse(float fovy, float aspect, float zNear, float zFar) { - float xmax = zNear * tan(fovy / 2); + float xmax = zNear * tanf(fovy / 2); float xmin = -xmax; float ymax = xmax / aspect; @@ -753,7 +753,7 @@ namespace nv // Get infinite perspective matrix. inline Matrix perspective(float fovy, float aspect, float zNear) { - float x = zNear * tan(fovy / 2); + float x = zNear * tanf(fovy / 2); float y = x / aspect; return frustum( -x, x, -y, y, zNear ); } diff --git a/src/nvmath/nvmath.h b/src/nvmath/nvmath.h index d15a506..259ab63 100644 --- a/src/nvmath/nvmath.h +++ b/src/nvmath/nvmath.h @@ -222,7 +222,7 @@ namespace nv inline float frac(float f) { - return f - floor(f); + return f - floorf(f); } inline float floatRound(float f) diff --git a/src/nvtt/CubeSurface.cpp b/src/nvtt/CubeSurface.cpp index 22b6a45..f79aa14 100644 --- a/src/nvtt/CubeSurface.cpp +++ b/src/nvtt/CubeSurface.cpp @@ -39,7 +39,7 @@ using namespace nvtt; // Solid angle of an axis aligned quad from (0,0,1) to (x,y,1) // See: http://www.fizzmoll11.com/thesis/ for a derivation of this formula. static float areaElement(float x, float y) { - return atan2(x*y, sqrtf(x*x + y*y + 1)); + return atan2f(x*y, sqrtf(x*x + y*y + 1)); } // Solid angle of a hemicube texel. @@ -206,19 +206,19 @@ static const Vector3 faceV[6] = { static Vector2 toPolar(Vector3::Arg v) { Vector2 p; - p.x = atan2(v.x, v.y); // theta + p.x = atan2f(v.x, v.y); // theta p.y = acosf(v.z); // phi return p; } static Vector2 toPlane(float theta, float phi) { - float x = sin(phi) * cos(theta); - float y = sin(phi) * sin(theta); - float z = cos(phi); + float x = sinf(phi) * cosf(theta); + float y = sinf(phi) * sinf(theta); + float z = cosf(phi); Vector2 p; - p.x = x / fabs(z); - p.y = y / fabs(z); + p.x = x / fabsf(z); + p.y = y / fabsf(z); //p.x = tan(phi) * cos(theta); //p.y = tan(phi) * sin(theta); @@ -227,8 +227,8 @@ static Vector2 toPlane(float theta, float phi) { static Vector2 toPlane(Vector3::Arg v) { Vector2 p; - p.x = v.x / fabs(v.z); - p.y = v.y / fabs(v.z); + p.x = v.x / fabsf(v.z); + p.y = v.y / fabsf(v.z); return p; } @@ -569,7 +569,7 @@ CubeSurface CubeSurface::irradianceFilter(int size, EdgeFixup fixupMethod) const // Convolve filter against this cube. Vector3 CubeSurface::Private::applyAngularFilter(const Vector3 & filterDir, float coneAngle, float * filterTable, int tableSize) { - const float cosineConeAngle = cos(coneAngle); + const float cosineConeAngle = cosf(coneAngle); nvDebugCheck(cosineConeAngle >= 0); Vector3 color(0); @@ -690,7 +690,7 @@ Vector3 CubeSurface::Private::applyAngularFilter(const Vector3 & filterDir, floa // Convolve filter against this cube. Vector3 CubeSurface::Private::applyCosinePowerFilter(const Vector3 & filterDir, float coneAngle, float cosinePower) { - const float cosineConeAngle = cos(coneAngle); + const float cosineConeAngle = cosf(coneAngle); nvDebugCheck(cosineConeAngle >= 0); Vector3 color(0); diff --git a/src/nvtt/Surface.cpp b/src/nvtt/Surface.cpp index 2d64dea..81775de 100644 --- a/src/nvtt/Surface.cpp +++ b/src/nvtt/Surface.cpp @@ -1993,7 +1993,7 @@ static Color32 toRgbe8(float r, float g, float b) } else { int e; - v = frexp(v, &e) * 256.0f / v; + v = frexpf(v, &e) * 256.0f / v; c.r = uint8(clamp(r * v, 0.0f, 255.0f)); c.g = uint8(clamp(g * v, 0.0f, 255.0f)); c.b = uint8(clamp(b * v, 0.0f, 255.0f)); @@ -2845,13 +2845,13 @@ void Surface::transformNormals(NormalTransform xform) float discriminant = b * b - 4.0f * a * c; float t = (-b + sqrtf(discriminant)) / (2.0f * a); - float d = fabs(n.z * t - (1 - n.x*n.x*t*t) * (1 - n.y*n.y*t*t)); + float d = fabsf(n.z * t - (1 - n.x*n.x*t*t) * (1 - n.y*n.y*t*t)); while (d > 0.0001) { float ft = 1 - n.z * t - (n.x*n.x + n.y*n.y)*t*t + n.x*n.x*n.y*n.y*t*t*t*t; float fit = - n.z - 2*(n.x*n.x + n.y*n.y)*t + 4*n.x*n.x*n.y*n.y*t*t*t; t -= ft / fit; - d = fabs(n.z * t - (1 - n.x*n.x*t*t) * (1 - n.y*n.y*t*t)); + d = fabsf(n.z * t - (1 - n.x*n.x*t*t) * (1 - n.y*n.y*t*t)); }; n.x = n.x * t;