diff --git a/src/Magnum/MeshTools/Test/BoundingVolumeTest.cpp b/src/Magnum/MeshTools/Test/BoundingVolumeTest.cpp index a50824429..c86265dec 100644 --- a/src/Magnum/MeshTools/Test/BoundingVolumeTest.cpp +++ b/src/Magnum/MeshTools/Test/BoundingVolumeTest.cpp @@ -48,6 +48,7 @@ struct BoundingVolumeTest: TestSuite::Tester { void boxAxisAligned(); void sphereBouncingBubble(); + void sphereBouncingBubbleNaN(); void benchmarkBoxAxisAligned(); void benchmarkSphereBouncingBubble(); @@ -55,7 +56,8 @@ struct BoundingVolumeTest: TestSuite::Tester { BoundingVolumeTest::BoundingVolumeTest() { addTests({&BoundingVolumeTest::boxAxisAligned, - &BoundingVolumeTest::sphereBouncingBubble}); + &BoundingVolumeTest::sphereBouncingBubble, + &BoundingVolumeTest::sphereBouncingBubbleNaN}); addBenchmarks({&BoundingVolumeTest::benchmarkBoxAxisAligned, &BoundingVolumeTest::benchmarkSphereBouncingBubble}, 150); @@ -121,32 +123,6 @@ void BoundingVolumeTest::sphereBouncingBubble() { CORRADE_COMPARE(sphere.first(), (Vector3{0.0f, 0.0f, 0.0f})); CORRADE_COMPARE(sphere.second(), 2.0f); - /* NaN position -- ignored except for the first */ - } { - const Containers::Pair sphere = - MeshTools::boundingSphereBouncingBubble(Containers::stridedArrayView({ - Vector3{1.0f, 1.0f, 1.0f}, - Vector3{Math::Constants::nan()}, - Vector3{2.0f, 2.0f, 2.0f} - })); - CORRADE_COMPARE(sphere.first(), (Vector3{1.5f})); - CORRADE_COMPARE(sphere.second(), Vector3{0.5f}.length()); - - } { - const Containers::Pair sphere = - MeshTools::boundingSphereBouncingBubble(Containers::stridedArrayView({ - Vector3{Math::Constants::nan()}, - Vector3{1.0f, 1.0f, 1.0f}, - Vector3{2.0f, 2.0f, 2.0f} - })); - { - CORRADE_EXPECT_FAIL("NaN in the first position is not ignored."); - CORRADE_COMPARE(sphere.first(), (Vector3{1.5f})); - CORRADE_COMPARE(sphere.second(), Vector3{0.5f}.length()); - } - CORRADE_VERIFY(Math::isNan(sphere.first())); - CORRADE_COMPARE(sphere.second(), Math::TypeTraits::epsilon()); - /* Icosphere -- original/translated and scaled */ } { const Trade::MeshData sphereMesh = Primitives::icosphereSolid(1); @@ -197,6 +173,36 @@ void BoundingVolumeTest::sphereBouncingBubble() { } } +void BoundingVolumeTest::sphereBouncingBubbleNaN() { + /* NaN is ignored except for the first position element */ + { + const Containers::Pair sphere = + MeshTools::boundingSphereBouncingBubble(Containers::stridedArrayView({ + Vector3{1.0f, 1.0f, 1.0f}, + Vector3{Constants::nan()}, + Vector3{2.0f, 2.0f, 2.0f}, + Vector3{Constants::nan()} + })); + CORRADE_COMPARE(sphere.first(), (Vector3{1.5f})); + CORRADE_COMPARE(sphere.second(), Vector3{0.5f}.length()); + + } { + const Containers::Pair sphere = + MeshTools::boundingSphereBouncingBubble(Containers::stridedArrayView({ + Vector3{Constants::nan()}, + Vector3{1.0f, 1.0f, 1.0f}, + Vector3{2.0f, 2.0f, 2.0f} + })); + { + CORRADE_EXPECT_FAIL("NaN in the first position is not ignored."); + CORRADE_COMPARE(sphere.first(), (Vector3{1.5f})); + CORRADE_COMPARE(sphere.second(), Vector3{0.5f}.length()); + } + CORRADE_VERIFY(Math::isNan(sphere.first())); + CORRADE_COMPARE(sphere.second(), Math::TypeTraits::epsilon()); + } +} + void BoundingVolumeTest::benchmarkBoxAxisAligned() { Containers::Array points{NoInit, 500}; for(size_t i = 0; i < points.size(); ++i) {