diff --git a/graphics/include/gz/common/SubMesh.hh b/graphics/include/gz/common/SubMesh.hh index e8e87de3..3915997f 100644 --- a/graphics/include/gz/common/SubMesh.hh +++ b/graphics/include/gz/common/SubMesh.hh @@ -20,7 +20,6 @@ #include #include #include -#include #include #include diff --git a/graphics/src/SubMesh.cc b/graphics/src/SubMesh.cc index 71c69437..5f50f712 100644 --- a/graphics/src/SubMesh.cc +++ b/graphics/src/SubMesh.cc @@ -18,7 +18,6 @@ #include #include #include -#include #include #include @@ -578,7 +577,8 @@ namespace { // Simple way to find neighbors by grouping all vertices // by X coordinate with (ordered) map. KD-tree maybe better // but not sure about construction overhead -struct Neighbors { +struct Neighbors +{ Neighbors(const std::vector &_indices, const std::vector &_vertices) : vertices(_vertices) @@ -591,7 +591,7 @@ struct Neighbors { } template - void Visit(const gz::math::Vector3d &_point, Visitor _v) + void Visit(const gz::math::Vector3d &_point, Visitor _v) const { auto it = this->neighbors.find(_point.X()); // find smaller acceptable value @@ -645,7 +645,7 @@ void SubMesh::RecalculateNormals() gz::math::Vector3d n = gz::math::Vector3d::Normal(v1, v2, v3); for (const auto &point : {v1, v2, v3}) - neighbors.Visit(point, [&](unsigned int index) + neighbors.Visit(point, [&](const unsigned int index) { this->dataPtr->normals[index] += n; }); diff --git a/graphics/src/SubMesh_TEST.cc b/graphics/src/SubMesh_TEST.cc index 8f299bab..9da91603 100644 --- a/graphics/src/SubMesh_TEST.cc +++ b/graphics/src/SubMesh_TEST.cc @@ -592,9 +592,9 @@ TEST_F(SubMeshTest, NormalsRecalculation) auto submesh = std::make_shared(); submesh->SetPrimitiveType(common::SubMesh::TRIANGLES); - constexpr unsigned int elements = 16384; - for (unsigned int i = 0; i < elements; ++i) { - // sub to X less than _epsilon from even elements + constexpr unsigned int triangles = 16384; + for (unsigned int i = 0; i < triangles; ++i) { + // sub to X less than _epsilon from even triangles // expect that the 2nd vertex should be matched with // the 1st of next triangle const auto jitter = i % 2 ? 1e-7 : 0.0;