Browse Source

MeshTools: make the generateFlatNormals() docs less handwavy.

If it takes *me* ten minutes to figure out how this needs to be used,
then it probably should be documented.
pull/280/head
Vladimír Vondruš 8 years ago
parent
commit
8dc1f8a7da
  1. 6
      doc/snippets/MagnumMeshTools.cpp
  2. 11
      src/Magnum/MeshTools/GenerateFlatNormals.h

6
doc/snippets/MagnumMeshTools.cpp

@ -92,6 +92,12 @@ std::vector<Vector3> normals;
std::tie(normalIndices, normals) =
MeshTools::generateFlatNormals(vertexIndices, positions);
/* [generateFlatNormals] */
/* [generateFlatNormals-recombine] */
std::vector<UnsignedInt> indices = MeshTools::combineIndexedArrays(
std::make_pair(std::cref(vertexIndices), std::ref(positions)),
std::make_pair(std::cref(normalIndices), std::ref(normals)));
/* [generateFlatNormals-recombine] */
}
{

11
src/Magnum/MeshTools/GenerateFlatNormals.h

@ -43,13 +43,16 @@ namespace Magnum { namespace MeshTools {
@param positions Array of vertex positions
@return Normal indices and vectors
For each face generates one normal vector, removes duplicates before
returning. Example usage:
All vertices in each triangle face get the same normal vector. Removes
duplicates before returning. Example usage:
@snippet MagnumMeshTools.cpp generateFlatNormals
You can then use @ref combineIndexedArrays() to combine normal and vertex array
to use the same indices.
This will generate index buffer that's different from the input @p indices
array, so you'll need to recombine them using @ref combineIndexedArrays() in
order to have a single index array for both vertices and normals:
@snippet MagnumMeshTools.cpp generateFlatNormals-recombine
@attention The function requires the mesh to have triangle faces, thus index
count must be divisible by 3.

Loading…
Cancel
Save