diff --git a/doc/changelog.dox b/doc/changelog.dox index 4b5682510..c2cf40483 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -174,8 +174,7 @@ See also: - New @ref MeshTools::boundingSphereBouncingBubble() algorithm for calculating a tight bounding sphere for a mesh, along with a trivial - @ref MeshTools::boundingBoxAxisAligned() for AABBs (see - [mosra/magnum#557](https://github.com/mosra/magnum/pull/557)) + @ref MeshTools::boundingRange() for AABBs (see [mosra/magnum#557](https://github.com/mosra/magnum/pull/557)) - Added @ref MeshTools::generateQuadIndices() for quad triangulation including non-convex and non-planar quads - New @ref MeshTools::filterOnlyAttributes() and diff --git a/src/Magnum/MeshTools/BoundingVolume.cpp b/src/Magnum/MeshTools/BoundingVolume.cpp index a3fd65b97..9fd59c4c3 100644 --- a/src/Magnum/MeshTools/BoundingVolume.cpp +++ b/src/Magnum/MeshTools/BoundingVolume.cpp @@ -35,7 +35,7 @@ namespace Magnum { namespace MeshTools { -Range3D boundingBoxAxisAligned(const Containers::StridedArrayView1D& points) { +Range3D boundingRange(const Containers::StridedArrayView1D& points) { return Math::minmax(points); } diff --git a/src/Magnum/MeshTools/BoundingVolume.h b/src/Magnum/MeshTools/BoundingVolume.h index 0b5582d62..d99a6a382 100644 --- a/src/Magnum/MeshTools/BoundingVolume.h +++ b/src/Magnum/MeshTools/BoundingVolume.h @@ -27,7 +27,7 @@ */ /** @file - * @brief Function @ref Magnum::MeshTools::boundingBoxAxisAligned(), @ref Magnum::MeshTools::boundingSphereBouncingBubble() + * @brief Function @ref Magnum::MeshTools::boundingRange(), @ref Magnum::MeshTools::boundingSphereBouncingBubble() * @m_since_latest */ @@ -37,14 +37,14 @@ namespace Magnum { namespace MeshTools { /** -@brief Calculate an axis-aligned bounding box +@brief Calculate a bounding range @param positions Vertex positions -@return Bounding box +@return Bounding range @m_since_latest Same as @ref Math::minmax(const Corrade::Containers::StridedArrayView1D&). */ -MAGNUM_MESHTOOLS_EXPORT Range3D boundingBoxAxisAligned(const Containers::StridedArrayView1D& positions); +MAGNUM_MESHTOOLS_EXPORT Range3D boundingRange(const Containers::StridedArrayView1D& positions); /** @brief Calculate an approximate bounding sphere using the Bouncing Bubble diff --git a/src/Magnum/MeshTools/Test/BoundingVolumeTest.cpp b/src/Magnum/MeshTools/Test/BoundingVolumeTest.cpp index 56af073e2..4a2613a0a 100644 --- a/src/Magnum/MeshTools/Test/BoundingVolumeTest.cpp +++ b/src/Magnum/MeshTools/Test/BoundingVolumeTest.cpp @@ -48,42 +48,42 @@ namespace Magnum { namespace MeshTools { namespace Test { namespace { struct BoundingVolumeTest: TestSuite::Tester { explicit BoundingVolumeTest(); - void boxAxisAligned(); - void boxAxisAlignedNaN(); + void range(); + void rangeNaN(); void sphereBouncingBubble(); void sphereBouncingBubbleNaN(); - void benchmarkBoxAxisAligned(); + void benchmarkRange(); void benchmarkSphereBouncingBubble(); }; BoundingVolumeTest::BoundingVolumeTest() { - addTests({&BoundingVolumeTest::boxAxisAligned, - &BoundingVolumeTest::boxAxisAlignedNaN, + addTests({&BoundingVolumeTest::range, + &BoundingVolumeTest::rangeNaN, &BoundingVolumeTest::sphereBouncingBubble, &BoundingVolumeTest::sphereBouncingBubbleNaN}); - addBenchmarks({&BoundingVolumeTest::benchmarkBoxAxisAligned, + addBenchmarks({&BoundingVolumeTest::benchmarkRange, &BoundingVolumeTest::benchmarkSphereBouncingBubble}, 150); } -void BoundingVolumeTest::boxAxisAligned() { +void BoundingVolumeTest::range() { /* boundingboxAxisAligned() is just a wrapper around minmax() so only test that the input and output are forwarded correctly */ constexpr Float cylinderLength = 7.0f; const Trade::MeshData cylinderMesh = Primitives::capsule3DSolid(3, 1, 12, cylinderLength*0.5f); - const Range3D box = MeshTools::boundingBoxAxisAligned( + const Range3D box = MeshTools::boundingRange( cylinderMesh.attribute(Trade::MeshAttribute::Position)); CORRADE_COMPARE(box.center(), Vector3{}); CORRADE_COMPARE(box.size(), (Vector3{2.0f, cylinderLength + 2.0f, 2.0f})); } -void BoundingVolumeTest::boxAxisAlignedNaN() { +void BoundingVolumeTest::rangeNaN() { /* NaNs are skipped (unless it's all NaNs), matching minmax() behaviour */ { - const Range3D box = MeshTools::boundingBoxAxisAligned(Containers::stridedArrayView({ + const Range3D box = MeshTools::boundingRange(Containers::stridedArrayView({ Vector3{Constants::nan()}, Vector3{1.0f, 1.0f, 1.0f}, Vector3{Constants::nan()}, @@ -93,7 +93,7 @@ void BoundingVolumeTest::boxAxisAlignedNaN() { CORRADE_COMPARE(box.min(), (Vector3{1.0f, 1.0f, 1.0f})); CORRADE_COMPARE(box.max(), (Vector3{2.0f, 2.0f, 2.0f})); } { - const Range3D box = MeshTools::boundingBoxAxisAligned(Containers::stridedArrayView({ + const Range3D box = MeshTools::boundingRange(Containers::stridedArrayView({ Vector3{Constants::nan()}, Vector3{Constants::nan()} })); @@ -230,7 +230,7 @@ void BoundingVolumeTest::sphereBouncingBubbleNaN() { } } -void BoundingVolumeTest::benchmarkBoxAxisAligned() { +void BoundingVolumeTest::benchmarkRange() { Containers::Array points{NoInit, 500}; for(size_t i = 0; i < points.size(); ++i) { points[i] = Vector3{Float(i)*0.01f}; @@ -238,7 +238,7 @@ void BoundingVolumeTest::benchmarkBoxAxisAligned() { Float r = 0.0f; CORRADE_BENCHMARK(50) { - const Range3D box = MeshTools::boundingBoxAxisAligned(points); + const Range3D box = MeshTools::boundingRange(points); r += box.size().x(); }