Blender V4.3
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
9#include "sculpt_hide.hh"
10
11#include "BKE_attribute.hh"
12#include "BKE_paint.hh"
13#include "BKE_pbvh_api.hh"
14#include "BKE_subdiv_ccg.hh"
15
16#include "DNA_mesh_types.h"
17#include "DNA_object_types.h"
18
20
22 const Span<bool> hide_vert,
23 Vector<int> &indices)
24{
26 return {};
27 }
28 const Span<int> verts = node.verts();
29 if (hide_vert.is_empty()) {
30 return verts;
31 }
32 indices.resize(verts.size());
33 const int *end = std::copy_if(verts.begin(), verts.end(), indices.begin(), [&](const int vert) {
34 return !hide_vert[vert];
35 });
36 indices.resize(end - indices.begin());
37 return indices;
38}
39
41 const GroupedSpan<int> vert_to_face_map,
42 const int vert)
43{
44 if (hide_poly.is_empty()) {
45 return true;
46 }
47
48 for (const int face : vert_to_face_map[vert]) {
49 if (hide_poly[face]) {
50 return false;
51 }
52 }
53 return true;
54}
55
57 const SubdivCCG &subdiv_ccg,
58 const SubdivCCGCoord vert)
59{
60 const int face_index = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, vert.grid_index);
61 return hide_poly[face_index];
62}
63
65{
66 BMEdge *edge = vert->e;
67
68 if (!edge) {
69 return true;
70 }
71
72 do {
73 BMLoop *loop = edge->l;
74
75 if (!loop) {
76 continue;
77 }
78
79 do {
81 return false;
82 }
83 } while ((loop = loop->radial_next) != edge->l);
84 } while ((edge = BM_DISK_EDGE_NEXT(edge, vert)) != vert->e);
85
86 return true;
87}
88} // 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:1542
int BKE_subdiv_ccg_grid_to_face_index(const SubdivCCG &subdiv_ccg, const int grid_index)
Object is a sort of wrapper for general info.
#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:261
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 * radial_next
struct BMFace * f
struct BMEdge * e