Browse Source

Primitives: fix a missing face in cylinder and cone primitives.

pull/388/head
Vladimír Vondruš 7 years ago
parent
commit
96ea050a74
  1. 6
      doc/changelog.dox
  2. 9
      src/Magnum/Primitives/Cone.cpp
  3. 9
      src/Magnum/Primitives/Cylinder.cpp
  4. 6
      src/Magnum/Primitives/Test/ConeTest.cpp
  5. 6
      src/Magnum/Primitives/Test/CylinderTest.cpp

6
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

9
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();
}

9
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();

6
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<UnsignedInt>{
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);
}

6
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<UnsignedInt>{
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);
}

Loading…
Cancel
Save