Browse Source

MeshTools: rename boundingBoxAxisAligned() to boundingRange().

I wanted to cross-link the intersection algos in Math with these and
realized this naming would be more consistent with what's already there.
pull/559/head
Vladimír Vondruš 4 years ago
parent
commit
c66797f654
  1. 3
      doc/changelog.dox
  2. 2
      src/Magnum/MeshTools/BoundingVolume.cpp
  3. 8
      src/Magnum/MeshTools/BoundingVolume.h
  4. 26
      src/Magnum/MeshTools/Test/BoundingVolumeTest.cpp

3
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

2
src/Magnum/MeshTools/BoundingVolume.cpp

@ -35,7 +35,7 @@
namespace Magnum { namespace MeshTools {
Range3D boundingBoxAxisAligned(const Containers::StridedArrayView1D<const Vector3>& points) {
Range3D boundingRange(const Containers::StridedArrayView1D<const Vector3>& points) {
return Math::minmax(points);
}

8
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<const T>&).
*/
MAGNUM_MESHTOOLS_EXPORT Range3D boundingBoxAxisAligned(const Containers::StridedArrayView1D<const Vector3>& positions);
MAGNUM_MESHTOOLS_EXPORT Range3D boundingRange(const Containers::StridedArrayView1D<const Vector3>& positions);
/**
@brief Calculate an approximate bounding sphere using the Bouncing Bubble

26
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<Vector3>(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<Vector3> 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();
}

Loading…
Cancel
Save