Skip to content

Commit

Permalink
Fix compiler warnings on windows (#250)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Kulla <[email protected]>
  • Loading branch information
fpsunflower authored and cary-ilm committed Nov 3, 2022
1 parent 2d05977 commit 878127f
Show file tree
Hide file tree
Showing 23 changed files with 480 additions and 388 deletions.
32 changes: 16 additions & 16 deletions src/Imath/ImathMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -3226,22 +3226,22 @@ template <class S>
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix44<T>&
Matrix44<T>::setValue (const Matrix44<S>& v) IMATH_NOEXCEPT
{
x[0][0] = v.x[0][0];
x[0][1] = v.x[0][1];
x[0][2] = v.x[0][2];
x[0][3] = v.x[0][3];
x[1][0] = v.x[1][0];
x[1][1] = v.x[1][1];
x[1][2] = v.x[1][2];
x[1][3] = v.x[1][3];
x[2][0] = v.x[2][0];
x[2][1] = v.x[2][1];
x[2][2] = v.x[2][2];
x[2][3] = v.x[2][3];
x[3][0] = v.x[3][0];
x[3][1] = v.x[3][1];
x[3][2] = v.x[3][2];
x[3][3] = v.x[3][3];
x[0][0] = T(v.x[0][0]);
x[0][1] = T(v.x[0][1]);
x[0][2] = T(v.x[0][2]);
x[0][3] = T(v.x[0][3]);
x[1][0] = T(v.x[1][0]);
x[1][1] = T(v.x[1][1]);
x[1][2] = T(v.x[1][2]);
x[1][3] = T(v.x[1][3]);
x[2][0] = T(v.x[2][0]);
x[2][1] = T(v.x[2][1]);
x[2][2] = T(v.x[2][2]);
x[2][3] = T(v.x[2][3]);
x[3][0] = T(v.x[3][0]);
x[3][1] = T(v.x[3][1]);
x[3][2] = T(v.x[3][2]);
x[3][3] = T(v.x[3][3]);
return *this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Imath/ImathMatrixAlgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ addOffset (const Matrix44<T>& inMat,
Matrix44<T> O;

Vec3<T> _rOffset (rOffset);
_rOffset *= M_PI / 180.0;
_rOffset *= T(M_PI / 180.0);
O.rotate (_rOffset);

O[3][0] = tOffset[0];
Expand Down
16 changes: 4 additions & 12 deletions src/ImathTest/half_perf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#endif

#include <ImathConfig.h>
#include <ImathRandom.h>
#include <half.h>

#include <stdio.h>
Expand Down Expand Up @@ -372,26 +373,17 @@ main (int argc, char* argv[])

if (halfs && floats)
{
srand (numentries);
Rand48 r(numentries);
for (int i = 0; i < numentries; ++i)
{
halfs[i] = (uint16_t) (rand());
halfs[i] = (uint16_t) r.nexti();
floats[i] = imath_half_to_float (halfs[i]);
}
perf_test_half_to_float (floats, halfs, numentries);

// test float -> half with real-world values
#ifdef _WIN32
unsigned int rv;
for (int i = 0; i < numentries; ++i)
{
rand_s( &rv );
floats[i] = 65504.0 * (((double) rand() / (double) UINT_MAX) * 2.0 - 1.0);
}
#else
for (int i = 0; i < numentries; ++i)
floats[i] = 65504.0 * (drand48() * 2.0 - 1.0);
#endif
floats[i] = float(r.nextf(-65504, 65504));
perf_test_float_to_half (halfs, floats, numentries);
}

Expand Down
36 changes: 22 additions & 14 deletions src/ImathTest/testBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ addItem (const std::vector<int>& value, std::vector<T>& perms)
T p;
for (unsigned int i = 0; i < value.size(); i++)
{
p[i] = value[i];
p[i] = static_cast<typename T::BaseType>(value[i]);
}
perms.push_back (p);
}
Expand Down Expand Up @@ -92,8 +92,8 @@ testConstructors (const char* type)
//
{
T p;
for (unsigned int i = 0; i < T::dimensions(); i++)
p[i] = i;
for (unsigned int i = 0; i < T::dimensions (); i++)
p[i] = static_cast<typename T::BaseType>(i);

IMATH_INTERNAL_NAMESPACE::Box<T> b (p);
assert (b.min == p && b.max == p);
Expand All @@ -107,8 +107,8 @@ testConstructors (const char* type)
T p1;
for (unsigned int i = 0; i < T::dimensions(); i++)
{
p0[i] = i;
p1[i] = 10 * T::dimensions() - i - 1;
p0[i] = static_cast<typename T::BaseType>(i);
p1[i] = static_cast<typename T::BaseType>(10 * T::dimensions () - i - 1);
}

IMATH_INTERNAL_NAMESPACE::Box<T> b (p0, p1);
Expand Down Expand Up @@ -610,7 +610,7 @@ testSize (const char* type)
T p;
for (unsigned int i = 0; i < T::dimensions(); i++)
{
p[i] = i;
p[i] = static_cast<typename T::BaseType>(i);
}
IMATH_INTERNAL_NAMESPACE::Box<T> b1 (-p, p);
assert (b1.size() == p * T (2));
Expand Down Expand Up @@ -669,8 +669,10 @@ testCenter (const char* type)
T p1;
for (unsigned int i = 0; i < T::dimensions(); i++)
{
p0[i] = -typename T::BaseType (1 << (i + 1));
p1[i] = typename T::BaseType (1 << (T::dimensions() - i));
int lo = 1 << (i + 1);
int hi = 1 << (T::dimensions () - i);
p0[i] = -static_cast<typename T::BaseType>(lo);
p1[i] = static_cast<typename T::BaseType>(hi);
}
IMATH_INTERNAL_NAMESPACE::Box<T> b1 (p0, p1);
assert (b1.center() == (p1 + p0) / 2);
Expand Down Expand Up @@ -722,8 +724,10 @@ testIsEmpty (const char* type)
T p1;
for (unsigned int i = 0; i < T::dimensions(); i++)
{
p0[i] = -typename T::BaseType (1 << (i + 1));
p1[i] = typename T::BaseType (1 << (T::dimensions() - i));
int lo = 1 << (i + 1);
int hi = 1 << (T::dimensions () - i);
p0[i] = -static_cast<typename T::BaseType>(lo);
p1[i] = static_cast<typename T::BaseType>(hi);
}
IMATH_INTERNAL_NAMESPACE::Box<T> b1 (p0, p1);
assert (!b1.isEmpty());
Expand Down Expand Up @@ -776,8 +780,10 @@ testIsInfinite (const char* type)
T p1;
for (unsigned int i = 0; i < T::dimensions(); i++)
{
p0[i] = -typename T::BaseType (1 << (i + 1));
p1[i] = typename T::BaseType (1 << (T::dimensions() - i));
int lo = 1 << (i + 1);
int hi = 1 << (T::dimensions () - i);
p0[i] = -static_cast<typename T::BaseType>(lo);
p1[i] = static_cast<typename T::BaseType>(hi);
}
IMATH_INTERNAL_NAMESPACE::Box<T> b1 (p0, p1);
assert (!b1.isInfinite());
Expand Down Expand Up @@ -838,8 +844,10 @@ testHasVolume (const char* type)
T p1;
for (unsigned int i = 0; i < T::dimensions(); i++)
{
p0[i] = -typename T::BaseType (1 << (i + 1));
p1[i] = typename T::BaseType (1 << (T::dimensions() - i));
int lo = 1 << (i + 1);
int hi = 1 << (T::dimensions () - i);
p0[i] = -static_cast<typename T::BaseType>(lo);
p1[i] = static_cast<typename T::BaseType>(hi);
}
IMATH_INTERNAL_NAMESPACE::Box<T> b1 (p0, p1);
assert (b1.hasVolume());
Expand Down
57 changes: 32 additions & 25 deletions src/ImathTest/testBoxAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ testEntryAndExitPoints (const Box3f& box)

for (int i = 0; i < 100000; ++i)
{
V3f p1 (random.nextf (box.max.x, box.min.x),
random.nextf (box.max.y, box.min.y),
random.nextf (box.max.z, box.min.z));
V3f p1 (
float(random.nextf (box.max.x, box.min.x)),
float(random.nextf (box.max.y, box.min.y)),
float(random.nextf (box.max.z, box.min.z)));

V3f p2 (p1 + hollowSphereRand<V3f> (random));

Expand Down Expand Up @@ -91,8 +92,8 @@ testEntryAndExitPoints (const Box3f& box)
// box, and it passes the box at a minimum distance of r1.
//

const float r1 = 0.00001;
const float r2 = 1.0;
const float r1 = 0.00001f;
const float r2 = 1.0f;

V3f p1 = box.min + r2 * hollowSphereRand<V3f> (random);
V3f p2;
Expand Down Expand Up @@ -133,18 +134,20 @@ testEntryAndExitPoints (const Box3f& box)

do
{
p1 = V3f (random.nextf (bigBox.min.x, bigBox.max.x),
random.nextf (bigBox.min.y, bigBox.max.y),
random.nextf (bigBox.min.z, bigBox.max.z));
p1 = V3f (
float(random.nextf (bigBox.min.x, bigBox.max.x)),
float(random.nextf (bigBox.min.y, bigBox.max.y)),
float(random.nextf (bigBox.min.z, bigBox.max.z)));
} while (box.intersects (p1));

V3f p2;

do
{
p2 = V3f (random.nextf (box.min.x, box.max.x),
random.nextf (box.min.y, box.max.y),
random.nextf (box.min.z, box.max.z));
p2 = V3f (
float(random.nextf (box.min.x, box.max.x)),
float(random.nextf (box.min.y, box.max.y)),
float(random.nextf (box.min.z, box.max.z)));
} while (approximatelyEqual (p1, p2, e));

Line3f ray (p1, p2);
Expand Down Expand Up @@ -422,9 +425,10 @@ testRayBoxIntersection (const Box3f& box)

for (int i = 0; i < 100000; ++i)
{
V3f p1 (random.nextf (box.max.x, box.min.x),
random.nextf (box.max.y, box.min.y),
random.nextf (box.max.z, box.min.z));
V3f p1 (
float(random.nextf (box.max.x, box.min.x)),
float(random.nextf (box.max.y, box.min.y)),
float(random.nextf (box.max.z, box.min.z)));

V3f p2 (p1 + hollowSphereRand<V3f> (random));

Expand Down Expand Up @@ -462,8 +466,8 @@ testRayBoxIntersection (const Box3f& box)
// box, and it passes the box at a minimum distance of r1.
//

const float r1 = 0.00001;
const float r2 = 1.0;
const float r1 = 0.00001f;
const float r2 = 1.0f;

V3f p1 = box.min + r2 * hollowSphereRand<V3f> (random);
V3f p2;
Expand Down Expand Up @@ -494,9 +498,10 @@ testRayBoxIntersection (const Box3f& box)

for (int i = 0; i < 1000; ++i)
{
V3f p1 (random.nextf (box.min.x, box.max.x),
random.nextf (box.min.y, box.max.y),
random.nextf (box.min.z, box.max.z));
V3f p1 (
float(random.nextf (box.min.x, box.max.x)),
float(random.nextf (box.min.y, box.max.y)),
float(random.nextf (box.min.z, box.max.z)));

V3f p2 (p1 + hollowSphereRand<V3f> (random));

Expand All @@ -520,18 +525,20 @@ testRayBoxIntersection (const Box3f& box)

do
{
p1 = V3f (random.nextf (bigBox.min.x, bigBox.max.x),
random.nextf (bigBox.min.y, bigBox.max.y),
random.nextf (bigBox.min.z, bigBox.max.z));
p1 = V3f (
float(random.nextf (bigBox.min.x, bigBox.max.x)),
float(random.nextf (bigBox.min.y, bigBox.max.y)),
float(random.nextf (bigBox.min.z, bigBox.max.z)));
} while (box.intersects (p1));

V3f p2;

do
{
p2 = V3f (random.nextf (box.min.x, box.max.x),
random.nextf (box.min.y, box.max.y),
random.nextf (box.min.z, box.max.z));
p2 = V3f (
float(random.nextf (box.min.x, box.max.x)),
float(random.nextf (box.min.y, box.max.y)),
float(random.nextf (box.min.z, box.max.z)));
} while (approximatelyEqual (p1, p2, e));

Line3f ray (p1, p2);
Expand Down
2 changes: 1 addition & 1 deletion src/ImathTest/testColor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ testColor()
assert (in3 == out3);

IMATH_INTERNAL_NAMESPACE::C4c testConstructor1;
IMATH_INTERNAL_NAMESPACE::C4c testConstructor1i (0.f);
IMATH_INTERNAL_NAMESPACE::C4c testConstructor1i (0);
IMATH_INTERNAL_NAMESPACE::C4c testConstructor2 (testConstructor1i);

testConstructor1 = testConstructor2; // use these so the compiler doesn't emit a warning
Expand Down
19 changes: 10 additions & 9 deletions src/ImathTest/testExtractEuler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace
float
rad (float deg)
{
return deg * (M_PI / 180);
return deg * float(M_PI / 180);
}

M44f
Expand Down Expand Up @@ -100,10 +100,11 @@ testRandomAngles (M44f (*matrixEulerMatrix) (const M44f&, Eulerf::Order), Eulerf
// Create a rotation matrix, M
//

Eulerf e (rad (r.nextf (-180, 180)),
rad (r.nextf (-180, 180)),
rad (r.nextf (-180, 180)),
Eulerf::XYZ);
Eulerf e (
rad (float(r.nextf (-180, 180))),
rad (float(r.nextf (-180, 180))),
rad (float(r.nextf (-180, 180))),
Eulerf::XYZ);

M44f M (e.toMatrix44());

Expand All @@ -113,7 +114,7 @@ testRandomAngles (M44f (*matrixEulerMatrix) (const M44f&, Eulerf::Order), Eulerf

for (int j = 0; j < 3; ++j)
for (int k = 0; k < 3; ++k)
M[j][k] += r.nextf (-1e-7, 1e-7);
M[j][k] += float(r.nextf (-1e-7, 1e-7));

//
// Extract Euler angles from M, convert the Euler angles
Expand Down Expand Up @@ -169,19 +170,19 @@ test (M44f (*matrixEulerMatrix) (const M44f&, Eulerf::Order), Eulerf::Order orde
for (int i = 0; i < 360; i += 90)
for (int j = 0; j < 360; j += 90)
for (int k = 0; k < 360; k += 90)
testAngles (V3f (i, j, k), matrixEulerMatrix, order);
testAngles (V3f (float(i), float(j), float(k)), matrixEulerMatrix, order);
}

void
testRandomAngles33()
{
Rand48 r (0);

float eps = 8.0 * std::numeric_limits<float>::epsilon();
float eps = 8.0f * std::numeric_limits<float>::epsilon ();

for (int i = 0; i < 100000; ++i)
{
float angle = rad (r.nextf (-180, 180));
float angle = rad (float(r.nextf (-180, 180)));

M33f M;
M.setRotation (angle);
Expand Down
Loading

0 comments on commit 878127f

Please sign in to comment.