Browse Source

MeshTools: drop now-obsolete special case for attrib-less meshes.

It was incomplete, asserting in some cases anyway.
pull/449/head
Vladimír Vondruš 6 years ago
parent
commit
6a97fa2fed
  1. 16
      src/Magnum/MeshTools/Interleave.cpp

16
src/Magnum/MeshTools/Interleave.cpp

@ -248,13 +248,6 @@ Trade::MeshData interleavedLayout(const Trade::MeshData& data, const UnsignedInt
} }
Trade::MeshData interleave(Trade::MeshData&& data, const Containers::ArrayView<const Trade::MeshAttributeData> extra) { Trade::MeshData interleave(Trade::MeshData&& data, const Containers::ArrayView<const Trade::MeshAttributeData> extra) {
/* If there are no attributes and no index buffer, bail -- the vertex count
is the only property we can transfer. If this wouldn't be done, the
return at the end would assert as vertex count is only passed implicitly
via attributes (which there are none). */
if(!data.attributeCount() && extra.empty() && !data.isIndexed())
return Trade::MeshData{data.primitive(), data.vertexCount()};
/* Transfer the indices unchanged, in case the mesh is indexed */ /* Transfer the indices unchanged, in case the mesh is indexed */
Containers::Array<char> indexData; Containers::Array<char> indexData;
Trade::MeshIndexData indices; Trade::MeshIndexData indices;
@ -272,6 +265,7 @@ Trade::MeshData interleave(Trade::MeshData&& data, const Containers::ArrayView<c
} }
const bool interleaved = isInterleaved(data); const bool interleaved = isInterleaved(data);
const UnsignedInt vertexCount = data.vertexCount();
/* If the mesh is already interleaved and we don't have anything extra, /* If the mesh is already interleaved and we don't have anything extra,
steal that data as well */ steal that data as well */
@ -284,7 +278,7 @@ Trade::MeshData interleave(Trade::MeshData&& data, const Containers::ArrayView<c
/* Otherwise do it the hard way */ /* Otherwise do it the hard way */
} else { } else {
/* Calculate the layout */ /* Calculate the layout */
Trade::MeshData layout = interleavedLayout(data, data.vertexCount(), extra); Trade::MeshData layout = interleavedLayout(data, vertexCount, extra);
/* Copy existing attributes to new locations */ /* Copy existing attributes to new locations */
for(UnsignedInt i = 0; i != data.attributeCount(); ++i) for(UnsignedInt i = 0; i != data.attributeCount(); ++i)
@ -305,8 +299,8 @@ Trade::MeshData interleave(Trade::MeshData&& data, const Containers::ArrayView<c
/* Copy the attribute in, if it is non-empty, otherwise keep the /* Copy the attribute in, if it is non-empty, otherwise keep the
memory uninitialized */ memory uninitialized */
if(extra[i].data()) { if(extra[i].data()) {
CORRADE_ASSERT(extra[i].data().size() == data.vertexCount(), CORRADE_ASSERT(extra[i].data().size() == vertexCount,
"MeshTools::interleave(): extra attribute" << i << "expected to have" << data.vertexCount() << "items but got" << extra[i].data().size(), "MeshTools::interleave(): extra attribute" << i << "expected to have" << vertexCount << "items but got" << extra[i].data().size(),
(Trade::MeshData{MeshPrimitive::Triangles, 0})); (Trade::MeshData{MeshPrimitive::Triangles, 0}));
const Containers::StridedArrayView2D<const char> attribute = const Containers::StridedArrayView2D<const char> attribute =
Containers::arrayCast<2, const char>(extra[i].data(), vertexFormatSize(extra[i].format())); Containers::arrayCast<2, const char>(extra[i].data(), vertexFormatSize(extra[i].format()));
@ -322,7 +316,7 @@ Trade::MeshData interleave(Trade::MeshData&& data, const Containers::ArrayView<c
} }
return Trade::MeshData{data.primitive(), std::move(indexData), indices, return Trade::MeshData{data.primitive(), std::move(indexData), indices,
std::move(vertexData), std::move(attributeData)}; std::move(vertexData), std::move(attributeData), vertexCount};
} }
Trade::MeshData interleave(Trade::MeshData&& data, const std::initializer_list<Trade::MeshAttributeData> extra) { Trade::MeshData interleave(Trade::MeshData&& data, const std::initializer_list<Trade::MeshAttributeData> extra) {

Loading…
Cancel
Save