From 9c79acf9b8b3f00a083ea9fc5c18dd31edb4883a Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Sat, 20 Jul 2024 02:14:08 +0200 Subject: [PATCH] Cleanup: Specialize vert_is_boundary Pull Request: https://projects.blender.org/blender/blender/pulls/125118 --- source/blender/editors/sculpt_paint/sculpt.cc | 40 +++++++++++++++++++ .../editors/sculpt_paint/sculpt_intern.hh | 9 +++++ 2 files changed, 49 insertions(+) diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index b45fdc33da7..2d43d830ac3 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -915,6 +915,46 @@ bool vert_is_boundary(const SculptSession &ss, const PBVHVertRef vertex) return false; } +bool vert_is_boundary(const Span hide_poly, + const GroupedSpan vert_to_face_map, + const BitSpan boundary, + const int vert) +{ + if (!hide::vert_all_faces_visible_get(hide_poly, vert_to_face_map, vert)) { + return true; + } + return boundary[vert].test(); +} + +bool vert_is_boundary(const Span /*hide_poly*/, + const SubdivCCG &subdiv_ccg, + const Span corner_verts, + const OffsetIndices faces, + const BitSpan boundary, + const SubdivCCGCoord vert) +{ + /* TODO: Unlike the base mesh implementation this method does NOT take into account face + * visibility. Either this should be noted as a intentional limitation or fixed.*/ + int v1, v2; + const SubdivCCGAdjacencyType adjacency = BKE_subdiv_ccg_coarse_mesh_adjacency_info_get( + subdiv_ccg, vert, corner_verts, faces, v1, v2); + switch (adjacency) { + case SUBDIV_CCG_ADJACENT_VERTEX: + return boundary[v1].test(); + case SUBDIV_CCG_ADJACENT_EDGE: + return boundary[v1].test() && boundary[v2].test(); + case SUBDIV_CCG_ADJACENT_NONE: + return false; + } +} + +bool vert_is_boundary(BMVert *vert) +{ + /* TODO: Unlike the base mesh implementation this method does NOT take into account face + * visibility. Either this should be noted as a intentional limitation or fixed.*/ + return BM_vert_is_boundary(vert); +} + } // namespace boundary } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.hh b/source/blender/editors/sculpt_paint/sculpt_intern.hh index 2a0dcc7907b..754ed8d965e 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.hh +++ b/source/blender/editors/sculpt_paint/sculpt_intern.hh @@ -941,6 +941,15 @@ void ensure_boundary_info(Object &object); * Requires #ensure_boundary_info to have been called. */ bool vert_is_boundary(const SculptSession &ss, PBVHVertRef vertex); +bool vert_is_boundary(Span hide_poly, + GroupedSpan vert_to_face_map, + BitSpan boundary, + int vert); +bool vert_is_boundary(Span hide_poly, + const SubdivCCG &subdiv_ccg, + BitSpan boundary, + SubdivCCGCoord vert); +bool vert_is_boundary(BMVert *vert); }