diff --git a/src/MeshTools/Test/TipsifyTest.cpp b/src/MeshTools/Test/TipsifyTest.cpp index db587a7bb..d52443bc1 100644 --- a/src/MeshTools/Test/TipsifyTest.cpp +++ b/src/MeshTools/Test/TipsifyTest.cpp @@ -17,7 +17,6 @@ #include -#include "MeshBuilder.h" #include "MeshTools/Tipsify.h" QTEST_APPLESS_MAIN(Magnum::MeshTools::Test::TipsifyTest) @@ -41,38 +40,34 @@ namespace Magnum { namespace MeshTools { namespace Test { */ -TipsifyTest::TipsifyTest(QObject* parent): QObject(parent) { - unsigned int vertices[19]; /* who cares */ - static const unsigned int indices[] = { - 4, 1, 0, - 10, 9, 13, - 6, 3, 2, - 9, 5, 4, - 12, 9, 8, - 11, 7, 6, - - 14, 15, 11, - 2, 1, 5, - 10, 6, 5, - 10, 5, 9, - 13, 14, 10, - 1, 4, 5, - - 7, 3, 6, - 6, 2, 5, - 9, 4, 8, - 6, 10, 11, - 13, 9, 12, - 14, 11, 10, - - 16, 17, 18 - }; - builder.setData(vertices, indices, 19, 19*3); -} +TipsifyTest::TipsifyTest(QObject* parent): QObject(parent), indices{ + 4, 1, 0, + 10, 9, 13, + 6, 3, 2, + 9, 5, 4, + 12, 9, 8, + 11, 7, 6, + + 14, 15, 11, + 2, 1, 5, + 10, 6, 5, + 10, 5, 9, + 13, 14, 10, + 1, 4, 5, + + 7, 3, 6, + 6, 2, 5, + 9, 4, 8, + 6, 10, 11, + 13, 9, 12, + 14, 11, 10, + + 16, 17, 18 +}, vertexCount(19) {} void TipsifyTest::buildAdjacency() { vector liveTriangleCount, neighborOffset, neighbors; - Tipsify(builder).buildAdjacency(liveTriangleCount, neighborOffset, neighbors); + Tipsify(indices, vertexCount).buildAdjacency(liveTriangleCount, neighborOffset, neighbors); QVERIFY((liveTriangleCount == vector{ 1, 3, 3, 2, @@ -116,9 +111,9 @@ void TipsifyTest::buildAdjacency() { } void TipsifyTest::tipsify() { - MeshTools::tipsify(builder, 3); + MeshTools::tipsify(indices, vertexCount, 3); - QVERIFY((builder.indices() == vector{ + QVERIFY((indices == vector{ 4, 1, 0, 9, 5, 4, 1, 4, 5, diff --git a/src/MeshTools/Test/TipsifyTest.h b/src/MeshTools/Test/TipsifyTest.h index 12b2c0047..68dbf8698 100644 --- a/src/MeshTools/Test/TipsifyTest.h +++ b/src/MeshTools/Test/TipsifyTest.h @@ -17,8 +17,6 @@ #include -#include "MeshBuilder.h" - namespace Magnum { namespace MeshTools { namespace Test { class TipsifyTest: public QObject { @@ -32,7 +30,8 @@ class TipsifyTest: public QObject { void tipsify(); private: - MeshBuilder builder; + std::vector indices; + size_t vertexCount; }; }}} diff --git a/src/MeshTools/Tipsify.h b/src/MeshTools/Tipsify.h index 589f1c9cf..d9acba3df 100644 --- a/src/MeshTools/Tipsify.h +++ b/src/MeshTools/Tipsify.h @@ -19,7 +19,10 @@ * @brief Class Magnum::MeshTools::Tipsify */ -#include "AbstractTool.h" +#include +#include + +#include "utilities.h" namespace Magnum { namespace MeshTools { @@ -28,13 +31,14 @@ namespace Magnum { namespace MeshTools { See tipsify() for full documentation. */ -class MESHTOOLS_EXPORT Tipsify: public AbstractIndexTool { +class MESHTOOLS_EXPORT Tipsify { public: - /** @copydoc AbstractIndexTool::AbstractIndexTool(MeshBuilder&) */ - template inline Tipsify(MeshBuilder& builder): AbstractIndexTool(builder) {} - - /** @copydoc AbstractIndexTool::AbstractIndexTool(std::vector&, unsigned int) */ - inline Tipsify(std::vector& indices, unsigned int vertexCount): AbstractIndexTool(indices, vertexCount) {} + /** + * @brief Constructor + * + * See tipsify() for full documentation. + */ + inline Tipsify(std::vector& indices, unsigned int vertexCount): indices(indices), vertexCount(vertexCount) {} /** * @brief Functor @@ -50,12 +54,16 @@ class MESHTOOLS_EXPORT Tipsify: public AbstractIndexTool { * (used internally). */ void buildAdjacency(std::vector& liveTriangleCount, std::vector& neighborOffset, std::vector& neighbors) const; + + private: + std::vector& indices; + const unsigned int vertexCount; }; /** @brief %Tipsify the mesh -@tparam Vertex Vertex data type (the same as in MeshBuilder) -@param builder %Mesh builder to operate on +@param indices Indices array to operate on +@param vertexCount Vertex count @param cacheSize Post-transform vertex cache size Optimizes the mesh for vertex-bound applications by rearranging its index @@ -76,18 +84,6 @@ you can just write MeshTools::tipsify(builder, cacheSize); @endcode */ -template inline void tipsify(MeshBuilder& builder, size_t cacheSize) { - Tipsify{builder}(cacheSize); -} - -/** -@brief %Tipsify the mesh -@param indices Indices array to operate on -@param vertexCount Vertex count -@param cacheSize Post-transform vertex cache size - -See tipsify(MeshBuilder&, size_t) for more information. -*/ inline void tipsify(std::vector& indices, unsigned int vertexCount, size_t cacheSize) { Tipsify(indices, vertexCount)(cacheSize); }