Browse Source

MeshTools: use reference() instead of copypasting the bugs everywhere.

pull/547/head
Vladimír Vondruš 4 years ago
parent
commit
6505276d0e
  1. 8
      src/Magnum/MeshTools/CompressIndices.cpp
  2. 11
      src/Magnum/MeshTools/GenerateIndices.cpp
  3. 18
      src/Magnum/MeshTools/Interleave.cpp

8
src/Magnum/MeshTools/CompressIndices.cpp

@ -31,6 +31,7 @@
#include <Corrade/Utility/Algorithms.h>
#include "Magnum/Math/FunctionsBatch.h"
#include "Magnum/MeshTools/Reference.h"
#include "Magnum/Trade/MeshData.h"
namespace Magnum { namespace MeshTools {
@ -166,10 +167,9 @@ Trade::MeshData compressIndices(Trade::MeshData&& data, MeshIndexType atLeast) {
}
Trade::MeshData compressIndices(const Trade::MeshData& data, MeshIndexType atLeast) {
return compressIndices(Trade::MeshData{data.primitive(),
{}, data.indexData(), Trade::MeshIndexData{data.indices()},
{}, data.vertexData(), Trade::meshAttributeDataNonOwningArray(data.attributeData()),
data.vertexCount()}, atLeast);
/* Pass through to the && overload, which then decides whether to reuse
anything based on the DataFlags */
return compressIndices(reference(data), atLeast);
}
#ifdef MAGNUM_BUILD_DEPRECATED

11
src/Magnum/MeshTools/GenerateIndices.cpp

@ -30,6 +30,7 @@
#include <Corrade/Utility/Algorithms.h>
#include "Magnum/Math/Vector3.h"
#include "Magnum/MeshTools/Reference.h"
#include "Magnum/Trade/MeshData.h"
namespace Magnum { namespace MeshTools {
@ -324,13 +325,9 @@ Trade::MeshData generateIndices(Trade::MeshData&& data) {
}
Trade::MeshData generateIndices(const Trade::MeshData& data) {
return generateIndices(Trade::MeshData{data.primitive(),
/* Passing the indices through. If the mesh isn't indexed, this makes
the reference non-indexed also, if the mesh is indexed, it causes an
assert inside the delegated generateIndices(). */
{}, data.indexData(), Trade::MeshIndexData{data.indices()},
{}, data.vertexData(), Trade::meshAttributeDataNonOwningArray(data.attributeData()),
data.vertexCount()});
/* Pass through to the && overload, which then decides whether to reuse
anything based on the DataFlags */
return generateIndices(reference(data));
}
}}

18
src/Magnum/MeshTools/Interleave.cpp

@ -29,6 +29,7 @@
#include <Corrade/Utility/Algorithms.h>
#include "Magnum/Math/Functions.h"
#include "Magnum/MeshTools/Reference.h"
#include "Magnum/Trade/MeshData.h"
namespace Magnum { namespace MeshTools {
@ -249,11 +250,9 @@ Trade::MeshData interleavedLayout(Trade::MeshData&& data, const UnsignedInt vert
}
Trade::MeshData interleavedLayout(const Trade::MeshData& data, const UnsignedInt vertexCount, const Containers::ArrayView<const Trade::MeshAttributeData> extra, const InterleaveFlags flags) {
return interleavedLayout(
Trade::MeshData{data.primitive(), {}, data.vertexData(),
Trade::meshAttributeDataNonOwningArray(data.attributeData()),
data.vertexCount()},
vertexCount, extra, flags);
/* Pass through to the && overload, which then decides whether to reuse
anything based on the DataFlags */
return interleavedLayout(reference(data), vertexCount, extra, flags);
}
Trade::MeshData interleavedLayout(const Trade::MeshData& data, const UnsignedInt vertexCount, const std::initializer_list<Trade::MeshAttributeData> extra, const InterleaveFlags flags) {
@ -374,12 +373,9 @@ Trade::MeshData interleave(Trade::MeshData&& data, const std::initializer_list<T
}
Trade::MeshData interleave(const Trade::MeshData& data, const Containers::ArrayView<const Trade::MeshAttributeData> extra, const InterleaveFlags flags) {
return interleave(Trade::MeshData{data.primitive(),
/* If data is not indexed, the reference will be also non-indexed */
{}, data.indexData(), Trade::MeshIndexData{data.indices()},
{}, data.vertexData(), Trade::meshAttributeDataNonOwningArray(data.attributeData()),
data.vertexCount()
}, extra, flags);
/* Pass through to the && overload, which then decides whether to reuse
anything based on the DataFlags */
return interleave(reference(data), extra, flags);
}
Trade::MeshData interleave(const Trade::MeshData& data, const std::initializer_list<Trade::MeshAttributeData> extra, const InterleaveFlags flags) {

Loading…
Cancel
Save