diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-04-05 01:41:18 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-04-05 01:41:18 +0100 |
commit | f27654e58bf2ab1eae8a30817c543393b40b4199 (patch) | |
tree | 92a8972c2dd44274410881cb5a093fa65aed519e | |
parent | Merge branch 'imgui' (diff) | |
parent | Replace call to calc_vertex_normal_correct (diff) | |
download | ilt-f27654e58bf2ab1eae8a30817c543393b40b4199.tar.bz2 ilt-f27654e58bf2ab1eae8a30817c543393b40b4199.tar.xz ilt-f27654e58bf2ab1eae8a30817c543393b40b4199.zip |
Merge branch 'openmesh-11'
-rw-r--r-- | game/geoData.cpp | 24 | ||||
-rw-r--r-- | thirdparty/openmesh/helpers.h | 22 |
2 files changed, 43 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 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<typename Iter, typename... IterParams> using IteratorFunction = Iter (OpenMesh::PolyConnectivity::*)(IterParams...) const; +#if OM_GET_VER < 8 template<typename Iter, typename CenterEntityHandle, IteratorFunction<Iter, CenterEntityHandle> BeginFunc, IteratorFunction<Iter, CenterEntityHandle> EndFunc, typename Adaptor> auto @@ -26,6 +27,27 @@ namespace OpenMesh { { return std::views::iota(range.begin(), range.end()) | std::forward<Adaptor>(adaptor); } +#else + template<typename Iter, typename CenterEntityHandle, typename ToEntityHandle, + IteratorFunction<Iter, CenterEntityHandle> BeginFunc, IteratorFunction<Iter, CenterEntityHandle> EndFunc, + typename Adaptor> + auto + operator|(const CirculatorRange<CirculatorRangeTraitT<OpenMesh::PolyConnectivity, Iter, CenterEntityHandle, + ToEntityHandle, BeginFunc, EndFunc>> & range, + Adaptor && adaptor) + { + return std::views::iota(range.begin(), range.end()) | std::forward<Adaptor>(adaptor); + } + + template<typename Iter, IteratorFunction<Iter> BeginFunc, IteratorFunction<Iter> EndFunc, typename Adaptor> + auto + operator|(const EntityRange<RangeTraitT<const OpenMesh::PolyConnectivity, Iter, BeginFunc, EndFunc>> & range, + Adaptor && adaptor) + { + return std::views::iota(range.begin(), range.end()) | std::forward<Adaptor>(adaptor); + } + +#endif namespace Helpers { template<typename Type, template<typename> typename PropertyT> struct Property : public PropertyT<Type> { |