From 352b00a1eeefba9cb1fddbb43d8d7d4fa94f3e25 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 4 Apr 2024 20:04:13 +0100 Subject: Don't garbage collect the terrain mesh Use skipping iterators instead, GC would be implicit during save/load --- game/geoData.cpp | 9 ++++----- game/terrain.cpp | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'game') diff --git a/game/geoData.cpp b/game/geoData.cpp index 9211369..ed4303b 100644 --- a/game/geoData.cpp +++ b/game/geoData.cpp @@ -107,11 +107,11 @@ GeoData::createFlat(GlobalPosition2D lower, GlobalPosition2D upper, GlobalDistan OpenMesh::FaceHandle GeoData::findPoint(GlobalPosition2D p) const { - return findPoint(p, *faces_begin()); + return findPoint(p, *faces_sbegin()); } GeoData::PointFace::PointFace(const GlobalPosition2D p, const GeoData * mesh) : - PointFace {p, mesh, *mesh->faces_begin()} + PointFace {p, mesh, *mesh->faces_sbegin()} { } @@ -135,7 +135,7 @@ GeoData::PointFace::face(const GeoData * mesh, FaceHandle start) const GeoData::FaceHandle GeoData::PointFace::face(const GeoData * mesh) const { - return face(mesh, *mesh->faces_begin()); + return face(mesh, *mesh->faces_sbegin()); } namespace { @@ -347,7 +347,7 @@ GeoData::triangleContainsPoint(const GlobalPosition2D p, FaceHandle face) const GeoData::HalfedgeHandle GeoData::findBoundaryStart() const { - return *std::find_if(halfedges_begin(), halfedges_end(), [this](const auto heh) { + return *std::find_if(halfedges_sbegin(), halfedges_end(), [this](const auto heh) { return is_boundary(heh); }); } @@ -664,5 +664,4 @@ GeoData::setHeights(const std::span triangleStrip) // Tidy up update_vertex_normals_only(VertexIter {*this, vertex_handle(initialVertexCount), true}); - garbage_collection(); } diff --git a/game/terrain.cpp b/game/terrain.cpp index 7f59b6c..91a228f 100644 --- a/game/terrain.cpp +++ b/game/terrain.cpp @@ -30,14 +30,14 @@ Terrain::generateMeshes() std::vector vertices; vertices.reserve(geoData->n_vertices()); std::map vertexIndex; - std::transform(geoData->vertices_begin(), geoData->vertices_end(), std::back_inserter(vertices), + std::transform(geoData->vertices_sbegin(), geoData->vertices_end(), std::back_inserter(vertices), [this, &vertexIndex](const GeoData::VertexHandle v) { vertexIndex.emplace(v, vertexIndex.size()); const auto p = geoData->point(v); return Vertex {p, RelativePosition2D(p) / 10000.F, geoData->normal(v)}; }); std::for_each( - geoData->faces_begin(), geoData->faces_end(), [this, &vertexIndex, &indices](const GeoData::FaceHandle f) { + geoData->faces_sbegin(), geoData->faces_end(), [this, &vertexIndex, &indices](const GeoData::FaceHandle f) { std::transform(geoData->fv_begin(f), geoData->fv_end(f), std::back_inserter(indices), [&vertexIndex](const GeoData::VertexHandle v) { return vertexIndex[v]; -- cgit v1.2.3