From 42363c4f91753036de1198d29d142c11571f37d8 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 5 Apr 2025 00:00:34 +0100 Subject: Add OpenMesh/range helpers which support OpenMesh11 Exactly which version introduces the new types, not sure... Easy to change the version check macro though. --- thirdparty/openmesh/helpers.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/thirdparty/openmesh/helpers.h b/thirdparty/openmesh/helpers.h index a0105c8..0e29261 100644 --- a/thirdparty/openmesh/helpers.h +++ b/thirdparty/openmesh/helpers.h @@ -7,6 +7,7 @@ namespace OpenMesh { template using IteratorFunction = Iter (OpenMesh::PolyConnectivity::*)(IterParams...) const; +#if OM_GET_VER < 8 template BeginFunc, IteratorFunction EndFunc, typename Adaptor> auto @@ -26,6 +27,27 @@ namespace OpenMesh { { return std::views::iota(range.begin(), range.end()) | std::forward(adaptor); } +#else + template BeginFunc, IteratorFunction EndFunc, + typename Adaptor> + auto + operator|(const CirculatorRange> & range, + Adaptor && adaptor) + { + return std::views::iota(range.begin(), range.end()) | std::forward(adaptor); + } + + template BeginFunc, IteratorFunction EndFunc, typename Adaptor> + auto + operator|(const EntityRange> & range, + Adaptor && adaptor) + { + return std::views::iota(range.begin(), range.end()) | std::forward(adaptor); + } + +#endif namespace Helpers { template typename PropertyT> struct Property : public PropertyT { -- cgit v1.2.3 From abb7103b26b3d2ab1674f0aea360375cee10906e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 5 Apr 2025 01:40:02 +0100 Subject: Replace call to calc_vertex_normal_correct Same code copied inline, but adjusted to avoid normalising using Scalar which is an integral type. --- game/geoData.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/game/geoData.cpp b/game/geoData.cpp index 5cea4dd..db0f3f4 100644 --- a/game/geoData.cpp +++ b/game/geoData.cpp @@ -286,9 +286,27 @@ GeoData::updateAllVertexNormals(const R & range) void GeoData::updateVertexNormal(VertexHandle vertex) { - Normal3D n; - calc_vertex_normal_correct(vertex, n); - set_normal(vertex, glm::normalize(n)); + Normal3D normal {}; + { // Lifted from calc_vertex_normal_correct in PolyMeshT_impl.hh but doesn't use Scalar to normalise + ConstVertexIHalfedgeIter cvih_it = this->cvih_iter(vertex); + if (!cvih_it.is_valid()) { // don't crash on isolated vertices + return; + } + Normal in_he_vec; + calc_edge_vector(*cvih_it, in_he_vec); + for (; cvih_it.is_valid(); ++cvih_it) { // calculates the sector normal defined by cvih_it and adds it to normal + if (this->is_boundary(*cvih_it)) { + continue; + } + HalfedgeHandle out_heh(this->next_halfedge_handle(*cvih_it)); + Normal out_he_vec; + calc_edge_vector(out_heh, out_he_vec); + normal += cross(in_he_vec, out_he_vec); // sector area is taken into account + in_he_vec = out_he_vec; + in_he_vec *= -1; // change the orientation + } + } // End lift + set_normal(vertex, glm::normalize(normal)); } OpenMesh::VertexHandle -- cgit v1.2.3