Browse Source

Trade,Primitives: use a correct type-erased view for MeshAttributeData.

This got probably implemented long before the change in
c74b4c6b90. Or actually maybe not at all.
In any case, it'd cause an ambiguity with the 2D char view constructor
when the "updimensioning" StridedArrayView constructor gets introduced.
pull/601/head
Vladimír Vondruš 3 years ago
parent
commit
0401c4ded8
  1. 12
      src/Magnum/Primitives/Implementation/Spheroid.cpp
  2. 4
      src/Magnum/Trade/Test/MeshDataTest.cpp

12
src/Magnum/Primitives/Implementation/Spheroid.cpp

@ -247,29 +247,25 @@ Trade::MeshData Spheroid::finalize() {
Containers::Array<Trade::MeshAttributeData> attributes{_attributeCount};
attributes[attributeOffset++] = Trade::MeshAttributeData{
Trade::MeshAttribute::Position, VertexFormat::Vector3,
/* GCC 4.8 can't handle the stridedArrayView() convenience thing */
Containers::StridedArrayView1D<const char>{_vertexData,
Containers::StridedArrayView1D<const void>{_vertexData,
_vertexData.data(),
_vertexData.size()/_stride, std::ptrdiff_t(_stride)}};
attributes[attributeOffset++] = Trade::MeshAttributeData{
Trade::MeshAttribute::Normal, VertexFormat::Vector3,
/* GCC 4.8 can't handle the stridedArrayView() convenience thing */
Containers::StridedArrayView1D<const char>{_vertexData,
Containers::StridedArrayView1D<const void>{_vertexData,
_vertexData.data() + sizeof(Vector3),
_vertexData.size()/_stride, std::ptrdiff_t(_stride)}};
if(_flags & Flag::Tangents)
attributes[attributeOffset++] = Trade::MeshAttributeData{
Trade::MeshAttribute::Tangent, VertexFormat::Vector4,
/* GCC 4.8 can't handle the stridedArrayView() convenience thing */
Containers::StridedArrayView1D<const char>{_vertexData,
Containers::StridedArrayView1D<const void>{_vertexData,
_vertexData.data() + _tangentOffset,
_vertexData.size()/_stride, std::ptrdiff_t(_stride)}};
if(_flags & Flag::TextureCoordinates)
attributes[attributeOffset++] = Trade::MeshAttributeData{
Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2,
/* GCC 4.8 can't handle the stridedArrayView() convenience thing */
Containers::StridedArrayView1D<const char>{_vertexData,
Containers::StridedArrayView1D<const void>{_vertexData,
_vertexData.data() + _textureCoordinateOffset,
_vertexData.size()/_stride, std::ptrdiff_t(_stride)}};

4
src/Magnum/Trade/Test/MeshDataTest.cpp

@ -889,7 +889,7 @@ void MeshDataTest::constructAttribute2DNonContiguous() {
void MeshDataTest::constructAttributeTypeErased() {
const Vector3 positionData[3]{};
MeshAttributeData positions{MeshAttribute::Position, VertexFormat::Vector3, Containers::arrayCast<const char>(Containers::stridedArrayView(positionData))};
MeshAttributeData positions{MeshAttribute::Position, VertexFormat::Vector3, Containers::StridedArrayView1D<const void>{positionData}};
CORRADE_VERIFY(!positions.isOffsetOnly());
CORRADE_COMPARE(positions.arraySize(), 0);
CORRADE_COMPARE(positions.name(), MeshAttribute::Position);
@ -1131,7 +1131,7 @@ void MeshDataTest::constructArrayAttribute2DNonContiguous() {
void MeshDataTest::constructArrayAttributeTypeErased() {
Vector2 vertexData[3*4];
Containers::StridedArrayView1D<Vector2> attribute{vertexData, 3, 4*sizeof(Vector2)};
MeshAttributeData data{meshAttributeCustom(35), VertexFormat::Vector2, Containers::arrayCast<const char>(attribute), 4};
MeshAttributeData data{meshAttributeCustom(35), VertexFormat::Vector2, Containers::StridedArrayView1D<const void>{attribute}, 4};
CORRADE_VERIFY(!data.isOffsetOnly());
CORRADE_COMPARE(data.name(), meshAttributeCustom(35));
CORRADE_COMPARE(data.format(), VertexFormat::Vector2);

Loading…
Cancel
Save