133 node_mask,
GrainSize(1), memory, [&](
const int i) {
136 verts.begin(),
verts.end(), [&](
const int i) { return hide_vert[i]; });
142 attributes.
remove(
".hide_vert");
151 SubdivCCG &subdiv_ccg = *
object.sculpt->subdiv_ccg;
157 node_mask,
GrainSize(1), memory, [&](
const int i) {
159 return std::any_of(grids.
begin(), grids.
end(), [&](
const int i) {
160 return bits::any_bit_set(grid_hidden[i]);
202 hide_face[
i] = std::any_of(
203 face_verts.
begin(), face_verts.
end(), [&](
const int v) { return hide_vert[v]; });
230 TLS &tls = all_tls.
local();
233 tls.new_hide.resize(node_faces.
size());
236 calc_face_hide(node_faces,
faces, corner_verts, hide_vert, tls.new_hide.as_mutable_span());
243 node_changed[
i] =
true;
292 bool any_changed =
false;
300 calc_hide(
verts, new_hide);
328 SubdivCCG &subdiv_ccg = *
object.sculpt->subdiv_ccg;
333 bool any_changed =
false;
338 new_hide[
i].copy_from(grid_hidden[grids[
i]].as_span());
342 calc_hide(grids[
i], new_hide[
i]);
346 return bits::spans_equal(grid_hidden[grids[i]], new_hide[i]);
356 grid_hidden[grids[
i]].copy_from(new_hide[
i].as_span());
359 node_changed[
i] =
true;
380 if (should_update(
v)) {
387 (*any_changed) =
true;
391 (*any_visible) =
true;
418 bool any_changed =
false;
419 bool any_visible =
false;
503 depsgraph, ob, node_mask, action, [](
const BMVert * ) {
return true; });
529 switch (pbvh.
type()) {
567 else if (!
mask.is_empty()) {
570 for (
const int i :
verts.index_range()) {
584 SubdivCCG &subdiv_ccg = *
object.sculpt->subdiv_ccg;
600 if (grid_masks[
i] > 0.5f) {
615 const auto mask_test_fn = [&](
const BMVert *
v) {
646 switch (pbvh.
type()) {
672 {0,
nullptr, 0,
nullptr,
nullptr},
680 "Whether to hide or show vertices");
685 ot->name =
"Hide/Show Masked";
686 ot->idname =
"PAINT_OT_hide_show_masked";
687 ot->description =
"Hide/show all masked vertices above a threshold";
700 ot->name =
"Hide/Show All";
701 ot->idname =
"PAINT_OT_hide_show_all";
702 ot->description =
"Hide/show all vertices";
729 hide_poly.
span[face] = !hide_poly.
span[face];
745 SubdivCCG &subdiv_ccg = *
object.sculpt->subdiv_ccg;
751 for (
const int i :
nodes[
i].grids()) {
771 bool fully_hidden =
true;
795 switch (pbvh.
type()) {
817 ot->name =
"Invert Visibility";
818 ot->idname =
"PAINT_OT_visibility_invert";
819 ot->description =
"Invert the visibility of all vertices";
838 for (
const int corner : face) {
839 int vert = corner_verts[corner];
840 if (read_buffer[vert] != value) {
845 const int prev_vert = corner_verts[prev];
846 write_buffer[prev_vert] = value;
849 const int next_vert = corner_verts[
next];
850 write_buffer[next_vert] = value;
860 return count % 2 == 0 ?
back.as_mutable_span() :
front.as_mutable_span();
873 const int iterations)
882 for (const int face_index : range) {
883 if (!hide_poly[face_index]) {
886 const IndexRange face = faces[face_index];
887 if (action == VisAction::Hide) {
888 affect_visibility_mesh<true>(face, corner_verts, read_buffer, write_buffer);
891 affect_visibility_mesh<false>(face, corner_verts, read_buffer, write_buffer);
911 if (old_hide_vert[vert] != new_hide_vert[vert]) {
929 bool any_changed =
false;
931 for (
const int face_index :
indices) {
932 if (orig_hide_poly[face_index] != new_hide_poly[face_index]) {
939 node_changed[
i] =
true;
948 pbvh.
draw_data->tag_visibility_changed(changed_nodes);
956 const int iterations)
960 if (!attributes.
contains(
".hide_vert")) {
1012 const int iterations)
1036 for (
const int grid :
nodes[
i].grids()) {
1040 if (read_buffer[grid][grid_elem_idx] != desired_state) {
1056 write_buffer[neighbor.
grid_index][neighbor_grid_elem_idx].set(desired_state);
1062 node_changed[
i] =
true;
1072 grid_hidden = std::move(last_buffer);
1087 for (
const int i :
result.index_range()) {
1097 const int iterations)
1138 switch (pbvh.
type()) {
1164 "Grow the visibility by one face based on mesh topology"},
1168 "Shrink Visibility",
1169 "Shrink the visibility by one face based on mesh topology"},
1170 {0,
nullptr, 0,
nullptr,
nullptr},
1173 ot->name =
"Visibility Filter";
1174 ot->idname =
"PAINT_OT_visibility_filter";
1175 ot->description =
"Edit the visibility of the current mesh";
1190 "Number of times that the filter is going to be applied",
1195 "auto_iteration_count",
1197 "Auto Iteration Count",
1198 "Use an automatic number of iterations based on the number of vertices of the sculpt");
1234 for (
const int i :
verts.index_range()) {
1250 SubdivCCG &subdiv_ccg = *
object->sculpt->subdiv_ccg;
1269 const auto selection_test_fn = [&](
const BMVert *
v) {
1335 if (!gesture_data) {
1346 if (!gesture_data) {
1357 if (!gesture_data) {
1368 if (!gesture_data) {
1383 "Hide or show vertices outside the selection"},
1388 "Hide or show vertices inside the selection"},
1389 {0,
nullptr, 0,
nullptr,
nullptr},
1397 "Which vertices to hide or show");
1402 ot->name =
"Hide/Show";
1403 ot->idname =
"PAINT_OT_hide_show";
1404 ot->description =
"Hide/show some vertices";
1422 ot->name =
"Hide/Show Lasso";
1423 ot->idname =
"PAINT_OT_hide_show_lasso_gesture";
1424 ot->description =
"Hide/show some vertices";
1442 ot->name =
"Hide/Show Line";
1443 ot->idname =
"PAINT_OT_hide_show_line_gesture";
1444 ot->description =
"Hide/show some vertices";
1462 ot->name =
"Hide/Show Polyline";
1463 ot->idname =
"PAINT_OT_hide_show_polyline_gesture";
1464 ot->description =
"Hide/show some vertices";
int CCG_grid_xy_to_index(const int grid_size, const int x, const int y)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, blender::StringRef name)
@ MULTIRES_HIDDEN_MODIFIED
void multires_mark_as_modified(Depsgraph *depsgraph, Object *object, MultiresModifiedFlags flags)
void BKE_sculpt_sync_face_visibility_to_grids(const Mesh &mesh, SubdivCCG &subdiv_ccg)
bool BKE_sculptsession_use_pbvh_draw(const Object *ob, const RegionView3D *rv3d)
bool paint_is_bmesh_face_hidden(const BMFace *f)
A BVH for high poly meshes.
void BKE_pbvh_node_fully_hidden_set(blender::bke::pbvh::Node &node, int fully_hidden)
const blender::Set< BMFace *, 0 > & BKE_pbvh_bmesh_node_faces(blender::bke::pbvh::BMeshNode *node)
const blender::Set< BMVert *, 0 > & BKE_pbvh_bmesh_node_unique_verts(blender::bke::pbvh::BMeshNode *node)
const blender::Set< BMVert *, 0 > & BKE_pbvh_bmesh_node_other_verts(blender::bke::pbvh::BMeshNode *node)
void BKE_pbvh_sync_visibility_from_verts(Object &object)
CCGKey BKE_subdiv_ccg_key_top_level(const SubdivCCG &subdiv_ccg)
blender::BitGroupVector & BKE_subdiv_ccg_grid_hidden_ensure(SubdivCCG &subdiv_ccg)
void BKE_subdiv_ccg_neighbor_coords_get(const SubdivCCG &subdiv_ccg, const SubdivCCGCoord &coord, bool include_duplicates, SubdivCCGNeighbors &r_neighbors)
void BKE_subdiv_ccg_grid_hidden_free(SubdivCCG &subdiv_ccg)
void DEG_id_tag_update(ID *id, unsigned int flags)
Object is a sort of wrapper for general info.
void ED_region_tag_redraw(ARegion *region)
Read Guarded memory(de)allocation.
@ OPTYPE_DEPENDS_ON_CURSOR
#define BM_ELEM_CD_GET_FLOAT(ele, offset)
#define BM_elem_index_get(ele)
#define BM_elem_flag_disable(ele, hflag)
#define BM_elem_flag_toggle(ele, hflag)
#define BM_elem_flag_test(ele, hflag)
#define BM_elem_flag_test_bool(ele, hflag)
#define BM_elem_flag_enable(ele, hflag)
#define BM_ITER_MESH(ele, iter, bm, itype)
BLI_INLINE BMVert * BM_vert_at_index(BMesh *bm, const int index)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert * v
BPy_StructRNA * depsgraph
static IndexMask from_bools(Span< bool > bools, IndexMaskMemory &memory)
static IndexMask from_predicate(const IndexMask &universe, GrainSize grain_size, IndexMaskMemory &memory, Fn &&predicate)
static IndexMask from_bools(Span< bool > bools, IndexMaskMemory &memory)
constexpr Iterator end() const
constexpr Iterator begin() const
constexpr Span slice(int64_t start, int64_t size) const
constexpr int64_t size() const
constexpr const T * end() const
constexpr IndexRange index_range() const
constexpr const T * begin() const
constexpr bool is_empty() const
void resize(const int64_t new_size)
MutableSpan< T > as_mutable_span()
Span< T > as_span() const
int64_t group_size() const
GAttributeReader lookup_or_default(StringRef attribute_id, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
bool contains(StringRef attribute_id) const
GAttributeReader lookup(const StringRef attribute_id) const
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef attribute_id, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
bool remove(const StringRef attribute_id)
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef attribute_id, AttrDomain domain, AttrType data_type)
Span< NodeT > nodes() const
std::unique_ptr< DrawCache > draw_data
void tag_visibility_changed(const IndexMask &node_mask)
void update_visibility(const Object &object)
int64_t min_array_size() const
void foreach_index(Fn &&fn) const
static float normals[][3]
void * MEM_callocN(size_t len, const char *str)
void copy(const GVArray &src, GMutableSpan dst, int64_t grain_size=4096)
bool indexed_data_equal(const Span< T > all_values, const Span< int > indices, const Span< T > values)
void invert(BitSpanT &&data)
IndexRange grid_range(const int grid_area, const int grid)
int face_corner_prev(const IndexRange face, const int corner)
int face_corner_next(const IndexRange face, const int corner)
pbvh::Tree & pbvh_ensure(Depsgraph &depsgraph, Object &object)
pbvh::Tree * pbvh_get(Object &object)
IndexMask all_leaf_nodes(const Tree &pbvh, IndexMaskMemory &memory)
void node_update_visibility_grids(const BitGroupVector<> &grid_hidden, GridsNode &node)
Span< float3 > vert_normals_eval(const Depsgraph &depsgraph, const Object &object_orig)
Span< float3 > vert_positions_eval(const Depsgraph &depsgraph, const Object &object_orig)
void node_update_visibility_mesh(Span< bool > hide_vert, MeshNode &node)
void mesh_face_hide_from_vert(OffsetIndices< int > faces, Span< int > corner_verts, Span< bool > hide_vert, MutableSpan< bool > hide_poly)
void mesh_hide_vert_flush(Mesh &mesh)
void mesh_hide_face_flush(Mesh &mesh)
void mesh_edge_hide_from_vert(Span< int2 > edges, Span< bool > hide_vert, MutableSpan< bool > hide_edge)
std::unique_ptr< GestureData > init_from_box(bContext *C, wmOperator *op)
void operator_properties(wmOperatorType *ot, ShapeType shapeType)
std::unique_ptr< GestureData > init_from_polyline(bContext *C, wmOperator *op)
std::unique_ptr< GestureData > init_from_line(bContext *C, const wmOperator *op)
void apply(bContext &C, GestureData &gesture_data, wmOperator &op)
std::unique_ptr< GestureData > init_from_lasso(bContext *C, wmOperator *op)
bool is_affected(const GestureData &gesture_data, const float3 &position, const float3 &normal)
static void invert_visibility_bmesh(const Depsgraph &depsgraph, Object &object, const IndexMask &node_mask)
static constexpr float VERTEX_ITERATION_THRESHOLD
static Array< bool > duplicate_visibility_bmesh(const Object &object)
static void flush_face_changes(Mesh &mesh, const Span< bool > hide_vert)
void PAINT_OT_hide_show_polyline_gesture(wmOperatorType *ot)
static void grow_shrink_visibility_bmesh(const Depsgraph &depsgraph, Object &object, const IndexMask &node_mask, const VisAction action, const int iterations)
static void partialvis_all_update_grids(Depsgraph &depsgraph, Object &object, const VisAction action, const IndexMask &node_mask)
static void partialvis_all_update_bmesh(const Depsgraph &depsgraph, Object &ob, const VisAction action, const IndexMask &node_mask)
void PAINT_OT_hide_show_masked(wmOperatorType *ot)
static void invert_visibility_mesh(const Depsgraph &depsgraph, Object &object, const IndexMask &node_mask)
void PAINT_OT_hide_show_line_gesture(wmOperatorType *ot)
static void grid_hide_update(Depsgraph &depsgraph, Object &object, const IndexMask &node_mask, const FunctionRef< void(const int, MutableBoundedBitSpan)> calc_hide)
void tag_update_visibility(const bContext &C)
static wmOperatorStatus hide_show_gesture_line_exec(bContext *C, wmOperator *op)
static void hide_show_end(bContext &C, gesture::GestureData &gesture_data)
static void affect_visibility_mesh(const IndexRange face, const Span< int > corner_verts, const Span< bool > read_buffer, MutableSpan< bool > write_buffer)
static void propagate_vertex_visibility(Mesh &mesh, DualBuffer &buffers, const VArraySpan< bool > &hide_poly, const VisAction action, const int iterations)
static void partialvis_gesture_update_bmesh(gesture::GestureData &gesture_data)
static void partialvis_gesture_update_grids(Depsgraph &depsgraph, gesture::GestureData &gesture_data)
static wmOperatorStatus hide_show_all_exec(bContext *C, wmOperator *op)
static void vert_hide_update(const Depsgraph &depsgraph, Object &object, const IndexMask &node_mask, const FunctionRef< void(Span< int >, MutableSpan< bool >)> calc_hide)
void PAINT_OT_visibility_invert(wmOperatorType *ot)
static wmOperatorStatus visibility_invert_exec(bContext *C, wmOperator *op)
static void calc_face_hide(const Span< int > node_faces, const OffsetIndices< int > faces, const Span< int > corner_verts, const Span< bool > hide_vert, MutableSpan< bool > hide_face)
static void hide_show_apply_for_symmetry_pass(bContext &C, gesture::GestureData &gesture_data)
void PAINT_OT_hide_show_lasso_gesture(wmOperatorType *ot)
void PAINT_OT_visibility_filter(wmOperatorType *ot)
static wmOperatorStatus hide_show_gesture_lasso_exec(bContext *C, wmOperator *op)
void grids_show_all(Depsgraph &depsgraph, Object &object, const IndexMask &node_mask)
static void partialvis_masked_update_grids(Depsgraph &depsgraph, Object &object, const VisAction action, const IndexMask &node_mask)
static void partialvis_masked_update_bmesh(const Depsgraph &depsgraph, Object &ob, const VisAction action, const IndexMask &node_mask)
static void grow_shrink_visibility_grid(Depsgraph &depsgraph, Object &object, const IndexMask &node_mask, const VisAction action, const int iterations)
static void partialvis_update_bmesh_nodes(const Depsgraph &depsgraph, Object &ob, const IndexMask &node_mask, const VisAction action, const FunctionRef< bool(BMVert *v)> vert_test_fn)
static wmOperatorStatus hide_show_masked_exec(bContext *C, wmOperator *op)
static void hide_show_init_properties(bContext &, gesture::GestureData &gesture_data, wmOperator &op)
static void partialvis_update_bmesh_faces(const Set< BMFace *, 0 > &faces)
static void update_node_visibility_from_face_changes(bke::pbvh::Tree &pbvh, const IndexMask &node_mask, const Span< bool > orig_hide_poly, const Span< bool > new_hide_poly, const Span< bool > hide_vert)
void mesh_show_all(const Depsgraph &depsgraph, Object &object, const IndexMask &node_mask)
void PAINT_OT_hide_show_all(wmOperatorType *ot)
static void invert_visibility_grids(Depsgraph &depsgraph, Object &object, const IndexMask &node_mask)
static void partialvis_all_update_mesh(const Depsgraph &depsgraph, Object &object, const VisAction action, const IndexMask &node_mask)
void sync_all_from_faces(Object &object)
static void flush_edge_changes(Mesh &mesh, const Span< bool > hide_vert)
static void grow_shrink_visibility_mesh(const Depsgraph &depsgraph, Object &object, const IndexMask &node_mask, const VisAction action, const int iterations)
static void hide_show_operator_gesture_properties(wmOperatorType *ot)
static wmOperatorStatus visibility_filter_exec(bContext *C, wmOperator *op)
static wmOperatorStatus hide_show_gesture_polyline_exec(bContext *C, wmOperator *op)
static void update_undo_state(const Depsgraph &depsgraph, Object &object, const IndexMask &node_mask, const Span< bool > old_hide_vert, const Span< bool > new_hide_vert)
void PAINT_OT_hide_show(wmOperatorType *ot)
static wmOperatorStatus hide_show_gesture_box_exec(bContext *C, wmOperator *op)
static void partialvis_gesture_update_mesh(gesture::GestureData &gesture_data)
static void flush_face_changes_node(Mesh &mesh, bke::pbvh::Tree &pbvh, const IndexMask &node_mask, const Span< bool > hide_vert)
static void partialvis_update_bmesh_verts(const Set< BMVert *, 0 > &verts, const VisAction action, const FunctionRef< bool(BMVert *v)> should_update, bool *any_changed, bool *any_visible)
static void partialvis_masked_update_mesh(const Depsgraph &depsgraph, Object &object, const VisAction action, const IndexMask &node_mask)
static void hide_show_begin(bContext &C, wmOperator &op, gesture::GestureData &)
static bool action_to_hide(const VisAction action)
static void hide_show_operator_properties(wmOperatorType *ot)
void invalidate(SculptSession &ss)
void push_end(Object &ob)
void push_nodes(const Depsgraph &depsgraph, Object &object, const IndexMask &node_mask, const Type type)
void push_begin_ex(const Scene &, Object &ob, const char *name)
void push_node(const Depsgraph &depsgraph, const Object &object, const bke::pbvh::Node *node, const Type type)
void push_begin(const Scene &scene, Object &ob, const wmOperator *op)
void vert_random_access_ensure(Object &object)
Vector< BMVert *, 64 > BMeshNeighborVerts
void scatter_data_mesh(Span< T > src, Span< int > indices, MutableSpan< T > dst)
Span< BMVert * > vert_neighbors_get_bmesh(BMVert &vert, BMeshNeighborVerts &r_neighbors)
void gather_data_mesh(Span< T > src, Span< int > indices, MutableSpan< T > dst)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
int RNA_int_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
bool SCULPT_mode_poll_view3d(bContext *C)
int SCULPT_vertex_count_get(const Object &object)
struct SculptSession * sculpt
SubdivCCGNeighborCoords coords
blender::Array< blender::float3 > normals
blender::Array< float > masks
blender::Array< blender::float3 > positions
MutableVArraySpan< T > span
SelectionType selection_type
void(* end)(bContext &, GestureData &)
void(* begin)(bContext &, wmOperator &, GestureData &)
void(* apply_for_symmetry_pass)(bContext &, GestureData &)
BitGroupVector & read_buffer(int count)
BitGroupVector & write_buffer(int count)
Span< bool > read_buffer(int count)
MutableSpan< bool > write_buffer(int count)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorStatus WM_gesture_polyline_modal(bContext *C, wmOperator *op, const wmEvent *event)
wmOperatorStatus WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
wmOperatorStatus WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
wmOperatorStatus WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmOperatorStatus WM_gesture_straightline_active_side_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmOperatorStatus WM_gesture_polyline_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmOperatorStatus WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmOperatorStatus WM_gesture_straightline_oneshot_modal(bContext *C, wmOperator *op, const wmEvent *event)
void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor)
void WM_operator_properties_border(wmOperatorType *ot)
void WM_operator_properties_gesture_lasso(wmOperatorType *ot)
void WM_operator_properties_gesture_polyline(wmOperatorType *ot)