Browse Source

MeshTools: deprecate owned() in favor of copy().

A bit sad it took me three years to invent the right name for this
utility, heh. Also moving it together with others to a new
MeshTools/Copy.h header because *this* is the mainly useful API, not
reference() / mutableReference().

MaterialTools and SceneTools will get similar copy() APIs doing the same
thing.
pull/620/head
Vladimír Vondruš 3 years ago
parent
commit
47a6bf0185
  1. 6
      doc/changelog.dox
  2. 7
      src/Magnum/MeshTools/CMakeLists.txt
  3. 2
      src/Magnum/MeshTools/CompressIndices.cpp
  4. 23
      src/Magnum/MeshTools/Copy.cpp
  5. 97
      src/Magnum/MeshTools/Copy.h
  6. 2
      src/Magnum/MeshTools/GenerateIndices.cpp
  7. 2
      src/Magnum/MeshTools/Interleave.cpp
  8. 66
      src/Magnum/MeshTools/Reference.h
  9. 19
      src/Magnum/MeshTools/RemoveDuplicates.cpp
  10. 6
      src/Magnum/MeshTools/Test/BoundingVolumeTest.cpp
  11. 2
      src/Magnum/MeshTools/Test/CMakeLists.txt
  12. 428
      src/Magnum/MeshTools/Test/CopyTest.cpp
  13. 4
      src/Magnum/Primitives/Axis.h
  14. 4
      src/Magnum/Primitives/Crosshair.h
  15. 6
      src/Magnum/Primitives/Cube.h
  16. 4
      src/Magnum/Primitives/Plane.h
  17. 4
      src/Magnum/Primitives/Square.h
  18. 2
      src/Magnum/SceneTools/sceneconverter.cpp
  19. 2
      src/Magnum/Trade/MeshData.h

6
doc/changelog.dox

@ -1078,6 +1078,12 @@ See also:
practice that meant compiling at most two or three shaders at once. The new
API allows for much larger parallelism as well as an ability to query
completion status.
- @cpp MeshTools::owned() @ce was deprecated in favor of a more clearly named
@ref MeshTools::copy() utility living in a new @ref Magnum/MeshTools/Copy.h
header. To avoid having too many little headers,
@ref MeshTools::reference() and @ref MeshTools::mutableReference() were
moved there as well, with @cpp Magnum/MeshTools/Reference.h @ce being a
deprecated alias now.
- @cpp Shaders::DistanceFieldVector @ce, @cpp Shaders::Flat @ce,
@cpp Shaders::Generic @ce, @cpp Shaders::MeshVisualizer2D @ce,
@cpp Shaders::MeshVisualizer3D @ce, @cpp Shaders::Phong @ce,

7
src/Magnum/MeshTools/CMakeLists.txt

@ -37,6 +37,7 @@ set(MagnumMeshTools_GracefulAssert_SRCS
Combine.cpp
CompressIndices.cpp
Concatenate.cpp
Copy.cpp
Duplicate.cpp
Filter.cpp
FlipNormals.cpp
@ -44,7 +45,6 @@ set(MagnumMeshTools_GracefulAssert_SRCS
GenerateLines.cpp
GenerateNormals.cpp
Interleave.cpp
Reference.cpp
RemoveDuplicates.cpp
Transform.cpp)
@ -53,6 +53,7 @@ set(MagnumMeshTools_HEADERS
Combine.h
CompressIndices.h
Concatenate.h
Copy.h
Duplicate.h
Filter.h
FlipNormals.h
@ -61,7 +62,6 @@ set(MagnumMeshTools_HEADERS
GenerateNormals.h
Interleave.h
InterleaveFlags.h
Reference.h
RemoveDuplicates.h
Subdivide.h
Tipsify.h
@ -78,7 +78,8 @@ if(MAGNUM_BUILD_DEPRECATED)
list(APPEND MagnumMeshTools_HEADERS
CombineIndexedArrays.h
FilterAttributes.h
GenerateFlatNormals.h)
GenerateFlatNormals.h
Reference.h)
endif()
if(MAGNUM_TARGET_GL)

2
src/Magnum/MeshTools/CompressIndices.cpp

@ -30,7 +30,7 @@
#include <Corrade/Utility/Algorithms.h>
#include "Magnum/Math/FunctionsBatch.h"
#include "Magnum/MeshTools/Reference.h"
#include "Magnum/MeshTools/Copy.h"
#include "Magnum/Trade/MeshData.h"
#ifdef MAGNUM_BUILD_DEPRECATED

23
src/Magnum/MeshTools/Reference.cpp → src/Magnum/MeshTools/Copy.cpp

@ -23,12 +23,17 @@
DEALINGS IN THE SOFTWARE.
*/
#include "Reference.h"
#include "Copy.h"
#include <Corrade/Utility/Algorithms.h>
#include "Magnum/Trade/MeshData.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#define _MAGNUM_NO_DEPRECATED_MESHTOOLS_REFERENCE
#include "Magnum/MeshTools/Reference.h"
#endif
namespace Magnum { namespace MeshTools {
Trade::MeshData reference(const Trade::MeshData& mesh) {
@ -75,11 +80,11 @@ Trade::MeshData mutableReference(Trade::MeshData& mesh) {
mesh.vertexCount()};
}
Trade::MeshData owned(const Trade::MeshData& mesh) {
return owned(reference(mesh));
Trade::MeshData copy(const Trade::MeshData& mesh) {
return copy(reference(mesh));
}
Trade::MeshData owned(Trade::MeshData&& mesh) {
Trade::MeshData copy(Trade::MeshData&& mesh) {
/** @todo copy only the actually used range instead of the whole thing? */
/* If index data are already owned, move them to the output. This works
@ -153,4 +158,14 @@ Trade::MeshData owned(Trade::MeshData&& mesh) {
vertexCount};
}
#ifdef MAGNUM_BUILD_DEPRECATED
Trade::MeshData owned(const Trade::MeshData& mesh) {
return copy(mesh);
}
Trade::MeshData owned(Trade::MeshData&& mesh) {
return copy(std::move(mesh));
}
#endif
}}

97
src/Magnum/MeshTools/Copy.h

@ -0,0 +1,97 @@
#ifndef Magnum_MeshTools_Copy_h
#define Magnum_MeshTools_Copy_h
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
2020, 2021, 2022 Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
/** @file
* @brief Function @ref Magnum::MeshTools::copy(), @ref Magnum::MeshTools::reference(), @ref Magnum::MeshTools::mutableReference()
* @m_since_latest
*/
#include "Magnum/MeshTools/visibility.h"
#include "Magnum/Trade/Trade.h"
namespace Magnum { namespace MeshTools {
/**
@brief Make an owned copy of the mesh
@m_since_latest
Allocates a copy of @ref Trade::MeshData::indexData(),
@relativeref{Trade::MeshData,vertexData()} and
@relativeref{Trade::MeshData,attributeData()} and returns a new mesh with them.
All other properties such as the primitive or importer state are passed through
unchanged, the data layout isn't changed in any way. The resulting
@ref Trade::MeshData::indexDataFlags() and
@relativeref{Trade::MeshData,vertexDataFlags()} are always
@ref Trade::DataFlag::Owned and @ref Trade::DataFlag::Mutable.
@see @ref copy(Trade::MeshData&&), @ref reference(), @ref mutableReference()
*/
MAGNUM_MESHTOOLS_EXPORT Trade::MeshData copy(const Trade::MeshData& mesh);
/**
@brief Make a mesh with owned data
@m_since_latest
If @ref Trade::MeshData::indexDataFlags() or
@relativeref{Trade::MeshData,vertexDataFlags()} are not
@ref Trade::DataFlag::Owned and @ref Trade::DataFlag::Mutable or the attribute
data don't have the default deleter, allocates a copy of
@ref Trade::MeshData::indexData(),
@relativeref{Trade::MeshData,vertexData()} or
@relativeref{Trade::MeshData,attributeData()}, otherwise transfers their
ownership. The resulting data are always owned and mutable, the data layout
isn't changed in any way.
@see @ref reference(), @ref mutableReference()
*/
MAGNUM_MESHTOOLS_EXPORT Trade::MeshData copy(Trade::MeshData&& mesh);
/**
@brief Create an immutable reference on a @ref Trade::MeshData
@m_since{2020,06}
The returned instance has empty @ref Trade::MeshData::indexDataFlags() and
@ref Trade::MeshData::vertexDataFlags() and references attribute data from the
@p mesh as well. The function performs no allocation or data copy. Use
@ref copy() for an inverse operation.
@see @ref mutableReference()
*/
MAGNUM_MESHTOOLS_EXPORT Trade::MeshData reference(const Trade::MeshData& mesh);
/**
@brief Create a mutable reference on a @ref Trade::MeshData
@m_since{2020,06}
The returned instance has @ref Trade::MeshData::indexDataFlags() and
@ref Trade::MeshData::vertexDataFlags() set to @ref Trade::DataFlag::Mutable.
The function performs no allocation or data copy. Use @ref copy() for an
inverse operation. Expects that @p mesh is mutable.
@see @ref reference()
*/
MAGNUM_MESHTOOLS_EXPORT Trade::MeshData mutableReference(Trade::MeshData& mesh);
}}
#endif

2
src/Magnum/MeshTools/GenerateIndices.cpp

@ -30,7 +30,7 @@
#include <Corrade/Utility/Algorithms.h>
#include "Magnum/Math/Vector3.h"
#include "Magnum/MeshTools/Reference.h"
#include "Magnum/MeshTools/Copy.h"
#include "Magnum/Trade/MeshData.h"
namespace Magnum { namespace MeshTools {

2
src/Magnum/MeshTools/Interleave.cpp

@ -29,7 +29,7 @@
#include <Corrade/Utility/Algorithms.h>
#include "Magnum/Math/Functions.h"
#include "Magnum/MeshTools/Reference.h"
#include "Magnum/MeshTools/Copy.h"
#include "Magnum/Trade/MeshData.h"
namespace Magnum { namespace MeshTools {

66
src/Magnum/MeshTools/Reference.h

@ -25,69 +25,43 @@
DEALINGS IN THE SOFTWARE.
*/
#ifdef MAGNUM_BUILD_DEPRECATED
/** @file
* @brief Function @ref Magnum::MeshTools::reference(), @ref Magnum::MeshTools::owned()
* @m_since{2020,06}
* @m_deprecated_since_latest Use @ref Magnum/MeshTools/Copy.h instead.
*/
#endif
#include "Magnum/MeshTools/visibility.h"
#include "Magnum/Trade/Trade.h"
#include "Magnum/configure.h"
namespace Magnum { namespace MeshTools {
#ifdef MAGNUM_BUILD_DEPRECATED
#include <Corrade/Utility/Macros.h>
/**
@brief Create an immutable reference on a @ref Trade::MeshData
@m_since{2020,06}
#include "Magnum/MeshTools/Copy.h"
The returned instance has empty @ref Trade::MeshData::indexDataFlags() and
@ref Trade::MeshData::vertexDataFlags() and references attribute data from the
@p mesh as well. The function performs no allocation or data copy. Use
@ref owned() for an inverse operation.
@see @ref mutableReference()
*/
MAGNUM_MESHTOOLS_EXPORT Trade::MeshData reference(const Trade::MeshData& mesh);
/**
@brief Create a mutable reference on a @ref Trade::MeshData
@m_since{2020,06}
#ifndef _MAGNUM_NO_DEPRECATED_MESHTOOLS_REFERENCE
CORRADE_DEPRECATED_FILE("use Magnum/MeshTools/Copy.h instead")
#endif
The returned instance has @ref Trade::MeshData::indexDataFlags() and
@ref Trade::MeshData::vertexDataFlags() set to @ref Trade::DataFlag::Mutable.
The function performs no allocation or data copy. Use @ref owned() for an
inverse operation. Expects that @p mesh is mutable.
@see @ref reference()
*/
MAGNUM_MESHTOOLS_EXPORT Trade::MeshData mutableReference(Trade::MeshData& mesh);
namespace Magnum { namespace MeshTools {
#ifdef MAGNUM_BUILD_DEPRECATED
/**
@brief Create an owned @ref Trade::MeshData
@m_since{2020,06}
The returned instance owns its index, vertex and attribute data --- both
@ref Trade::MeshData::indexDataFlags() and
@ref Trade::MeshData::vertexDataFlags() have @ref Trade::DataFlag::Mutable and
@ref Trade::DataFlag::Owned set. This function unconditionally does an
allocation and a copy even if the @p mesh is already owned, use
@ref owned(Trade::MeshData&&) to make an owned copy only if the instance isn't
already owned.
@see @ref reference(), @ref mutableReference()
@m_deprecated_since_latest Use @ref copy(const Trade::MeshData&) instead.
*/
MAGNUM_MESHTOOLS_EXPORT Trade::MeshData owned(const Trade::MeshData& mesh);
CORRADE_DEPRECATED("use copy(Trade::MeshData&&) instead") MAGNUM_MESHTOOLS_EXPORT Trade::MeshData owned(const Trade::MeshData& mesh);
/**
@brief Create an owned @ref Trade::MeshData, if not already
@m_since{2020,06}
The returned instance owns its index, vertex and attribute data --- both
@ref Trade::MeshData::indexDataFlags() and
@ref Trade::MeshData::vertexDataFlags() have @ref Trade::DataFlag::Mutable and
@ref Trade::DataFlag::Owned set. Index, vertex and attribute data that are
already owned are simply moved to the output, otherwise the data get copied
into newly allocated arrays.
@see @ref reference(), @ref mutableReference()
@m_deprecated_since_latest Use @ref copy(Trade::MeshData&&) instead.
*/
MAGNUM_MESHTOOLS_EXPORT Trade::MeshData owned(Trade::MeshData&& mesh);
CORRADE_DEPRECATED("use copy(Trade::MeshData&&) instead") MAGNUM_MESHTOOLS_EXPORT Trade::MeshData owned(Trade::MeshData&& mesh);
#endif
}}
#else
#error use Magnum/MeshTools/Copy.h instead
#endif
#endif

19
src/Magnum/MeshTools/RemoveDuplicates.cpp

@ -37,7 +37,7 @@
#include "Magnum/Math/FunctionsBatch.h"
#include "Magnum/Math/Range.h"
#include "Magnum/MeshTools/Reference.h"
#include "Magnum/MeshTools/Copy.h"
#include "Magnum/MeshTools/Duplicate.h"
#include "Magnum/MeshTools/Interleave.h"
#include "Magnum/Trade/MeshData.h"
@ -417,14 +417,13 @@ Trade::MeshData removeDuplicates(const Trade::MeshData& mesh) {
(Trade::MeshData{MeshPrimitive{}, 0}));
/* Turn the passed data into an interleaved owned mutable instance we can
operate on -- owned() alone only makes the data owned, interleave()
alone only makes the data interleaved (but the index data can stay
non-owned). Additionally we need to ensure the interleaved data are
tightly packed by removing InterleaveFlag::PreserveInterleavedAttributes
which is set by default, otherwise random padding bytes or filtered-out
attributes may contribute to the non-uniqueness of particular
elements. */
Trade::MeshData ownedInterleaved = owned(interleave(mesh, {}, InterleaveFlags{}));
operate on -- copy() alone only makes the data owned, interleave() alone
only makes the data interleaved (but the index data can stay non-owned).
Additionally we need to ensure the interleaved data are tightly packed
by removing InterleaveFlag::PreserveInterleavedAttributes which is set
by default, otherwise random padding bytes or filtered-out attributes
may contribute to the non-uniqueness of particular elements. */
Trade::MeshData ownedInterleaved = copy(interleave(mesh, {}, InterleaveFlags{}));
/* Because the interleaved mesh was forced to be repacked, the vertex data
should span the whole stride -- this is relied on in the attribute
@ -480,7 +479,7 @@ Trade::MeshData removeDuplicatesFuzzy(const Trade::MeshData& mesh, const Float f
/* Turn the passed data into an owned mutable instance we can operate on.
There's a chance the original data are already like this, in which case
this will be just a passthrough. */
Trade::MeshData owned = MeshTools::owned(std::move(mesh));
Trade::MeshData owned = MeshTools::copy(std::move(mesh));
/* Allocate an interleaved index array for all vertices times all
attributes */

6
src/Magnum/MeshTools/Test/BoundingVolumeTest.cpp

@ -36,7 +36,7 @@
#include "Magnum/Math/Range.h"
#include "Magnum/Math/Vector3.h"
#include "Magnum/MeshTools/BoundingVolume.h"
#include "Magnum/MeshTools/Reference.h"
#include "Magnum/MeshTools/Copy.h"
#include "Magnum/MeshTools/Transform.h"
#include "Magnum/Primitives/Capsule.h"
#include "Magnum/Primitives/Cube.h"
@ -173,7 +173,7 @@ void BoundingVolumeTest::sphereBouncingBubble() {
/* Cube -- translated and scaled */
} {
Trade::MeshData cubeMesh = MeshTools::owned(Primitives::cubeSolid());
Trade::MeshData cubeMesh = MeshTools::copy(Primitives::cubeSolid());
constexpr Vector3 translation{1.0f, 2.0f, 3.0f};
constexpr Float scale = 13.2f;
MeshTools::transform3DInPlace(cubeMesh, Matrix4::translation(translation)*Matrix4::scaling(Vector3{scale}));
@ -191,7 +191,7 @@ void BoundingVolumeTest::sphereBouncingBubble() {
for(Deg degrees = 0.0_degf; degrees < 360.0_degf; degrees += 60.0_degf) {
CORRADE_ITERATION(degrees);
Trade::MeshData cubeMesh = MeshTools::owned(Primitives::cubeSolid());
Trade::MeshData cubeMesh = MeshTools::copy(Primitives::cubeSolid());
constexpr Vector3 translation{1.0f, 2.0f, 3.0f};
MeshTools::transform3DInPlace(cubeMesh, Matrix4::rotationY(degrees)*Matrix4::translation(translation));
const Containers::Pair<Vector3, Float> sphere =

2
src/Magnum/MeshTools/Test/CMakeLists.txt

@ -31,6 +31,7 @@ corrade_add_test(MeshToolsBoundingVolumeTest BoundingVolumeTest.cpp LIBRARIES Ma
corrade_add_test(MeshToolsCombineTest CombineTest.cpp LIBRARIES MagnumMeshToolsTestLib)
corrade_add_test(MeshToolsCompressIndicesTest CompressIndicesTest.cpp LIBRARIES MagnumMeshToolsTestLib)
corrade_add_test(MeshToolsConcatenateTest ConcatenateTest.cpp LIBRARIES MagnumMeshToolsTestLib)
corrade_add_test(MeshToolsCopyTest CopyTest.cpp LIBRARIES MagnumMeshToolsTestLib MagnumPrimitives)
corrade_add_test(MeshToolsDuplicateTest DuplicateTest.cpp LIBRARIES MagnumMeshToolsTestLib)
corrade_add_test(MeshToolsFilterTest FilterTest.cpp LIBRARIES MagnumMeshToolsTestLib)
corrade_add_test(MeshToolsFlipNormalsTest FlipNormalsTest.cpp LIBRARIES MagnumMeshToolsTestLib)
@ -40,7 +41,6 @@ corrade_add_test(MeshToolsGenerateLinesTest GenerateLinesTest.cpp
LIBRARIES MagnumMeshToolsTestLib MagnumShaders)
corrade_add_test(MeshToolsGenerateNormalsTest GenerateNormalsTest.cpp LIBRARIES MagnumMeshToolsTestLib MagnumPrimitives)
corrade_add_test(MeshToolsInterleaveTest InterleaveTest.cpp LIBRARIES MagnumMeshToolsTestLib)
corrade_add_test(MeshToolsReferenceTest ReferenceTest.cpp LIBRARIES MagnumMeshToolsTestLib MagnumPrimitives)
corrade_add_test(MeshToolsRemoveDuplicatesTest RemoveDuplicatesTest.cpp LIBRARIES MagnumMeshToolsTestLib)
corrade_add_test(MeshToolsSubdivideTest SubdivideTest.cpp LIBRARIES Magnum MagnumPrimitives)
corrade_add_test(MeshToolsTipsifyTest TipsifyTest.cpp LIBRARIES MagnumMeshTools)

428
src/Magnum/MeshTools/Test/ReferenceTest.cpp → src/Magnum/MeshTools/Test/CopyTest.cpp

@ -29,7 +29,7 @@
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Color.h"
#include "Magnum/MeshTools/Reference.h"
#include "Magnum/MeshTools/Copy.h"
#include "Magnum/Primitives/Cube.h"
#include "Magnum/Primitives/Gradient.h"
#include "Magnum/Primitives/Grid.h"
@ -38,8 +38,17 @@
namespace Magnum { namespace MeshTools { namespace Test { namespace {
struct ReferenceTest: TestSuite::Tester {
explicit ReferenceTest();
struct CopyTest: TestSuite::Tester {
explicit CopyTest();
void copy();
void copyNoIndexData();
void copyNoAttributeVertexData();
void copyStridedIndices();
void copyArrayAttribute();
void copyImplementationSpecificVertexFormat();
void copyRvaluePassthrough();
void copyRvaluePartialPassthrough();
void reference();
void referenceNoIndexData();
@ -51,15 +60,6 @@ struct ReferenceTest: TestSuite::Tester {
void mutableReferenceImplementationSpecificIndexType();
void mutableReferenceNoIndexVertexAttributeData();
void mutableReferenceNotMutable();
void owned();
void ownedNoIndexData();
void ownedNoAttributeVertexData();
void ownedStridedIndices();
void ownedArrayAttribute();
void ownedImplementationSpecificVertexFormat();
void ownedRvaluePassthrough();
void ownedRvaluePartialPassthrough();
};
struct {
@ -70,32 +70,205 @@ struct {
{"implementation-specific index format", meshIndexTypeWrap(0xcaca)}
};
ReferenceTest::ReferenceTest() {
addTests({&ReferenceTest::reference,
&ReferenceTest::referenceNoIndexData,
&ReferenceTest::referenceImplementationSpecificIndexType,
&ReferenceTest::referenceNoIndexVertexAttributeData,
CopyTest::CopyTest() {
addTests({&CopyTest::copy,
&CopyTest::copyNoIndexData,
&CopyTest::copyNoAttributeVertexData});
&ReferenceTest::mutableReference,
&ReferenceTest::mutableReferenceNoIndexData,
&ReferenceTest::mutableReferenceImplementationSpecificIndexType,
&ReferenceTest::mutableReferenceNoIndexVertexAttributeData,
&ReferenceTest::mutableReferenceNotMutable,
addInstancedTests({&CopyTest::copyStridedIndices},
Containers::arraySize(StridedIndicesData));
&ReferenceTest::owned,
&ReferenceTest::ownedNoIndexData,
&ReferenceTest::ownedNoAttributeVertexData});
addTests({&CopyTest::copyArrayAttribute,
&CopyTest::copyImplementationSpecificVertexFormat,
&CopyTest::copyRvaluePassthrough,
&CopyTest::copyRvaluePartialPassthrough,
&CopyTest::reference,
&CopyTest::referenceNoIndexData,
&CopyTest::referenceImplementationSpecificIndexType,
&CopyTest::referenceNoIndexVertexAttributeData,
&CopyTest::mutableReference,
&CopyTest::mutableReferenceNoIndexData,
&CopyTest::mutableReferenceImplementationSpecificIndexType,
&CopyTest::mutableReferenceNoIndexVertexAttributeData,
&CopyTest::mutableReferenceNotMutable});
}
addInstancedTests({&ReferenceTest::ownedStridedIndices},
Containers::arraySize(StridedIndicesData));
void CopyTest::copy() {
Trade::MeshData cube = Primitives::cubeSolid();
CORRADE_COMPARE(cube.indexDataFlags(), Trade::DataFlag::Global);
CORRADE_COMPARE(cube.vertexDataFlags(), Trade::DataFlag::Global);
Trade::MeshData copy = MeshTools::copy(cube);
CORRADE_VERIFY(copy.isIndexed());
CORRADE_COMPARE(copy.primitive(), cube.primitive());
CORRADE_COMPARE(copy.indexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(copy.vertexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(copy.indexCount(), cube.indexCount());
CORRADE_COMPARE(copy.indexType(), cube.indexType());
CORRADE_COMPARE(copy.indexOffset(), cube.indexOffset());
CORRADE_COMPARE(copy.indexStride(), cube.indexStride());
CORRADE_COMPARE(copy.vertexCount(), cube.vertexCount());
CORRADE_COMPARE(copy.attributeCount(), cube.attributeCount());
for(std::size_t i = 0; i != cube.attributeCount(); ++i) {
CORRADE_ITERATION(i);
CORRADE_COMPARE(copy.attributeName(i), cube.attributeName(i));
CORRADE_COMPARE(copy.attributeFormat(i), cube.attributeFormat(i));
CORRADE_COMPARE(copy.attributeOffset(i), cube.attributeOffset(i));
CORRADE_COMPARE(copy.attributeStride(i), cube.attributeStride(i));
CORRADE_COMPARE(copy.attributeArraySize(i), cube.attributeArraySize(i));
}
CORRADE_COMPARE_AS(copy.indexData(), cube.indexData(), TestSuite::Compare::Container);
CORRADE_COMPARE_AS(copy.vertexData(), cube.vertexData(), TestSuite::Compare::Container);
}
void CopyTest::copyNoIndexData() {
Trade::MeshData cube = Primitives::cubeSolidStrip();
CORRADE_VERIFY(!cube.isIndexed());
CORRADE_COMPARE(cube.vertexDataFlags(), Trade::DataFlag::Global);
Trade::MeshData copy = MeshTools::copy(cube);
CORRADE_VERIFY(!copy.isIndexed());
CORRADE_COMPARE(copy.primitive(), cube.primitive());
CORRADE_COMPARE(copy.indexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(copy.vertexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(copy.vertexCount(), cube.vertexCount());
CORRADE_COMPARE(copy.attributeCount(), cube.attributeCount());
}
void CopyTest::copyNoAttributeVertexData() {
UnsignedShort indexData[]{0, 41, 2};
Trade::MeshData indexedFourtytwo{MeshPrimitive::Edges,
{}, indexData, Trade::MeshIndexData{indexData},
42};
Trade::MeshData copy = MeshTools::copy(indexedFourtytwo);
CORRADE_VERIFY(copy.isIndexed());
CORRADE_COMPARE(copy.primitive(), MeshPrimitive::Edges);
CORRADE_COMPARE(copy.indexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(copy.vertexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(copy.indexCount(), 3);
CORRADE_COMPARE(copy.indexType(), MeshIndexType::UnsignedShort);
CORRADE_COMPARE(copy.indexOffset(), 0);
CORRADE_COMPARE(copy.vertexCount(), 42);
CORRADE_COMPARE(copy.attributeCount(), 0);
CORRADE_COMPARE_AS(copy.indexData(), indexedFourtytwo.indexData(), TestSuite::Compare::Container);
CORRADE_VERIFY(!static_cast<const void*>(copy.vertexData().data()));
CORRADE_VERIFY(!static_cast<const void*>(copy.attributeData().data()));
}
void CopyTest::copyStridedIndices() {
auto&& data = StridedIndicesData[testCaseInstanceId()];
setTestCaseDescription(data.name);
const UnsignedShort indices[7]{0, 3, 0, 7, 0, 15, 0};
Trade::MeshData stuff{MeshPrimitive::Points,
{}, indices, Trade::MeshIndexData{data.type, Containers::stridedArrayView(indices).exceptPrefix(1).every(2)},
16};
/* The full index data layout including whatever format should be
preserved */
Trade::MeshData copy = MeshTools::copy(stuff);
CORRADE_VERIFY(copy.isIndexed());
CORRADE_COMPARE(copy.primitive(), MeshPrimitive::Points);
CORRADE_COMPARE(copy.indexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(copy.vertexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(copy.indexCount(), 3);
CORRADE_COMPARE(copy.indexType(), data.type);
CORRADE_COMPARE(copy.indexOffset(), 2);
CORRADE_COMPARE(copy.indexStride(), 4);
CORRADE_COMPARE(copy.vertexCount(), 16);
CORRADE_COMPARE(copy.attributeCount(), 0);
/* Has to do a prefix() because for an implementation-specific index type
the returned size is equal to stride */
CORRADE_COMPARE_AS((Containers::arrayCast<1, const UnsignedShort>(copy.indices().prefix({copy.indexCount(), 2}))),
Containers::arrayView<UnsignedShort>({3, 7, 15}),
TestSuite::Compare::Container);
CORRADE_COMPARE_AS(copy.indexData(), stuff.indexData(),
TestSuite::Compare::Container);
}
void CopyTest::copyArrayAttribute() {
const Vector3us vertexData[13]{};
/* Verify that array attributes are propagated correctly */
Trade::MeshData weirdThing{MeshPrimitive::Faces,
{}, vertexData,
{Trade::MeshAttributeData{Trade::meshAttributeCustom(42), VertexFormat::Half, Containers::arrayView(vertexData), 3}}};
Trade::MeshData copy = MeshTools::copy(weirdThing);
CORRADE_COMPARE(copy.vertexCount(), 13);
CORRADE_COMPARE(copy.attributeCount(), 1);
CORRADE_COMPARE(copy.attributeArraySize(0), 3);
}
void CopyTest::copyImplementationSpecificVertexFormat() {
const Int vertexData[13]{};
/* Verify that custom vertex formats are propagated without a problem */
Trade::MeshData weirdThing{MeshPrimitive::Faces,
{}, vertexData,
{Trade::MeshAttributeData{Trade::meshAttributeCustom(42), vertexFormatWrap(0xcaca), Containers::arrayView(vertexData)}}};
Trade::MeshData copy = MeshTools::copy(weirdThing);
CORRADE_COMPARE(copy.vertexCount(), 13);
CORRADE_COMPARE(copy.attributeCount(), 1);
CORRADE_COMPARE(copy.attributeArraySize(0), 0);
CORRADE_COMPARE(copy.attributeFormat(0), vertexFormatWrap(0xcaca));
CORRADE_COMPARE_AS((Containers::arrayCast<1, const Int>(copy.attribute(0))),
Containers::arrayView(vertexData),
TestSuite::Compare::Container);
}
void CopyTest::copyRvaluePassthrough() {
Trade::MeshData grid = Primitives::grid3DSolid({15, 3}, Primitives::GridFlag::Tangents);
CORRADE_COMPARE(grid.indexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(grid.vertexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
UnsignedInt indexCount = grid.indexCount();
MeshIndexType indexType = grid.indexType();
std::size_t indexOffset = grid.indexOffset();
Int indexStride = grid.indexStride();
UnsignedInt vertexCount = grid.vertexCount();
const void* indexData = grid.indexData();
const void* vertexData = grid.vertexData();
const void* attributeData = grid.attributeData();
Trade::MeshData copy = MeshTools::copy(std::move(grid));
CORRADE_VERIFY(copy.isIndexed());
CORRADE_COMPARE(copy.indexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(copy.vertexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(copy.indexCount(), indexCount);
CORRADE_COMPARE(copy.indexType(), indexType);
CORRADE_COMPARE(copy.indexOffset(), indexOffset);
CORRADE_COMPARE(copy.indexStride(), indexStride);
CORRADE_COMPARE(copy.vertexCount(), vertexCount);
CORRADE_COMPARE(copy.indexData(), indexData);
CORRADE_COMPARE(copy.vertexData(), vertexData);
CORRADE_COMPARE(copy.attributeData(), attributeData);
}
void CopyTest::copyRvaluePartialPassthrough() {
Trade::MeshData gradient = Primitives::gradient3DHorizontal({}, {});
CORRADE_COMPARE(gradient.vertexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
UnsignedInt vertexCount = gradient.vertexCount();
const void* vertexData = gradient.vertexData();
const void* attributeData = gradient.attributeData();
addTests({&ReferenceTest::ownedArrayAttribute,
&ReferenceTest::ownedImplementationSpecificVertexFormat,
&ReferenceTest::ownedRvaluePassthrough,
&ReferenceTest::ownedRvaluePartialPassthrough});
Trade::MeshData copy = MeshTools::copy(std::move(gradient));
CORRADE_VERIFY(!copy.isIndexed());
CORRADE_COMPARE(copy.indexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(copy.vertexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(copy.vertexCount(), vertexCount);
CORRADE_COMPARE(copy.vertexData(), vertexData);
/* Attribute data is constant in the original, so this gets copied */
CORRADE_VERIFY(copy.attributeData() != attributeData);
}
void ReferenceTest::reference() {
void CopyTest::reference() {
const Trade::MeshData grid = Primitives::grid3DSolid({15, 3}, Primitives::GridFlag::Tangents);
CORRADE_VERIFY(grid.isIndexed());
@ -114,7 +287,7 @@ void ReferenceTest::reference() {
CORRADE_COMPARE(static_cast<const void*>(reference.attributeData().data()), grid.attributeData().data());
}
void ReferenceTest::referenceNoIndexData() {
void CopyTest::referenceNoIndexData() {
const Trade::MeshData circle = Primitives::circle3DSolid(5);
CORRADE_VERIFY(!circle.isIndexed());
@ -129,7 +302,7 @@ void ReferenceTest::referenceNoIndexData() {
CORRADE_COMPARE(static_cast<const void*>(reference.attributeData().data()), circle.attributeData().data());
}
void ReferenceTest::referenceImplementationSpecificIndexType() {
void CopyTest::referenceImplementationSpecificIndexType() {
const UnsignedShort indices[7]{0, 3, 0, 7, 0, 15, 0};
Trade::MeshData stuff{MeshPrimitive::Points,
{}, indices, Trade::MeshIndexData{meshIndexTypeWrap(0xcaca), Containers::stridedArrayView(indices)},
@ -140,7 +313,7 @@ void ReferenceTest::referenceImplementationSpecificIndexType() {
CORRADE_COMPARE(reference.indexType(), meshIndexTypeWrap(0xcaca));
}
void ReferenceTest::referenceNoIndexVertexAttributeData() {
void CopyTest::referenceNoIndexVertexAttributeData() {
Trade::MeshData fourtytwo{MeshPrimitive::Edges, 42};
Trade::MeshData reference = MeshTools::reference(fourtytwo);
@ -153,7 +326,7 @@ void ReferenceTest::referenceNoIndexVertexAttributeData() {
CORRADE_VERIFY(!static_cast<const void*>(reference.attributeData().data()));
}
void ReferenceTest::mutableReference() {
void CopyTest::mutableReference() {
Trade::MeshData grid = Primitives::grid3DSolid({15, 3}, Primitives::GridFlag::Tangents);
CORRADE_VERIFY(grid.isIndexed());
@ -172,7 +345,7 @@ void ReferenceTest::mutableReference() {
CORRADE_COMPARE(static_cast<const void*>(reference.attributeData().data()), grid.attributeData().data());
}
void ReferenceTest::mutableReferenceNoIndexData() {
void CopyTest::mutableReferenceNoIndexData() {
Trade::MeshData circle = Primitives::circle3DSolid(5);
CORRADE_VERIFY(!circle.isIndexed());
@ -187,7 +360,7 @@ void ReferenceTest::mutableReferenceNoIndexData() {
CORRADE_COMPARE(static_cast<const void*>(reference.attributeData().data()), circle.attributeData().data());
}
void ReferenceTest::mutableReferenceImplementationSpecificIndexType() {
void CopyTest::mutableReferenceImplementationSpecificIndexType() {
UnsignedShort indices[7]{0, 3, 0, 7, 0, 15, 0};
Trade::MeshData stuff{MeshPrimitive::Points,
Trade::DataFlag::Mutable, indices, Trade::MeshIndexData{meshIndexTypeWrap(0xcaca), Containers::stridedArrayView(indices)},
@ -198,7 +371,7 @@ void ReferenceTest::mutableReferenceImplementationSpecificIndexType() {
CORRADE_COMPARE(reference.indexType(), meshIndexTypeWrap(0xcaca));
}
void ReferenceTest::mutableReferenceNoIndexVertexAttributeData() {
void CopyTest::mutableReferenceNoIndexVertexAttributeData() {
Trade::MeshData fourtytwo{MeshPrimitive::Edges, 42};
Trade::MeshData reference = MeshTools::mutableReference(fourtytwo);
@ -211,7 +384,7 @@ void ReferenceTest::mutableReferenceNoIndexVertexAttributeData() {
CORRADE_VERIFY(!static_cast<const void*>(reference.attributeData().data()));
}
void ReferenceTest::mutableReferenceNotMutable() {
void CopyTest::mutableReferenceNotMutable() {
CORRADE_SKIP_IF_NO_ASSERT();
Trade::MeshData cube = Primitives::cubeSolid();
@ -224,179 +397,6 @@ void ReferenceTest::mutableReferenceNotMutable() {
CORRADE_COMPARE(out.str(), "MeshTools::mutableReference(): data not mutable\n");
}
void ReferenceTest::owned() {
Trade::MeshData cube = Primitives::cubeSolid();
CORRADE_COMPARE(cube.indexDataFlags(), Trade::DataFlag::Global);
CORRADE_COMPARE(cube.vertexDataFlags(), Trade::DataFlag::Global);
Trade::MeshData owned = MeshTools::owned(cube);
CORRADE_VERIFY(owned.isIndexed());
CORRADE_COMPARE(owned.primitive(), cube.primitive());
CORRADE_COMPARE(owned.indexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(owned.vertexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(owned.indexCount(), cube.indexCount());
CORRADE_COMPARE(owned.indexType(), cube.indexType());
CORRADE_COMPARE(owned.indexOffset(), cube.indexOffset());
CORRADE_COMPARE(owned.indexStride(), cube.indexStride());
CORRADE_COMPARE(owned.vertexCount(), cube.vertexCount());
CORRADE_COMPARE(owned.attributeCount(), cube.attributeCount());
for(std::size_t i = 0; i != cube.attributeCount(); ++i) {
CORRADE_ITERATION(i);
CORRADE_COMPARE(owned.attributeName(i), cube.attributeName(i));
CORRADE_COMPARE(owned.attributeFormat(i), cube.attributeFormat(i));
CORRADE_COMPARE(owned.attributeOffset(i), cube.attributeOffset(i));
CORRADE_COMPARE(owned.attributeStride(i), cube.attributeStride(i));
CORRADE_COMPARE(owned.attributeArraySize(i), cube.attributeArraySize(i));
}
CORRADE_COMPARE_AS(owned.indexData(), cube.indexData(), TestSuite::Compare::Container);
CORRADE_COMPARE_AS(owned.vertexData(), cube.vertexData(), TestSuite::Compare::Container);
}
void ReferenceTest::ownedNoIndexData() {
Trade::MeshData cube = Primitives::cubeSolidStrip();
CORRADE_VERIFY(!cube.isIndexed());
CORRADE_COMPARE(cube.vertexDataFlags(), Trade::DataFlag::Global);
Trade::MeshData owned = MeshTools::owned(cube);
CORRADE_VERIFY(!owned.isIndexed());
CORRADE_COMPARE(owned.primitive(), cube.primitive());
CORRADE_COMPARE(owned.indexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(owned.vertexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(owned.vertexCount(), cube.vertexCount());
CORRADE_COMPARE(owned.attributeCount(), cube.attributeCount());
}
void ReferenceTest::ownedNoAttributeVertexData() {
UnsignedShort indexData[]{0, 41, 2};
Trade::MeshData indexedFourtytwo{MeshPrimitive::Edges,
{}, indexData, Trade::MeshIndexData{indexData},
42};
Trade::MeshData owned = MeshTools::owned(indexedFourtytwo);
CORRADE_VERIFY(owned.isIndexed());
CORRADE_COMPARE(owned.primitive(), MeshPrimitive::Edges);
CORRADE_COMPARE(owned.indexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(owned.vertexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(owned.indexCount(), 3);
CORRADE_COMPARE(owned.indexType(), MeshIndexType::UnsignedShort);
CORRADE_COMPARE(owned.indexOffset(), 0);
CORRADE_COMPARE(owned.vertexCount(), 42);
CORRADE_COMPARE(owned.attributeCount(), 0);
CORRADE_COMPARE_AS(owned.indexData(), indexedFourtytwo.indexData(), TestSuite::Compare::Container);
CORRADE_VERIFY(!static_cast<const void*>(owned.vertexData().data()));
CORRADE_VERIFY(!static_cast<const void*>(owned.attributeData().data()));
}
void ReferenceTest::ownedStridedIndices() {
auto&& data = StridedIndicesData[testCaseInstanceId()];
setTestCaseDescription(data.name);
const UnsignedShort indices[7]{0, 3, 0, 7, 0, 15, 0};
Trade::MeshData stuff{MeshPrimitive::Points,
{}, indices, Trade::MeshIndexData{data.type, Containers::stridedArrayView(indices).exceptPrefix(1).every(2)},
16};
/* The full index data layout including whatever format should be
preserved */
Trade::MeshData owned = MeshTools::owned(stuff);
CORRADE_VERIFY(owned.isIndexed());
CORRADE_COMPARE(owned.primitive(), MeshPrimitive::Points);
CORRADE_COMPARE(owned.indexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(owned.vertexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(owned.indexCount(), 3);
CORRADE_COMPARE(owned.indexType(), data.type);
CORRADE_COMPARE(owned.indexOffset(), 2);
CORRADE_COMPARE(owned.indexStride(), 4);
CORRADE_COMPARE(owned.vertexCount(), 16);
CORRADE_COMPARE(owned.attributeCount(), 0);
/* Has to do a prefix() because for an implementation-specific index type
the returned size is equal to stride */
CORRADE_COMPARE_AS((Containers::arrayCast<1, const UnsignedShort>(owned.indices().prefix({owned.indexCount(), 2}))),
Containers::arrayView<UnsignedShort>({3, 7, 15}),
TestSuite::Compare::Container);
CORRADE_COMPARE_AS(owned.indexData(), stuff.indexData(),
TestSuite::Compare::Container);
}
void ReferenceTest::ownedArrayAttribute() {
const Vector3us vertexData[13]{};
/* Verify that array attributes are propagated correctly */
Trade::MeshData weirdThing{MeshPrimitive::Faces,
{}, vertexData,
{Trade::MeshAttributeData{Trade::meshAttributeCustom(42), VertexFormat::Half, Containers::arrayView(vertexData), 3}}};
Trade::MeshData owned = MeshTools::owned(weirdThing);
CORRADE_COMPARE(owned.vertexCount(), 13);
CORRADE_COMPARE(owned.attributeCount(), 1);
CORRADE_COMPARE(owned.attributeArraySize(0), 3);
}
void ReferenceTest::ownedImplementationSpecificVertexFormat() {
const Int vertexData[13]{};
/* Verify that custom vertex formats are propagated without a problem */
Trade::MeshData weirdThing{MeshPrimitive::Faces,
{}, vertexData,
{Trade::MeshAttributeData{Trade::meshAttributeCustom(42), vertexFormatWrap(0xcaca), Containers::arrayView(vertexData)}}};
Trade::MeshData owned = MeshTools::owned(weirdThing);
CORRADE_COMPARE(owned.vertexCount(), 13);
CORRADE_COMPARE(owned.attributeCount(), 1);
CORRADE_COMPARE(owned.attributeArraySize(0), 0);
CORRADE_COMPARE(owned.attributeFormat(0), vertexFormatWrap(0xcaca));
CORRADE_COMPARE_AS((Containers::arrayCast<1, const Int>(owned.attribute(0))),
Containers::arrayView(vertexData),
TestSuite::Compare::Container);
}
void ReferenceTest::ownedRvaluePassthrough() {
Trade::MeshData grid = Primitives::grid3DSolid({15, 3}, Primitives::GridFlag::Tangents);
CORRADE_COMPARE(grid.indexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(grid.vertexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
UnsignedInt indexCount = grid.indexCount();
MeshIndexType indexType = grid.indexType();
std::size_t indexOffset = grid.indexOffset();
Int indexStride = grid.indexStride();
UnsignedInt vertexCount = grid.vertexCount();
const void* indexData = grid.indexData();
const void* vertexData = grid.vertexData();
const void* attributeData = grid.attributeData();
Trade::MeshData owned = MeshTools::owned(std::move(grid));
CORRADE_VERIFY(owned.isIndexed());
CORRADE_COMPARE(owned.indexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(owned.vertexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(owned.indexCount(), indexCount);
CORRADE_COMPARE(owned.indexType(), indexType);
CORRADE_COMPARE(owned.indexOffset(), indexOffset);
CORRADE_COMPARE(owned.indexStride(), indexStride);
CORRADE_COMPARE(owned.vertexCount(), vertexCount);
CORRADE_COMPARE(owned.indexData(), indexData);
CORRADE_COMPARE(owned.vertexData(), vertexData);
CORRADE_COMPARE(owned.attributeData(), attributeData);
}
void ReferenceTest::ownedRvaluePartialPassthrough() {
Trade::MeshData gradient = Primitives::gradient3DHorizontal({}, {});
CORRADE_COMPARE(gradient.vertexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
UnsignedInt vertexCount = gradient.vertexCount();
const void* vertexData = gradient.vertexData();
const void* attributeData = gradient.attributeData();
Trade::MeshData owned = MeshTools::owned(std::move(gradient));
CORRADE_VERIFY(!owned.isIndexed());
CORRADE_COMPARE(owned.indexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(owned.vertexDataFlags(), Trade::DataFlag::Mutable|Trade::DataFlag::Owned);
CORRADE_COMPARE(owned.vertexCount(), vertexCount);
CORRADE_COMPARE(owned.vertexData(), vertexData);
/* Attribute data is constant in the original, so this gets copied */
CORRADE_VERIFY(owned.attributeData() != attributeData);
}
}}}}
CORRADE_TEST_MAIN(Magnum::MeshTools::Test::ReferenceTest)
CORRADE_TEST_MAIN(Magnum::MeshTools::Test::CopyTest)

4
src/Magnum/Primitives/Axis.h

@ -42,7 +42,7 @@ Two color-coded arrows for visualizing orientation (XY is RG), going from
with @ref MeshIndexType::UnsignedShort indices, interleaved
@ref VertexFormat::Vector2 positions and @ref VertexFormat::Vector3 colors. The
returned instance references @ref Trade::DataFlag::Global data --- pass the
mesh through @ref MeshTools::owned() to get a mutable copy, if needed.
mesh through @ref MeshTools::copy() to get a mutable copy, if needed.
@image html primitives-axis2d.png width=256px
@ -58,7 +58,7 @@ Three color-coded arrows for visualizing orientation (XYZ is RGB), going from
@ref MeshPrimitive::Lines with @ref MeshIndexType::UnsignedShort indices,
interleaved @ref VertexFormat::Vector3 positions and @ref VertexFormat::Vector3
colors. The returned instance references @ref Trade::DataFlag::Global data ---
pass the mesh through @ref MeshTools::owned() to get a mutable copy, if needed.
pass the mesh through @ref MeshTools::copy() to get a mutable copy, if needed.
@image html primitives-axis3d.png width=256px

4
src/Magnum/Primitives/Crosshair.h

@ -40,7 +40,7 @@ namespace Magnum { namespace Primitives {
2x2 crosshair (two crossed lines), centered at origin. Non-indexed
@ref MeshPrimitive::Lines with @ref VertexFormat::Vector2 positions. The
returned instance references @ref Trade::DataFlag::Global data --- pass the
mesh through @ref MeshTools::owned() to get a mutable copy, if needed.
mesh through @ref MeshTools::copy() to get a mutable copy, if needed.
@image html primitives-crosshair2d.png width=256px
@ -54,7 +54,7 @@ MAGNUM_PRIMITIVES_EXPORT Trade::MeshData crosshair2D();
2x2x2 crosshair (three crossed lines), centered at origin. Non-indexed
@ref MeshPrimitive::Lines with @ref VertexFormat::Vector3 positions. The
returned instance references @ref Trade::DataFlag::Global data --- pass the
mesh through @ref MeshTools::owned() to get a mutable copy, if needed.
mesh through @ref MeshTools::copy() to get a mutable copy, if needed.
@image html primitives-crosshair3d.png width=256px

6
src/Magnum/Primitives/Cube.h

@ -41,7 +41,7 @@ namespace Magnum { namespace Primitives {
@ref MeshIndexType::UnsignedShort indices, interleaved
@ref VertexFormat::Vector3 positions and flat @ref VertexFormat::Vector3
normals. The returned instance references @ref Trade::DataFlag::Global data ---
pass the mesh through @ref MeshTools::owned() to get a mutable copy, if needed.
pass the mesh through @ref MeshTools::copy() to get a mutable copy, if needed.
@image html primitives-cubesolid.png width=256px
@ -56,7 +56,7 @@ MAGNUM_PRIMITIVES_EXPORT Trade::MeshData cubeSolid();
with @ref VertexFormat::Vector3 positions. No normals or anything else, use
@ref cubeSolid() instead if you need these. The returned instance references
@ref Trade::DataFlag::Global data --- pass the mesh through
@ref MeshTools::owned() to get a mutable copy, if needed.
@ref MeshTools::copy() to get a mutable copy, if needed.
Vertex positions of this mesh can be also generated directly in the vertex
shader using @glsl gl_VertexID @ce ([source](https://twitter.com/turanszkij/status/1141638406956617730),
@ -74,7 +74,7 @@ MAGNUM_PRIMITIVES_EXPORT Trade::MeshData cubeSolidStrip();
2x2x2 cube, centered at origin. @ref MeshPrimitive::Lines with
@ref MeshIndexType::UnsignedShort indices and @ref VertexFormat::Vector3
positions. The returned instance references @ref Trade::DataFlag::Global data
--- pass the mesh through @ref MeshTools::owned() to get a mutable copy, if
--- pass the mesh through @ref MeshTools::copy() to get a mutable copy, if
needed.
@image html primitives-cubewireframe.png width=256px

4
src/Magnum/Primitives/Plane.h

@ -90,7 +90,7 @@ enum class CORRADE_DEPRECATED_ENUM("use PlaneFlags instead") PlaneTextureCoords:
@ref VertexFormat::Vector4 tangents and optional @ref VertexFormat::Vector2
texture coordinates. The returned instance may reference
@ref Trade::DataFlag::Global data --- pass the mesh through
@ref MeshTools::owned() to get a mutable copy, if needed.
@ref MeshTools::copy() to get a mutable copy, if needed.
@image html primitives-planesolid.png width=256px
@ -120,7 +120,7 @@ CORRADE_IGNORE_DEPRECATED_POP
2x2 square on the XY plane, centered at origin. Non-indexed
@ref MeshPrimitive::LineLoop on the XY plane with @ref VertexFormat::Vector3
positions. The returned instance references @ref Trade::DataFlag::Global data
--- pass the mesh through @ref MeshTools::owned() to get a mutable copy, if
--- pass the mesh through @ref MeshTools::copy() to get a mutable copy, if
needed.
@image html primitives-planewireframe.png width=256px

4
src/Magnum/Primitives/Square.h

@ -80,7 +80,7 @@ enum class CORRADE_DEPRECATED_ENUM("use SquareFlags instead") SquareTextureCoord
with interleaved @ref VertexFormat::Vector2 positions and optional
@ref VertexFormat::Vector2 texture coordinates. The returned instance
references @ref Trade::DataFlag::Global data --- pass the mesh through
@ref MeshTools::owned() to get a mutable copy, if needed.
@ref MeshTools::copy() to get a mutable copy, if needed.
@image html primitives-squaresolid.png width=256px
@ -105,7 +105,7 @@ CORRADE_IGNORE_DEPRECATED_POP
2x2 square, centered at origin. Non-indexed @ref MeshPrimitive::LineLoop with
@ref VertexFormat::Vector2 positions. The returned instance references
@ref Trade::DataFlag::Global data --- pass the mesh through
@ref MeshTools::owned() to get a mutable copy, if needed.
@ref MeshTools::copy() to get a mutable copy, if needed.
@image html primitives-squarewireframe.png width=256px

2
src/Magnum/SceneTools/sceneconverter.cpp

@ -35,7 +35,7 @@
#include "Magnum/MaterialTools/PhongToPbrMetallicRoughness.h"
#include "Magnum/MeshTools/Concatenate.h"
#include "Magnum/MeshTools/Reference.h"
#include "Magnum/MeshTools/Copy.h"
#include "Magnum/MeshTools/RemoveDuplicates.h"
#include "Magnum/MeshTools/Transform.h"
#include "Magnum/SceneTools/Hierarchy.h"

2
src/Magnum/Trade/MeshData.h

@ -786,7 +786,7 @@ cases when it's desirable to modify the data in-place, there's the
@ref mutableAttribute() set of functions. To use these, you need to check that
the data are mutable using @ref indexDataFlags() or @ref vertexDataFlags()
first, and if not then you may want to make a mutable copy first using
@ref MeshTools::owned(). The following snippet applies a transformation to the
@ref MeshTools::copy(). The following snippet applies a transformation to the
mesh positions:
@snippet MagnumTrade.cpp MeshData-usage-mutable

Loading…
Cancel
Save