Magnum::MeshTools namespace

Mesh tools.

Contents

Tools for generating, optimizing and cleaning meshes.

This library is built if WITH_MESHTOOLS is enabled when building Magnum. To use this library with CMake, request the MeshTools component of the Magnum package and link to the Magnum::MeshTools target:

find_package(Magnum REQUIRED MeshTools)

# ...
target_link_libraries(your-app PRIVATE Magnum::MeshTools)

Note that functionality depending on GL APIs is available only if Magnum is built with both WITH_GL and TARGET_GL enabled (which is done by default).

See Downloading and building and Usage with CMake for more information.

Enums

enum class CompileFlag: UnsignedByte { GenerateFlatNormals = 1 << 0, GenerateSmoothNormals = 1 << 1, NoWarnOnCustomAttributes = 1 << 2 new in Git master } new in 2019.10
Mesh compilation flag.

Typedefs

using CompileFlags = Containers::EnumSet<CompileFlag> new in 2019.10
Mesh compilation flags.

Functions

auto combineIndexedAttributes(const Containers::ArrayView<const Containers::Reference<const Trade::MeshData>> data) -> Trade::MeshData new in Git master
Combine differently indexed attributes into a single mesh.
auto combineIndexedAttributes(std::initializer_list<Containers::Reference<const Trade::MeshData>> data) -> Trade::MeshData new in Git master
auto combineFaceAttributes(const Trade::MeshData& mesh, const Trade::MeshData& faceAttributes) -> Trade::MeshData new in Git master
Combine per-face attributes into an existing mesh.
auto combineFaceAttributes(const Trade::MeshData& mesh, Containers::ArrayView<const Trade::MeshAttributeData> faceAttributes) -> Trade::MeshData new in Git master
auto combineFaceAttributes(const Trade::MeshData& mesh, std::initializer_list<Trade::MeshAttributeData> faceAttributes) -> Trade::MeshData new in Git master
auto combineIndexArrays(const std::vector<std::reference_wrapper<std::vector<UnsignedInt>>>& arrays) -> std::vector<UnsignedInt> deprecated in Git master
Combine index arrays.
auto combineIndexArrays(std::initializer_list<std::reference_wrapper<std::vector<UnsignedInt>>> arrays) -> std::vector<UnsignedInt> deprecated in Git master
auto combineIndexArrays(const std::vector<UnsignedInt>& interleavedArrays, UnsignedInt stride) -> std::pair<std::vector<UnsignedInt>, std::vector<UnsignedInt>> deprecated in Git master
Combine interleaved index arrays.
template<class ... T>
auto combineIndexedArrays(const std::pair<const std::vector<UnsignedInt>&, std::vector<T>&>&... indexedArrays) -> std::vector<UnsignedInt> deprecated in Git master
Combine indexed arrays.
auto compile(const Trade::MeshData& meshData, CompileFlags flags) -> GL::Mesh new in Git master
Compile mesh data.
auto compile(const Trade::MeshData& meshData) -> GL::Mesh new in Git master
auto compile(const Trade::MeshData& meshData, GL::Buffer& indices, GL::Buffer& vertices) -> GL::Mesh new in Git master
Compile mesh data using external buffers.
auto compile(const Trade::MeshData& meshData, GL::Buffer& indices, GL::Buffer&& vertices) -> GL::Mesh new in Git master
auto compile(const Trade::MeshData& meshData, GL::Buffer&& indices, GL::Buffer& vertices) -> GL::Mesh new in Git master
auto compile(const Trade::MeshData& meshData, GL::Buffer&& indices, GL::Buffer&& vertices) -> GL::Mesh new in Git master
auto compile(const Trade::MeshData2D& meshData) -> GL::Mesh deprecated in Git master
Compile 2D mesh data.
auto compile(const Trade::MeshData2D& meshData, GL::BufferUsage usage) -> std::tuple<GL::Mesh, std::unique_ptr<GL::Buffer>, std::unique_ptr<GL::Buffer>> deprecated in 2018.10
Compile 2D mesh data.
auto compile(const Trade::MeshData3D& meshData, CompileFlags flags = {}) -> GL::Mesh deprecated in Git master
Compile 3D mesh data.
auto compile(const Trade::MeshData3D& meshData, GL::BufferUsage usage) -> std::tuple<GL::Mesh, std::unique_ptr<GL::Buffer>, std::unique_ptr<GL::Buffer>> deprecated in 2018.10
Compile 3D mesh data.
auto compressIndices(const Containers::StridedArrayView1D<const UnsignedInt>& indices, MeshIndexType atLeast = MeshIndexType::UnsignedShort, Long offset = 0) -> std::pair<Containers::Array<char>, MeshIndexType> new in Git master
Compress an index array.
auto compressIndices(const Containers::StridedArrayView1D<const UnsignedShort>& indices, MeshIndexType atLeast = MeshIndexType::UnsignedShort, Long offset = 0) -> std::pair<Containers::Array<char>, MeshIndexType> new in Git master
auto compressIndices(const Containers::StridedArrayView1D<const UnsignedByte>& indices, MeshIndexType atLeast = MeshIndexType::UnsignedShort, Long offset = 0) -> std::pair<Containers::Array<char>, MeshIndexType> new in Git master
auto compressIndices(const Containers::StridedArrayView1D<const UnsignedInt>& indices, Long offset) -> std::pair<Containers::Array<char>, MeshIndexType> new in Git master
auto compressIndices(const Containers::StridedArrayView1D<const UnsignedShort>& indices, Long offset) -> std::pair<Containers::Array<char>, MeshIndexType> new in Git master
auto compressIndices(const Containers::StridedArrayView1D<const UnsignedByte>& indices, Long offset) -> std::pair<Containers::Array<char>, MeshIndexType> new in Git master
auto compressIndices(const Containers::StridedArrayView2D<const char>& indices, MeshIndexType atLeast = MeshIndexType::UnsignedShort, Long offset = 0) -> std::pair<Containers::Array<char>, MeshIndexType> new in Git master
Compress a type-erased index array.
auto compressIndices(const Containers::StridedArrayView2D<const char>& indices, Long offset) -> std::pair<Containers::Array<char>, MeshIndexType> new in Git master
auto compressIndices(const Trade::MeshData& data, MeshIndexType atLeast = MeshIndexType::UnsignedShort) -> Trade::MeshData new in Git master
Compress mesh data indices.
auto compressIndices(Trade::MeshData&& data, MeshIndexType atLeast = MeshIndexType::UnsignedShort) -> Trade::MeshData new in Git master
Compress mesh data indices.
auto compressIndices(const std::vector<UnsignedInt>& indices) -> std::tuple<Containers::Array<char>, MeshIndexType, UnsignedInt, UnsignedInt> deprecated in Git master
Compress vertex indices.
template<class T>
auto compressIndicesAs(const std::vector<UnsignedInt>& indices) -> Containers::Array<T> deprecated in Git master
Compress vertex indices as given type.
auto concatenate(const Trade::MeshData& first, const Containers::ArrayView<const Containers::Reference<const Trade::MeshData>> next = {}) -> Trade::MeshData new in Git master
Concatenate meshes together.
auto concatenate(const Trade::MeshData& first, std::initializer_list<Containers::Reference<const Trade::MeshData>> next) -> Trade::MeshData new in Git master
auto concatenate(Trade::MeshData&& first, const Containers::ArrayView<const Containers::Reference<const Trade::MeshData>> next = {}) -> Trade::MeshData new in Git master
Concatenate meshes together.
auto concatenate(Trade::MeshData&& first, std::initializer_list<Containers::Reference<const Trade::MeshData>> next) -> Trade::MeshData new in Git master
template<template<class> class Allocator = Containers::ArrayAllocator>
void concatenateInto(Trade::MeshData& destination, const Containers::ArrayView<const Containers::Reference<const Trade::MeshData>> meshes) new in Git master
Concatenate a list of meshes into a pre-existing destination, enlarging it if necessary.
template<template<class> class Allocator = Containers::ArrayAllocator>
void concatenateInto(Trade::MeshData& destination, const std::initializer_list<Containers::Reference<const Trade::MeshData>> meshes) new in Git master
template<class IndexType, class T>
auto duplicate(const Containers::StridedArrayView1D<const IndexType>& indices, const Containers::StridedArrayView1D<const T>& data) -> Containers::Array<T> new in 2019.10
Duplicate data using given index array.
template<class T>
auto duplicate(const std::vector<UnsignedInt>& indices, const std::vector<T>& data) -> std::vector<T> deprecated in Git master
Duplicate data using given index array.
template<class IndexType, class T>
void duplicateInto(const Containers::StridedArrayView1D<const IndexType>& indices, const Containers::StridedArrayView1D<const T>& data, const Containers::StridedArrayView1D<T>& out) new in 2019.10
Duplicate data using an index array into given output array.
void duplicateInto(const Containers::StridedArrayView1D<const UnsignedInt>& indices, const Containers::StridedArrayView2D<const char>& data, const Containers::StridedArrayView2D<char>& out) new in Git master
Duplicate type-erased data using an index array into given output array.
void duplicateInto(const Containers::StridedArrayView1D<const UnsignedShort>& indices, const Containers::StridedArrayView2D<const char>& data, const Containers::StridedArrayView2D<char>& out) new in Git master
void duplicateInto(const Containers::StridedArrayView1D<const UnsignedByte>& indices, const Containers::StridedArrayView2D<const char>& data, const Containers::StridedArrayView2D<char>& out) new in Git master
void duplicateInto(const Containers::StridedArrayView2D<const char>& indices, const Containers::StridedArrayView2D<const char>& data, const Containers::StridedArrayView2D<char>& out) new in Git master
Duplicate type-erased data using a type-erased index array into given output array.
auto duplicate(const Trade::MeshData& data, Containers::ArrayView<const Trade::MeshAttributeData> extra = {}) -> Trade::MeshData new in Git master
Duplicate indexed mesh data.
auto duplicate(const Trade::MeshData& data, std::initializer_list<Trade::MeshAttributeData> extra) -> Trade::MeshData new in Git master
void flipNormalsInPlace(const Containers::StridedArrayView1D<UnsignedInt>& indices, const Containers::StridedArrayView1D<Vector3>& normals)
Flip mesh normals and face winding in-place.
void flipNormalsInPlace(const Containers::StridedArrayView1D<UnsignedShort>& indices, const Containers::StridedArrayView1D<Vector3>& normals) new in Git master
void flipNormalsInPlace(const Containers::StridedArrayView1D<UnsignedByte>& indices, const Containers::StridedArrayView1D<Vector3>& normals) new in Git master
void flipNormalsInPlace(const Containers::StridedArrayView2D<char>& indices, const Containers::StridedArrayView1D<Vector3>& normals) new in Git master
Flip mesh normals and face winding in-place on a type-erased index array.
void flipNormals(std::vector<UnsignedInt>& indices, std::vector<Vector3>& normals) deprecated in Git master
Flip mesh normals and face winding in-place.
void flipFaceWindingInPlace(const Containers::StridedArrayView1D<UnsignedInt>& indices) new in Git master
Flip face winding in-place.
void flipFaceWindingInPlace(const Containers::StridedArrayView1D<UnsignedShort>& indices) new in Git master
void flipFaceWindingInPlace(const Containers::StridedArrayView1D<UnsignedByte>& indices) new in Git master
void flipFaceWindingInPlace(const Containers::StridedArrayView2D<char>& indices) new in Git master
Flip face winding in-place on a type-erased index array.
void flipFaceWinding(std::vector<UnsignedInt>& indices) deprecated in Git master
Flip face winding in-place.
void flipNormalsInPlace(const Containers::StridedArrayView1D<Vector3>& normals)
Flip mesh normals in-place.
void flipNormals(std::vector<Vector3>& normals) deprecated in Git master
Flip mesh normals in-place.
auto fullScreenTriangle(GL::Version version) -> GL::Mesh
Full screen triangle mesh.
auto fullScreenTriangle() -> GL::Mesh
auto primitiveCount(MeshPrimitive primitive, UnsignedInt elementCount) -> UnsignedInt new in Git master
Actual primitive count for given primitive type and element count.
auto generateLineStripIndices(UnsignedInt vertexCount) -> Containers::Array<UnsignedInt> new in Git master
Create index buffer for a line strip primitive.
void generateLineStripIndicesInto(UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& indices) new in Git master
Create index buffer for a line strip primitive into an existing array.
auto generateLineLoopIndices(UnsignedInt vertexCount) -> Containers::Array<UnsignedInt> new in Git master
Create index buffer for a line loop primitive.
void generateLineLoopIndicesInto(UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& into) new in Git master
Create index buffer for a line loop primitive into an existing array.
auto generateTriangleStripIndices(UnsignedInt vertexCount) -> Containers::Array<UnsignedInt> new in Git master
Create index buffer for a triangle strip primitive.
void generateTriangleStripIndicesInto(UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& into) new in Git master
Create index buffer for a triangle strip primitive into an existing array.
auto generateTriangleFanIndices(UnsignedInt vertexCount) -> Containers::Array<UnsignedInt> new in Git master
Create index buffer for a triangle fan primitive.
void generateTriangleFanIndicesInto(UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& into) new in Git master
Create index buffer for a triangle fan primitive into an existing array.
auto generateIndices(const Trade::MeshData& mesh) -> Trade::MeshData new in Git master
Convert a mesh to plain indexed lines or triangles.
auto generateIndices(Trade::MeshData&& data) -> Trade::MeshData new in Git master
Convert a mesh to plain indexed lines or triangles.
auto generateFlatNormals(const Containers::StridedArrayView1D<const Vector3>& positions) -> Containers::Array<Vector3> new in 2019.10
Generate flat normals.
void generateFlatNormalsInto(const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<Vector3>& normals) new in 2019.10
Generate flat normals into an existing array.
auto generateFlatNormals(const std::vector<UnsignedInt>& indices, const std::vector<Vector3>& positions) -> std::pair<std::vector<UnsignedInt>, std::vector<Vector3>> deprecated in 2019.10
Generate flat normals.
auto generateSmoothNormals(const Containers::StridedArrayView1D<const UnsignedInt>& indices, const Containers::StridedArrayView1D<const Vector3>& positions) -> Containers::Array<Vector3> new in 2019.10
Generate smooth normals.
auto generateSmoothNormals(const Containers::StridedArrayView1D<const UnsignedShort>& indices, const Containers::StridedArrayView1D<const Vector3>& positions) -> Containers::Array<Vector3> new in 2019.10
auto generateSmoothNormals(const Containers::StridedArrayView1D<const UnsignedByte>& indices, const Containers::StridedArrayView1D<const Vector3>& positions) -> Containers::Array<Vector3> new in 2019.10
auto generateSmoothNormals(const Containers::StridedArrayView2D<const char>& indices, const Containers::StridedArrayView1D<const Vector3>& positions) -> Containers::Array<Vector3> new in Git master
Generate smooth normals using a type-erased index array.
void generateSmoothNormalsInto(const Containers::StridedArrayView1D<const UnsignedInt>& indices, const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<Vector3>& normals) new in 2019.10
Generate smooth normals into an existing array.
void generateSmoothNormalsInto(const Containers::StridedArrayView1D<const UnsignedShort>& indices, const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<Vector3>& normals) new in 2019.10
void generateSmoothNormalsInto(const Containers::StridedArrayView1D<const UnsignedByte>& indices, const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<Vector3>& normals) new in 2019.10
void generateSmoothNormalsInto(const Containers::StridedArrayView2D<const char>& indices, const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<Vector3>& normals) new in Git master
Generate smooth normals into an existing array using a type-erased index array.
template<class T, class ... U>
auto interleave(const T& first, const U&... next) -> Containers::Array<char>
Interleave vertex attributes.
template<class T, class ... U>
void interleaveInto(Containers::ArrayView<char> buffer, const T& first, const U&... next)
Interleave vertex attributes into existing buffer.
auto isInterleaved(const Trade::MeshData& data) -> bool new in Git master
If the mesh data is interleaved.
auto interleavedData(const Trade::MeshData& data) -> Containers::StridedArrayView2D<const char> new in Git master
Type-erased view on interleaved mesh data.
auto interleavedMutableData(Trade::MeshData& data) -> Containers::StridedArrayView2D<char> new in Git master
Mutable type-erased view on interleaved mesh data.
auto interleavedLayout(const Trade::MeshData& data, UnsignedInt vertexCount, Containers::ArrayView<const Trade::MeshAttributeData> extra = {}) -> Trade::MeshData new in Git master
Create an interleaved mesh layout.
auto interleavedLayout(const Trade::MeshData& data, UnsignedInt vertexCount, std::initializer_list<Trade::MeshAttributeData> extra) -> Trade::MeshData new in Git master
auto interleavedLayout(Trade::MeshData&& data, UnsignedInt vertexCount, Containers::ArrayView<const Trade::MeshAttributeData> extra = {}) -> Trade::MeshData new in Git master
Create an interleaved mesh layout.
auto interleavedLayout(Trade::MeshData&& data, UnsignedInt vertexCount, std::initializer_list<Trade::MeshAttributeData> extra) -> Trade::MeshData new in Git master
auto interleave(const Trade::MeshData& data, Containers::ArrayView<const Trade::MeshAttributeData> extra = {}) -> Trade::MeshData new in Git master
Interleave mesh data.
auto interleave(const Trade::MeshData& data, std::initializer_list<Trade::MeshAttributeData> extra) -> Trade::MeshData new in Git master
auto interleave(Trade::MeshData&& data, Containers::ArrayView<const Trade::MeshAttributeData> extra = {}) -> Trade::MeshData new in Git master
Interleave mesh data.
auto interleave(Trade::MeshData&& data, std::initializer_list<Trade::MeshAttributeData> extra) -> Trade::MeshData new in Git master
auto removeDuplicatesInPlace(const Containers::StridedArrayView2D<char>& data) -> std::pair<Containers::Array<UnsignedInt>, std::size_t> new in Git master
Remove duplicate data from given array in-place.
auto removeDuplicatesInPlaceInto(const Containers::StridedArrayView2D<char>& data, const Containers::StridedArrayView1D<UnsignedInt>& indices) -> std::size_t new in Git master
Remove duplicate data from given array in-place into given output index array.
auto removeDuplicates(const Containers::StridedArrayView2D<const char>& data) -> std::pair<Containers::Array<UnsignedInt>, std::size_t> new in Git master
Remove duplicate data from given array.
auto removeDuplicatesInto(const Containers::StridedArrayView2D<const char>& data, const Containers::StridedArrayView1D<UnsignedInt>& indices) -> std::size_t new in Git master
Remove duplicate data from given array into given output index array.
auto removeDuplicatesIndexedInPlace(const Containers::StridedArrayView1D<UnsignedInt>& indices, const Containers::StridedArrayView2D<char>& data) -> std::size_t new in Git master
Remove duplicates from indexed data in-place.
auto removeDuplicatesIndexedInPlace(const Containers::StridedArrayView1D<UnsignedShort>& indices, const Containers::StridedArrayView2D<char>& data) -> std::size_t new in Git master
auto removeDuplicatesIndexedInPlace(const Containers::StridedArrayView1D<UnsignedByte>& indices, const Containers::StridedArrayView2D<char>& data) -> std::size_t new in Git master
auto removeDuplicatesIndexedInPlace(const Containers::StridedArrayView2D<char>& indices, const Containers::StridedArrayView2D<char>& data) -> std::size_t new in Git master
Remove duplicates from indexed data in-place on a type-erased index array.
auto removeDuplicatesFuzzyInPlace(const Containers::StridedArrayView2D<Float>& data, Float epsilon = Math::TypeTraits<Float>::epsilon()) -> std::pair<Containers::Array<UnsignedInt>, std::size_t> new in Git master
Remove duplicate data from given array using fuzzy comparison in-place.
auto removeDuplicatesFuzzyInPlace(const Containers::StridedArrayView2D<Double>& data, Double epsilon = Math::TypeTraits<Double>::epsilon()) -> std::pair<Containers::Array<UnsignedInt>, std::size_t> new in Git master
auto removeDuplicatesFuzzyInPlaceInto(const Containers::StridedArrayView2D<Float>& data, const Containers::StridedArrayView1D<UnsignedInt>& indices, Float epsilon = Math::TypeTraits<Float>::epsilon()) -> std::size_t new in Git master
Remove duplicate data from given array using fuzzy comparison in-place into given output index array.
auto removeDuplicatesFuzzyInPlaceInto(const Containers::StridedArrayView2D<Double>& data, const Containers::StridedArrayView1D<UnsignedInt>& indices, Double epsilon = Math::TypeTraits<Double>::epsilon()) -> std::size_t new in Git master
template<class Vector>
auto removeDuplicates(std::vector<Vector>& data, typename Vector::Type epsilon = Math::TypeTraits<typename Vector::Type>::epsilon()) -> std::vector<UnsignedInt> deprecated in Git master
Remove duplicate data from a STL vector using fuzzy comparison in-place.
auto removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView1D<UnsignedInt>& indices, const Containers::StridedArrayView2D<Float>& data, Float epsilon = Math::TypeTraits<Float>::epsilon()) -> std::size_t new in Git master
Remove duplicates from indexed data using fuzzy comparison in-place.
auto removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView1D<UnsignedShort>& indices, const Containers::StridedArrayView2D<Float>& data, Float epsilon = Math::TypeTraits<Float>::epsilon()) -> std::size_t new in Git master
auto removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView1D<UnsignedByte>& indices, const Containers::StridedArrayView2D<Float>& data, Float epsilon = Math::TypeTraits<Float>::epsilon()) -> std::size_t new in Git master
auto removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView1D<UnsignedInt>& indices, const Containers::StridedArrayView2D<Double>& data, Double epsilon = Math::TypeTraits<Double>::epsilon()) -> std::size_t new in Git master
auto removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView1D<UnsignedShort>& indices, const Containers::StridedArrayView2D<Double>& data, Double epsilon = Math::TypeTraits<Double>::epsilon()) -> std::size_t new in Git master
auto removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView1D<UnsignedByte>& indices, const Containers::StridedArrayView2D<Double>& data, Double epsilon = Math::TypeTraits<Double>::epsilon()) -> std::size_t new in Git master
auto removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView2D<char>& indices, const Containers::StridedArrayView2D<Float>& data, Float epsilon = Math::TypeTraits<Float>::epsilon()) -> std::size_t new in Git master
Remove duplicates from indexed data using fuzzy comparison in-place on a type-erased index array.
auto removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView2D<char>& indices, const Containers::StridedArrayView2D<Double>& data, Double epsilon = Math::TypeTraits<Double>::epsilon()) -> std::size_t new in Git master
auto removeDuplicates(const Trade::MeshData& data) -> Trade::MeshData new in Git master
Remove mesh data duplicates.
auto removeDuplicates(Trade::MeshData&& data) -> Trade::MeshData new in Git master
Remove mesh data duplicates.
auto removeDuplicatesFuzzy(const Trade::MeshData& data, Float floatEpsilon = Math::TypeTraits<Float>::epsilon(), Double doubleEpsilon = Math::TypeTraits<Double>::epsilon()) -> Trade::MeshData new in Git master
Remove mesh data duplicates with fuzzy comparison for floating-point attributes.
template<class IndexType, class Vertex, class Interpolator>
void subdivide(Containers::Array<IndexType>& indices, Containers::Array<Vertex>& vertices, Interpolator interpolator) new in Git master
Subdivide a mesh.
template<class Vertex, class Interpolator>
void subdivide(std::vector<UnsignedInt>& indices, std::vector<Vertex>& vertices, Interpolator interpolator) deprecated in Git master
Subdivide a mesh.
template<class IndexType, class Vertex, class Interpolator>
void subdivideInPlace(const Containers::StridedArrayView1D<IndexType>& indices, const Containers::StridedArrayView1D<Vertex>& vertices, Interpolator interpolator) new in Git master
Subdivide a mesh in-place.
template<class IndexType, class Vertex, class Interpolator>
void subdivideInPlace(const Containers::ArrayView<IndexType>& indices, const Containers::StridedArrayView1D<Vertex>& vertices, Interpolator interpolator) new in Git master
void tipsifyInPlace(const Containers::StridedArrayView1D<UnsignedInt>& indices, UnsignedInt vertexCount, std::size_t cacheSize)
Tipsify the mesh in-place.
void tipsifyInPlace(const Containers::StridedArrayView1D<UnsignedShort>& indices, UnsignedInt vertexCount, std::size_t cacheSize) new in Git master
void tipsifyInPlace(const Containers::StridedArrayView1D<UnsignedByte>& indices, UnsignedInt vertexCount, std::size_t cacheSize) new in Git master
void tipsify(std::vector<UnsignedInt>& indices, UnsignedInt vertexCount, std::size_t cacheSize) deprecated in Git master
Tipsify the mesh in-place.
template<class T, class U>
void transformVectorsInPlace(const Math::Matrix4<T>& matrix, U&& vectors)
Transform vectors in-place using given transformation.
template<class T, class U>
void transformVectorsInPlace(const Math::Matrix3<T>& matrix, U&& vectors)
template<class T, class U>
void transformVectorsInPlace(const Math::Complex<T>& complex, U&& vectors)
template<class T, class U>
void transformVectorsInPlace(const Math::Quaternion<T>& normalizedQuaternion, U&& vectors)
template<class T, class U>
auto transformVectors(const T& transformation, U vectors) -> U
Transform vectors using given transformation.
template<class T, class U>
void transformPointsInPlace(const Math::Matrix4<T>& matrix, U&& points)
Transform points in-place using given transformation.
template<class T, class U>
void transformPointsInPlace(const Math::Matrix3<T>& matrix, U&& points)
template<class T, class U>
void transformPointsInPlace(const Math::DualComplex<T>& dualComplex, U&& points)
template<class T, class U>
void transformPointsInPlace(const Math::DualQuaternion<T>& normalizedDualQuaternion, U&& points)
template<class T, class U>
auto transformPoints(const T& transformation, U vectors) -> U
Transform points using given transformation.

Enum documentation

enum class Magnum::MeshTools::CompileFlag: UnsignedByte new in 2019.10

Mesh compilation flag.

Enumerators
GenerateFlatNormals

If the mesh is MeshPrimitive::Triangles, generates normals using MeshTools::generateFlatNormals(). If the mesh is not a triangle mesh or doesn't have 3D positions, this flag does nothing. If the mesh already has its own normals, these get replaced. If CompileFlag::GenerateSmoothNormals is specified together with this flag, this flag gets a priority.

GenerateSmoothNormals

If the mesh MeshPrimitive::Triangles, generates normals using MeshTools::generateSmoothNormals() based on triangle adjacency information from the index buffer. If the mesh is not indexed, this behaves the same as CompileFlag::GenerateFlatNormals. If the mesh is not a triangle mesh or doesn't have 3D positions, this flag does nothing. If the mesh already has its own normals, these get replaced.

NoWarnOnCustomAttributes new in Git master

By default, compile() warns when it encounters custom attributes and attributes with implementation-specific format, as those get ignored by it. If you're binding those manually with compile(const Trade::MeshData&, GL::Buffer&, GL::Buffer&) or handling them in some other way on the application side already, use this flag to suppress the warning messages.

Typedef documentation

Function documentation

Trade::MeshData Magnum::MeshTools::combineIndexedAttributes(const Containers::ArrayView<const Containers::Reference<const Trade::MeshData>> data) new in Git master

Combine differently indexed attributes into a single mesh.

Assuming each data contains only unique vertex data, creates an indexed mesh that contains all attributes from data combined, with duplicate vertices removed. For example, when you have a position and a normal array, each indexed with separate indices like this:

{pA, pB, pC, pD, pE, pF}        // positions
{nA, nB, nC, nD, nE, nF, nG}    // normals

{0, 2, 5, 0, 0, 1, 3, 2, 2}     // position indices
{1, 3, 4, 1, 4, 6, 1, 3, 1}     // normal indices

Then the first triangle in the mesh is defined as {pA, nB}, {pC, nD}, {pF, nE}. When combined together using this function, the resulting mesh stays the same but there's just one index array, indexing both positions and normals:

{{pA, nB}, {pC, nD}, {pF, nE}, {pA, nE}, {pB, nG}, {pD, nB}, {pC, nB}}
                                // unique pairs of positions and normals

{0, 1, 2, 0, 3, 4, 5, 1, 6}     // unified indices

The function preserves all attribute data including repeated or custom attributes. The resulting mesh is interleaved, with all attributes packed tightly together. If you need to add specific padding for alignment preservation, pass the result to interleave() and specify the paddings between attributes manually. Similarly, for simplicity the resulting mesh has always MeshIndexType::UnsignedInt — use compressIndices(const Trade::MeshData&, MeshIndexType) if you want to have it compressed to a smaller type.

Vertex data unreferenced by the index buffers are discarded. This means the function can be also called with just a single argument to compact a mesh with a sparse index buffer.

Expects that data is non-empty and all data have the same primitive and index count. All inputs have to be indexed, although the particular MeshIndexType doesn't matter. For non-indexed attributes combining can be done much more efficiently using duplicate(const Trade::MeshData&, Containers::ArrayView<const Trade::MeshAttributeData>), alternatively you can turn a non-indexed attribute to an indexed one first using removeDuplicatesInPlace() and then call this function.

Trade::MeshData Magnum::MeshTools::combineIndexedAttributes(std::initializer_list<Containers::Reference<const Trade::MeshData>> data) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Trade::MeshData Magnum::MeshTools::combineFaceAttributes(const Trade::MeshData& mesh, const Trade::MeshData& faceAttributes) new in Git master

Combine per-face attributes into an existing mesh.

The resulting mesh will have all per-face attributes turned into per-vertex attributes, leaving only unique combinations and adjusting the index buffer accordingly. The resulting mesh has the same amount of indices, but likely more vertices.

Expects that mesh is indexed MeshPrimitive::Triangles and faceAttributes is MeshPrimitive::Faces, with face element count of the latter corresponding to triangle count of the former. If faceAttributes is indexed, it's assumed to have the data unique; if it's not indexed, it's first made unique using removeDuplicates() and in that case it's expected to be interleaved.

Trade::MeshData Magnum::MeshTools::combineFaceAttributes(const Trade::MeshData& mesh, Containers::ArrayView<const Trade::MeshAttributeData> faceAttributes) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Same as above with faceAttributes wrapped in a Trade::MeshData with MeshPrimitive::Faces and no index buffer. Same as in the above case, faceAttributes is expected to be interleaved. Note that offset-only Trade::MeshAttributeData instances are not supported in the faceAttributes array.

Trade::MeshData Magnum::MeshTools::combineFaceAttributes(const Trade::MeshData& mesh, std::initializer_list<Trade::MeshAttributeData> faceAttributes) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

std::vector<UnsignedInt> Magnum::MeshTools::combineIndexArrays(const std::vector<std::reference_wrapper<std::vector<UnsignedInt>>>& arrays)

Combine index arrays.

Parameters
arrays in/out Index arrays to combine. These arrays are updated in-place to contain unique combinations of the original indices.
Returns Resulting combined index array

Creates new combined index array and updates the original ones with translation to new ones. For example, when you have position and normal array, each indexed with separate indices and you want to index both of them with single index array:

a b c d e f         // positions
A B C D E F G       // normals

0 2 5 0 0 1 3 2 2   // position indices
1 3 4 1 4 6 1 3 1   // normal indices

In particular, first triangle in the mesh will have positions a c f and normals B D E. You can see that not all combinations are unique and also that there are some vertices unused. When you pass the two index arrays above to this function, the following combined index array is returned:

0 1 2 0 3 4 5 1 6

And the original arrays are cleaned up to have only unique combinations:

0 2 5 0 1 3 2
1 3 4 4 6 1 1

You can use these as translation table to create new vertex and normal arrays which can be then indexed with the combined index array:

a c f a b d c
B D E E G B B

Again, first triangle in the mesh will have positions a c f and normals B D E.

This function calls combineIndexArrays(const std::vector<UnsignedInt>&, UnsignedInt) internally. See also combineIndexedArrays() which does the vertex data reordering automatically.

std::vector<UnsignedInt> Magnum::MeshTools::combineIndexArrays(std::initializer_list<std::reference_wrapper<std::vector<UnsignedInt>>> arrays)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

std::pair<std::vector<UnsignedInt>, std::vector<UnsignedInt>> Magnum::MeshTools::combineIndexArrays(const std::vector<UnsignedInt>& interleavedArrays, UnsignedInt stride)

Combine interleaved index arrays.

Unlike above, this function takes one interleaved array instead of separate index arrays. Continuing with the above example, you would call this function with the following array (odd value is vertex index, even is normal index, stride is thus 2):

0 1 2 3 5 4 0 1 0 4 1 6 3 1 2 3 2 1

Similarly to above this function will return the following combined index array as first pair value:

0 1 2 0 3 4 5 1 6

And second pair value is the cleaned up interleaved array:

0 1 2 3 5 4 0 4 1 6 3 1 2 1

template<class ... T>
std::vector<UnsignedInt> Magnum::MeshTools::combineIndexedArrays(const std::pair<const std::vector<UnsignedInt>&, std::vector<T>&>&... indexedArrays)

Combine indexed arrays.

Parameters
indexedArrays in/out Index and attribute arrays
Returns Array with resulting indices

Creates new combined index array and reorders original attribute arrays so they can be indexed with the new single index array.

The index array must be passed as const reference (to avoid copying) and attribute array as reference, so it can be replaced with combined data. To avoid explicit verbose specification of tuple type, you can write it with help of some STL functions like shown below. Also if one index array is shared by more than one attribute array, just pass the index array more times. Example:

std::vector<UnsignedInt> vertexIndices;
std::vector<Vector3> positions;
std::vector<UnsignedInt> normalTextureIndices;
std::vector<Vector3> normals;
std::vector<Vector2> textureCoordinates;

std::vector<UnsignedInt> indices = MeshTools::combineIndexedArrays(
    std::make_pair(std::cref(vertexIndices), std::ref(positions)),
    std::make_pair(std::cref(normalTextureIndices), std::ref(normals)),
    std::make_pair(std::cref(normalTextureIndices), std::ref(textureCoordinates))
);

See combineIndexArrays() documentation for more information about the procedure.

GL::Mesh Magnum::MeshTools::compile(const Trade::MeshData& meshData, CompileFlags flags) new in Git master

Compile mesh data.

Configures a mesh for a Shaders::Generic shader with a vertex buffer and possibly also an index buffer, if the mesh is indexed.

If normal generation is not requested, Trade::MeshData::indexData() and Trade::MeshData::vertexData() are uploaded as-is without any further modifications, keeping the original layout and vertex formats. If CompileFlag::GenerateSmoothNormals is requested, vertex data is interleaved together with the generated normals; if CompileFlag::GenerateFlatNormals is requested, the mesh is first deindexed and then the vertex data is interleaved together with the generated normals.

The generated mesh owns the index and vertex buffers and there's no possibility to access them afterwards. For alternative solutions see the compile(const Trade::MeshData&, GL::Buffer&, GL::Buffer&) overloads.

GL::Mesh Magnum::MeshTools::compile(const Trade::MeshData& meshData) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

GL::Mesh Magnum::MeshTools::compile(const Trade::MeshData& meshData, GL::Buffer& indices, GL::Buffer& vertices) new in Git master

Compile mesh data using external buffers.

Assumes the whole vertex / index data are already uploaded to indices / vertices and sets up the mesh using those. Can be used to have a single index/vertex buffer when multiple Trade::MeshData instances share the same data arrays, or to allow buffer access later. For example:

GL::Buffer indices, vertices;
indices.setData(meshData.indexData());
vertices.setData(meshData.vertexData());

GL::Mesh mesh = MeshTools::compile(meshData, indices, vertices);

Another use case is specifying additional vertex attributes that are not recognized by the function itself. You can choose among various r-value overloads depending on whether you want to have the index/vertex buffers owned by the mesh or not:

GL::Buffer indices, vertices;
indices.setData(meshData.indexData());
vertices.setData(meshData.vertexData());

/* Let compile() handle the usual attributes and configure custom ones after */
GL::Mesh mesh = MeshTools::compile(meshData, std::move(indices), vertices);
mesh.addVertexBuffer(std::move(vertices),
    meshData.attributeOffset(myCustomAttribute),
    meshData.attributeStride(myCustomAttribute),
    GL::DynamicAttribute{
        GL::DynamicAttribute::Kind::Generic, 7,
        GL::DynamicAttribute::Components::One,
        GL::DynamicAttribute::DataType::Float});

If meshData is not indexed, the indices parameter is ignored — in that case you can pass a NoCreate-d instance to avoid allocating an unnecessary OpenGL buffer object.

Compared to compile(const Trade::MeshData&, CompileFlags), this function implicitly enables the CompileFlag::NoWarnOnCustomAttributes flag, assuming that custom attributes and attributes with implementation-specific formats are explicitly handled on the application side.

GL::Mesh Magnum::MeshTools::compile(const Trade::MeshData& meshData, GL::Buffer& indices, GL::Buffer&& vertices) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

GL::Mesh Magnum::MeshTools::compile(const Trade::MeshData& meshData, GL::Buffer&& indices, GL::Buffer& vertices) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

GL::Mesh Magnum::MeshTools::compile(const Trade::MeshData& meshData, GL::Buffer&& indices, GL::Buffer&& vertices) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

GL::Mesh Magnum::MeshTools::compile(const Trade::MeshData2D& meshData)

Compile 2D mesh data.

Configures a mesh for Shaders::Generic2D shader with vertex buffer and possibly also an index buffer, if the mesh is indexed. Positions are bound to Shaders::Generic2D::Position attribute. If the mesh contains texture coordinates, these are bound to Shaders::Generic2D::TextureCoordinates attribute. If the mesh contains colors, these are bound to Shaders::Generic3D::Color4 attribute. No data compression or index optimization (except for index buffer packing) is done, both the vertex buffer and the index buffer (if any) is owned by the mesh, both created with GL::BufferUsage::StaticDraw.

This is just a convenience function for creating generic meshes, you might want to use interleave() and compressIndices() functions together with GL::Mesh::setPrimitive(), GL::Mesh::setCount(), GL::Mesh::addVertexBuffer(), GL::Mesh::setIndexBuffer() instead for greater flexibility.

std::tuple<GL::Mesh, std::unique_ptr<GL::Buffer>, std::unique_ptr<GL::Buffer>> Magnum::MeshTools::compile(const Trade::MeshData2D& meshData, GL::BufferUsage usage)

Compile 2D mesh data.

GL::Mesh Magnum::MeshTools::compile(const Trade::MeshData3D& meshData, CompileFlags flags = {})

Compile 3D mesh data.

Configures mesh for Shaders::Generic3D shader with vertex buffer and possibly also index buffer, if the mesh is indexed. Positions are bound to Shaders::Generic3D::Position attribute. If the mesh contains normals, they are bound to Shaders::Generic3D::Normal attribute, texture coordinates are bound to Shaders::Generic3D::TextureCoordinates attribute. If the mesh contains colors, they are bound to Shaders::Generic3D::Color4 attribute. No data compression or index optimization (except for index buffer packing) is done, both the vertex buffer and the index buffer (if any) is owned by the mesh, both created with GL::BufferUsage::StaticDraw.

This is just a convenience function for creating generic meshes, you might want to use interleave() and compressIndices() functions together with GL::Mesh::setPrimitive(), GL::Mesh::setCount(), GL::Mesh::addVertexBuffer(), GL::Mesh::setIndexBuffer() instead for greater flexibility.

std::tuple<GL::Mesh, std::unique_ptr<GL::Buffer>, std::unique_ptr<GL::Buffer>> Magnum::MeshTools::compile(const Trade::MeshData3D& meshData, GL::BufferUsage usage)

Compile 3D mesh data.

std::pair<Containers::Array<char>, MeshIndexType> Magnum::MeshTools::compressIndices(const Containers::StridedArrayView1D<const UnsignedInt>& indices, MeshIndexType atLeast = MeshIndexType::UnsignedShort, Long offset = 0) new in Git master

Compress an index array.

Parameters
indices Index array
atLeast Smallest allowed type
offset Offset to subtract from each index
Returns Compressed index array and corresponding type

This function compresses indices to the smallest possible size. For example when your indices have the maximum vertex index 463, it's wasteful to store them in array of 32-bit integers, array of 16-bit integers is sufficient. The atLeast parameter allows you to specify the smallest type to use and it defaults to MeshIndexType::UnsignedShort as 8-bit types are not friendly to many GPUs (and for example unextended Vulkan or D3D12 don't even support them). It's also possible to choose a type larger than the input type to "inflate" an index buffer of a smaller type. Example usage:

Containers::Array<UnsignedInt> indices;

Containers::Array<char> indexData;
MeshIndexType indexType;
std::tie(indexData, indexType) = MeshTools::compressIndices(indices);

GL::Buffer indexBuffer;
indexBuffer.setData(indexData);

GL::Mesh mesh;
mesh.setCount(indices.size())
    .setIndexBuffer(indexBuffer, 0, indexType);

In case the indices all start from a large offset, the offset parameter can be used to subtract it, allowing them to be compressed even further. For example, if all indices are in range $ [ 75000 ; 96000 ] $ (which fits only into a 32-bit type), subtracting 75000 makes them in range $ [ 0; 21000 ] $ which fits into 16 bits. Note that you also need to update vertex attribute offsets accordingly. Example:

Containers::ArrayView<const UnsignedInt> indices;
UnsignedInt offset = Math::min(indices);
std::pair<Containers::Array<char>, MeshIndexType> result =
    MeshTools::compressIndices(indices, offset);

// use `offset` to adjust vertex attribute offset …

A negative offset value will do an operation inverse to the above. See also compressIndices(const Trade::MeshData&, MeshIndexType) that can do this operation directly on a Trade::MeshData instance.

std::pair<Containers::Array<char>, MeshIndexType> Magnum::MeshTools::compressIndices(const Containers::StridedArrayView1D<const UnsignedShort>& indices, MeshIndexType atLeast = MeshIndexType::UnsignedShort, Long offset = 0) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

std::pair<Containers::Array<char>, MeshIndexType> Magnum::MeshTools::compressIndices(const Containers::StridedArrayView1D<const UnsignedByte>& indices, MeshIndexType atLeast = MeshIndexType::UnsignedShort, Long offset = 0) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

std::pair<Containers::Array<char>, MeshIndexType> Magnum::MeshTools::compressIndices(const Containers::StridedArrayView1D<const UnsignedInt>& indices, Long offset) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Same as compressIndices(const Containers::StridedArrayView1D<const UnsignedInt>&, MeshIndexType, Long) with atLeast set to MeshIndexType::UnsignedShort.

std::pair<Containers::Array<char>, MeshIndexType> Magnum::MeshTools::compressIndices(const Containers::StridedArrayView1D<const UnsignedShort>& indices, Long offset) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Same as compressIndices(const Containers::StridedArrayView1D<const UnsignedShort>&, MeshIndexType, Long) with atLeast set to MeshIndexType::UnsignedShort.

std::pair<Containers::Array<char>, MeshIndexType> Magnum::MeshTools::compressIndices(const Containers::StridedArrayView1D<const UnsignedByte>& indices, Long offset) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Same as compressIndices(const Containers::StridedArrayView1D<const UnsignedByte>&, MeshIndexType, Long) with atLeast set to MeshIndexType::UnsignedShort.

std::pair<Containers::Array<char>, MeshIndexType> Magnum::MeshTools::compressIndices(const Containers::StridedArrayView2D<const char>& indices, MeshIndexType atLeast = MeshIndexType::UnsignedShort, Long offset = 0) new in Git master

Compress a type-erased index array.

Expects that the second dimension of indices is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the compressIndices(const Containers::StridedArrayView1D<const UnsignedInt>&, MeshIndexType, Long) etc. overloads.

std::pair<Containers::Array<char>, MeshIndexType> Magnum::MeshTools::compressIndices(const Containers::StridedArrayView2D<const char>& indices, Long offset) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Same as compressIndices(const Containers::StridedArrayView2D<const char>&, MeshIndexType, Long) with atLeast set to MeshIndexType::UnsignedShort.

Trade::MeshData Magnum::MeshTools::compressIndices(const Trade::MeshData& data, MeshIndexType atLeast = MeshIndexType::UnsignedShort) new in Git master

Compress mesh data indices.

Does the same as compressIndices(const Containers::StridedArrayView2D<const char>&, MeshIndexType, Long), but together with adjusting vertex attribute offsets in the passed Trade::MeshData instance. This function will unconditionally make a copy of all vertex data, use compressIndices(Trade::MeshData&&, MeshIndexType) to avoid that copy.

Trade::MeshData Magnum::MeshTools::compressIndices(Trade::MeshData&& data, MeshIndexType atLeast = MeshIndexType::UnsignedShort) new in Git master

Compress mesh data indices.

Compared to compressIndices(const Trade::MeshData&, MeshIndexType) this function can transfer ownership of data vertex buffer (in case it is owned) to the returned instance instead of making a copy of it. Index and attribute data are copied always.

std::tuple<Containers::Array<char>, MeshIndexType, UnsignedInt, UnsignedInt> Magnum::MeshTools::compressIndices(const std::vector<UnsignedInt>& indices)

Compress vertex indices.

Parameters
indices Index array
Returns Index range, type and compressed index array

This function takes index array and outputs them compressed to smallest possible size. For example when your indices have maximum number 463, it's wasteful to store them in array of 32bit integers, array of 16bit integers is sufficient.

Example usage:

std::vector<UnsignedInt> indices;

Containers::Array<char> indexData;
MeshIndexType indexType;
UnsignedInt indexStart, indexEnd;
std::tie(indexData, indexType, indexStart, indexEnd) =
    MeshTools::compressIndices(indices);

GL::Buffer indexBuffer;
indexBuffer.setData(indexData, GL::BufferUsage::StaticDraw);

GL::Mesh mesh;
mesh.setCount(indices.size())
    .setIndexBuffer(indexBuffer, 0, indexType, indexStart, indexEnd);

template<class T>
Containers::Array<T> Magnum::MeshTools::compressIndicesAs(const std::vector<UnsignedInt>& indices)

Compress vertex indices as given type.

The type can be either UnsignedByte, UnsignedShort or UnsignedInt. Values in the index array are expected to be representable with given type.

Example usage:

std::vector<UnsignedInt> indices;
Containers::Array<UnsignedShort> indexData =
    MeshTools::compressIndicesAs<UnsignedShort>(indices);

Trade::MeshData Magnum::MeshTools::concatenate(const Trade::MeshData& first, const Containers::ArrayView<const Containers::Reference<const Trade::MeshData>> next = {}) new in Git master

Concatenate meshes together.

The returned mesh contains vertices from all meshes concatenated together. If any mesh is indexed, the resulting mesh is indexed as well, with indices adjusted for vertex offsets of particular meshes. The behavior is undefined if any mesh has indices out of bounds for its particular vertex count. Meshes with MeshPrimitive::LineStrip, MeshPrimitive::LineLoop, MeshPrimitive::TriangleStrip and MeshPrimitive::TriangleFan can't be concatenated — use generateIndices() to turn them into MeshPrimitive::Lines or MeshPrimitive::Triangles first.

All attributes from the first mesh are taken; for each mesh in next, attributes present in first are copied, superfluous attributes ignored and missing attributes zeroed out. Matching attributes are expected to have the same type, all meshes are expected to have the same primitive. The vertex data are concatenated in the same order as passed, with no duplicate removal. Returned instance vertex and index data flags always have both Trade::DataFlag::Owned and Trade::DataFlag::Mutable to guarante mutable access to particular parts of the concatenated mesh — for example for applying transformations.

If an index buffer is needed, MeshIndexType::UnsignedInt is always used. Call compressIndices(const Trade::MeshData&, MeshIndexType) on the result to compress it to a smaller type, if desired.

Trade::MeshData Magnum::MeshTools::concatenate(const Trade::MeshData& first, std::initializer_list<Containers::Reference<const Trade::MeshData>> next) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Trade::MeshData Magnum::MeshTools::concatenate(Trade::MeshData&& first, const Containers::ArrayView<const Containers::Reference<const Trade::MeshData>> next = {}) new in Git master

Concatenate meshes together.

Compared to concatenate(const Trade::MeshData&, const Containers::ArrayView<const Containers::Reference<const Trade::MeshData>>), if first has both vertex and index data owned and next is empty, it's passed through without any extra allocations or other work. This can be used for example to ensure a mesh is mutable in order to do various modifications on its data:

/* Flip triangles on a cube primitive so it's counterclockwise from the inside
   in order to render a cube map */
Trade::MeshData mesh = MeshTools::concatenate(Primitives::cubeSolid());
MeshTools::flipFaceWindingInPlace(mesh.mutableIndices());

Trade::MeshData Magnum::MeshTools::concatenate(Trade::MeshData&& first, std::initializer_list<Containers::Reference<const Trade::MeshData>> next) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<template<class> class Allocator = Containers::ArrayAllocator>
void Magnum::MeshTools::concatenateInto(Trade::MeshData& destination, const Containers::ArrayView<const Containers::Reference<const Trade::MeshData>> meshes) new in Git master

Concatenate a list of meshes into a pre-existing destination, enlarging it if necessary.

Template parameters
Allocator Allocator to use
Parameters
destination in/out Destination mesh from which the output arrays as well as desired attribute layout is taken
meshes in Meshes to concatenate

Compared to concatenate(const Trade::MeshData&, const Containers::ArrayView<const Containers::Reference<const Trade::MeshData>>) this function resizes existing index and vertex buffers in destination using Containers::arrayResize() and given allocator, and reuses its atttribute data array instead of always allocating new ones. Only the attribute layout from destination is used, all vertex/index data are taken from meshes. Expects that meshes contains at least one item.

template<template<class> class Allocator = Containers::ArrayAllocator>
void Magnum::MeshTools::concatenateInto(Trade::MeshData& destination, const std::initializer_list<Containers::Reference<const Trade::MeshData>> meshes) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class IndexType, class T>
Containers::Array<T> Magnum::MeshTools::duplicate(const Containers::StridedArrayView1D<const IndexType>& indices, const Containers::StridedArrayView1D<const T>& data) new in 2019.10

Duplicate data using given index array.

Converts indexed array to non-indexed, for example data {a, b, c, d} with index array {1, 1, 0, 3, 2, 2} will be converted to {b, b, a, d, c, c}. The resulting array size is the same as size of indices, expects that all indices are in range for the data array.

If you want to fill an existing memory (or, for example a std::vector), use duplicateInto().

template<class IndexType, class T>
void Magnum::MeshTools::duplicateInto(const Containers::StridedArrayView1D<const IndexType>& indices, const Containers::StridedArrayView1D<const T>& data, const Containers::StridedArrayView1D<T>& out) new in 2019.10

Duplicate data using an index array into given output array.

Parameters
indices in Index array to use
data in Input data
out out Where to store the output

A variant of duplicate() that fills existing memory instead of allocating a new array. Expects that out has the same size as indices and all indices are in range for the data array.

void Magnum::MeshTools::duplicateInto(const Containers::StridedArrayView1D<const UnsignedInt>& indices, const Containers::StridedArrayView2D<const char>& data, const Containers::StridedArrayView2D<char>& out) new in Git master

Duplicate type-erased data using an index array into given output array.

Parameters
indices in Index array to use
data in Input data
out out Where to store the output

Compared to duplicateInto(const Containers::StridedArrayView1D<const IndexType>&, const Containers::StridedArrayView1D<const T>&, const Containers::StridedArrayView1D<T>&) accepts a 2D view, where the second dimension spans the actual type. Expects that out has the same size as indices and all indices are in range for the data array, and that the second dimension of both data and out is contiguous and has the same size.

void Magnum::MeshTools::duplicateInto(const Containers::StridedArrayView1D<const UnsignedShort>& indices, const Containers::StridedArrayView2D<const char>& data, const Containers::StridedArrayView2D<char>& out) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::MeshTools::duplicateInto(const Containers::StridedArrayView1D<const UnsignedByte>& indices, const Containers::StridedArrayView2D<const char>& data, const Containers::StridedArrayView2D<char>& out) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::MeshTools::duplicateInto(const Containers::StridedArrayView2D<const char>& indices, const Containers::StridedArrayView2D<const char>& data, const Containers::StridedArrayView2D<char>& out) new in Git master

Duplicate type-erased data using a type-erased index array into given output array.

Expects that the second dimension of indices is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the duplicateInto(const Containers::StridedArrayView1D<const UnsignedInt>&, const Containers::StridedArrayView2D<const char>&, const Containers::StridedArrayView2D<char>&) etc. overloads.

Trade::MeshData Magnum::MeshTools::duplicate(const Trade::MeshData& data, Containers::ArrayView<const Trade::MeshAttributeData> extra = {}) new in Git master

Duplicate indexed mesh data.

Returns a copy of data that's not indexed and has all attributes interleaved and duplicated according to data's index buffer. The extra attributes, if any, are duplicated and interleaved together with existing attributes (or, in case the attribute view is empty, only the corresponding space for given attribute type is reserved, with memory left uninitialized). The data layouting is done by interleavedLayout(), see its documentation for detailed behavior description. Note that offset-only Trade::MeshAttributeData instances are not supported in the extra array.

Expects that data is indexed and each attribute in extra has either the same amount of elements as data vertex count (not index count) or has none.

Trade::MeshData Magnum::MeshTools::duplicate(const Trade::MeshData& data, std::initializer_list<Trade::MeshAttributeData> extra) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::MeshTools::flipNormalsInPlace(const Containers::StridedArrayView1D<UnsignedInt>& indices, const Containers::StridedArrayView1D<Vector3>& normals)

Flip mesh normals and face winding in-place.

Parameters
indices in/out Index array to operate on
normals in/out Normal array to operate on

Flips normal vectors and face winding in index array for face culling to work properly too. See also flipNormalsInPlace(const Containers::StridedArrayView1D<Vector3>&) and flipFaceWindingInPlace(), which flip normals or face winding only. Expects a triangle mesh, thus the index count has to be divisible by 3.

void Magnum::MeshTools::flipNormalsInPlace(const Containers::StridedArrayView1D<UnsignedShort>& indices, const Containers::StridedArrayView1D<Vector3>& normals) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::MeshTools::flipNormalsInPlace(const Containers::StridedArrayView1D<UnsignedByte>& indices, const Containers::StridedArrayView1D<Vector3>& normals) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::MeshTools::flipNormalsInPlace(const Containers::StridedArrayView2D<char>& indices, const Containers::StridedArrayView1D<Vector3>& normals) new in Git master

Flip mesh normals and face winding in-place on a type-erased index array.

Expects that the second dimension of indices is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the flipNormalsInPlace(const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView1D<Vector3>&) etc. overloads.

void Magnum::MeshTools::flipFaceWindingInPlace(const Containers::StridedArrayView1D<UnsignedInt>& indices) new in Git master

Flip face winding in-place.

Parameters
indices in/out Index array to operate on

Same as flipNormalsInPlace(const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView1D<Vector3>&), but flips only face winding. Expects a triangle mesh, thus the index count has to be divisible by 3.

void Magnum::MeshTools::flipFaceWindingInPlace(const Containers::StridedArrayView1D<UnsignedShort>& indices) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::MeshTools::flipFaceWindingInPlace(const Containers::StridedArrayView1D<UnsignedByte>& indices) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::MeshTools::flipFaceWindingInPlace(const Containers::StridedArrayView2D<char>& indices) new in Git master

Flip face winding in-place on a type-erased index array.

Expects that the second dimension of indices is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the flipFaceWindingInPlace(const Containers::StridedArrayView1D<UnsignedInt>&) etc. overloads.

void Magnum::MeshTools::flipNormalsInPlace(const Containers::StridedArrayView1D<Vector3>& normals)

Flip mesh normals in-place.

Parameters
normals in/out Normal array to operate on

Same as flipNormalsInPlace(const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView1D<Vector3>&), but flips only normals, not face winding.

GL::Mesh Magnum::MeshTools::fullScreenTriangle(GL::Version version)

Full screen triangle mesh.

Returns a pre-configured mesh along with vertex buffer which can be used for full-screen post-processing effects. The mesh is a single triangle covering whole screen area ( $ (-1, -1) - (1, 1) $ in both dimensions) and provides only vertex positions, as other attributes (such as texture coordinates) can be calculated from them. The vertex positions are, in order:

\[ \begin{pmatrix} -1 \\ 1 \end{pmatrix}, \begin{pmatrix} -1 \\ -3 \end{pmatrix}, \begin{pmatrix} 3 \\ 1 \end{pmatrix} \]

Based on the version parameter, on OpenGL 2.1, OpenGL ES 2.0 and WebGL 1 the vertex positions are passed explicitly as attribute 0, contained in a vertex buffer owned by the mesh. On OpenGL 3.0+, OpenGL ES 3.0+ and WebGL 2 the mesh is attribute-less and the vertex positions can be calculated using the gl_VertexID builtin shader variable.

Calculating positions in the shader in a portable way can be done like this. For OpenGL 2.1 and OpenGL ES 2.0 you then need to bind location of the position attribute to 0.

#if (!defined(GL_ES) && __VERSION__ >= 130) || (defined(GL_ES) && __VERSION__ >= 300)
#define NEW_GLSL
#endif

#ifndef NEW_GLSL
attribute lowp vec4 position;
#endif

void main() {
    #ifdef NEW_GLSL
    gl_Position = vec4((gl_VertexID == 2) ?  3.0 : -1.0,
                       (gl_VertexID == 1) ? -3.0 :  1.0, 0.0, 1.0);
    #else
    gl_Position = position;
    #endif
}

GL::Mesh Magnum::MeshTools::fullScreenTriangle()

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

This function implicitly uses current context version.

UnsignedInt Magnum::MeshTools::primitiveCount(MeshPrimitive primitive, UnsignedInt elementCount) new in Git master

Actual primitive count for given primitive type and element count.

Returns how many primitives is generated for given primitive and elementCount, for example for MeshPrimitive::Triangles returns elementCount/3. Expects that primitive is valid, return value is rounded down if there's not enough elements for given primitive type (so for 14 vertices you get just 4 triangles, for example).

Containers::Array<UnsignedInt> Magnum::MeshTools::generateLineStripIndices(UnsignedInt vertexCount) new in Git master

Create index buffer for a line strip primitive.

Can be used to convert a MeshPrimitive::LineStrip mesh to MeshPrimitive::Lines. The vertexCount is expected to be at least 2. Primitive restart is not supported.

void Magnum::MeshTools::generateLineStripIndicesInto(UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& indices) new in Git master

Create index buffer for a line strip primitive into an existing array.

A variant of generateLineStripIndicesInto() that fills existing memory instead of allocating a new array. The vertexCount is expected to be at least 2, the indices array is expected to have a size of 2*(vertexCount - 1). Primitive restart is not supported.

Containers::Array<UnsignedInt> Magnum::MeshTools::generateLineLoopIndices(UnsignedInt vertexCount) new in Git master

Create index buffer for a line loop primitive.

Can be used to convert a MeshPrimitive::LineLoop mesh to MeshPrimitive::Lines. The vertexCount is expected to be at least 2. Primitive restart is not supported.

void Magnum::MeshTools::generateLineLoopIndicesInto(UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& into) new in Git master

Create index buffer for a line loop primitive into an existing array.

A variant of generateLineLoopIndicesInto() that fills existing memory instead of allocating a new array. The vertexCount is expected to be at least 2, the indices array is expected to have a size of 2*vertexCount. Primitive restart is not supported.

Containers::Array<UnsignedInt> Magnum::MeshTools::generateTriangleStripIndices(UnsignedInt vertexCount) new in Git master

Create index buffer for a triangle strip primitive.

Can be used to convert a MeshPrimitive::TriangleStrip mesh to MeshPrimitive::Triangles. The vertexCount is expected to be at least 3. Primitive restart is not supported.

void Magnum::MeshTools::generateTriangleStripIndicesInto(UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& into) new in Git master

Create index buffer for a triangle strip primitive into an existing array.

A variant of generateTriangleStripIndicesInto() that fills existing memory instead of allocating a new array. The vertexCount is expected to be at least 3, the indices array is expected to have a size of 3*(vertexCount - 2). Primitive restart is not supported.

Containers::Array<UnsignedInt> Magnum::MeshTools::generateTriangleFanIndices(UnsignedInt vertexCount) new in Git master

Create index buffer for a triangle fan primitive.

Can be used to convert a MeshPrimitive::TriangleFan mesh to MeshPrimitive::Triangles. The vertexCount is expected to be at least 3. Primitive restart is not supported.

void Magnum::MeshTools::generateTriangleFanIndicesInto(UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& into) new in Git master

Create index buffer for a triangle fan primitive into an existing array.

A variant of generateTriangleFanIndicesInto() that fills existing memory instead of allocating a new array. The vertexCount is expected to be at least 3, the indices array is expected to have a size of 3*(vertexCount - 2). Primitive restart is not supported.

Trade::MeshData Magnum::MeshTools::generateIndices(const Trade::MeshData& mesh) new in Git master

Convert a mesh to plain indexed lines or triangles.

Expects that mesh is not indexed and is one of MeshPrimitive::LineStrip, MeshPrimitive::LineLoop, MeshPrimitive::TriangleStrip, MeshPrimitive::TriangleFan primitives. If your mesh is indexed, call duplicate(const Trade::MeshData& data, Containers::ArrayView<const Trade::MeshAttributeData>) on it first.

The resulting mesh always has MeshIndexType::UnsignedInt, call compressIndices(const Trade::MeshData&, MeshIndexType) on the result to compress it to a smaller type, if desired. This function will unconditionally make a copy of all vertex data, use generateIndices(Trade::MeshData&&) to avoid that copy.

Trade::MeshData Magnum::MeshTools::generateIndices(Trade::MeshData&& data) new in Git master

Convert a mesh to plain indexed lines or triangles.

Compared to generateIndices(const Trade::MeshData&) this function can transfer ownership of data vertex buffer (in case it is owned) to the returned instance instead of making a copy of it. Attribute data is copied always.

Containers::Array<Vector3> Magnum::MeshTools::generateFlatNormals(const Containers::StridedArrayView1D<const Vector3>& positions) new in 2019.10

Generate flat normals.

Parameters
positions Triangle vertex positions
Returns Per-vertex normals

All vertices in each triangle face get the same normal vector. Expects that the position count is divisible by 3. If you need to generate flat normals for an indexed mesh, duplicate() the vertices first, after the operation you might want to remove the duplicates again using removeDuplicatesInPlace(). Example usage:

Containers::ArrayView<UnsignedInt> indices;
Containers::ArrayView<Vector3> indexedPositions;

Containers::Array<Vector3> positions =
    MeshTools::duplicate<UnsignedInt, Vector3>(indices, indexedPositions);

Containers::Array<Vector3> normals =
    MeshTools::generateFlatNormals(positions);

void Magnum::MeshTools::generateFlatNormalsInto(const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<Vector3>& normals) new in 2019.10

Generate flat normals into an existing array.

Parameters
positions in Triangle vertex positions
normals out Where to put the generated normals

A variant of generateFlatNormals() that fills existing memory instead of allocating a new array. The normals array is expected to have the same size as positions.

Useful when you need to interface for example with STL containers — in that case #include Corrade/Containers/ArrayViewStl.h to get implicit conversions:

#include <Corrade/Containers/ArrayViewStl.h>

// …

std::vector<Vector3> positions;

std::vector<Vector3> normals{positions.size()};
MeshTools::generateFlatNormalsInto(positions, normals);

std::pair<std::vector<UnsignedInt>, std::vector<Vector3>> Magnum::MeshTools::generateFlatNormals(const std::vector<UnsignedInt>& indices, const std::vector<Vector3>& positions)

Generate flat normals.

Parameters
indices Triangle face indices
positions Triangle vertex positions
Returns Normal indices and vectors

All vertices in each triangle face get the same normal vector. Removes duplicates before returning. Expects that the position count is divisible by 3.

Containers::Array<Vector3> Magnum::MeshTools::generateSmoothNormals(const Containers::StridedArrayView1D<const UnsignedInt>& indices, const Containers::StridedArrayView1D<const Vector3>& positions) new in 2019.10

Generate smooth normals.

Parameters
indices Triangle face indices
positions Triangle vertex positions
Returns Per-vertex normals

Uses the indices array to discover adjacent triangles and then for each vertex position calculates a normal averaged from all triangles that share it. The normal is weighted according to adjacent triangle area and angle at given vertex; hard edges are preserved where adjacent triangles don't share vertices. Triangles with zero area or triangles containing invalid positions (NaNs) don't contribute to calculated vertex normals.

Implementation is based on the article Weighted Vertex Normals by Martijn Buijs.

Containers::Array<Vector3> Magnum::MeshTools::generateSmoothNormals(const Containers::StridedArrayView1D<const UnsignedShort>& indices, const Containers::StridedArrayView1D<const Vector3>& positions) new in 2019.10

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Containers::Array<Vector3> Magnum::MeshTools::generateSmoothNormals(const Containers::StridedArrayView1D<const UnsignedByte>& indices, const Containers::StridedArrayView1D<const Vector3>& positions) new in 2019.10

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Containers::Array<Vector3> Magnum::MeshTools::generateSmoothNormals(const Containers::StridedArrayView2D<const char>& indices, const Containers::StridedArrayView1D<const Vector3>& positions) new in Git master

Generate smooth normals using a type-erased index array.

Expects that the second dimension of indices is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the generateSmoothNormals(const Containers::StridedArrayView1D<const UnsignedInt>&, const Containers::StridedArrayView1D<const Vector3>&) etc. overloads.

void Magnum::MeshTools::generateSmoothNormalsInto(const Containers::StridedArrayView1D<const UnsignedInt>& indices, const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<Vector3>& normals) new in 2019.10

Generate smooth normals into an existing array.

Parameters
indices in Triangle face indices
positions in Triangle vertex positions
normals out Where to put the generated normals

A variant of generateSmoothNormals() that fills existing memory instead of allocating a new array. The normals array is expected to have the same size as positions. Note that even with the output array this function isn't fully allocation-free — it still allocates three additional internal arrays for adjacent face calculation.

Useful when you need to interface for example with STL containers — in that case #include Corrade/Containers/ArrayViewStl.h to get implicit conversions:

#include <Corrade/Containers/ArrayViewStl.h>

// …

std::vector<UnsignedInt> indices;
std::vector<Vector3> positions;

std::vector<Vector3> normals{positions.size()};
MeshTools::generateSmoothNormalsInto(indices, positions, normals);

void Magnum::MeshTools::generateSmoothNormalsInto(const Containers::StridedArrayView1D<const UnsignedShort>& indices, const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<Vector3>& normals) new in 2019.10

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::MeshTools::generateSmoothNormalsInto(const Containers::StridedArrayView1D<const UnsignedByte>& indices, const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<Vector3>& normals) new in 2019.10

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::MeshTools::generateSmoothNormalsInto(const Containers::StridedArrayView2D<const char>& indices, const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<Vector3>& normals) new in Git master

Generate smooth normals into an existing array using a type-erased index array.

Expects that normals has the same size as positions and that the second dimension of indices is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the generateSmoothNormalsInto(const Containers::StridedArrayView1D<const UnsignedInt>&, const Containers::StridedArrayView1D<const Vector3>&, const Containers::StridedArrayView1D<Vector3>&) etc. overloads.

template<class T, class ... U>
Containers::Array<char> Magnum::MeshTools::interleave(const T& first, const U&... next)

Interleave vertex attributes.

This function takes list of attribute arrays and returns them interleaved, so data for each attribute are in continuous place in memory. Expects that all attributes have the same element count.

Example usage:

Containers::ArrayView<const Vector3> positions;
Containers::ArrayView<const Vector2> textureCoordinates;

GL::Buffer vertexBuffer;
vertexBuffer.setData(MeshTools::interleave(positions, textureCoordinates));

GL::Mesh mesh;
mesh.setCount(positions.size())
    .addVertexBuffer(vertexBuffer, 0, MyShader::Position{},
                                      MyShader::TextureCoordinates{});

It's often desirable to align data for one vertex on 32bit boundaries. To achieve that, you can specify gaps between the attributes:

Containers::ArrayView<const Vector4> positions;
Containers::ArrayView<const UnsignedShort> weights;
Containers::ArrayView<const Color3ub> vertexColors;

auto data = MeshTools::interleave(positions, weights, 2, vertexColors, 1);

All gap bytes are set zero. This way vertex stride is 24 bytes, without gaps it would be 21 bytes, causing possible performance loss.

template<class T, class ... U>
void Magnum::MeshTools::interleaveInto(Containers::ArrayView<char> buffer, const T& first, const U&... next)

Interleave vertex attributes into existing buffer.

Unlike interleave() this function interleaves the data into existing buffer and leaves gaps untouched instead of zero-initializing them. This function can thus be used for interleaving data depending on runtime parameters. Expects that all arrays have the same size and the passed buffer is large enough to contain the interleaved data.

bool Magnum::MeshTools::isInterleaved(const Trade::MeshData& data) new in Git master

If the mesh data is interleaved.

Returns true if all attributes have the same stride and the difference between minimal and maximal offset is not larger than the stride, false otherwise. In particular, returns true also if the mesh has just one or no attributes.

Containers::StridedArrayView2D<const char> Magnum::MeshTools::interleavedData(const Trade::MeshData& data) new in Git master

Type-erased view on interleaved mesh data.

Returns a 2D view on Trade::MeshData::vertexData() that spans all interleaved attributes, with the first dimension being the vertex count and the second being the attribute stride that's common for all attributes. Expects that the mesh is interleaved.

Containers::StridedArrayView2D<char> Magnum::MeshTools::interleavedMutableData(Trade::MeshData& data) new in Git master

Mutable type-erased view on interleaved mesh data.

Same as interleavedData(), but returns a mutable view. Expects that the mesh is interleaved and vertex data is mutable.

Trade::MeshData Magnum::MeshTools::interleavedLayout(const Trade::MeshData& data, UnsignedInt vertexCount, Containers::ArrayView<const Trade::MeshAttributeData> extra = {}) new in Git master

Create an interleaved mesh layout.

Returns a Trade::MeshData instance with its vertex data allocated for vertexCount vertices containing attributes from both data and extra interleaved together. No data is actually copied, only an interleaved layout is created. If data is already interleaved, keeps the attributes in the same layout, potentially extending them with extra. The extra attributes, if any, are interleaved together with existing attributes. Returned instance vertex data flags have both Trade::DataFlag::Mutable and Trade::DataFlag::Owned, so mutable attribute access is guaranteed.

For greater control you can also pass an empty Trade::MeshData instance and fill extra with attributes cherry-picked using Trade::MeshData::attributeData(UnsignedInt) const on an existing instance. By default the attributes are tightly packed, you can add arbitrary padding using instances constructed via Trade::MeshAttributeData::MeshAttributeData(Int). Example:

Containers::ArrayView<const Trade::MeshAttributeData> attributes =
    data.attributeData();

/* Take just positions and normals and add a four-byte padding in between */
Trade::MeshData layout = MeshTools::interleavedLayout(
    Trade::MeshData{MeshPrimitive::Triangles, 0}, vertexCount, {
        attributes[data.attributeId(Trade::MeshAttribute::Position)],
        Trade::MeshAttributeData{4},
        attributes[data.attributeId(Trade::MeshAttribute::Normal)]
    });

This function doesn't preserve index data information in any way, making the output non-indexed. If you want to preserve index data, create a new indexed instance with attribute and vertex data transferred from the returned instance:

Trade::MeshData layout =
    MeshTools::interleavedLayout(data, vertexCount, extraAttributes);

Trade::MeshIndexData indices;
Trade::MeshData indexed{data.primitive(),
    std::move(indexData), indices,
    layout.releaseVertexData(), layout.releaseAttributeData()};

This function will unconditionally allocate a new array to store all Trade::MeshAttributeData, use interleavedLayout(Trade::MeshData&&, UnsignedInt, Containers::ArrayView<const Trade::MeshAttributeData>) to avoid that allocation.

Trade::MeshData Magnum::MeshTools::interleavedLayout(const Trade::MeshData& data, UnsignedInt vertexCount, std::initializer_list<Trade::MeshAttributeData> extra) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Trade::MeshData Magnum::MeshTools::interleavedLayout(Trade::MeshData&& data, UnsignedInt vertexCount, Containers::ArrayView<const Trade::MeshAttributeData> extra = {}) new in Git master

Create an interleaved mesh layout.

Compared to interleavedLayout(const Trade::MeshData&, UnsignedInt, Containers::ArrayView<const Trade::MeshAttributeData>) this function can reuse the Trade::MeshAttributeData array from data instead of allocating a new one if there are no attributes passed in extra and the attribute array is owned by the mesh.

Trade::MeshData Magnum::MeshTools::interleavedLayout(Trade::MeshData&& data, UnsignedInt vertexCount, std::initializer_list<Trade::MeshAttributeData> extra) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Trade::MeshData Magnum::MeshTools::interleave(const Trade::MeshData& data, Containers::ArrayView<const Trade::MeshAttributeData> extra = {}) new in Git master

Interleave mesh data.

Returns a copy of data with all attributes interleaved. Indices (if any) are kept as-is. The extra attributes, if any, are interleaved together with existing attributes (or, in case the attribute view is empty, only the corresponding space for given attribute type is reserved, with memory left uninitialized). The data layouting is done by interleavedLayout(), see its documentation for detailed behavior description. Note that offset-only Trade::MeshAttributeData instances are not supported in the extra array.

Expects that each attribute in extra has either the same amount of elements as data vertex count or has none. This function will unconditionally make a copy of all data even if data is already interleaved and needs no change, use interleave(Trade::MeshData&&, Containers::ArrayView<const Trade::MeshAttributeData>) to avoid that copy.

Trade::MeshData Magnum::MeshTools::interleave(const Trade::MeshData& data, std::initializer_list<Trade::MeshAttributeData> extra) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Trade::MeshData Magnum::MeshTools::interleave(Trade::MeshData&& data, Containers::ArrayView<const Trade::MeshAttributeData> extra = {}) new in Git master

Interleave mesh data.

Compared to interleave(const Trade::MeshData&, Containers::ArrayView<const Trade::MeshAttributeData>) this function can transfer ownership of data index buffer (in case it is owned) and vertex buffer (in case it is owned, already interleaved and there's no extra attributes) to the returned instance instead of making copies of them.

Trade::MeshData Magnum::MeshTools::interleave(Trade::MeshData&& data, std::initializer_list<Trade::MeshAttributeData> extra) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

std::pair<Containers::Array<UnsignedInt>, std::size_t> Magnum::MeshTools::removeDuplicatesInPlace(const Containers::StridedArrayView2D<char>& data) new in Git master

Remove duplicate data from given array in-place.

Parameters
data in/out Data array, duplicate items will be cut away with order preserved
Returns The resulting index array and size of unique prefix in the cleaned up data array

Removes duplicate data from given array by comparing the second dimension of each item, the second dimension is expected to be contiguous. A plain bit-exact matching is used, if you need fuzzy comparison for floating-point data, use removeDuplicatesFuzzyInPlace() instead. If you want to remove duplicate data from an already indexed array, use removeDuplicatesIndexedInPlace(const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView2D<char>&) instead. Usage example:

Containers::ArrayView<Vector3i> data;

std::size_t size;
Containers::Array<UnsignedInt> indices;
std::tie(indices, size) = MeshTools::removeDuplicatesInPlace(
    Containers::arrayCast<2, char>(data));
data = data.prefix(size);

See removeDuplicates(const Containers::StridedArrayView2D<const char>&) for a variant that doesn't modify the input data in any way but instead returns an index array pointing to original data locations.

std::size_t Magnum::MeshTools::removeDuplicatesInPlaceInto(const Containers::StridedArrayView2D<char>& data, const Containers::StridedArrayView1D<UnsignedInt>& indices) new in Git master

Remove duplicate data from given array in-place into given output index array.

Parameters
data in/out Data array, duplicate items will be cut away with order preserved
indices out Where to put the resulting index array
Returns Size of unique prefix in the cleaned up data array

Same as above, except that the index array is not allocated but put into indices instead. Expects that indices has the same size as data.

std::pair<Containers::Array<UnsignedInt>, std::size_t> Magnum::MeshTools::removeDuplicates(const Containers::StridedArrayView2D<const char>& data) new in Git master

Remove duplicate data from given array.

Parameters
data in Data array
Returns The resulting index array and count of unique items in the original data array

Compared to removeDuplicatesInPlace(const Containers::StridedArrayView2D<char>&) this function doesn't modify the input data array in any way but instead returns an index array pointing to original data locations.

std::size_t Magnum::MeshTools::removeDuplicatesInto(const Containers::StridedArrayView2D<const char>& data, const Containers::StridedArrayView1D<UnsignedInt>& indices) new in Git master

Remove duplicate data from given array into given output index array.

Parameters
data in Data array
indices out Where to put the resulting index array
Returns Count of unique items in the original data array

Compared to removeDuplicatesInPlaceInto(const Containers::StridedArrayView2D<char>&, const Containers::StridedArrayView1D<UnsignedInt>&) this function doesn't modify the input data array in any way but instead makes an index array pointing to original data locations.

std::size_t Magnum::MeshTools::removeDuplicatesIndexedInPlace(const Containers::StridedArrayView1D<UnsignedInt>& indices, const Containers::StridedArrayView2D<char>& data) new in Git master

Remove duplicates from indexed data in-place.

Parameters
indices in/out Index array, which will get remapped to list just unique data
data in/out Data array, duplicate items will be cut away with order preserved
Returns Size of unique prefix in the cleaned up data array

Compared to removeDuplicatesInPlace(const Containers::StridedArrayView2D<char>&) this variant is more suited for data that is already indexed as it works on the existing index array instead of allocating a new one.

std::size_t Magnum::MeshTools::removeDuplicatesIndexedInPlace(const Containers::StridedArrayView1D<UnsignedShort>& indices, const Containers::StridedArrayView2D<char>& data) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

std::size_t Magnum::MeshTools::removeDuplicatesIndexedInPlace(const Containers::StridedArrayView1D<UnsignedByte>& indices, const Containers::StridedArrayView2D<char>& data) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

std::size_t Magnum::MeshTools::removeDuplicatesIndexedInPlace(const Containers::StridedArrayView2D<char>& indices, const Containers::StridedArrayView2D<char>& data) new in Git master

Remove duplicates from indexed data in-place on a type-erased index array.

Expects that the second dimension of indices is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the removeDuplicatesIndexedInPlace(const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView2D<char>&) etc. overloads.

std::pair<Containers::Array<UnsignedInt>, std::size_t> Magnum::MeshTools::removeDuplicatesFuzzyInPlace(const Containers::StridedArrayView2D<Float>& data, Float epsilon = Math::TypeTraits<Float>::epsilon()) new in Git master

Remove duplicate data from given array using fuzzy comparison in-place.

Parameters
data in/out Data array, duplicate items will be cut away with order preserved
epsilon in Epsilon value, data closer than this distance will be melt together
Returns Size of unique prefix in the cleaned up data array and the resulting index array

Removes duplicate data from the array by collapsing them into buckets of size epsilon. First vector in given bucket is used, other ones are thrown away, no interpolation is done. Note that this function is meant to be used for floating-point data (or generally with non-zero epsilon), for data where bit-exact matching is sufficient use removeDuplicatesInPlace(const Containers::StridedArrayView2D<char>&) instead.

If you want to remove duplicate data from an already indexed array, use removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView2D<Float>&, Float) and friends instead.

If you want to remove duplicates in multiple incidental arrays, first remove duplicates in each array separately and then combine the resulting index arrays back into a single one using combineIndexedAttributes().

std::pair<Containers::Array<UnsignedInt>, std::size_t> Magnum::MeshTools::removeDuplicatesFuzzyInPlace(const Containers::StridedArrayView2D<Double>& data, Double epsilon = Math::TypeTraits<Double>::epsilon()) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

std::size_t Magnum::MeshTools::removeDuplicatesFuzzyInPlaceInto(const Containers::StridedArrayView2D<Float>& data, const Containers::StridedArrayView1D<UnsignedInt>& indices, Float epsilon = Math::TypeTraits<Float>::epsilon()) new in Git master

Remove duplicate data from given array using fuzzy comparison in-place into given output index array.

Parameters
data in/out Data array, duplicate items will be cut away with order preserved
indices out Where to put the resulting index array
epsilon in Epsilon value, data closer than this distance will be melt together
Returns Size of unique prefix in the cleaned up data array

Same as above, except that the index array is not allocated but put into indices instead. Expects that indices has the same size as data.

std::size_t Magnum::MeshTools::removeDuplicatesFuzzyInPlaceInto(const Containers::StridedArrayView2D<Double>& data, const Containers::StridedArrayView1D<UnsignedInt>& indices, Double epsilon = Math::TypeTraits<Double>::epsilon()) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class Vector>
std::vector<UnsignedInt> Magnum::MeshTools::removeDuplicates(std::vector<Vector>& data, typename Vector::Type epsilon = Math::TypeTraits<typename Vector::Type>::epsilon())

Remove duplicate data from a STL vector using fuzzy comparison in-place.

Parameters
data in/out Data array, duplicate items will be cut away with order preserved and the size shrunk to just the unique prefix
epsilon in Epsilon value, vertices closer than this distance will be melt together
Returns Resulting index array

Similar to the above, except that it's operating on a std::vector, which gets shrunk as a result (instead of the prefix size being returned). This variant is useful together with combineIndexedArrays() to remove duplicates in multiple incidental arrays — first remove duplicates in each array separately and then combine the resulting index arrays to single index array, and reorder the data accordingly:

std::vector<Vector3> positions;
std::vector<Vector2> texCoords;

std::vector<UnsignedInt> positionIndices = MeshTools::removeDuplicates(positions);
std::vector<UnsignedInt> texCoordIndices = MeshTools::removeDuplicates(texCoords);

std::vector<UnsignedInt> indices = MeshTools::combineIndexedArrays(
    std::make_pair(std::cref(positionIndices), std::ref(positions)),
    std::make_pair(std::cref(texCoordIndices), std::ref(texCoords))
);

std::size_t Magnum::MeshTools::removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView1D<UnsignedInt>& indices, const Containers::StridedArrayView2D<Float>& data, Float epsilon = Math::TypeTraits<Float>::epsilon()) new in Git master

Remove duplicates from indexed data using fuzzy comparison in-place.

Parameters
indices in/out Index array, which will get remapped to list just unique vertices
data in/out Data array, duplicate items will be cut away with order preserved
epsilon in Epsilon value, vertices closer than this distance will be melt together
Returns Size of unique prefix in the cleaned up data array

Compared to removeDuplicatesFuzzyInPlace(const Containers::StridedArrayView2D<Float>&, Float) this variant is more suited for data that is already indexed as it works on the existing index array instead of allocating a new one.

std::size_t Magnum::MeshTools::removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView1D<UnsignedShort>& indices, const Containers::StridedArrayView2D<Float>& data, Float epsilon = Math::TypeTraits<Float>::epsilon()) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

std::size_t Magnum::MeshTools::removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView1D<UnsignedByte>& indices, const Containers::StridedArrayView2D<Float>& data, Float epsilon = Math::TypeTraits<Float>::epsilon()) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

std::size_t Magnum::MeshTools::removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView1D<UnsignedInt>& indices, const Containers::StridedArrayView2D<Double>& data, Double epsilon = Math::TypeTraits<Double>::epsilon()) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

std::size_t Magnum::MeshTools::removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView1D<UnsignedShort>& indices, const Containers::StridedArrayView2D<Double>& data, Double epsilon = Math::TypeTraits<Double>::epsilon()) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

std::size_t Magnum::MeshTools::removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView1D<UnsignedByte>& indices, const Containers::StridedArrayView2D<Double>& data, Double epsilon = Math::TypeTraits<Double>::epsilon()) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

std::size_t Magnum::MeshTools::removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView2D<char>& indices, const Containers::StridedArrayView2D<Float>& data, Float epsilon = Math::TypeTraits<Float>::epsilon()) new in Git master

Remove duplicates from indexed data using fuzzy comparison in-place on a type-erased index array.

Expects that the second dimension of indices is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView1D<UnsignedInt>&, const Containers::StridedArrayView2D<Float>&, Float) or the other overloads.

std::size_t Magnum::MeshTools::removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView2D<char>& indices, const Containers::StridedArrayView2D<Double>& data, Double epsilon = Math::TypeTraits<Double>::epsilon()) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Trade::MeshData Magnum::MeshTools::removeDuplicates(const Trade::MeshData& data) new in Git master

Remove mesh data duplicates.

Equivalent to calling removeDuplicatesInPlace() (or removeDuplicatesIndexedInPlace(), in case the mesh is indexed) on a mutable copy of every attribute and then putting the unique prefix and newly generated index buffer into a new Trade::MeshData instance. If the mesh is indexed, the original index type is preserved, otherwise the mesh gets MeshIndexType::UnsignedInt indices. The resulting mesh is always interleaved and owned, if the input is already interleaved attribute offsets and paddings are preserved.

This function unconditionally copies and interleaves passed vertex and index data in order to operate on them in-place. If your data is interleaved and owned by the instance and you don't need the original data after the process, call removeDuplicates(Trade::MeshData&&) instead to avoid the extra copy.

Trade::MeshData Magnum::MeshTools::removeDuplicates(Trade::MeshData&& data) new in Git master

Remove mesh data duplicates.

Same as removeDuplicates(const Trade::MeshData&), except that it operates in-place on the passed instance, avoiding an extra copy of vertex and index data.

Trade::MeshData Magnum::MeshTools::removeDuplicatesFuzzy(const Trade::MeshData& data, Float floatEpsilon = Math::TypeTraits<Float>::epsilon(), Double doubleEpsilon = Math::TypeTraits<Double>::epsilon()) new in Git master

Remove mesh data duplicates with fuzzy comparison for floating-point attributes.

Compared to removeDuplicates(const Trade::MeshData&), calls removeDuplicatesFuzzyInPlace() or removeDuplicatesFuzzyIndexedInPlace() on floating-point attributes. For attributes with a known range (such as Trade::MeshAttribute::Normal being always $ [-1, 1] $ in each direction) the floatEpsilon / doubleEpsilon is scaled appropriately, otherwise it's scaled to calculated value range.

template<class IndexType, class Vertex, class Interpolator>
void Magnum::MeshTools::subdivide(Containers::Array<IndexType>& indices, Containers::Array<Vertex>& vertices, Interpolator interpolator) new in Git master

Subdivide a mesh.

Template parameters
IndexType
Vertex Vertex data type
Interpolator See the interpolator function parameter
Parameters
indices in/out Index array to operate on
vertices in/out Vertex array to operate on
interpolator Functor or function pointer which interpolates two adjacent vertices: Vertex interpolator(Vertex a, Vertex b)

Goes through all triangle faces and subdivides them into four new, enlarging the indices and vertices arrays as appropriate. Removing duplicate vertices in the mesh is up to the user.

template<class Vertex, class Interpolator>
void Magnum::MeshTools::subdivide(std::vector<UnsignedInt>& indices, std::vector<Vertex>& vertices, Interpolator interpolator)

Subdivide a mesh.

template<class IndexType, class Vertex, class Interpolator>
void Magnum::MeshTools::subdivideInPlace(const Containers::StridedArrayView1D<IndexType>& indices, const Containers::StridedArrayView1D<Vertex>& vertices, Interpolator interpolator) new in Git master

Subdivide a mesh in-place.

Template parameters
IndexType
Vertex Vertex data type
Interpolator See the interpolator function parameter
Parameters
indices in/out Index array to operate on
vertices in/out Vertex array to operate on
interpolator Functor or function pointer which interpolates two adjacent vertices: Vertex interpolator(Vertex a, Vertex b)

Assuming the original mesh has $ i $ indices and $ v $ vertices, expects the indices array to have a size of $ 4i $ (as every triangle face would be divided into four new), with the original indices being in the first quarter, and the vertices array to have a size of $ v + i $ (as every original triangle face will get three new vertices). Removing duplicate vertices in the mesh is up to the user.

Generally, for $ k $ subsequent subdivisions, the resulting index and vertex array sizes $ i' $ and $ v' $ will be as following. To subdivide the mesh multiple times in-place, pass correctly sized prefix of the arrays to each step.

\[ \begin{array}{rcl} i' & = & 4^k i \\ v' & = & v + \frac{1}{3}(i' - i) \end{array} \]

template<class IndexType, class Vertex, class Interpolator>
void Magnum::MeshTools::subdivideInPlace(const Containers::ArrayView<IndexType>& indices, const Containers::StridedArrayView1D<Vertex>& vertices, Interpolator interpolator) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::MeshTools::tipsifyInPlace(const Containers::StridedArrayView1D<UnsignedInt>& indices, UnsignedInt vertexCount, std::size_t cacheSize)

Tipsify the mesh in-place.

Parameters
indices in/out Indices array to operate on
vertexCount in Vertex count
cacheSize in Post-transform vertex cache size

Optimizes the mesh for vertex-bound applications by rearranging its index array for beter usage of post-transform vertex cache. Algorithm used: Pedro V. Sander, Diego Nehab, and Joshua Barczak — Fast Triangle Reordering for Vertex Locality and Reduced Overdraw, SIGGRAPH 2007, http://gfx.cs.princeton.edu/pubs/Sander_2007_%3ETR/index.php.

void Magnum::MeshTools::tipsifyInPlace(const Containers::StridedArrayView1D<UnsignedShort>& indices, UnsignedInt vertexCount, std::size_t cacheSize) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::MeshTools::tipsifyInPlace(const Containers::StridedArrayView1D<UnsignedByte>& indices, UnsignedInt vertexCount, std::size_t cacheSize) new in Git master

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::MeshTools::tipsify(std::vector<UnsignedInt>& indices, UnsignedInt vertexCount, std::size_t cacheSize)

Tipsify the mesh in-place.

template<class T, class U>
void Magnum::MeshTools::transformVectorsInPlace(const Math::Matrix4<T>& matrix, U&& vectors)

Transform vectors in-place using given transformation.

Usable for one-time mesh transformations that would otherwise negatively affect dependent objects, such as (uneven) scaling. Accepts any forward-iterable type with compatible vector type as vectors. Expects that Quaternion is normalized, no further requirements are for other transformation representations.

Unlike in transformPointsInPlace(), the transformation does not involve translation.

Example usage:

std::vector<Vector3> vectors;
auto transformation = Quaternion::rotation(35.0_degf, Vector3::yAxis());
MeshTools::transformVectorsInPlace(transformation, vectors);

template<class T, class U>
void Magnum::MeshTools::transformVectorsInPlace(const Math::Matrix3<T>& matrix, U&& vectors)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, class U>
void Magnum::MeshTools::transformVectorsInPlace(const Math::Complex<T>& complex, U&& vectors)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, class U>
void Magnum::MeshTools::transformVectorsInPlace(const Math::Quaternion<T>& normalizedQuaternion, U&& vectors)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, class U>
U Magnum::MeshTools::transformVectors(const T& transformation, U vectors)

Transform vectors using given transformation.

Returns transformed vectors instead of modifying them in-place. See transformVectorsInPlace() for more information.

template<class T, class U>
void Magnum::MeshTools::transformPointsInPlace(const Math::Matrix4<T>& matrix, U&& points)

Transform points in-place using given transformation.

Usable for one-time mesh transformations that would otherwise negatively affect dependent objects, such as (uneven) scaling. Accepts any forward-iterable type with compatible vector type as vectors. Expects that DualQuaternion is normalized, no further requirements are for other transformation representations.

Unlike in transformVectorsInPlace(), the transformation also involves translation.

Example usage:

std::vector<Vector3> points;
auto transformation =
    DualQuaternion::rotation(35.0_degf, Vector3::yAxis())*
    DualQuaternion::translation({0.5f, -1.0f, 3.0f});
MeshTools::transformPointsInPlace(transformation, points);

template<class T, class U>
void Magnum::MeshTools::transformPointsInPlace(const Math::Matrix3<T>& matrix, U&& points)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, class U>
void Magnum::MeshTools::transformPointsInPlace(const Math::DualComplex<T>& dualComplex, U&& points)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, class U>
void Magnum::MeshTools::transformPointsInPlace(const Math::DualQuaternion<T>& normalizedDualQuaternion, U&& points)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, class U>
U Magnum::MeshTools::transformPoints(const T& transformation, U vectors)

Transform points using given transformation.

Returns transformed points instead of modifying them in-place. See transformPointsInPlace() for more information.