summaryrefslogtreecommitdiff
path: root/game/geoData.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'game/geoData.cpp')
-rw-r--r--game/geoData.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/game/geoData.cpp b/game/geoData.cpp
index 1d11fda..9211369 100644
--- a/game/geoData.cpp
+++ b/game/geoData.cpp
@@ -373,11 +373,19 @@ GeoData::centre(const HalfedgeHandle heh) const
void
GeoData::update_vertex_normals_only()
{
- for (auto vh : all_vertices()) {
- Normal3D n;
- calc_vertex_normal_correct(vh, n);
- this->set_normal(vh, glm::normalize(n));
- }
+ update_vertex_normals_only(vertices_sbegin());
+}
+
+void
+GeoData::update_vertex_normals_only(VertexIter start)
+{
+ std::for_each(start, vertices_end(), [this](const auto vh) {
+ if (normal(vh) == Normal3D {}) {
+ Normal3D n;
+ calc_vertex_normal_correct(vh, n);
+ this->set_normal(vh, glm::normalize(n));
+ }
+ });
}
bool
@@ -462,6 +470,8 @@ GeoData::setHeights(const std::span<const GlobalPosition3D> triangleStrip)
return;
}
+ const auto initialVertexCount = static_cast<unsigned int>(n_vertices());
+
// Create new vertices
std::vector<VertexHandle> newVerts;
newVerts.reserve(newVerts.size());
@@ -653,6 +663,6 @@ GeoData::setHeights(const std::span<const GlobalPosition3D> triangleStrip)
});
// Tidy up
+ update_vertex_normals_only(VertexIter {*this, vertex_handle(initialVertexCount), true});
garbage_collection();
- update_vertex_normals_only();
}