Browse Source

Trade: add (deprecated) implicit conversion of MeshData to MeshDataXD.

pull/371/head
Vladimír Vondruš 7 years ago
parent
commit
ccd3d24185
  1. 12
      src/Magnum/Trade/CMakeLists.txt
  2. 31
      src/Magnum/Trade/MeshData2D.cpp
  3. 13
      src/Magnum/Trade/MeshData2D.h
  4. 36
      src/Magnum/Trade/MeshData3D.cpp
  5. 13
      src/Magnum/Trade/MeshData3D.h
  6. 124
      src/Magnum/Trade/Test/MeshData2DTest.cpp
  7. 141
      src/Magnum/Trade/Test/MeshData3DTest.cpp

12
src/Magnum/Trade/CMakeLists.txt

@ -30,8 +30,6 @@ set(MagnumTrade_SRCS
ArrayAllocator.cpp ArrayAllocator.cpp
Data.cpp Data.cpp
LightData.cpp LightData.cpp
MeshData2D.cpp
MeshData3D.cpp
MeshObjectData2D.cpp MeshObjectData2D.cpp
MeshObjectData3D.cpp MeshObjectData3D.cpp
SceneData.cpp SceneData.cpp
@ -44,6 +42,16 @@ set(MagnumTrade_GracefulAssert_SRCS
CameraData.cpp CameraData.cpp
ImageData.cpp ImageData.cpp
MeshData.cpp MeshData.cpp
# These have to be here instead of in MagnumTrade_SRCS because they include
# MeshData.h and call (and thus instantiate) various functions with inline
# asserts. We need the linker to pick the variant with graceful asserts for
# tests, and if there would be two different copies, it may happen it picks
# the non-graceful-assert variant, causing the tests to blow up. Happens
# only on the MSVC linker, but let's be safe and do this everywhere.
MeshData2D.cpp
MeshData3D.cpp
ObjectData2D.cpp ObjectData2D.cpp
ObjectData3D.cpp ObjectData3D.cpp
PhongMaterialData.cpp) PhongMaterialData.cpp)

31
src/Magnum/Trade/MeshData2D.cpp

@ -25,6 +25,8 @@
#include "MeshData2D.h" #include "MeshData2D.h"
#include <Corrade/Containers/ArrayViewStl.h>
#include "Magnum/Math/Color.h" #include "Magnum/Math/Color.h"
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {
@ -33,6 +35,35 @@ MeshData2D::MeshData2D(const MeshPrimitive primitive, std::vector<UnsignedInt> i
CORRADE_ASSERT(!_positions.empty(), "Trade::MeshData2D: no position array specified", ); CORRADE_ASSERT(!_positions.empty(), "Trade::MeshData2D: no position array specified", );
} }
#ifdef MAGNUM_BUILD_DEPRECATED
MeshData2D::MeshData2D(const MeshData& other): _primitive{other.primitive()}, _importerState{other.importerState()} {
/* Copy indices, if any */
if(other.isIndexed()) {
_indices.resize(other.indexCount());
other.indicesInto(_indices);
}
/* Copy attributes */
_positions.resize(other.attributeCount(MeshAttribute::Position));
for(UnsignedInt i = 0; i != _positions.size(); ++i) {
_positions[i].resize(other.vertexCount());
other.positions2DInto(_positions[i], i);
}
_textureCoords2D.resize(other.attributeCount(MeshAttribute::TextureCoordinates));
for(UnsignedInt i = 0; i != _textureCoords2D.size(); ++i) {
_textureCoords2D[i].resize(other.vertexCount());
other.textureCoordinates2DInto(_textureCoords2D[i], i);
}
_colors.resize(other.attributeCount(MeshAttribute::Color));
for(UnsignedInt i = 0; i != _colors.size(); ++i) {
_colors[i].resize(other.vertexCount());
other.colorsInto(_colors[i], i);
}
CORRADE_ASSERT(!_positions.empty(), "Trade::MeshData3D: no position array specified in MeshData", );
}
#endif
MeshData2D::MeshData2D(MeshData2D&&) MeshData2D::MeshData2D(MeshData2D&&)
#if !defined(__GNUC__) || __GNUC__*100 + __GNUC_MINOR__ != 409 #if !defined(__GNUC__) || __GNUC__*100 + __GNUC_MINOR__ != 409
noexcept noexcept

13
src/Magnum/Trade/MeshData2D.h

@ -31,8 +31,7 @@
#include <vector> #include <vector>
#include "Magnum/Magnum.h" #include "Magnum/Trade/MeshData.h"
#include "Magnum/Trade/visibility.h"
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {
@ -67,6 +66,16 @@ class MAGNUM_TRADE_EXPORT MeshData2D {
*/ */
explicit MeshData2D(MeshPrimitive primitive, std::vector<UnsignedInt> indices, std::vector<std::vector<Vector2>> positions, std::vector<std::vector<Vector2>> textureCoords2D, std::vector<std::vector<Color4>> colors, const void* importerState = nullptr); explicit MeshData2D(MeshPrimitive primitive, std::vector<UnsignedInt> indices, std::vector<std::vector<Vector2>> positions, std::vector<std::vector<Vector2>> textureCoords2D, std::vector<std::vector<Color4>> colors, const void* importerState = nullptr);
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @brief Construct from @ref MeshData
* @m_deprecated_since_latest Use @ref MeshData directly instead.
*/
/* No data moving can take place because std::vector is damn shitty
regarding memory ownership transfer, so it can well be a copy. */
CORRADE_DEPRECATED("use MeshData directly instead") /*implicit*/ MeshData2D(const MeshData& other);
#endif
/** @brief Copying is not allowed */ /** @brief Copying is not allowed */
MeshData2D(const MeshData2D&) = delete; MeshData2D(const MeshData2D&) = delete;

36
src/Magnum/Trade/MeshData3D.cpp

@ -25,6 +25,8 @@
#include "MeshData3D.h" #include "MeshData3D.h"
#include <Corrade/Containers/ArrayViewStl.h>
#include "Magnum/Math/Color.h" #include "Magnum/Math/Color.h"
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {
@ -33,6 +35,40 @@ MeshData3D::MeshData3D(const MeshPrimitive primitive, std::vector<UnsignedInt> i
CORRADE_ASSERT(!_positions.empty(), "Trade::MeshData3D: no position array specified", ); CORRADE_ASSERT(!_positions.empty(), "Trade::MeshData3D: no position array specified", );
} }
#ifdef MAGNUM_BUILD_DEPRECATED
MeshData3D::MeshData3D(const MeshData& other): _primitive{other.primitive()}, _importerState{other.importerState()} {
/* Copy indices, if any */
if(other.isIndexed()) {
_indices.resize(other.indexCount());
other.indicesInto(_indices);
}
/* Copy attributes */
_positions.resize(other.attributeCount(MeshAttribute::Position));
for(UnsignedInt i = 0; i != _positions.size(); ++i) {
_positions[i].resize(other.vertexCount());
other.positions3DInto(_positions[i], i);
}
_normals.resize(other.attributeCount(MeshAttribute::Normal));
for(UnsignedInt i = 0; i != _normals.size(); ++i) {
_normals[i].resize(other.vertexCount());
other.normalsInto(_normals[i], i);
}
_textureCoords2D.resize(other.attributeCount(MeshAttribute::TextureCoordinates));
for(UnsignedInt i = 0; i != _textureCoords2D.size(); ++i) {
_textureCoords2D[i].resize(other.vertexCount());
other.textureCoordinates2DInto(_textureCoords2D[i], i);
}
_colors.resize(other.attributeCount(MeshAttribute::Color));
for(UnsignedInt i = 0; i != _colors.size(); ++i) {
_colors[i].resize(other.vertexCount());
other.colorsInto(_colors[i], i);
}
CORRADE_ASSERT(!_positions.empty(), "Trade::MeshData3D: no position array specified in MeshData", );
}
#endif
MeshData3D::MeshData3D(MeshData3D&&) MeshData3D::MeshData3D(MeshData3D&&)
#if !defined(__GNUC__) || __GNUC__*100 + __GNUC_MINOR__ != 409 #if !defined(__GNUC__) || __GNUC__*100 + __GNUC_MINOR__ != 409
noexcept noexcept

13
src/Magnum/Trade/MeshData3D.h

@ -31,8 +31,7 @@
#include <vector> #include <vector>
#include "Magnum/Magnum.h" #include "Magnum/Trade/MeshData.h"
#include "Magnum/Trade/visibility.h"
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {
@ -68,6 +67,16 @@ class MAGNUM_TRADE_EXPORT MeshData3D {
*/ */
explicit MeshData3D(MeshPrimitive primitive, std::vector<UnsignedInt> indices, std::vector<std::vector<Vector3>> positions, std::vector<std::vector<Vector3>> normals, std::vector<std::vector<Vector2>> textureCoords2D, std::vector<std::vector<Color4>> colors, const void* importerState = nullptr); explicit MeshData3D(MeshPrimitive primitive, std::vector<UnsignedInt> indices, std::vector<std::vector<Vector3>> positions, std::vector<std::vector<Vector3>> normals, std::vector<std::vector<Vector2>> textureCoords2D, std::vector<std::vector<Color4>> colors, const void* importerState = nullptr);
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @brief Construct from @ref MeshData
* @m_deprecated_since_latest Use @ref MeshData directly instead.
*/
/* No data moving can take place because std::vector is damn shitty
regarding memory ownership transfer, so it can well be a copy. */
CORRADE_DEPRECATED("use MeshData directly instead") /*implicit*/ MeshData3D(const MeshData& other);
#endif
/** @brief Copying is not allowed */ /** @brief Copying is not allowed */
MeshData3D(const MeshData3D&) = delete; MeshData3D(const MeshData3D&) = delete;

124
src/Magnum/Trade/Test/MeshData2DTest.cpp

@ -42,59 +42,111 @@ struct MeshData2DTest: TestSuite::Tester {
void constructMove(); void constructMove();
}; };
using namespace Math::Literals;
const UnsignedByte Indices[]{12, 1, 0};
const struct Vertex {
Vector2 position1, position2;
Vector2 textureCoords1, textureCoords2, textureCoords3;
Color4 color;
} Vertices[] {
{{0.5f, 1.0f}, {1.4f, 0.2f},
{0.0f, 0.0f}, {0.1f, 0.2f}, {0.0f, 0.0f},
0xff98ab_rgbf},
{{-1.0f, 0.3f}, {1.1f, 0.13f},
{0.3f, 0.7f}, {0.7f, 1.0f}, {1.0f, 1.0f},
0xff3366_rgbf}
};
const int State = 3;
CORRADE_IGNORE_DEPRECATED_PUSH
struct {
const char* name;
const MeshData2D data, dataNonIndexed;
} ConstructData[] {
{"",
MeshData2D{MeshPrimitive::Lines, {12, 1, 0},
{{{0.5f, 1.0f}, {-1.0f, 0.3f}},
{{1.4f, 0.2f}, {1.1f, 0.13f}}},
{{{0.0f, 0.0f}, {0.3f, 0.7f}},
{{0.1f, 0.2f}, {0.7f, 1.0f}},
{{0.0f, 0.0f}, {1.0f, 1.0f}}},
{{0xff98ab_rgbf, 0xff3366_rgbf}},
&State},
MeshData2D{MeshPrimitive::Lines, {},
{{{0.5f, 1.0f}, {-1.0f, 0.3f}}},
{{{0.0f, 0.0f}, {0.3f, 0.7f}}},
{{0xff98ab_rgbf, 0xff3366_rgbf}},
&State}},
{"from MeshData",
MeshData{MeshPrimitive::Lines, {}, Indices, MeshIndexData{Indices}, {}, Vertices, {
MeshAttributeData{MeshAttribute::Position,
Containers::StridedArrayView1D<const Vector2>{Vertices, &Vertices[0].position1, 2, sizeof(Vertex)}},
MeshAttributeData{MeshAttribute::Position,
Containers::StridedArrayView1D<const Vector2>{Vertices, &Vertices[0].position2, 2, sizeof(Vertex)}},
MeshAttributeData{MeshAttribute::TextureCoordinates,
Containers::StridedArrayView1D<const Vector2>{Vertices, &Vertices[0].textureCoords1, 2, sizeof(Vertex)}},
MeshAttributeData{MeshAttribute::TextureCoordinates,
Containers::StridedArrayView1D<const Vector2>{Vertices, &Vertices[0].textureCoords2, 2, sizeof(Vertex)}},
MeshAttributeData{MeshAttribute::TextureCoordinates,
Containers::StridedArrayView1D<const Vector2>{Vertices, &Vertices[0].textureCoords3, 2, sizeof(Vertex)}},
MeshAttributeData{MeshAttribute::Color,
Containers::StridedArrayView1D<const Color4>{Vertices, &Vertices[0].color, 2, sizeof(Vertex)}},
}, &State},
MeshData{MeshPrimitive::Lines, {}, Vertices, {
MeshAttributeData{MeshAttribute::Position,
Containers::StridedArrayView1D<const Vector2>{Vertices, &Vertices[0].position1, 2, sizeof(Vertex)}},
MeshAttributeData{MeshAttribute::TextureCoordinates,
Containers::StridedArrayView1D<const Vector2>{Vertices, &Vertices[0].textureCoords1, 2, sizeof(Vertex)}},
MeshAttributeData{MeshAttribute::Color,
Containers::StridedArrayView1D<const Color4>{Vertices, &Vertices[0].color, 2, sizeof(Vertex)}},
}, &State}
}
};
CORRADE_IGNORE_DEPRECATED_POP
MeshData2DTest::MeshData2DTest() { MeshData2DTest::MeshData2DTest() {
addTests({&MeshData2DTest::construct, addInstancedTests({&MeshData2DTest::construct,
&MeshData2DTest::constructNonIndexed, &MeshData2DTest::constructNonIndexed},
&MeshData2DTest::constructNoTexCoords, Containers::arraySize(ConstructData));
addTests({&MeshData2DTest::constructNoTexCoords,
&MeshData2DTest::constructNoColors, &MeshData2DTest::constructNoColors,
&MeshData2DTest::constructCopy, &MeshData2DTest::constructCopy,
&MeshData2DTest::constructMove}); &MeshData2DTest::constructMove});
} }
using namespace Math::Literals;
void MeshData2DTest::construct() { void MeshData2DTest::construct() {
const int a{}; auto&& data = ConstructData[testCaseInstanceId()];
const MeshData2D data{MeshPrimitive::Lines, {12, 1, 0}, setTestCaseDescription(data.name);
{{{0.5f, 1.0f}, {-1.0f, 0.3f}},
{{1.4f, 0.2f}, {1.1f, 0.13f}}},
{{{0.0f, 0.0f}, {0.3f, 0.7f}},
{{0.1f, 0.2f}, {0.7f, 1.0f}},
{{0.0f, 0.0f}, {1.0f, 1.0f}}},
{{0xff98ab_rgbf, 0xff3366_rgbf}},
&a};
CORRADE_COMPARE(data.primitive(), MeshPrimitive::Lines); CORRADE_COMPARE(data.data.primitive(), MeshPrimitive::Lines);
CORRADE_VERIFY(data.isIndexed()); CORRADE_VERIFY(data.data.isIndexed());
CORRADE_COMPARE(data.indices(), (std::vector<UnsignedInt>{12, 1, 0})); CORRADE_COMPARE(data.data.indices(), (std::vector<UnsignedInt>{12, 1, 0}));
CORRADE_COMPARE(data.positionArrayCount(), 2); CORRADE_COMPARE(data.data.positionArrayCount(), 2);
CORRADE_COMPARE(data.positions(0), (std::vector<Vector2>{{0.5f, 1.0f}, {-1.0f, 0.3f}})); CORRADE_COMPARE(data.data.positions(0), (std::vector<Vector2>{{0.5f, 1.0f}, {-1.0f, 0.3f}}));
CORRADE_COMPARE(data.positions(1), (std::vector<Vector2>{{1.4f, 0.2f}, {1.1f, 0.13f}})); CORRADE_COMPARE(data.data.positions(1), (std::vector<Vector2>{{1.4f, 0.2f}, {1.1f, 0.13f}}));
CORRADE_VERIFY(data.hasTextureCoords2D()); CORRADE_VERIFY(data.data.hasTextureCoords2D());
CORRADE_COMPARE(data.textureCoords2DArrayCount(), 3); CORRADE_COMPARE(data.data.textureCoords2DArrayCount(), 3);
CORRADE_COMPARE(data.textureCoords2D(0), (std::vector<Vector2>{{0.0f, 0.0f}, {0.3f, 0.7f}})); CORRADE_COMPARE(data.data.textureCoords2D(0), (std::vector<Vector2>{{0.0f, 0.0f}, {0.3f, 0.7f}}));
CORRADE_COMPARE(data.textureCoords2D(1), (std::vector<Vector2>{{0.1f, 0.2f}, {0.7f, 1.0f}})); CORRADE_COMPARE(data.data.textureCoords2D(1), (std::vector<Vector2>{{0.1f, 0.2f}, {0.7f, 1.0f}}));
CORRADE_COMPARE(data.textureCoords2D(2), (std::vector<Vector2>{{0.0f, 0.0f}, {1.0f, 1.0f}})); CORRADE_COMPARE(data.data.textureCoords2D(2), (std::vector<Vector2>{{0.0f, 0.0f}, {1.0f, 1.0f}}));
CORRADE_VERIFY(data.hasColors()); CORRADE_VERIFY(data.data.hasColors());
CORRADE_COMPARE(data.colorArrayCount(), 1); CORRADE_COMPARE(data.data.colorArrayCount(), 1);
CORRADE_COMPARE(data.colors(0), (std::vector<Color4>{0xff98ab_rgbf, 0xff3366_rgbf})); CORRADE_COMPARE(data.data.colors(0), (std::vector<Color4>{0xff98ab_rgbf, 0xff3366_rgbf}));
CORRADE_COMPARE(data.importerState(), &a); CORRADE_COMPARE(data.data.importerState(), &State);
} }
void MeshData2DTest::constructNonIndexed() { void MeshData2DTest::constructNonIndexed() {
const int a{}; auto&& data = ConstructData[testCaseInstanceId()];
const MeshData2D data{MeshPrimitive::Lines, {}, setTestCaseDescription(data.name);
{{{0.5f, 1.0f}, {-1.0f, 0.3f}}},
{{{0.0f, 0.0f}, {0.3f, 0.7f}}},
{{0xff98ab_rgbf, 0xff3366_rgbf}},
&a};
CORRADE_VERIFY(!data.isIndexed()); CORRADE_VERIFY(!data.dataNonIndexed.isIndexed());
} }
void MeshData2DTest::constructNoTexCoords() { void MeshData2DTest::constructNoTexCoords() {

141
src/Magnum/Trade/Test/MeshData3DTest.cpp

@ -43,66 +43,125 @@ struct MeshData3DTest: TestSuite::Tester {
void constructMove(); void constructMove();
}; };
using namespace Math::Literals;
const UnsignedByte Indices[]{12, 1, 0};
const struct Vertex {
Vector3 position1, position2;
Vector3 normal;
Vector2 textureCoords1, textureCoords2, textureCoords3;
Color4 color;
} Vertices[] {
{{0.5f, 1.0f, 0.1f}, {1.4f, 0.2f, 0.5f},
{0.0f, 1.0f, 0.0f},
{0.0f, 0.0f}, {0.1f, 0.2f}, {0.0f, 0.0f},
0xff98ab_rgbf},
{{-1.0f, 0.3f, -1.0f}, {1.1f, 0.13f, -0.3f},
{-1.0f, 0.0f, 0.0f},
{0.3f, 0.7f}, {0.7f, 1.0f}, {1.0f, 1.0f},
0xff3366_rgbf}
};
const int State = 3;
CORRADE_IGNORE_DEPRECATED_PUSH
struct {
const char* name;
const MeshData3D data, dataNonIndexed;
} ConstructData[] {
{"",
MeshData3D{MeshPrimitive::Lines, {12, 1, 0},
{{{0.5f, 1.0f, 0.1f}, {-1.0f, 0.3f, -1.0f}},
{{1.4f, 0.2f, 0.5f}, {1.1f, 0.13f, -0.3f}}},
{{{0.0f, 1.0f, 0.0f}, {-1.0f, 0.0f, 0.0f}}},
{{{0.0f, 0.0f}, {0.3f, 0.7f}},
{{0.1f, 0.2f}, {0.7f, 1.0f}},
{{0.0f, 0.0f}, {1.0f, 1.0f}}},
{{0xff98ab_rgbf, 0xff3366_rgbf}},
&State},
MeshData3D{MeshPrimitive::Lines, {},
{{{0.5f, 1.0f, 0.1f}, {-1.0f, 0.3f, -1.0f}}},
{{{0.0f, 1.0f, 0.0f}, {-1.0f, 0.0f, 0.0f}}},
{{{0.0f, 0.0f}, {0.3f, 0.7f}}},
{{0xff98ab_rgbf, 0xff3366_rgbf}},
&State}},
{"from MeshData",
MeshData{MeshPrimitive::Lines, {}, Indices, MeshIndexData{Indices}, {}, Vertices, {
MeshAttributeData{MeshAttribute::Position,
Containers::StridedArrayView1D<const Vector3>{Vertices, &Vertices[0].position1, 2, sizeof(Vertex)}},
MeshAttributeData{MeshAttribute::Position,
Containers::StridedArrayView1D<const Vector3>{Vertices, &Vertices[0].position2, 2, sizeof(Vertex)}},
MeshAttributeData{MeshAttribute::Normal,
Containers::StridedArrayView1D<const Vector3>{Vertices, &Vertices[0].normal, 2, sizeof(Vertex)}},
MeshAttributeData{MeshAttribute::TextureCoordinates,
Containers::StridedArrayView1D<const Vector2>{Vertices, &Vertices[0].textureCoords1, 2, sizeof(Vertex)}},
MeshAttributeData{MeshAttribute::TextureCoordinates,
Containers::StridedArrayView1D<const Vector2>{Vertices, &Vertices[0].textureCoords2, 2, sizeof(Vertex)}},
MeshAttributeData{MeshAttribute::TextureCoordinates,
Containers::StridedArrayView1D<const Vector2>{Vertices, &Vertices[0].textureCoords3, 2, sizeof(Vertex)}},
MeshAttributeData{MeshAttribute::Color,
Containers::StridedArrayView1D<const Color4>{Vertices, &Vertices[0].color, 2, sizeof(Vertex)}},
}, &State},
MeshData{MeshPrimitive::Lines, {}, Vertices, {
MeshAttributeData{MeshAttribute::Position,
Containers::StridedArrayView1D<const Vector3>{Vertices, &Vertices[0].position1, 2, sizeof(Vertex)}},
MeshAttributeData{MeshAttribute::Normal,
Containers::StridedArrayView1D<const Vector3>{Vertices, &Vertices[0].normal, 2, sizeof(Vertex)}},
MeshAttributeData{MeshAttribute::TextureCoordinates,
Containers::StridedArrayView1D<const Vector2>{Vertices, &Vertices[0].textureCoords1, 2, sizeof(Vertex)}},
MeshAttributeData{MeshAttribute::Color,
Containers::StridedArrayView1D<const Color4>{Vertices, &Vertices[0].color, 2, sizeof(Vertex)}},
}, &State}
}
};
CORRADE_IGNORE_DEPRECATED_POP
MeshData3DTest::MeshData3DTest() { MeshData3DTest::MeshData3DTest() {
addTests({&MeshData3DTest::construct, addInstancedTests({&MeshData3DTest::construct,
&MeshData3DTest::constructNonIndexed, &MeshData3DTest::constructNonIndexed},
&MeshData3DTest::constructNoNormals, Containers::arraySize(ConstructData));
addTests({&MeshData3DTest::constructNoNormals,
&MeshData3DTest::constructNoTexCoords, &MeshData3DTest::constructNoTexCoords,
&MeshData3DTest::constructNoColors, &MeshData3DTest::constructNoColors,
&MeshData3DTest::constructCopy, &MeshData3DTest::constructCopy,
&MeshData3DTest::constructMove}); &MeshData3DTest::constructMove});
} }
using namespace Math::Literals;
void MeshData3DTest::construct() { void MeshData3DTest::construct() {
const int a{}; auto&& data = ConstructData[testCaseInstanceId()];
const MeshData3D data{MeshPrimitive::Lines, {12, 1, 0}, setTestCaseDescription(data.name);
{{{0.5f, 1.0f, 0.1f}, {-1.0f, 0.3f, -1.0f}},
{{1.4f, 0.2f, 0.5f}, {1.1f, 0.13f, -0.3f}}},
{{{0.0f, 1.0f, 0.0f}, {-1.0f, 0.0f, 0.0f}}},
{{{0.0f, 0.0f}, {0.3f, 0.7f}},
{{0.1f, 0.2f}, {0.7f, 1.0f}},
{{0.0f, 0.0f}, {1.0f, 1.0f}}},
{{0xff98ab_rgbf, 0xff3366_rgbf}},
&a};
CORRADE_COMPARE(data.primitive(), MeshPrimitive::Lines); CORRADE_COMPARE(data.data.primitive(), MeshPrimitive::Lines);
CORRADE_VERIFY(data.isIndexed()); CORRADE_VERIFY(data.data.isIndexed());
CORRADE_COMPARE(data.indices(), (std::vector<UnsignedInt>{12, 1, 0})); CORRADE_COMPARE(data.data.indices(), (std::vector<UnsignedInt>{12, 1, 0}));
CORRADE_COMPARE(data.positionArrayCount(), 2); CORRADE_COMPARE(data.data.positionArrayCount(), 2);
CORRADE_COMPARE(data.positions(0), (std::vector<Vector3>{{0.5f, 1.0f, 0.1f}, {-1.0f, 0.3f, -1.0f}})); CORRADE_COMPARE(data.data.positions(0), (std::vector<Vector3>{{0.5f, 1.0f, 0.1f}, {-1.0f, 0.3f, -1.0f}}));
CORRADE_COMPARE(data.positions(1), (std::vector<Vector3>{{1.4f, 0.2f, 0.5f}, {1.1f, 0.13f, -0.3f}})); CORRADE_COMPARE(data.data.positions(1), (std::vector<Vector3>{{1.4f, 0.2f, 0.5f}, {1.1f, 0.13f, -0.3f}}));
CORRADE_VERIFY(data.hasNormals()); CORRADE_VERIFY(data.data.hasNormals());
CORRADE_COMPARE(data.normalArrayCount(), 1); CORRADE_COMPARE(data.data.normalArrayCount(), 1);
CORRADE_COMPARE(data.normals(0), (std::vector<Vector3>{{0.0f, 1.0f, 0.0f}, {-1.0f, 0.0f, 0.0f}})); CORRADE_COMPARE(data.data.normals(0), (std::vector<Vector3>{{0.0f, 1.0f, 0.0f}, {-1.0f, 0.0f, 0.0f}}));
CORRADE_VERIFY(data.hasTextureCoords2D()); CORRADE_VERIFY(data.data.hasTextureCoords2D());
CORRADE_COMPARE(data.textureCoords2DArrayCount(), 3); CORRADE_COMPARE(data.data.textureCoords2DArrayCount(), 3);
CORRADE_COMPARE(data.textureCoords2D(0), (std::vector<Vector2>{{0.0f, 0.0f}, {0.3f, 0.7f}})); CORRADE_COMPARE(data.data.textureCoords2D(0), (std::vector<Vector2>{{0.0f, 0.0f}, {0.3f, 0.7f}}));
CORRADE_COMPARE(data.textureCoords2D(1), (std::vector<Vector2>{{0.1f, 0.2f}, {0.7f, 1.0f}})); CORRADE_COMPARE(data.data.textureCoords2D(1), (std::vector<Vector2>{{0.1f, 0.2f}, {0.7f, 1.0f}}));
CORRADE_COMPARE(data.textureCoords2D(2), (std::vector<Vector2>{{0.0f, 0.0f}, {1.0f, 1.0f}})); CORRADE_COMPARE(data.data.textureCoords2D(2), (std::vector<Vector2>{{0.0f, 0.0f}, {1.0f, 1.0f}}));
CORRADE_VERIFY(data.hasColors()); CORRADE_VERIFY(data.data.hasColors());
CORRADE_COMPARE(data.colorArrayCount(), 1); CORRADE_COMPARE(data.data.colorArrayCount(), 1);
CORRADE_COMPARE(data.colors(0), (std::vector<Color4>{0xff98ab_rgbf, 0xff3366_rgbf})); CORRADE_COMPARE(data.data.colors(0), (std::vector<Color4>{0xff98ab_rgbf, 0xff3366_rgbf}));
CORRADE_COMPARE(data.importerState(), &a); CORRADE_COMPARE(data.data.importerState(), &State);
} }
void MeshData3DTest::constructNonIndexed() { void MeshData3DTest::constructNonIndexed() {
const int a{}; auto&& data = ConstructData[testCaseInstanceId()];
const MeshData3D data{MeshPrimitive::Lines, {}, setTestCaseDescription(data.name);
{{{0.5f, 1.0f, 0.1f}, {-1.0f, 0.3f, -1.0f}}},
{{{0.0f, 1.0f, 0.0f}, {-1.0f, 0.0f, 0.0f}}},
{{{0.0f, 0.0f}, {0.3f, 0.7f}}},
{{0xff98ab_rgbf, 0xff3366_rgbf}},
&a};
CORRADE_VERIFY(!data.isIndexed()); CORRADE_VERIFY(!data.dataNonIndexed.isIndexed());
} }
void MeshData3DTest::constructNoNormals() { void MeshData3DTest::constructNoNormals() {

Loading…
Cancel
Save