Magnum::Trade::MeshIndexData class new in 2020.06

Mesh index data.

Convenience type for populating MeshData, see its documentation for an introduction.

Usage

The most straightforward usage is constructing the instance from a view on the index array. The MeshIndexType gets inferred from the view type:

Containers::ArrayView<const UnsignedShort> indices;

Trade::MeshIndexData data{indices};

Alternatively, you can pass a typeless const void view and supply MeshIndexType explicitly, or a contiguous 2D view and let the class detect the actual index type from second dimension size.

Constructors, destructors, conversion operators

MeshIndexData(std::nullptr_t = nullptr) explicit noexcept
Construct for a non-indexed mesh.
MeshIndexData(MeshIndexType type, Containers::ArrayView<const void> data) explicit noexcept
Construct a contiguous index array with a runtime-specified index type.
MeshIndexData(MeshIndexType type, Containers::StridedArrayView1D<const void> data) explicit constexpr noexcept new in Git master
Construct a strided index array with a runtime-specified index type.
MeshIndexData(Containers::StridedArrayView1D<const UnsignedByte> data) explicit constexpr noexcept
Construct with unsigned byte indices.
MeshIndexData(Containers::StridedArrayView1D<const UnsignedShort> data) explicit constexpr noexcept
Construct with unsigned short indices.
MeshIndexData(Containers::StridedArrayView1D<const UnsignedInt> data) explicit constexpr noexcept
Construct with unsigned int indices.
MeshIndexData(const Containers::StridedArrayView2D<const char>& data) explicit noexcept
Constructor.

Public functions

auto type() const -> MeshIndexType constexpr
Index type.
auto data() const -> Containers::StridedArrayView1D<const void> constexpr
Type-erased index data.

Function documentation

Magnum::Trade::MeshIndexData::MeshIndexData(MeshIndexType type, Containers::ArrayView<const void> data) explicit noexcept

Construct a contiguous index array with a runtime-specified index type.

Parameters
type Index type
data Index data

This overload is picked over MeshIndexData(MeshIndexType, Containers::StridedArrayView1D<const void>) if data is convertible to a contiguous view. The data size is then expected to correspond to given type (e.g., for MeshIndexType::UnsignedInt the data array size should be divisible by 4). If you know the type at compile time, you can use one of the MeshIndexData(Containers::StridedArrayView1D<const UnsignedByte>), MeshIndexData(Containers::StridedArrayView1D<const UnsignedShort>) or MeshIndexData(Containers::StridedArrayView1D<const UnsignedInt>) constructors, which infer the index type automatically.

If data is empty, the mesh will be treated as indexed but with zero indices. To create a non-indexed mesh, use the MeshIndexData(std::nullptr_t) constructor.

Magnum::Trade::MeshIndexData::MeshIndexData(MeshIndexType type, Containers::StridedArrayView1D<const void> data) explicit constexpr noexcept new in Git master

Construct a strided index array with a runtime-specified index type.

Parameters
type Index type
data Index data

If you know the type at compile time, you can use one of the MeshIndexData(Containers::StridedArrayView1D<const UnsignedByte>), MeshIndexData(Containers::StridedArrayView1D<const UnsignedShort>) or MeshIndexData(Containers::StridedArrayView1D<const UnsignedInt>) constructors, which infer the index type automatically. The view doesn't need to be contiguous and the stride can be even zero or negative, but note that such data layout is not commonly supported by GPU APIs.

If data is empty, the mesh will be treated as indexed but with zero indices. To create a non-indexed mesh, use the MeshIndexData(std::nullptr_t) constructor.

Magnum::Trade::MeshIndexData::MeshIndexData(Containers::StridedArrayView1D<const UnsignedByte> data) explicit constexpr noexcept

Construct with unsigned byte indices.

The view doesn't need to be contiguous and the stride can be even zero or negative, but note that such data layout is not commonly supported by GPU APIs.

Magnum::Trade::MeshIndexData::MeshIndexData(Containers::StridedArrayView1D<const UnsignedShort> data) explicit constexpr noexcept

Construct with unsigned short indices.

The view doesn't need to be contiguous and the stride can be even zero or negative, but note that such data layout is not commonly supported by GPU APIs.

Magnum::Trade::MeshIndexData::MeshIndexData(Containers::StridedArrayView1D<const UnsignedInt> data) explicit constexpr noexcept

Construct with unsigned int indices.

The view doesn't need to be contiguous and the stride can be even zero or negative, but note that such data layout is not commonly supported by GPU APIs.

Magnum::Trade::MeshIndexData::MeshIndexData(const Containers::StridedArrayView2D<const char>& data) explicit noexcept

Constructor.

Expects that the second dimension of data is contiguous and its size is either 1, 2 or 4, corresponding to one of the MeshIndexType values. The first dimension doesn't need to be contiguous and its stride can be even zero or negative, but note that such data layout is not commonly supported by GPU APIs. As a special case, if second dimension size is 0, the constructor is equivalent to MeshIndexData(std::nullptr_t).

Containers::StridedArrayView1D<const void> Magnum::Trade::MeshIndexData::data() const constexpr

Type-erased index data.

In rare cases the stride may be different from the index type size and even be zero or negative, such data layouts are however not commonly supported by GPU APIs.