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 <ckulla@gmail.com>
  • Loading branch information
fpsunflower committed May 2, 2022
1 parent a2446e3 commit 3ffb078
Show file tree
Hide file tree
Showing 23 changed files with 333 additions and 323 deletions.
32 changes: 16 additions & 16 deletions src/Imath/ImathMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -3574,22 +3574,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 @@ -1094,7 +1094,7 @@ addOffset (
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
18 changes: 4 additions & 14 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 <limits.h>
Expand Down Expand Up @@ -378,28 +379,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
34 changes: 21 additions & 13 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 @@ -94,7 +94,7 @@ testConstructors (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> b (p);
assert (b.min == p && b.max == p);
Expand All @@ -108,8 +108,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 @@ -625,7 +625,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 @@ -684,8 +684,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 @@ -737,8 +739,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 @@ -791,8 +795,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 @@ -853,8 +859,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
50 changes: 25 additions & 25 deletions src/ImathTest/testBoxAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ 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));
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 @@ -99,8 +99,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 @@ -142,19 +142,19 @@ 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));
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));
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 @@ -423,9 +423,9 @@ 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));
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 @@ -471,8 +471,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 @@ -504,9 +504,9 @@ 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));
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 @@ -531,19 +531,19 @@ 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));
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));
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 =
Expand Down
16 changes: 8 additions & 8 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 @@ -103,9 +103,9 @@ testRandomAngles (
//

Eulerf e (
rad (r.nextf (-180, 180)),
rad (r.nextf (-180, 180)),
rad (r.nextf (-180, 180)),
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 @@ -116,7 +116,7 @@ testRandomAngles (

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 @@ -176,19 +176,19 @@ test (
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

0 comments on commit 3ffb078

Please sign in to comment.