Browse Source

MeshTools: rename generate*IndicesInto() output parameters for clarity.

pull/601/head
Vladimír Vondruš 3 years ago
parent
commit
d8b90135cc
  1. 92
      src/Magnum/MeshTools/GenerateIndices.cpp
  2. 26
      src/Magnum/MeshTools/GenerateIndices.h
  3. 24
      src/Magnum/MeshTools/Test/GenerateIndicesTest.cpp

92
src/Magnum/MeshTools/GenerateIndices.cpp

@ -83,13 +83,13 @@ UnsignedInt primitiveCount(const MeshPrimitive primitive, const UnsignedInt elem
CORRADE_ASSERT_UNREACHABLE("MeshTools::primitiveCount(): invalid primitive" << primitive, {}); CORRADE_ASSERT_UNREACHABLE("MeshTools::primitiveCount(): invalid primitive" << primitive, {});
} }
void generateLineStripIndicesInto(const UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& indices) { void generateLineStripIndicesInto(const UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& output) {
CORRADE_ASSERT(vertexCount == 0 || vertexCount >= 2, CORRADE_ASSERT(vertexCount == 0 || vertexCount >= 2,
"MeshTools::generateLineStripIndicesInto(): expected either zero or at least two vertices, got" << vertexCount, ); "MeshTools::generateLineStripIndicesInto(): expected either zero or at least two vertices, got" << vertexCount, );
const UnsignedInt iMax = Math::max(vertexCount, 1u) - 1; const UnsignedInt iMax = Math::max(vertexCount, 1u) - 1;
CORRADE_ASSERT(indices.size() == 2*iMax, CORRADE_ASSERT(output.size() == 2*iMax,
"MeshTools::generateLineStripIndicesInto(): bad output size, expected" << 2*iMax << "but got" << indices.size(), ); "MeshTools::generateLineStripIndicesInto(): bad output size, expected" << 2*iMax << "but got" << output.size(), );
/* /*
1 --- 2 1 2 --- 3 4 1 --- 2 1 2 --- 3 4
@ -99,22 +99,22 @@ void generateLineStripIndicesInto(const UnsignedInt vertexCount, const Container
0 3 0 5 0 3 0 5
*/ */
for(std::size_t i = 0; i != iMax; ++i) { for(std::size_t i = 0; i != iMax; ++i) {
indices[i*2 + 0] = i; output[i*2 + 0] = i;
indices[i*2 + 1] = i + 1; output[i*2 + 1] = i + 1;
} }
} }
Containers::Array<UnsignedInt> generateLineStripIndices(const UnsignedInt vertexCount) { Containers::Array<UnsignedInt> generateLineStripIndices(const UnsignedInt vertexCount) {
Containers::Array<UnsignedInt> indices{NoInit, 2*(Math::max(vertexCount, 1u) - 1)}; Containers::Array<UnsignedInt> output{NoInit, 2*(Math::max(vertexCount, 1u) - 1)};
generateLineStripIndicesInto(vertexCount, indices); generateLineStripIndicesInto(vertexCount, output);
return indices; return output;
} }
void generateLineLoopIndicesInto(const UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& indices) { void generateLineLoopIndicesInto(const UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& output) {
CORRADE_ASSERT(vertexCount == 0 || vertexCount >= 2, CORRADE_ASSERT(vertexCount == 0 || vertexCount >= 2,
"MeshTools::generateLineLoopIndicesInto(): expected either zero or at least two vertices, got" << vertexCount, ); "MeshTools::generateLineLoopIndicesInto(): expected either zero or at least two vertices, got" << vertexCount, );
CORRADE_ASSERT(indices.size() == 2*vertexCount, CORRADE_ASSERT(output.size() == 2*vertexCount,
"MeshTools::generateLineLoopIndicesInto(): bad output size, expected" << 2*vertexCount << "but got" << indices.size(), ); "MeshTools::generateLineLoopIndicesInto(): bad output size, expected" << 2*vertexCount << "but got" << output.size(), );
/* /*
Same as with line strip, with one additional line segment at the end. Same as with line strip, with one additional line segment at the end.
@ -126,28 +126,28 @@ void generateLineLoopIndicesInto(const UnsignedInt vertexCount, const Containers
0 ----------- 3 0 7 ----------- 6 5 0 ----------- 3 0 7 ----------- 6 5
*/ */
for(std::size_t i = 0, iMax = Math::max(vertexCount, 1u) - 1; i != iMax; ++i) { for(std::size_t i = 0, iMax = Math::max(vertexCount, 1u) - 1; i != iMax; ++i) {
indices[i*2 + 0] = i; output[i*2 + 0] = i;
indices[i*2 + 1] = i + 1; output[i*2 + 1] = i + 1;
} }
if(vertexCount >= 2) { if(vertexCount >= 2) {
indices[2*vertexCount - 2] = vertexCount - 1; output[2*vertexCount - 2] = vertexCount - 1;
indices[2*vertexCount - 1] = 0; output[2*vertexCount - 1] = 0;
} }
} }
Containers::Array<UnsignedInt> generateLineLoopIndices(const UnsignedInt vertexCount) { Containers::Array<UnsignedInt> generateLineLoopIndices(const UnsignedInt vertexCount) {
Containers::Array<UnsignedInt> indices{NoInit, 2*vertexCount}; Containers::Array<UnsignedInt> output{NoInit, 2*vertexCount};
generateLineLoopIndicesInto(vertexCount, indices); generateLineLoopIndicesInto(vertexCount, output);
return indices; return output;
} }
void generateTriangleStripIndicesInto(const UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& indices) { void generateTriangleStripIndicesInto(const UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& output) {
CORRADE_ASSERT(vertexCount == 0 || vertexCount >= 3, CORRADE_ASSERT(vertexCount == 0 || vertexCount >= 3,
"MeshTools::generateTriangleStripIndicesInto(): expected either zero or at least three vertices, got" << vertexCount, ); "MeshTools::generateTriangleStripIndicesInto(): expected either zero or at least three vertices, got" << vertexCount, );
const UnsignedInt iMax = Math::max(vertexCount, 2u) - 2; const UnsignedInt iMax = Math::max(vertexCount, 2u) - 2;
CORRADE_ASSERT(indices.size() == 3*iMax, CORRADE_ASSERT(output.size() == 3*iMax,
"MeshTools::generateTriangleStripIndicesInto(): bad output size, expected" << 3*iMax << "but got" << indices.size(), ); "MeshTools::generateTriangleStripIndicesInto(): bad output size, expected" << 3*iMax << "but got" << output.size(), );
/* /*
Triangles starting with odd vertices (marked with !) have the first two Triangles starting with odd vertices (marked with !) have the first two
@ -160,25 +160,25 @@ void generateTriangleStripIndicesInto(const UnsignedInt vertexCount, const Conta
1 ----- 3 ----- 5 1 4 ----- 5 7 10 ---- 11 1 ----- 3 ----- 5 1 4 ----- 5 7 10 ---- 11
*/ */
for(std::size_t i = 0; i != iMax; ++i) { for(std::size_t i = 0; i != iMax; ++i) {
indices[i*3 + 0] = i % 2 ? i + 1 : i; output[i*3 + 0] = i % 2 ? i + 1 : i;
indices[i*3 + 1] = i % 2 ? i : i + 1; output[i*3 + 1] = i % 2 ? i : i + 1;
indices[i*3 + 2] = i + 2; output[i*3 + 2] = i + 2;
} }
} }
Containers::Array<UnsignedInt> generateTriangleStripIndices(const UnsignedInt vertexCount) { Containers::Array<UnsignedInt> generateTriangleStripIndices(const UnsignedInt vertexCount) {
Containers::Array<UnsignedInt> indices{NoInit, 3*(Math::max(vertexCount, 2u) - 2u)}; Containers::Array<UnsignedInt> output{NoInit, 3*(Math::max(vertexCount, 2u) - 2u)};
generateTriangleStripIndicesInto(vertexCount, indices); generateTriangleStripIndicesInto(vertexCount, output);
return indices; return output;
} }
void generateTriangleFanIndicesInto(const UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& indices) { void generateTriangleFanIndicesInto(const UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& output) {
CORRADE_ASSERT(vertexCount == 0 || vertexCount >= 3, CORRADE_ASSERT(vertexCount == 0 || vertexCount >= 3,
"MeshTools::generateTriangleFanIndicesInto(): expected either zero or at least three vertices, got" << vertexCount, ); "MeshTools::generateTriangleFanIndicesInto(): expected either zero or at least three vertices, got" << vertexCount, );
const UnsignedInt iMax = Math::max(vertexCount, 2u) - 2; const UnsignedInt iMax = Math::max(vertexCount, 2u) - 2;
CORRADE_ASSERT(indices.size() == 3*iMax, CORRADE_ASSERT(output.size() == 3*iMax,
"MeshTools::generateTriangleFanIndicesInto(): bad output size, expected" << 3*iMax << "but got" << indices.size(), ); "MeshTools::generateTriangleFanIndicesInto(): bad output size, expected" << 3*iMax << "but got" << output.size(), );
/* 10 8 ----- 7 5 /* 10 8 ----- 7 5
4 ----- 3 / \ \ / / \ 4 ----- 3 / \ \ / / \
@ -192,25 +192,25 @@ void generateTriangleFanIndicesInto(const UnsignedInt vertexCount, const Contain
1 1 1 1
*/ */
for(std::size_t i = 0; i != iMax; ++i) { for(std::size_t i = 0; i != iMax; ++i) {
indices[i*3 + 0] = 0; output[i*3 + 0] = 0;
indices[i*3 + 1] = i + 1; output[i*3 + 1] = i + 1;
indices[i*3 + 2] = i + 2; output[i*3 + 2] = i + 2;
} }
} }
Containers::Array<UnsignedInt> generateTriangleFanIndices(const UnsignedInt vertexCount) { Containers::Array<UnsignedInt> generateTriangleFanIndices(const UnsignedInt vertexCount) {
Containers::Array<UnsignedInt> indices{NoInit, 3*(Math::max(vertexCount, 2u) - 2)}; Containers::Array<UnsignedInt> output{NoInit, 3*(Math::max(vertexCount, 2u) - 2)};
generateTriangleFanIndicesInto(vertexCount, indices); generateTriangleFanIndicesInto(vertexCount, output);
return indices; return output;
} }
namespace { namespace {
template<class T> inline void generateQuadIndicesIntoImplementation(const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<const T>& quads, const Containers::StridedArrayView1D<T>& into) { template<class T> inline void generateQuadIndicesIntoImplementation(const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<const T>& quads, const Containers::StridedArrayView1D<T>& output) {
CORRADE_ASSERT(quads.size() % 4 == 0, CORRADE_ASSERT(quads.size() % 4 == 0,
"MeshTools::generateQuadIndicesInto(): quad index count" << quads.size() << "not divisible by 4", ); "MeshTools::generateQuadIndicesInto(): quad index count" << quads.size() << "not divisible by 4", );
CORRADE_ASSERT(quads.size()*6/4 == into.size(), CORRADE_ASSERT(quads.size()*6/4 == output.size(),
"MeshTools::generateQuadIndicesInto(): bad output size, expected" << quads.size()*6/4 << "but got" << into.size(), ); "MeshTools::generateQuadIndicesInto(): bad output size, expected" << quads.size()*6/4 << "but got" << output.size(), );
for(std::size_t i = 0, max = quads.size()/4; i != max; ++i) { for(std::size_t i = 0, max = quads.size()/4; i != max; ++i) {
auto get = [&](UnsignedInt j) -> const Vector3& { auto get = [&](UnsignedInt j) -> const Vector3& {
@ -243,7 +243,7 @@ template<class T> inline void generateQuadIndicesIntoImplementation(const Contai
/* Assign the two triangles */ /* Assign the two triangles */
for(std::size_t j = 0; j != 6; ++j) for(std::size_t j = 0; j != 6; ++j)
into[6*i + j] = quads[4*i + split[j]]; output[6*i + j] = quads[4*i + split[j]];
} }
} }
@ -292,16 +292,16 @@ Containers::Array<UnsignedInt> generateQuadIndices(const Containers::StridedArra
return out; return out;
} }
void generateQuadIndicesInto(const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<const UnsignedInt>& quads, const Containers::StridedArrayView1D<UnsignedInt>& into) { void generateQuadIndicesInto(const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<const UnsignedInt>& quads, const Containers::StridedArrayView1D<UnsignedInt>& output) {
return generateQuadIndicesIntoImplementation(positions, quads, into); return generateQuadIndicesIntoImplementation(positions, quads, output);
} }
void generateQuadIndicesInto(const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<const UnsignedShort>& quads, const Containers::StridedArrayView1D<UnsignedShort>& into) { void generateQuadIndicesInto(const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<const UnsignedShort>& quads, const Containers::StridedArrayView1D<UnsignedShort>& output) {
return generateQuadIndicesIntoImplementation(positions, quads, into); return generateQuadIndicesIntoImplementation(positions, quads, output);
} }
void generateQuadIndicesInto(const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<const UnsignedByte>& quads, const Containers::StridedArrayView1D<UnsignedByte>& into) { void generateQuadIndicesInto(const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<const UnsignedByte>& quads, const Containers::StridedArrayView1D<UnsignedByte>& output) {
return generateQuadIndicesIntoImplementation(positions, quads, into); return generateQuadIndicesIntoImplementation(positions, quads, output);
} }
Trade::MeshData generateIndices(Trade::MeshData&& data) { Trade::MeshData generateIndices(Trade::MeshData&& data) {

26
src/Magnum/MeshTools/GenerateIndices.h

@ -68,10 +68,10 @@ MAGNUM_MESHTOOLS_EXPORT Containers::Array<UnsignedInt> generateLineStripIndices(
A variant of @ref generateLineStripIndicesInto() that fills existing memory A variant of @ref generateLineStripIndicesInto() that fills existing memory
instead of allocating a new array. The @p vertexCount is expected to be either instead of allocating a new array. The @p vertexCount is expected to be either
@cpp 0 @ce or at least @cpp 2 @ce, the @p indices array is expected to have a @cpp 0 @ce or at least @cpp 2 @ce, the @p output array is expected to have a
size of @cpp 2*(vertexCount - 1) @ce. Primitive restart is not supported. size of @cpp 2*(vertexCount - 1) @ce. Primitive restart is not supported.
*/ */
MAGNUM_MESHTOOLS_EXPORT void generateLineStripIndicesInto(UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& indices); MAGNUM_MESHTOOLS_EXPORT void generateLineStripIndicesInto(UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& output);
/** /**
@brief Create index buffer for a line loop primitive @brief Create index buffer for a line loop primitive
@ -92,10 +92,10 @@ MAGNUM_MESHTOOLS_EXPORT Containers::Array<UnsignedInt> generateLineLoopIndices(U
A variant of @ref generateLineLoopIndicesInto() that fills existing memory A variant of @ref generateLineLoopIndicesInto() that fills existing memory
instead of allocating a new array. The @p vertexCount is expected to be either instead of allocating a new array. The @p vertexCount is expected to be either
@cpp 0 @ce or at least @cpp 2 @ce, the @p indices array is expected to have a @cpp 0 @ce or at least @cpp 2 @ce, the @p output array is expected to have a
size of @cpp 2*vertexCount @ce. Primitive restart is not supported. size of @cpp 2*vertexCount @ce. Primitive restart is not supported.
*/ */
MAGNUM_MESHTOOLS_EXPORT void generateLineLoopIndicesInto(UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& into); MAGNUM_MESHTOOLS_EXPORT void generateLineLoopIndicesInto(UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& output);
/** /**
@brief Create index buffer for a triangle strip primitive @brief Create index buffer for a triangle strip primitive
@ -116,10 +116,10 @@ MAGNUM_MESHTOOLS_EXPORT Containers::Array<UnsignedInt> generateTriangleStripIndi
A variant of @ref generateTriangleStripIndicesInto() that fills existing memory A variant of @ref generateTriangleStripIndicesInto() that fills existing memory
instead of allocating a new array. The @p vertexCount is expected to be either instead of allocating a new array. The @p vertexCount is expected to be either
@cpp 0 @ce or at least @cpp 3 @ce, the @p indices array is expected to have a @cpp 0 @ce or at least @cpp 3 @ce, the @p output array is expected to have a
size of @cpp 3*(vertexCount - 2) @ce. Primitive restart is not supported. size of @cpp 3*(vertexCount - 2) @ce. Primitive restart is not supported.
*/ */
MAGNUM_MESHTOOLS_EXPORT void generateTriangleStripIndicesInto(UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& into); MAGNUM_MESHTOOLS_EXPORT void generateTriangleStripIndicesInto(UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& output);
/** /**
@brief Create index buffer for a triangle fan primitive @brief Create index buffer for a triangle fan primitive
@ -140,10 +140,10 @@ MAGNUM_MESHTOOLS_EXPORT Containers::Array<UnsignedInt> generateTriangleFanIndice
A variant of @ref generateTriangleFanIndicesInto() that fills existing memory A variant of @ref generateTriangleFanIndicesInto() that fills existing memory
instead of allocating a new array. The @p vertexCount is expected to be either instead of allocating a new array. The @p vertexCount is expected to be either
@cpp 0 @ce or at least @cpp 3 @ce, the @p indices array is expected to have a @cpp 0 @ce or at least @cpp 3 @ce, the @p output array is expected to have a
size of @cpp 3*(vertexCount - 2) @ce. Primitive restart is not supported. size of @cpp 3*(vertexCount - 2) @ce. Primitive restart is not supported.
*/ */
MAGNUM_MESHTOOLS_EXPORT void generateTriangleFanIndicesInto(UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& into); MAGNUM_MESHTOOLS_EXPORT void generateTriangleFanIndicesInto(UnsignedInt vertexCount, const Containers::StridedArrayView1D<UnsignedInt>& output);
/** /**
@brief Create a triangle index buffer for quad primitives @brief Create a triangle index buffer for quad primitives
@ -191,22 +191,22 @@ MAGNUM_MESHTOOLS_EXPORT Containers::Array<UnsignedInt> generateQuadIndices(const
@m_since_latest @m_since_latest
A variant of @ref generateQuadIndices() that fills existing memory instead of A variant of @ref generateQuadIndices() that fills existing memory instead of
allocating a new array. Size of @p quads is expected to be divisible by @cpp 4 @ce allocating a new array. Size of @p quads is expected to be divisible by
and @p into should have a size that's @cpp quads.size()*6/4 @ce. @cpp 4 @ce and @p output should have a size that's @cpp quads.size()*6/4 @ce.
*/ */
MAGNUM_MESHTOOLS_EXPORT void generateQuadIndicesInto(const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<const UnsignedInt>& quads, const Containers::StridedArrayView1D<UnsignedInt>& into); MAGNUM_MESHTOOLS_EXPORT void generateQuadIndicesInto(const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<const UnsignedInt>& quads, const Containers::StridedArrayView1D<UnsignedInt>& output);
/** /**
* @overload * @overload
* @m_since_latest * @m_since_latest
*/ */
MAGNUM_MESHTOOLS_EXPORT void generateQuadIndicesInto(const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<const UnsignedShort>& quads, const Containers::StridedArrayView1D<UnsignedShort>& into); MAGNUM_MESHTOOLS_EXPORT void generateQuadIndicesInto(const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<const UnsignedShort>& quads, const Containers::StridedArrayView1D<UnsignedShort>& output);
/** /**
* @overload * @overload
* @m_since_latest * @m_since_latest
*/ */
MAGNUM_MESHTOOLS_EXPORT void generateQuadIndicesInto(const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<const UnsignedByte>& quads, const Containers::StridedArrayView1D<UnsignedByte>& into); MAGNUM_MESHTOOLS_EXPORT void generateQuadIndicesInto(const Containers::StridedArrayView1D<const Vector3>& positions, const Containers::StridedArrayView1D<const UnsignedByte>& quads, const Containers::StridedArrayView1D<UnsignedByte>& output);
/** /**
@brief Convert a mesh to plain indexed lines or triangles @brief Convert a mesh to plain indexed lines or triangles

24
src/Magnum/MeshTools/Test/GenerateIndicesTest.cpp

@ -320,12 +320,12 @@ void GenerateIndicesTest::generateLineStripIndicesWrongVertexCount() {
void GenerateIndicesTest::generateLineStripIndicesIntoWrongSize() { void GenerateIndicesTest::generateLineStripIndicesIntoWrongSize() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
UnsignedInt indices[7]; UnsignedInt output[7];
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateLineStripIndicesInto(0, indices); MeshTools::generateLineStripIndicesInto(0, output);
MeshTools::generateLineStripIndicesInto(5, indices); MeshTools::generateLineStripIndicesInto(5, output);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"MeshTools::generateLineStripIndicesInto(): bad output size, expected 0 but got 7\n" "MeshTools::generateLineStripIndicesInto(): bad output size, expected 0 but got 7\n"
"MeshTools::generateLineStripIndicesInto(): bad output size, expected 8 but got 7\n"); "MeshTools::generateLineStripIndicesInto(): bad output size, expected 8 but got 7\n");
@ -379,12 +379,12 @@ void GenerateIndicesTest::generateLineLoopIndicesWrongVertexCount() {
void GenerateIndicesTest::generateLineLoopIndicesIntoWrongSize() { void GenerateIndicesTest::generateLineLoopIndicesIntoWrongSize() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
UnsignedInt indices[9]; UnsignedInt output[9];
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateLineLoopIndicesInto(0, indices); MeshTools::generateLineLoopIndicesInto(0, output);
MeshTools::generateLineLoopIndicesInto(5, indices); MeshTools::generateLineLoopIndicesInto(5, output);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"MeshTools::generateLineLoopIndicesInto(): bad output size, expected 0 but got 9\n" "MeshTools::generateLineLoopIndicesInto(): bad output size, expected 0 but got 9\n"
"MeshTools::generateLineLoopIndicesInto(): bad output size, expected 10 but got 9\n"); "MeshTools::generateLineLoopIndicesInto(): bad output size, expected 10 but got 9\n");
@ -437,12 +437,12 @@ void GenerateIndicesTest::generateTriangleStripIndicesWrongVertexCount() {
void GenerateIndicesTest::generateTriangleStripIndicesIntoWrongSize() { void GenerateIndicesTest::generateTriangleStripIndicesIntoWrongSize() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
UnsignedInt indices[8]; UnsignedInt output[8];
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateTriangleStripIndicesInto(0, indices); MeshTools::generateTriangleStripIndicesInto(0, output);
MeshTools::generateTriangleStripIndicesInto(5, indices); MeshTools::generateTriangleStripIndicesInto(5, output);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"MeshTools::generateTriangleStripIndicesInto(): bad output size, expected 0 but got 8\n" "MeshTools::generateTriangleStripIndicesInto(): bad output size, expected 0 but got 8\n"
"MeshTools::generateTriangleStripIndicesInto(): bad output size, expected 9 but got 8\n"); "MeshTools::generateTriangleStripIndicesInto(): bad output size, expected 9 but got 8\n");
@ -495,12 +495,12 @@ void GenerateIndicesTest::generateTriangleFanIndicesWrongVertexCount() {
void GenerateIndicesTest::generateTriangleFanIndicesIntoWrongSize() { void GenerateIndicesTest::generateTriangleFanIndicesIntoWrongSize() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
UnsignedInt indices[8]; UnsignedInt output[8];
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateTriangleFanIndicesInto(0, indices); MeshTools::generateTriangleFanIndicesInto(0, output);
MeshTools::generateTriangleFanIndicesInto(5, indices); MeshTools::generateTriangleFanIndicesInto(5, output);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"MeshTools::generateTriangleFanIndicesInto(): bad output size, expected 0 but got 8\n" "MeshTools::generateTriangleFanIndicesInto(): bad output size, expected 0 but got 8\n"
"MeshTools::generateTriangleFanIndicesInto(): bad output size, expected 9 but got 8\n"); "MeshTools::generateTriangleFanIndicesInto(): bad output size, expected 9 but got 8\n");

Loading…
Cancel
Save