Commit b23ddc70 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

vertexForEdge: simplified.

parent 5e66581b
......@@ -94,25 +94,20 @@ normalizeVector(const vec3 &a)
using Lookup = std::map<std::pair<Index, Index>, Index>;
Index
static Index
vertexForEdge(Lookup &lookup, VertexList &vertices, Index first, Index second)
{
Lookup::key_type key(first, second);
if (key.first > key.second) std::swap(key.first, key.second);
auto inserted = lookup.insert({ key, vertices.size() });
const auto inserted = lookup.insert({ key, vertices.size() });
if (inserted.second)
{
auto &edge0 = vertices[first];
auto &edge1 = vertices[second];
auto point = normalizeVector(addVector(edge0, edge1));
vertices.push_back(point);
}
vertices.push_back(normalizeVector(addVector(vertices[first], vertices[second])));
return inserted.first->second;
}
TriangleList
static TriangleList
subdivide(VertexList &vertices, TriangleList triangles)
{
Lookup lookup;
......@@ -135,7 +130,7 @@ subdivide(VertexList &vertices, TriangleList triangles)
using IndexedMesh = std::pair<VertexList, TriangleList>;
IndexedMesh
static IndexedMesh
makeIcosphere(int subdivisions)
{
icosahedron::init();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment