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

11
src/Magnum/MeshTools/GenerateIndices.cpp

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

18
src/Magnum/MeshTools/Interleave.cpp

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

Loading…
Cancel
Save