Browse Source

MeshTools: fix generateIndices() to work with attribute-less meshes.

The vertex count has to be explicitly propagated to the output in
that case because it can't be figured out from any attributes in this
case.
pull/601/head
Vladimír Vondruš 3 years ago
parent
commit
d51ad4213c
  1. 2
      doc/changelog.dox
  2. 2
      src/Magnum/MeshTools/GenerateIndices.cpp
  3. 15
      src/Magnum/MeshTools/Test/GenerateIndicesTest.cpp

2
doc/changelog.dox

@ -841,6 +841,8 @@ See also:
usually just didn't remove any duplicate whatsoever while
`--remove-duplicates-fuzzy` did, no matter how ridiculously low epsilon
was used.
- Fixed @ref MeshTools::generateIndices() to work correctly with
attribute-less @ref Trade::MeshData instances
- @ref Platform::EmscriptenApplication randomly created antialiased contexts
due to an uninitialized variable in its
@ref Platform::EmscriptenApplication::GLConfiguration "GLConfiguration"

2
src/Magnum/MeshTools/GenerateIndices.cpp

@ -321,7 +321,7 @@ Trade::MeshData generateIndices(Trade::MeshData&& data) {
Trade::MeshIndexData indices{MeshIndexType::UnsignedInt, indexData};
return Trade::MeshData{primitive, std::move(indexData), indices,
std::move(vertexData), std::move(attributeData)};
std::move(vertexData), std::move(attributeData), vertexCount};
}
Trade::MeshData generateIndices(const Trade::MeshData& data) {

15
src/Magnum/MeshTools/Test/GenerateIndicesTest.cpp

@ -67,6 +67,7 @@ struct GenerateIndicesTest: TestSuite::Tester {
void generateIndicesMeshData();
void generateIndicesMeshDataMove();
void generateIndicesMeshDataNoAttributes();
void generateIndicesMeshDataIndexed();
void generateIndicesMeshDataInvalidPrimitive();
};
@ -196,6 +197,7 @@ GenerateIndicesTest::GenerateIndicesTest() {
Containers::arraySize(MeshDataData));
addTests({&GenerateIndicesTest::generateIndicesMeshDataMove,
&GenerateIndicesTest::generateIndicesMeshDataNoAttributes,
&GenerateIndicesTest::generateIndicesMeshDataIndexed,
&GenerateIndicesTest::generateIndicesMeshDataInvalidPrimitive});
}
@ -688,6 +690,19 @@ void GenerateIndicesTest::generateIndicesMeshDataMove() {
CORRADE_COMPARE(out.vertexData().data(), static_cast<void*>(vertices.data()));
}
void GenerateIndicesTest::generateIndicesMeshDataNoAttributes() {
Trade::MeshData out = generateIndices(Trade::MeshData{MeshPrimitive::TriangleStrip, 4});
CORRADE_VERIFY(out.isIndexed());
CORRADE_COMPARE(out.indexType(), MeshIndexType::UnsignedInt);
CORRADE_COMPARE_AS(out.indices<UnsignedInt>(),
Containers::arrayView<UnsignedInt>({
0, 1, 2,
2, 1, 3, /* Reversed */
}), TestSuite::Compare::Container);
CORRADE_COMPARE(out.vertexCount(), 4);
CORRADE_COMPARE(out.attributeCount(), 0);
}
void GenerateIndicesTest::generateIndicesMeshDataIndexed() {
CORRADE_SKIP_IF_NO_ASSERT();

Loading…
Cancel
Save