diff --git a/doc/changelog.dox b/doc/changelog.dox index 84f82cd1f..f9b6b2c91 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -55,6 +55,12 @@ See also: imported data instead of going through a converter plugin if you specify `--converter raw` +@subsection changelog-latest-bugfixes Bug fixes + +- The @ref Primitives::cylinderSolid() and @ref Primitives::coneSolid() + primitives were missing a face when both caps and texture coordinates were + enabled (see [mosra/magnum#386](https://github.com/mosra/magnum/issues/386)) + @section changelog-2019-10 2019.10 Released 2019-10-24, tagged as diff --git a/src/Magnum/Primitives/Cone.cpp b/src/Magnum/Primitives/Cone.cpp index a2b43e017..856b6c976 100644 --- a/src/Magnum/Primitives/Cone.cpp +++ b/src/Magnum/Primitives/Cone.cpp @@ -52,9 +52,14 @@ Trade::MeshData3D coneSolid(const UnsignedInt rings, const UnsignedInt segments, /* Vertex rings */ cone.cylinderVertexRings(rings+1, -halfLength, {-1.0f/rings, length/rings}, textureCoordsV, length/(rings*(flags & ConeFlag::CapEnd ? length + 1.0f : length))); - /* Faces */ + /* Faces. Account for the extra vertices for caps and texture coords. */ if(flags & ConeFlag::CapEnd) cone.bottomFaceRing(); - cone.faceRings(rings, flags & ConeFlag::CapEnd ? (1 + segments) : 0); + if(flags >= (ConeFlag::CapEnd|ConeFlag::GenerateTextureCoords)) + cone.faceRings(rings, 2 + segments); + else if(flags & ConeFlag::CapEnd) + cone.faceRings(rings, 1 + segments); + else + cone.faceRings(rings, 0); return cone.finalize(); } diff --git a/src/Magnum/Primitives/Cylinder.cpp b/src/Magnum/Primitives/Cylinder.cpp index daf50e88e..640f91f48 100644 --- a/src/Magnum/Primitives/Cylinder.cpp +++ b/src/Magnum/Primitives/Cylinder.cpp @@ -58,9 +58,14 @@ Trade::MeshData3D cylinderSolid(const UnsignedInt rings, const UnsignedInt segme cylinder.capVertex(halfLength, 1.0f, 1.0f); } - /* Faces */ + /* Faces. Account for the extra vertices for caps and texture coords. */ if(flags & CylinderFlag::CapEnds) cylinder.bottomFaceRing(); - cylinder.faceRings(rings, flags & CylinderFlag::CapEnds ? (1 + segments) : 0); + if(flags >= (CylinderFlag::CapEnds|CylinderFlag::GenerateTextureCoords)) + cylinder.faceRings(rings, 2 + segments); + else if(flags & CylinderFlag::CapEnds) + cylinder.faceRings(rings, 1 + segments); + else + cylinder.faceRings(rings, 0); if(flags & CylinderFlag::CapEnds) cylinder.topFaceRing(); return cylinder.finalize(); diff --git a/src/Magnum/Primitives/Test/ConeTest.cpp b/src/Magnum/Primitives/Test/ConeTest.cpp index cbf1fca6c..bc3e84806 100644 --- a/src/Magnum/Primitives/Test/ConeTest.cpp +++ b/src/Magnum/Primitives/Test/ConeTest.cpp @@ -286,11 +286,11 @@ void ConeTest::solidWithTextureCoordsAndCaps() { }), TestSuite::Compare::Container); /* Faces of the caps and sides do not share any vertices due to different - normals */ + normals, each ring has an extra vertex for texture coords */ CORRADE_COMPARE_AS(cone.indices(), (std::vector{ 0, 2, 1, 0, 3, 2, 0, 4, 3, - 4, 5, 9, 4, 9, 8, 5, 6, 10, 5, 10, 9, 6, 7, 11, 6, 11, 10, - 8, 9, 13, 8, 13, 12, 9, 10, 14, 9, 14, 13, 10, 11, 15, 10, 15, 14 + 5, 6, 10, 5, 10, 9, 6, 7, 11, 6, 11, 10, 7, 8, 12, 7, 12, 11, + 9, 10, 14, 9, 14, 13, 10, 11, 15, 10, 15, 14, 11, 12, 16, 11, 16, 15 }), TestSuite::Compare::Container); } diff --git a/src/Magnum/Primitives/Test/CylinderTest.cpp b/src/Magnum/Primitives/Test/CylinderTest.cpp index fd6b62204..93392a2ea 100644 --- a/src/Magnum/Primitives/Test/CylinderTest.cpp +++ b/src/Magnum/Primitives/Test/CylinderTest.cpp @@ -320,11 +320,11 @@ void CylinderTest::solidWithTextureCoordsAndCaps() { }), TestSuite::Compare::Container); /* Faces of the caps and sides do not share any vertices due to different - normals */ + normals, each ring has an extra vertex for texture coords */ CORRADE_COMPARE_AS(cylinder.indices(), (std::vector{ 0, 2, 1, 0, 3, 2, 0, 4, 3, - 4, 5, 9, 4, 9, 8, 5, 6, 10, 5, 10, 9, 6, 7, 11, 6, 11, 10, - 8, 9, 13, 8, 13, 12, 9, 10, 14, 9, 14, 13, 10, 11, 15, 10, 15, 14, + 5, 6, 10, 5, 10, 9, 6, 7, 11, 6, 11, 10, 7, 8, 12, 7, 12, 11, + 9, 10, 14, 9, 14, 13, 10, 11, 15, 10, 15, 14, 11, 12, 16, 11, 16, 15, 17, 18, 21, 18, 19, 21, 19, 20, 21 }), TestSuite::Compare::Container); }