diff --git a/src/Magnum/MeshTools/Duplicate.cpp b/src/Magnum/MeshTools/Duplicate.cpp index 7e4fcb997..36310e689 100644 --- a/src/Magnum/MeshTools/Duplicate.cpp +++ b/src/Magnum/MeshTools/Duplicate.cpp @@ -80,6 +80,9 @@ void duplicateInto(const Containers::StridedArrayView2D& indices, co Trade::MeshData duplicate(const Trade::MeshData& data, const Containers::ArrayView extra) { CORRADE_ASSERT(data.isIndexed(), "MeshTools::duplicate(): mesh data not indexed", (Trade::MeshData{MeshPrimitive::Triangles, 0})); + CORRADE_ASSERT(!isMeshIndexTypeImplementationSpecific(data.indexType()), + "MeshTools::duplicate(): mesh has an implementation-specific index type" << reinterpret_cast(meshIndexTypeUnwrap(data.indexType())), + (Trade::MeshData{MeshPrimitive{}, 0})); #ifndef CORRADE_NO_ASSERT for(std::size_t i = 0; i != data.attributeCount(); ++i) { const VertexFormat format = data.attributeFormat(i); diff --git a/src/Magnum/MeshTools/Duplicate.h b/src/Magnum/MeshTools/Duplicate.h index 7a1e7a808..cf3b6ee3f 100644 --- a/src/Magnum/MeshTools/Duplicate.h +++ b/src/Magnum/MeshTools/Duplicate.h @@ -144,11 +144,12 @@ is done by @ref interleavedLayout(), see its documentation for detailed behavior description. Note that offset-only @ref Trade::MeshAttributeData instances are not supported in the @p extra array. -Expects that @p data is indexed and each attribute in @p extra has either the -same amount of elements as @p data vertex count (*not* index count) or has -none. All attributes are expected to not have an implementation-specific -format. -@see @ref isVertexFormatImplementationSpecific(), +Expects that @p data is indexed with a non-implementation-specific index type +and each attribute in @p extra has either the same amount of elements as +@p data vertex count (*not* index count) or has none. All attributes are +expected to not have an implementation-specific format. +@see @ref isMeshIndexTypeImplementationSpecific(), + @ref isVertexFormatImplementationSpecific(), @ref Trade::MeshData::attributeData() */ MAGNUM_MESHTOOLS_EXPORT Trade::MeshData duplicate(const Trade::MeshData& data, Containers::ArrayView extra = {}); diff --git a/src/Magnum/MeshTools/Test/DuplicateTest.cpp b/src/Magnum/MeshTools/Test/DuplicateTest.cpp index 1b53ebe00..e85d5875f 100644 --- a/src/Magnum/MeshTools/Test/DuplicateTest.cpp +++ b/src/Magnum/MeshTools/Test/DuplicateTest.cpp @@ -59,6 +59,7 @@ struct DuplicateTest: TestSuite::Tester { template void duplicateMeshData(); void duplicateMeshDataNotIndexed(); + void duplicateMeshDataImplementationSpecificIndexType(); void duplicateMeshDataImplementationSpecificVertexFormat(); void duplicateMeshDataExtra(); void duplicateMeshDataExtraEmpty(); @@ -94,6 +95,7 @@ DuplicateTest::DuplicateTest() { &DuplicateTest::duplicateMeshData, &DuplicateTest::duplicateMeshData, &DuplicateTest::duplicateMeshDataNotIndexed, + &DuplicateTest::duplicateMeshDataImplementationSpecificIndexType, &DuplicateTest::duplicateMeshDataImplementationSpecificVertexFormat, &DuplicateTest::duplicateMeshDataExtra, &DuplicateTest::duplicateMeshDataExtraEmpty, @@ -330,6 +332,24 @@ void DuplicateTest::duplicateMeshDataNotIndexed() { CORRADE_COMPARE(out.str(), "MeshTools::duplicate(): mesh data not indexed\n"); } +void DuplicateTest::duplicateMeshDataImplementationSpecificIndexType() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + Trade::MeshData a{MeshPrimitive::Lines, + nullptr, Trade::MeshIndexData{meshIndexTypeWrap(0xcaca), Containers::StridedArrayView1D{}}, + nullptr, { + Trade::MeshAttributeData{Trade::MeshAttribute::Position, + VertexFormat::Vector3, nullptr}, + }}; + + std::ostringstream out; + Error redirectError{&out}; + MeshTools::duplicate(a); + CORRADE_COMPARE(out.str(), "MeshTools::duplicate(): mesh has an implementation-specific index type 0xcaca\n"); +} + void DuplicateTest::duplicateMeshDataImplementationSpecificVertexFormat() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");