Browse Source

MeshTools: fix compile() with a non-trivial index offset.

Haha, what the heck, how did nobody hit this yet.
pull/547/head
Vladimír Vondruš 4 years ago
parent
commit
344dd3fc17
  1. 2
      doc/changelog.dox
  2. 2
      src/Magnum/MeshTools/Compile.cpp
  3. 6
      src/Magnum/MeshTools/Test/CompileGLTest.cpp

2
doc/changelog.dox

@ -530,6 +530,8 @@ See also:
- Fixed an assertion when using @ref MeshTools::removeDuplicates() on an
interleaved @ref Trade::MeshData that included padding at the beginning or
end of each vertex
- Fixed @ref MeshTools::compile() to properly take into account index buffer
offsets
- Fixed @ref MeshTools::removeDuplicates() to not take into account random
padding bytes and filtered-out attributes in interleaved source
@ref Trade::MeshData. This was a particularly glaring issue when using

2
src/Magnum/MeshTools/Compile.cpp

@ -154,7 +154,7 @@ GL::Mesh compileInternal(const Trade::MeshData& meshData, GL::Buffer&& indices,
}
if(meshData.isIndexed()) {
mesh.setIndexBuffer(std::move(indices), 0, meshData.indexType())
mesh.setIndexBuffer(std::move(indices), meshData.indexOffset(), meshData.indexType())
.setCount(meshData.indexCount());
} else mesh.setCount(meshData.vertexCount());

6
src/Magnum/MeshTools/Test/CompileGLTest.cpp

@ -445,6 +445,7 @@ template<class T> void CompileGLTest::twoDimensions() {
Containers::arraySize(vertexData), sizeof(Vertex))});
const UnsignedInt indexData[]{
66, 78, 23, /* offset */
0, 1, 4, 0, 4, 3,
1, 2, 5, 1, 5, 4,
3, 4, 7, 3, 7, 6,
@ -452,7 +453,7 @@ template<class T> void CompileGLTest::twoDimensions() {
};
Trade::MeshData meshData{MeshPrimitive::Triangles,
{}, indexData, Trade::MeshIndexData{indexData},
{}, indexData, Trade::MeshIndexData{Containers::arrayView(indexData).suffix(3)},
{}, vertexData, std::move(attributeData)};
/* Duplicate everything if data is non-indexed */
@ -672,6 +673,7 @@ template<class T> void CompileGLTest::threeDimensions() {
Containers::arraySize(vertexData), sizeof(Vertex))});
const UnsignedByte indexData[]{
66, 78, 23, /* offset */
0, 1, 4, 0, 4, 3,
1, 2, 5, 1, 5, 4,
3, 4, 7, 3, 7, 6,
@ -679,7 +681,7 @@ template<class T> void CompileGLTest::threeDimensions() {
};
Trade::MeshData meshData{MeshPrimitive::Triangles,
{}, indexData, Trade::MeshIndexData{indexData},
{}, indexData, Trade::MeshIndexData{Containers::arrayView(indexData).suffix(3)},
{}, vertexData, std::move(attributeData)};
/* Duplicate everything if data is non-indexed */

Loading…
Cancel
Save