Blender V5.0
sculpt_hide.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "sculpt_hide.hh"
10
11#include "BKE_paint_bvh.hh"
12#include "BKE_subdiv_ccg.hh"
13
14#include "DNA_mesh_types.h"
15
16#include "bmesh.hh"
17
19
21 const Span<bool> hide_vert,
23{
25 return {};
26 }
27 const Span<int> verts = node.verts();
28 if (hide_vert.is_empty()) {
29 return verts;
30 }
31 indices.resize(verts.size());
32 const int *end = std::copy_if(verts.begin(), verts.end(), indices.begin(), [&](const int vert) {
33 return !hide_vert[vert];
34 });
35 indices.resize(end - indices.begin());
36 return indices;
37}
38
40 const GroupedSpan<int> vert_to_face_map,
41 const int vert)
42{
43 if (hide_poly.is_empty()) {
44 return true;
45 }
46
47 for (const int face : vert_to_face_map[vert]) {
48 if (hide_poly[face]) {
49 return false;
50 }
51 }
52 return true;
53}
54
56 const SubdivCCG &subdiv_ccg,
57 const SubdivCCGCoord vert)
58{
59 const int face_index = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, vert.grid_index);
60 return hide_poly[face_index];
61}
62
64{
65 BMEdge *edge = vert->e;
66
67 if (!edge) {
68 return true;
69 }
70
71 do {
72 BMLoop *loop = edge->l;
73
74 if (!loop) {
75 continue;
76 }
77
78 do {
80 return false;
81 }
82 } while ((loop = loop->radial_next) != edge->l);
83 } while ((edge = BM_DISK_EDGE_NEXT(edge, vert)) != vert->e);
84
85 return true;
86}
87} // namespace blender::ed::sculpt_paint::hide
A BVH for high poly meshes.
bool BKE_pbvh_node_fully_hidden_get(const blender::bke::pbvh::Node &node)
Definition pbvh.cc:1723
int BKE_subdiv_ccg_grid_to_face_index(const SubdivCCG &subdiv_ccg, const int grid_index)
#define BM_DISK_EDGE_NEXT(e, v)
@ BM_ELEM_HIDDEN
#define BM_elem_flag_test(ele, hflag)
constexpr bool is_empty() const
Definition BLI_span.hh:260
static ushort indices[]
static float verts[][3]
bool vert_all_faces_visible_get(const Span< bool > hide_poly, const GroupedSpan< int > vert_to_face_map, const int vert)
Span< int > node_visible_verts(const bke::pbvh::MeshNode &node, const Span< bool > hide_vert, Vector< int > &indices)
struct BMLoop * l
struct BMLoop * radial_next
struct BMFace * f
struct BMEdge * e