Browse Source

MeshTools: explicitly use default array deleters in copy().

To make sure it can be used in plugin implementations.
pull/620/head
Vladimír Vondruš 3 years ago
parent
commit
d0124b268e
  1. 4
      src/Magnum/MeshTools/Copy.cpp
  2. 8
      src/Magnum/MeshTools/Test/CopyTest.cpp

4
src/Magnum/MeshTools/Copy.cpp

@ -138,7 +138,9 @@ Trade::MeshData copy(Trade::MeshData&& mesh) {
/* Otherwise we have to allocate a new one and re-route the attributes to
a potentially different vertex array */
} else {
attributeData = Containers::Array<Trade::MeshAttributeData>{originalAttributeData.size()};
/* Using DefaultInit so the array has a default deleter and isn't
problematic to use in plugins */
attributeData = Containers::Array<Trade::MeshAttributeData>{DefaultInit, originalAttributeData.size()};
for(std::size_t i = 0; i != originalAttributeData.size(); ++i) {
attributeData[i] = Trade::MeshAttributeData{
originalAttributeData[i].name(),

8
src/Magnum/MeshTools/Test/CopyTest.cpp

@ -124,6 +124,14 @@ void CopyTest::copy() {
CORRADE_COMPARE_AS(copy.indexData(), cube.indexData(), TestSuite::Compare::Container);
CORRADE_COMPARE_AS(copy.vertexData(), cube.vertexData(), TestSuite::Compare::Container);
/* The data should have a default deleter to make this usable in plugins */
Containers::Array<char> indexData = copy.releaseIndexData();
Containers::Array<char> vertexData = copy.releaseVertexData();
Containers::Array<Trade::MeshAttributeData> attributeData = copy.releaseAttributeData();
CORRADE_VERIFY(!indexData.deleter());
CORRADE_VERIFY(!vertexData.deleter());
CORRADE_VERIFY(!attributeData.deleter());
}
void CopyTest::copyNoIndexData() {

Loading…
Cancel
Save