Blender V5.3
sculpt_filter_mask.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLI_array_utils.hh"
11#include "BLI_math_base.hh"
12
13#include "BKE_attribute.hh"
14#include "BKE_context.hh"
15#include "BKE_layer.hh"
16#include "BKE_mesh.hh"
17#include "BKE_object_types.hh"
18#include "BKE_paint.hh"
19#include "BKE_paint_bvh.hh"
20#include "BKE_subdiv_ccg.hh"
21
22#include "WM_api.hh"
23#include "WM_types.hh"
24
25#include "../paint_intern.hh"
26#include "mesh_brush_common.hh"
27#include "paint_mask.hh"
28#include "sculpt_hide.hh"
29#include "sculpt_intern.hh"
30#include "sculpt_smooth.hh"
31#include "sculpt_undo.hh"
32
33#include "RNA_access.hh"
34#include "RNA_define.hh"
35
36#include "bmesh.hh"
37
39
40enum class FilterType {
41 Smooth = 0,
43 Grow = 2,
44 Shrink = 3,
47};
48
50 const Span<bool> hide_vert,
51 const Span<float> mask,
52 const MutableSpan<float> new_mask)
53{
54 BLI_assert(verts.size() == new_mask.size());
55 if (hide_vert.is_empty()) {
56 return;
57 }
58
59 for (const int i : verts.index_range()) {
60 if (hide_vert[verts[i]]) {
61 new_mask[i] = mask[verts[i]];
62 }
63 }
64}
65
67 const float factor,
68 const float offset,
69 const MutableSpan<float> dst)
70{
71 for (const int i : src.index_range()) {
72 dst[i] = factor * src[i] + offset;
73 }
74}
75
77 const MutableSpan<float> dst)
78{
79 const float contrast = 0.1f;
80 const float delta = contrast * 0.5f;
81 const float gain = math::rcp(1.0f - contrast);
82 const float offset = gain * -delta;
83 multiply_add(src, gain, offset, dst);
84
86}
87
89 const MutableSpan<float> dst)
90{
91 const float contrast = -0.1f;
92 const float delta = contrast * 0.5f;
93 const float gain = 1.0f - contrast;
94 const float offset = gain * -delta;
95 multiply_add(src, gain, offset, dst);
96
98}
99
100BLI_NOINLINE static void sharpen_masks(const Span<float> old_masks,
101 const MutableSpan<float> new_mask)
102{
103 for (const int i : old_masks.index_range()) {
104 float val = new_mask[i];
105 float mask = old_masks[i];
106 val -= mask;
107 if (mask > 0.5f) {
108 mask += 0.05f;
109 }
110 else {
111 mask -= 0.05f;
112 }
113 mask += val / 2.0f;
114 new_mask[i] = mask;
115 }
116
117 mask::clamp_mask(new_mask);
118}
119
127
128static void apply_new_mask_mesh(const Depsgraph &depsgraph,
129 Object &object,
130 const IndexMask &node_mask,
131 const OffsetIndices<int> node_verts,
132 const Span<float> new_mask,
134{
137
138 Array<bool> node_changed(node_mask.min_array_size(), false);
139
140 node_mask.foreach_index(
141 [&](const int i, const int pos) {
142 const Span<int> verts = nodes[i].verts();
143 const Span<float> new_node_mask = new_mask.slice(node_verts[pos]);
144 if (array_utils::indexed_data_equal<float>(mask, verts, new_node_mask)) {
145 return;
146 }
147 undo::push_node(depsgraph, object, &nodes[i], undo::Type::Mask);
148 scatter_data_mesh(new_node_mask, verts, mask);
150 node_changed[i] = true;
151 },
153
154 IndexMaskMemory memory;
155 pbvh.tag_masks_changed(IndexMask::from_bools(node_changed, memory));
156}
157
158static void smooth_mask_mesh(const OffsetIndices<int> faces,
159 const Span<int> corner_verts,
160 const GroupedSpan<int> vert_to_face,
161 const Span<bool> hide_poly,
162 const Span<bool> hide_vert,
163 const Span<float> mask,
165 FilterLocalData &tls,
166 MutableSpan<float> new_mask)
167{
168 const Span<int> verts = node.verts();
169
170 const GroupedSpan<int> neighbors = calc_vert_neighbors(faces,
171 corner_verts,
172 vert_to_face,
173 hide_poly,
174 verts,
176 tls.neighbor_data);
177
178 tls.node_mask.resize(verts.size());
179 const MutableSpan<float> node_mask = tls.node_mask;
180 gather_data_mesh(mask, verts, node_mask);
181
182 smooth::neighbor_data_average_mesh(mask, neighbors, new_mask);
183 mask::mix_new_masks(new_mask, 0.5f, node_mask);
184 copy_old_hidden_mask_mesh(verts, hide_vert, mask, node_mask);
185 mask::clamp_mask(node_mask);
186 new_mask.copy_from(node_mask);
187}
188
189static void sharpen_mask_mesh(const OffsetIndices<int> faces,
190 const Span<int> corner_verts,
191 const GroupedSpan<int> vert_to_face,
192 const Span<bool> hide_poly,
193 const Span<bool> hide_vert,
194 const Span<float> mask,
196 FilterLocalData &tls,
197 MutableSpan<float> new_mask)
198{
199 const Span<int> verts = node.verts();
200
201 tls.node_mask.resize(verts.size());
202 const MutableSpan<float> node_mask = tls.node_mask;
203 gather_data_mesh(mask, verts, node_mask);
204
205 const GroupedSpan<int> neighbors = calc_vert_neighbors(faces,
206 corner_verts,
207 vert_to_face,
208 hide_poly,
209 verts,
211 tls.neighbor_data);
212
213 smooth::neighbor_data_average_mesh(mask, neighbors, new_mask);
214
215 sharpen_masks(node_mask, new_mask);
216 copy_old_hidden_mask_mesh(verts, hide_vert, mask, new_mask);
217}
218
219static void grow_mask_mesh(const OffsetIndices<int> faces,
220 const Span<int> corner_verts,
221 const GroupedSpan<int> vert_to_face,
222 const Span<bool> hide_poly,
223 const Span<bool> hide_vert,
224 const Span<float> mask,
226 FilterLocalData &tls,
227 MutableSpan<float> new_mask)
228{
229 const Span<int> verts = node.verts();
230
231 const GroupedSpan<int> neighbors = calc_vert_neighbors(faces,
232 corner_verts,
233 vert_to_face,
234 hide_poly,
235 verts,
237 tls.neighbor_data);
238
239 for (const int i : verts.index_range()) {
240 new_mask[i] = mask[verts[i]];
241 for (const int neighbor : neighbors[i]) {
242 new_mask[i] = std::max(mask[neighbor], new_mask[i]);
243 }
244 }
245 copy_old_hidden_mask_mesh(verts, hide_vert, mask, new_mask);
246}
247
248static void shrink_mask_mesh(const OffsetIndices<int> faces,
249 const Span<int> corner_verts,
250 const GroupedSpan<int> vert_to_face,
251 const Span<bool> hide_poly,
252 const Span<bool> hide_vert,
253 const Span<float> mask,
255 FilterLocalData &tls,
256 MutableSpan<float> new_mask)
257{
258 const Span<int> verts = node.verts();
259
260 const GroupedSpan<int> neighbors = calc_vert_neighbors(faces,
261 corner_verts,
262 vert_to_face,
263 hide_poly,
264 verts,
266 tls.neighbor_data);
267
268 for (const int i : verts.index_range()) {
269 new_mask[i] = mask[verts[i]];
270 for (const int neighbor : neighbors[i]) {
271 new_mask[i] = std::min(mask[neighbor], new_mask[i]);
272 }
273 }
274 copy_old_hidden_mask_mesh(verts, hide_vert, mask, new_mask);
275}
276
277static bool increase_contrast_mask_mesh(const Depsgraph &depsgraph,
278 const Object &object,
279 const Span<bool> hide_vert,
282{
284 const Span<int> verts = hide::node_visible_verts(node, hide_vert, index_data);
285
287 gather_data_mesh(mask.as_span(), verts, node_mask.as_mutable_span());
288
290 mask_increase_contrast(node_mask, new_mask);
291 copy_old_hidden_mask_mesh(verts, hide_vert, mask, new_mask);
292
293 if (node_mask.as_span() == new_mask.as_span()) {
294 return false;
295 }
296
297 undo::push_node(depsgraph, object, &node, undo::Type::Mask);
298 scatter_data_mesh(new_mask.as_span(), verts, mask);
300 return true;
301}
302
303static bool decrease_contrast_mask_mesh(const Depsgraph &depsgraph,
304 const Object &object,
305 const Span<bool> hide_vert,
308{
310 const Span<int> verts = hide::node_visible_verts(node, hide_vert, index_data);
311
313 gather_data_mesh(mask.as_span(), verts, node_mask.as_mutable_span());
314
316 mask_decrease_contrast(node_mask, new_mask);
317 copy_old_hidden_mask_mesh(verts, hide_vert, mask, new_mask);
318
319 if (node_mask.as_span() == new_mask.as_span()) {
320 return false;
321 }
322
323 undo::push_node(depsgraph, object, &node, undo::Type::Mask);
324 scatter_data_mesh(new_mask.as_span(), verts, mask);
326 return true;
327}
328
330 const Span<int> grids,
331 const MutableSpan<float> new_mask)
332{
333 const BitGroupVector<> &grid_hidden = subdiv_ccg.grid_hidden;
334 if (subdiv_ccg.grid_hidden.is_empty()) {
335 return;
336 }
337 const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg);
338 const Span<float> masks = subdiv_ccg.masks;
339 for (const int i : grids.index_range()) {
340 const Span grid_masks = masks.slice(bke::ccg::grid_range(key, grids[i]));
341 MutableSpan grid_dst = new_mask.slice(bke::ccg::grid_range(key, i));
342 bits::foreach_1_index(grid_hidden[grids[i]],
343 [&](const int offset) { grid_dst[offset] = grid_masks[offset]; });
344 }
345}
346
347static void apply_new_mask_grids(const Depsgraph &depsgraph,
348 Object &object,
349 const IndexMask &node_mask,
350 const OffsetIndices<int> node_verts,
351 const Span<float> new_mask)
352{
353 SculptSession &ss = *object.runtime->sculpt_session;
356 SubdivCCG &subdiv_ccg = *ss.subdiv_ccg;
357 const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg);
358 MutableSpan<float> masks = subdiv_ccg.masks;
359
360 Array<bool> node_changed(node_mask.min_array_size(), false);
361
362 node_mask.foreach_index(
363 [&](const int i, const int pos) {
364 const Span<int> grids = nodes[i].grids();
365 const Span<float> new_node_mask = new_mask.slice(node_verts[pos]);
366 if (mask_equals_array_grids(masks, key, grids, new_node_mask)) {
367 return;
368 }
369 undo::push_node(depsgraph, object, &nodes[i], undo::Type::Mask);
370 scatter_data_grids(subdiv_ccg, new_node_mask, grids, masks);
372 node_changed[i] = true;
373 },
375
376 IndexMaskMemory memory;
377 pbvh.tag_masks_changed(IndexMask::from_bools(node_changed, memory));
378
379 /* New mask values need propagation across grid boundaries. */
381}
382
383static void smooth_mask_grids(const SubdivCCG &subdiv_ccg,
385 FilterLocalData &tls,
386 MutableSpan<float> new_mask)
387{
388 const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg);
389
390 const Span<int> grids = node.grids();
391 const int grid_verts_num = grids.size() * key.grid_area;
392
393 tls.node_mask.resize(grid_verts_num);
394 const MutableSpan<float> node_mask = tls.node_mask;
395 gather_data_grids(subdiv_ccg, subdiv_ccg.masks.as_span(), grids, node_mask);
396
397 smooth::average_data_grids(subdiv_ccg, subdiv_ccg.masks.as_span(), grids, new_mask);
398 mask::mix_new_masks(new_mask, 0.5f, node_mask);
399 copy_old_hidden_mask_grids(subdiv_ccg, grids, node_mask);
400 mask::clamp_mask(node_mask);
401 new_mask.copy_from(node_mask);
402}
403
404static void sharpen_mask_grids(const SubdivCCG &subdiv_ccg,
406 FilterLocalData &tls,
407 MutableSpan<float> new_mask)
408{
409 const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg);
410
411 const Span<int> grids = node.grids();
412 const int grid_verts_num = grids.size() * key.grid_area;
413
414 tls.node_mask.resize(grid_verts_num);
415 const MutableSpan<float> node_mask = tls.node_mask;
416 gather_data_grids(subdiv_ccg, subdiv_ccg.masks.as_span(), grids, node_mask);
417
418 smooth::average_data_grids(subdiv_ccg, subdiv_ccg.masks.as_span(), grids, new_mask);
419
420 sharpen_masks(node_mask, new_mask);
421
422 copy_old_hidden_mask_grids(subdiv_ccg, grids, new_mask);
423}
424
425static void grow_mask_grids(const SubdivCCG &subdiv_ccg,
427 MutableSpan<float> new_mask)
428{
429 const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg);
430 const Span<float> masks = subdiv_ccg.masks;
431
432 const Span<int> grids = node.grids();
433
434 for (const int i : grids.index_range()) {
435 const int grid = grids[i];
436 const Span grid_masks = masks.slice(bke::ccg::grid_range(key, grid));
437 MutableSpan grid_dst = new_mask.slice(bke::ccg::grid_range(key, i));
438
439 for (const short y : IndexRange(key.grid_size)) {
440 for (const short x : IndexRange(key.grid_size)) {
441 const int offset = CCG_grid_xy_to_index(key.grid_size, x, y);
442
443 SubdivCCGNeighbors neighbors;
444 SubdivCCGCoord coord{grid, x, y};
445 BKE_subdiv_ccg_neighbor_coords_get(subdiv_ccg, coord, false, neighbors);
446
447 grid_dst[offset] = grid_masks[offset];
448 for (const SubdivCCGCoord neighbor : neighbors.coords) {
449 grid_dst[offset] = std::max(masks[neighbor.to_index(key)], grid_dst[offset]);
450 }
451 }
452 }
453 }
454
455 copy_old_hidden_mask_grids(subdiv_ccg, grids, new_mask);
456}
457
458static void shrink_mask_grids(const SubdivCCG &subdiv_ccg,
460 MutableSpan<float> new_mask)
461{
462 const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg);
463 const Span<float> masks = subdiv_ccg.masks;
464
465 const Span<int> grids = node.grids();
466
467 for (const int i : grids.index_range()) {
468 const int grid = grids[i];
469 const Span grid_masks = masks.slice(bke::ccg::grid_range(key, grid));
470 MutableSpan grid_dst = new_mask.slice(bke::ccg::grid_range(key, i));
471
472 for (const short y : IndexRange(key.grid_size)) {
473 for (const short x : IndexRange(key.grid_size)) {
474 const int offset = CCG_grid_xy_to_index(key.grid_size, x, y);
475
476 SubdivCCGNeighbors neighbors;
477 SubdivCCGCoord coord{grid, x, y};
478 BKE_subdiv_ccg_neighbor_coords_get(subdiv_ccg, coord, false, neighbors);
479
480 grid_dst[offset] = grid_masks[offset];
481 for (const SubdivCCGCoord neighbor : neighbors.coords) {
482 grid_dst[offset] = std::min(masks[neighbor.to_index(key)], grid_dst[offset]);
483 }
484 }
485 }
486 }
487
488 copy_old_hidden_mask_grids(subdiv_ccg, grids, new_mask);
489}
490
491static bool increase_contrast_mask_grids(const Depsgraph &depsgraph,
492 const Object &object,
494 FilterLocalData &tls)
495{
496 SculptSession &ss = *object.runtime->sculpt_session;
497 SubdivCCG &subdiv_ccg = *ss.subdiv_ccg;
498 const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg);
499
500 const Span<int> grids = node.grids();
501 const int grid_verts_num = grids.size() * key.grid_area;
502
503 tls.node_mask.resize(grid_verts_num);
504 const MutableSpan<float> node_mask = tls.node_mask;
505 gather_data_grids(subdiv_ccg, subdiv_ccg.masks.as_span(), grids, node_mask);
506
507 tls.new_mask.resize(grid_verts_num);
508 const MutableSpan<float> new_mask = tls.new_mask;
509 mask_increase_contrast(node_mask, new_mask);
510
511 copy_old_hidden_mask_grids(subdiv_ccg, grids, new_mask);
512
513 if (node_mask.as_span() == new_mask.as_span()) {
514 return false;
515 }
516
517 undo::push_node(depsgraph, object, &node, undo::Type::Mask);
518 scatter_data_grids(subdiv_ccg, new_mask.as_span(), grids, subdiv_ccg.masks.as_mutable_span());
520 return true;
521}
522
523static bool decrease_contrast_mask_grids(const Depsgraph &depsgraph,
524 const Object &object,
526 FilterLocalData &tls)
527{
528 SculptSession &ss = *object.runtime->sculpt_session;
529 SubdivCCG &subdiv_ccg = *ss.subdiv_ccg;
530 const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg);
531
532 const Span<int> grids = node.grids();
533 const int grid_verts_num = grids.size() * key.grid_area;
534
535 tls.node_mask.resize(grid_verts_num);
536 const MutableSpan<float> node_mask = tls.node_mask;
537 gather_data_grids(subdiv_ccg, subdiv_ccg.masks.as_span(), grids, node_mask);
538
539 tls.new_mask.resize(grid_verts_num);
540 const MutableSpan<float> new_mask = tls.new_mask;
541 mask_decrease_contrast(node_mask, new_mask);
542
543 copy_old_hidden_mask_grids(subdiv_ccg, grids, new_mask);
544
545 if (node_mask.as_span() == new_mask.as_span()) {
546 return false;
547 }
548
549 undo::push_node(depsgraph, object, &node, undo::Type::Mask);
550 scatter_data_grids(subdiv_ccg, new_mask.as_span(), grids, subdiv_ccg.masks.as_mutable_span());
552 return true;
553}
554
555BLI_NOINLINE static void copy_old_hidden_mask_bmesh(const int mask_offset,
556 const Set<BMVert *, 0> &verts,
557 const MutableSpan<float> new_mask)
558{
559 int i = 0;
560 for (const BMVert *vert : verts) {
562 new_mask[i] = BM_ELEM_CD_GET_FLOAT(vert, mask_offset);
563 }
564 i++;
565 }
566}
567
568static void apply_new_mask_bmesh(const Depsgraph &depsgraph,
569 Object &object,
570 const int mask_offset,
571 const IndexMask &node_mask,
572 const OffsetIndices<int> node_verts,
573 const Span<float> new_mask)
574{
575 SculptSession &ss = *object.runtime->sculpt_session;
578 BMesh &bm = *ss.bm;
579
580 Array<bool> node_changed(node_mask.min_array_size(), false);
581
582 node_mask.foreach_index(
583 [&](const int i, const int pos) {
585 const Span<float> new_node_mask = new_mask.slice(node_verts[pos]);
586 if (mask_equals_array_bmesh(mask_offset, verts, new_node_mask)) {
587 return;
588 }
589 undo::push_node(depsgraph, object, &nodes[i], undo::Type::Mask);
590 scatter_mask_bmesh(new_node_mask, bm, verts);
592 node_changed[i] = true;
593 },
595
596 IndexMaskMemory memory;
597 pbvh.tag_masks_changed(IndexMask::from_bools(node_changed, memory));
598}
599
600static void smooth_mask_bmesh(const BMesh &bm,
601 const int mask_offset,
603 FilterLocalData &tls,
604 MutableSpan<float> new_mask)
605{
607
608 tls.node_mask.resize(verts.size());
609 const MutableSpan<float> node_mask = tls.node_mask;
610 gather_mask_bmesh(bm, verts, node_mask);
611
612 average_neighbor_mask_bmesh(mask_offset, verts, new_mask);
613 mask::mix_new_masks(new_mask, 0.5f, node_mask);
614 copy_old_hidden_mask_bmesh(mask_offset, verts, node_mask);
615 mask::clamp_mask(node_mask);
616 new_mask.copy_from(node_mask);
617}
618
619static void sharpen_mask_bmesh(const BMesh &bm,
620 const int mask_offset,
622 FilterLocalData &tls,
623 MutableSpan<float> new_mask)
624{
626
627 tls.node_mask.resize(verts.size());
628 const MutableSpan<float> node_mask = tls.node_mask;
629 gather_mask_bmesh(bm, verts, node_mask);
630
631 average_neighbor_mask_bmesh(mask_offset, verts, new_mask);
632
633 sharpen_masks(node_mask, new_mask);
634
635 copy_old_hidden_mask_bmesh(mask_offset, verts, new_mask);
636}
637
638static void grow_mask_bmesh(const int mask_offset,
640 MutableSpan<float> new_mask)
641{
643
644 BMeshNeighborVerts neighbors;
645 int i = 0;
646 for (BMVert *vert : verts) {
647 new_mask[i] = BM_ELEM_CD_GET_FLOAT(vert, mask_offset);
648 for (const BMVert *neighbor : vert_neighbors_get_bmesh(*vert, neighbors)) {
649 new_mask[i] = std::max(BM_ELEM_CD_GET_FLOAT(neighbor, mask_offset), new_mask[i]);
650 }
651 i++;
652 }
653
654 copy_old_hidden_mask_bmesh(mask_offset, verts, new_mask);
655}
656
657static void shrink_mask_bmesh(const int mask_offset,
659 MutableSpan<float> new_mask)
660{
662
663 BMeshNeighborVerts neighbors;
664 int i = 0;
665 for (BMVert *vert : verts) {
666 new_mask[i] = BM_ELEM_CD_GET_FLOAT(vert, mask_offset);
667 for (const BMVert *neighbor : vert_neighbors_get_bmesh(*vert, neighbors)) {
668 new_mask[i] = std::min(BM_ELEM_CD_GET_FLOAT(neighbor, mask_offset), new_mask[i]);
669 }
670 i++;
671 }
672
673 copy_old_hidden_mask_bmesh(mask_offset, verts, new_mask);
674}
675
676static bool increase_contrast_mask_bmesh(const Depsgraph &depsgraph,
677 Object &object,
678 const int mask_offset,
680 FilterLocalData &tls)
681{
682 SculptSession &ss = *object.runtime->sculpt_session;
683 BMesh &bm = *ss.bm;
684
686
687 tls.node_mask.resize(verts.size());
688 const MutableSpan<float> node_mask = tls.node_mask;
689 gather_mask_bmesh(bm, verts, node_mask);
690
691 tls.new_mask.resize(verts.size());
692 const MutableSpan<float> new_mask = tls.new_mask;
693 mask_increase_contrast(node_mask, new_mask);
694
695 copy_old_hidden_mask_bmesh(mask_offset, verts, new_mask);
696
697 if (node_mask.as_span() == new_mask.as_span()) {
698 return false;
699 }
700
701 undo::push_node(depsgraph, object, &node, undo::Type::Mask);
702 scatter_mask_bmesh(new_mask.as_span(), bm, verts);
704 return true;
705}
706
707static bool decrease_contrast_mask_bmesh(const Depsgraph &depsgraph,
708 Object &object,
709 const int mask_offset,
711 FilterLocalData &tls)
712{
713 SculptSession &ss = *object.runtime->sculpt_session;
714 BMesh &bm = *ss.bm;
715
717
718 tls.node_mask.resize(verts.size());
719 const MutableSpan<float> node_mask = tls.node_mask;
720 gather_mask_bmesh(bm, verts, node_mask);
721
722 tls.new_mask.resize(verts.size());
723 const MutableSpan<float> new_mask = tls.new_mask;
724 mask_decrease_contrast(node_mask, new_mask);
725
726 copy_old_hidden_mask_bmesh(mask_offset, verts, new_mask);
727
728 if (node_mask.as_span() == new_mask.as_span()) {
729 return false;
730 }
731
732 undo::push_node(depsgraph, object, &node, undo::Type::Mask);
733 scatter_mask_bmesh(new_mask.as_span(), bm, verts);
735 return true;
736}
737
739{
740 const Scene &scene = *CTX_data_scene(C);
742 Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
743 const FilterType filter_type = FilterType(RNA_enum_get(op->ptr, "filter_type"));
744
745 const View3D *v3d = CTX_wm_view3d(C);
746 const Base *base = CTX_data_active_base(C);
747 if (!BKE_base_is_visible(v3d, base)) {
748 return OPERATOR_CANCELLED;
749 }
750
753
755
756 BKE_sculptsession_update_for_edit(depsgraph, &ob, false);
757
760
761 IndexMaskMemory memory;
762 const IndexMask node_mask = bke::pbvh::all_leaf_nodes(pbvh, memory);
763 undo::push_begin(scene, ob, op);
764
765 int iterations = RNA_int_get(op->ptr, "iterations");
766
767 /* Auto iteration count calculates the number of iteration based on the vertices of the mesh to
768 * avoid adding an unnecessary amount of undo steps when using the operator from a shortcut.
769 * One iteration per 50000 vertices in the mesh should be fine in most cases.
770 * Maybe we want this to be configurable. */
771 if (RNA_boolean_get(op->ptr, "auto_iteration_count")) {
772 iterations = int(vertex_count_get(ob) / 50000.0f) + 1;
773 }
774
776 switch (pbvh.type()) {
779 Mesh &mesh = *id_cast<Mesh *>(ob.data);
780 const OffsetIndices<int> faces = mesh.faces();
781 const Span<int> corner_verts = mesh.corner_verts();
782 const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
783 bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
784 const VArraySpan hide_vert = *attributes.lookup<bool>(".hide_vert", bke::AttrDomain::Point);
785 const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
786 bke::SpanAttributeWriter mask = attributes.lookup_for_write_span<float>(".sculpt_mask");
787
788 Array<int> node_vert_offset_data;
790 nodes, node_mask, node_vert_offset_data);
791 Array<float> new_masks(node_offsets.total_size());
792
793 for ([[maybe_unused]] const int iteration : IndexRange(iterations)) {
794 switch (filter_type) {
795 case FilterType::Smooth: {
796 node_mask.foreach_index(
797 [&](const int i, const int pos) {
798 FilterLocalData &tls = all_tls.local();
799 smooth_mask_mesh(faces,
800 corner_verts,
801 vert_to_face_map,
802 hide_poly,
803 hide_vert,
804 mask.span,
805 nodes[i],
806 tls,
807 new_masks.as_mutable_span().slice(node_offsets[pos]));
808 },
810 apply_new_mask_mesh(*depsgraph, ob, node_mask, node_offsets, new_masks, mask.span);
811 break;
812 }
813 case FilterType::Sharpen: {
814 node_mask.foreach_index(
815 [&](const int i, const int pos) {
816 FilterLocalData &tls = all_tls.local();
817 sharpen_mask_mesh(faces,
818 corner_verts,
819 vert_to_face_map,
820 hide_poly,
821 hide_vert,
822 mask.span,
823 nodes[i],
824 tls,
825 new_masks.as_mutable_span().slice(node_offsets[pos]));
826 },
828 apply_new_mask_mesh(*depsgraph, ob, node_mask, node_offsets, new_masks, mask.span);
829 break;
830 }
831 case FilterType::Grow: {
832 node_mask.foreach_index(
833 [&](const int i, const int pos) {
834 FilterLocalData &tls = all_tls.local();
835 grow_mask_mesh(faces,
836 corner_verts,
837 vert_to_face_map,
838 hide_poly,
839 hide_vert,
840 mask.span,
841 nodes[i],
842 tls,
843 new_masks.as_mutable_span().slice(node_offsets[pos]));
844 },
846 apply_new_mask_mesh(*depsgraph, ob, node_mask, node_offsets, new_masks, mask.span);
847 break;
848 }
849 case FilterType::Shrink: {
850 node_mask.foreach_index(
851 [&](const int i, const int pos) {
852 FilterLocalData &tls = all_tls.local();
853 shrink_mask_mesh(faces,
854 corner_verts,
855 vert_to_face_map,
856 hide_poly,
857 hide_vert,
858 mask.span,
859 nodes[i],
860 tls,
861 new_masks.as_mutable_span().slice(node_offsets[pos]));
862 },
864 apply_new_mask_mesh(*depsgraph, ob, node_mask, node_offsets, new_masks, mask.span);
865 break;
866 }
868 Array<bool> node_changed(node_mask.min_array_size(), false);
869 node_mask.foreach_index(
870 [&](const int i) {
871 node_changed[i] = increase_contrast_mask_mesh(
872 *depsgraph, ob, hide_vert, nodes[i], mask.span);
873 },
875 IndexMaskMemory memory;
876 pbvh.tag_masks_changed(IndexMask::from_bools(node_changed, memory));
877 break;
878 }
880 Array<bool> node_changed(node_mask.min_array_size(), false);
881 node_mask.foreach_index(
882 [&](const int i) {
883 node_changed[i] = decrease_contrast_mask_mesh(
884 *depsgraph, ob, hide_vert, nodes[i], mask.span);
885 },
887 IndexMaskMemory memory;
888 pbvh.tag_masks_changed(IndexMask::from_bools(node_changed, memory));
889 break;
890 }
891 }
892 }
893 mask.finish();
894 break;
895 }
898 SubdivCCG &subdiv_ccg = *ss.subdiv_ccg;
899
900 Array<int> node_vert_offset_data;
902 BKE_subdiv_ccg_key_top_level(subdiv_ccg), nodes, node_mask, node_vert_offset_data);
903 Array<float> new_masks(node_offsets.total_size());
904
905 for ([[maybe_unused]] const int iteration : IndexRange(iterations)) {
906 switch (filter_type) {
907 case FilterType::Smooth: {
908 node_mask.foreach_index(
909 [&](const int i, const int pos) {
910 FilterLocalData &tls = all_tls.local();
911 smooth_mask_grids(subdiv_ccg,
912 nodes[i],
913 tls,
914 new_masks.as_mutable_span().slice(node_offsets[pos]));
915 },
917 apply_new_mask_grids(*depsgraph, ob, node_mask, node_offsets, new_masks);
918 break;
919 }
920 case FilterType::Sharpen: {
921 node_mask.foreach_index(
922 [&](const int i, const int pos) {
923 FilterLocalData &tls = all_tls.local();
924 sharpen_mask_grids(subdiv_ccg,
925 nodes[i],
926 tls,
927 new_masks.as_mutable_span().slice(node_offsets[pos]));
928 },
930 apply_new_mask_grids(*depsgraph, ob, node_mask, node_offsets, new_masks);
931 break;
932 }
933 case FilterType::Grow: {
934 node_mask.foreach_index(
935 [&](const int i, const int pos) {
937 subdiv_ccg, nodes[i], new_masks.as_mutable_span().slice(node_offsets[pos]));
938 },
940 apply_new_mask_grids(*depsgraph, ob, node_mask, node_offsets, new_masks);
941 break;
942 }
943 case FilterType::Shrink: {
944 node_mask.foreach_index(
945 [&](const int i, const int pos) {
947 subdiv_ccg, nodes[i], new_masks.as_mutable_span().slice(node_offsets[pos]));
948 },
950 apply_new_mask_grids(*depsgraph, ob, node_mask, node_offsets, new_masks);
951 break;
952 }
954 Array<bool> node_changed(node_mask.min_array_size(), false);
955 node_mask.foreach_index(
956 [&](const int i) {
957 FilterLocalData &tls = all_tls.local();
958 node_changed[i] = increase_contrast_mask_grids(*depsgraph, ob, nodes[i], tls);
959 },
961 IndexMaskMemory memory;
962 pbvh.tag_masks_changed(IndexMask::from_bools(node_changed, memory));
963 break;
964 }
966 Array<bool> node_changed(node_mask.min_array_size(), false);
967 node_mask.foreach_index(
968 [&](const int i) {
969 FilterLocalData &tls = all_tls.local();
970 node_changed[i] = decrease_contrast_mask_grids(*depsgraph, ob, nodes[i], tls);
971 },
973 IndexMaskMemory memory;
974 pbvh.tag_masks_changed(IndexMask::from_bools(node_changed, memory));
975 break;
976 }
977 }
978 }
979 break;
980 }
983 BMesh &bm = *ss.bm;
985 const int mask_offset = CustomData_get_offset_named(
986 &bm.vdata, CD_PROP_FLOAT, ".sculpt_mask");
987
988 Array<int> node_vert_offset_data;
990 nodes, node_mask, node_vert_offset_data);
991 Array<float> new_masks(node_offsets.total_size());
992
993 for ([[maybe_unused]] const int iteration : IndexRange(iterations)) {
994 switch (filter_type) {
995 case FilterType::Smooth: {
996 node_mask.foreach_index(
997 [&](const int i, const int pos) {
998 FilterLocalData &tls = all_tls.local();
1000 mask_offset,
1001 nodes[i],
1002 tls,
1003 new_masks.as_mutable_span().slice(node_offsets[pos]));
1004 },
1006 apply_new_mask_bmesh(*depsgraph, ob, mask_offset, node_mask, node_offsets, new_masks);
1007 break;
1008 }
1009 case FilterType::Sharpen: {
1010 node_mask.foreach_index(
1011 [&](const int i, const int pos) {
1012 FilterLocalData &tls = all_tls.local();
1014 mask_offset,
1015 nodes[i],
1016 tls,
1017 new_masks.as_mutable_span().slice(node_offsets[pos]));
1018 },
1020 apply_new_mask_bmesh(*depsgraph, ob, mask_offset, node_mask, node_offsets, new_masks);
1021 break;
1022 }
1023 case FilterType::Grow: {
1024 node_mask.foreach_index(
1025 [&](const int i, const int pos) {
1027 mask_offset, nodes[i], new_masks.as_mutable_span().slice(node_offsets[pos]));
1028 },
1030 apply_new_mask_bmesh(*depsgraph, ob, mask_offset, node_mask, node_offsets, new_masks);
1031 break;
1032 }
1033 case FilterType::Shrink: {
1034 node_mask.foreach_index(
1035 [&](const int i, const int pos) {
1037 mask_offset, nodes[i], new_masks.as_mutable_span().slice(node_offsets[pos]));
1038 },
1040 apply_new_mask_bmesh(*depsgraph, ob, mask_offset, node_mask, node_offsets, new_masks);
1041 break;
1042 }
1044 Array<bool> node_changed(node_mask.min_array_size(), false);
1045 node_mask.foreach_index(
1046 [&](const int i) {
1047 FilterLocalData &tls = all_tls.local();
1048 node_changed[i] = increase_contrast_mask_bmesh(
1049 *depsgraph, ob, mask_offset, nodes[i], tls);
1050 },
1052 IndexMaskMemory memory;
1053 pbvh.tag_masks_changed(IndexMask::from_bools(node_changed, memory));
1054 break;
1055 }
1057 Array<bool> node_changed(node_mask.min_array_size(), false);
1058 node_mask.foreach_index(
1059 [&](const int i) {
1060 FilterLocalData &tls = all_tls.local();
1061 node_changed[i] = decrease_contrast_mask_bmesh(
1062 *depsgraph, ob, mask_offset, nodes[i], tls);
1063 },
1065 IndexMaskMemory memory;
1066 pbvh.tag_masks_changed(IndexMask::from_bools(node_changed, memory));
1067 break;
1068 }
1069 }
1070 }
1071 break;
1072 }
1073 }
1074
1075 undo::push_end(ob);
1076
1079
1081
1082 return OPERATOR_FINISHED;
1083}
1084
1086{
1087 ot->name = "Mask Filter";
1088 ot->idname = "SCULPT_OT_mask_filter";
1089 ot->description = "Applies a filter to modify the current mask";
1090
1092 ot->poll = sculpt_mode_poll;
1093
1095
1096 static EnumPropertyItem type_items[] = {
1097 {int(FilterType::Smooth), "SMOOTH", 0, "Smooth Mask", ""},
1098 {int(FilterType::Sharpen), "SHARPEN", 0, "Sharpen Mask", ""},
1099 {int(FilterType::Grow), "GROW", 0, "Grow Mask", ""},
1100 {int(FilterType::Shrink), "SHRINK", 0, "Shrink Mask", ""},
1101 {int(FilterType::ContrastIncrease), "CONTRAST_INCREASE", 0, "Increase Contrast", ""},
1102 {int(FilterType::ContrastDecrease), "CONTRAST_DECREASE", 0, "Decrease Contrast", ""},
1103 {0, nullptr, 0, nullptr, nullptr},
1104 };
1105
1106 RNA_def_enum(ot->srna,
1107 "filter_type",
1108 type_items,
1109 int(FilterType::Smooth),
1110 "Type",
1111 "Filter that is going to be applied to the mask");
1112 RNA_def_int(ot->srna,
1113 "iterations",
1114 1,
1115 1,
1116 100,
1117 "Iterations",
1118 "Number of times that the filter is going to be applied",
1119 1,
1120 100);
1122 ot->srna,
1123 "auto_iteration_count",
1124 true,
1125 "Auto Iteration Count",
1126 "Use an automatic number of iterations based on the number of vertices of the sculpt");
1127}
1128
1129} // namespace blender::ed::sculpt_paint::mask
A BVH for high poly meshes.
#define C
Definition RandGen.cpp:29
#define BLI_NOINLINE
#define BM_ELEM_CD_GET_FLOAT(ele, offset)
#define BM_elem_flag_test(ele, hflag)
Span< T > as_span() const
Definition BLI_array.hh:254
MutableSpan< T > as_mutable_span()
Definition BLI_array.hh:259
static IndexMask from_bools(Span< bool > bools, LinearAllocator<> &memory)
constexpr IndexRange()=default
constexpr int64_t size() const
Definition BLI_span.hh:499
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
Definition BLI_span.hh:579
constexpr Span< T > as_span() const
Definition BLI_span.hh:667
constexpr void copy_from(Span< T > values) const
Definition BLI_span.hh:745
int64_t size() const
Definition BLI_set.hh:606
constexpr Span slice(int64_t start, int64_t size) const
Definition BLI_span.hh:141
constexpr int64_t size() const
Definition BLI_span.hh:256
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
constexpr bool is_empty() const
Definition BLI_span.hh:264
GAttributeReader lookup(const StringRef name) const
GSpanAttributeWriter lookup_for_write_span(StringRef name)
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
bool indexed_data_equal(const Span< T > all_values, const Span< int > indices, const Span< T > values)
void foreach_1_index(const BitSpanT &data, Fn &&fn)
IndexRange grid_range(const int grid_area, const int grid)
pbvh::Tree * pbvh_get(Object &object)
IndexMask all_leaf_nodes(const Tree &pbvh, IndexMaskMemory &memory)
Definition pbvh.cc:2522
void node_update_mask_bmesh(int mask_offset, BMeshNode &node)
Definition pbvh.cc:1404
void node_update_mask_mesh(Span< float > mask, MeshNode &node)
Definition pbvh.cc:1345
void node_update_mask_grids(const CCGKey &key, Span< float > masks, GridsNode &node)
Definition pbvh.cc:1373
Span< int > node_visible_verts(const bke::pbvh::MeshNode &node, const Span< bool > hide_vert, Vector< int, bke::pbvh::MESH_LEAF_LIMIT > &indices)
static BLI_NOINLINE void copy_old_hidden_mask_mesh(const Span< int > verts, const Span< bool > hide_vert, const Span< float > mask, const MutableSpan< float > new_mask)
bool mask_equals_array_bmesh(const int mask_offset, const Set< BMVert *, 0 > &verts, const Span< float > values)
static BLI_NOINLINE void multiply_add(const Span< float > src, const float factor, const float offset, const MutableSpan< float > dst)
static void grow_mask_bmesh(const int mask_offset, bke::pbvh::BMeshNode &node, MutableSpan< float > new_mask)
void SCULPT_OT_mask_filter(wmOperatorType *ot)
static void smooth_mask_mesh(const OffsetIndices< int > faces, const Span< int > corner_verts, const GroupedSpan< int > vert_to_face, const Span< bool > hide_poly, const Span< bool > hide_vert, const Span< float > mask, const bke::pbvh::MeshNode &node, FilterLocalData &tls, MutableSpan< float > new_mask)
static void grow_mask_mesh(const OffsetIndices< int > faces, const Span< int > corner_verts, const GroupedSpan< int > vert_to_face, const Span< bool > hide_poly, const Span< bool > hide_vert, const Span< float > mask, const bke::pbvh::MeshNode &node, FilterLocalData &tls, MutableSpan< float > new_mask)
bool mask_equals_array_grids(const Span< float > masks, const CCGKey &key, const Span< int > grids, const Span< float > values)
static void shrink_mask_bmesh(const int mask_offset, bke::pbvh::BMeshNode &node, MutableSpan< float > new_mask)
static void sharpen_mask_bmesh(const BMesh &bm, const int mask_offset, bke::pbvh::BMeshNode &node, FilterLocalData &tls, MutableSpan< float > new_mask)
static bool increase_contrast_mask_grids(const Depsgraph &depsgraph, const Object &object, bke::pbvh::GridsNode &node, FilterLocalData &tls)
static bool decrease_contrast_mask_mesh(const Depsgraph &depsgraph, const Object &object, const Span< bool > hide_vert, bke::pbvh::MeshNode &node, MutableSpan< float > mask)
static bool decrease_contrast_mask_grids(const Depsgraph &depsgraph, const Object &object, bke::pbvh::GridsNode &node, FilterLocalData &tls)
static bool decrease_contrast_mask_bmesh(const Depsgraph &depsgraph, Object &object, const int mask_offset, bke::pbvh::BMeshNode &node, FilterLocalData &tls)
static void smooth_mask_grids(const SubdivCCG &subdiv_ccg, const bke::pbvh::GridsNode &node, FilterLocalData &tls, MutableSpan< float > new_mask)
static void sharpen_mask_mesh(const OffsetIndices< int > faces, const Span< int > corner_verts, const GroupedSpan< int > vert_to_face, const Span< bool > hide_poly, const Span< bool > hide_vert, const Span< float > mask, const bke::pbvh::MeshNode &node, FilterLocalData &tls, MutableSpan< float > new_mask)
static void apply_new_mask_grids(const Depsgraph &depsgraph, Object &object, const IndexMask &node_mask, const OffsetIndices< int > node_verts, const Span< float > new_mask)
static bool increase_contrast_mask_bmesh(const Depsgraph &depsgraph, Object &object, const int mask_offset, bke::pbvh::BMeshNode &node, FilterLocalData &tls)
static void shrink_mask_mesh(const OffsetIndices< int > faces, const Span< int > corner_verts, const GroupedSpan< int > vert_to_face, const Span< bool > hide_poly, const Span< bool > hide_vert, const Span< float > mask, const bke::pbvh::MeshNode &node, FilterLocalData &tls, MutableSpan< float > new_mask)
static BLI_NOINLINE void sharpen_masks(const Span< float > old_masks, const MutableSpan< float > new_mask)
void scatter_mask_bmesh(const Span< float > mask, const BMesh &bm, const Set< BMVert *, 0 > &verts)
void gather_mask_bmesh(const BMesh &bm, const Set< BMVert *, 0 > &verts, const MutableSpan< float > r_mask)
void mix_new_masks(const Span< float > new_masks, const float factor, const MutableSpan< float > masks)
Definition paint_mask.cc:96
static void smooth_mask_bmesh(const BMesh &bm, const int mask_offset, bke::pbvh::BMeshNode &node, FilterLocalData &tls, MutableSpan< float > new_mask)
static void shrink_mask_grids(const SubdivCCG &subdiv_ccg, const bke::pbvh::GridsNode &node, MutableSpan< float > new_mask)
static void apply_new_mask_mesh(const Depsgraph &depsgraph, Object &object, const IndexMask &node_mask, const OffsetIndices< int > node_verts, const Span< float > new_mask, MutableSpan< float > mask)
static wmOperatorStatus sculpt_mask_filter_exec(bContext *C, wmOperator *op)
static BLI_NOINLINE void mask_increase_contrast(const Span< float > src, const MutableSpan< float > dst)
static BLI_NOINLINE void mask_decrease_contrast(const Span< float > src, const MutableSpan< float > dst)
static void apply_new_mask_bmesh(const Depsgraph &depsgraph, Object &object, const int mask_offset, const IndexMask &node_mask, const OffsetIndices< int > node_verts, const Span< float > new_mask)
static void sharpen_mask_grids(const SubdivCCG &subdiv_ccg, const bke::pbvh::GridsNode &node, FilterLocalData &tls, MutableSpan< float > new_mask)
static void grow_mask_grids(const SubdivCCG &subdiv_ccg, const bke::pbvh::GridsNode &node, MutableSpan< float > new_mask)
static bool increase_contrast_mask_mesh(const Depsgraph &depsgraph, const Object &object, const Span< bool > hide_vert, bke::pbvh::MeshNode &node, MutableSpan< float > mask)
static BLI_NOINLINE void copy_old_hidden_mask_bmesh(const int mask_offset, const Set< BMVert *, 0 > &verts, const MutableSpan< float > new_mask)
void clamp_mask(const MutableSpan< float > masks)
void average_neighbor_mask_bmesh(const int mask_offset, const Set< BMVert *, 0 > &verts, const MutableSpan< float > new_masks)
static BLI_NOINLINE void copy_old_hidden_mask_grids(const SubdivCCG &subdiv_ccg, const Span< int > grids, const MutableSpan< float > new_mask)
void neighbor_data_average_mesh(const Span< T > src, const GroupedSpan< int > vert_neighbors, const MutableSpan< T > dst)
void average_data_grids(const SubdivCCG &subdiv_ccg, const Span< T > src, const Span< int > grids, const MutableSpan< T > dst)
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 gather_data_grids(const SubdivCCG &subdiv_ccg, Span< T > src, Span< int > grids, MutableSpan< T > node_data)
Definition sculpt.cc:6528
void vert_random_access_ensure(Object &object)
Definition sculpt.cc:154
GroupedSpan< int > calc_vert_neighbors(OffsetIndices< int > faces, Span< int > corner_verts, GroupedSpan< int > vert_to_face, Span< bool > hide_poly, Span< int > verts, Vector< int > &r_offset_data, Vector< int > &r_data)
Definition sculpt.cc:7949
Vector< BMVert *, 64 > BMeshNeighborVerts
int vertex_count_get(const Object &object)
Definition sculpt.cc:163
bool sculpt_mode_poll(bContext *C)
Definition sculpt.cc:3800
void scatter_data_mesh(Span< T > src, Span< int > indices, MutableSpan< T > dst)
OffsetIndices< int > create_node_vert_offsets(Span< bke::pbvh::MeshNode > nodes, const IndexMask &node_mask, Array< int > &node_data)
Definition sculpt.cc:7912
Span< BMVert * > vert_neighbors_get_bmesh(BMVert &vert, BMeshNeighborVerts &r_neighbors)
Definition sculpt.cc:490
void flush_update_step(bContext *C, const UpdateType update_type)
Definition sculpt.cc:5090
void gather_data_mesh(Span< T > src, Span< int > indices, MutableSpan< T > dst)
void flush_update_done(bContext *C, Object &ob, const UpdateType update_type)
Definition sculpt.cc:5131
void mask_overlay_check(bContext &C, wmOperator &op)
Definition sculpt.cc:8298
void scatter_data_grids(const SubdivCCG &subdiv_ccg, Span< T > node_data, Span< int > grids, MutableSpan< T > dst)
Definition sculpt.cc:6560
OffsetIndices< int > create_node_vert_offsets_bmesh(Span< bke::pbvh::BMeshNode > nodes, const IndexMask &node_mask, Array< int > &node_data)
Definition sculpt.cc:7936
void tag_update_overlays(bContext *C)
Definition sculpt.cc:895
constexpr ParallelGrainSize grain_size(int grain_size)
T rcp(const T &a)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
int RNA_enum_get(PointerRNA *ptr, const char *name)
MultiresModifierData * BKE_sculpt_multires_active(const Scene *scene, Object *ob)
bool BKE_base_is_visible(const View3D *v3d, const Base *base)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
int RNA_int_get(PointerRNA *ptr, const char *name)
void BKE_subdiv_ccg_average_grids(SubdivCCG &subdiv_ccg)
Base * CTX_data_active_base(const bContext *C)
void BKE_sculpt_mask_layers_ensure(Depsgraph *depsgraph, Main *bmain, Object *ob, MultiresModifierData *mmd)
CCGKey BKE_subdiv_ccg_key_top_level(const SubdivCCG &subdiv_ccg)
void BKE_subdiv_ccg_neighbor_coords_get(const SubdivCCG &subdiv_ccg, const SubdivCCGCoord &coord, bool include_duplicates, SubdivCCGNeighbors &r_neighbors)
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, StringRef name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int CCG_grid_xy_to_index(const int grid_size, const int x, const int y)
Definition BKE_ccg.hh:75
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)
Main * CTX_data_main(const bContext *C)
void BKE_sculptsession_update_for_edit(Depsgraph *depsgraph, Object *ob_orig, bool is_paint_tool)
Scene * CTX_data_scene(const bContext *C)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
Object * CTX_data_active_object(const bContext *C)
const Set< BMVert *, 0 > & BKE_pbvh_bmesh_node_unique_verts(bke::pbvh::BMeshNode *node)
View3D * CTX_wm_view3d(const bContext *C)
CustomData vdata
bke::ObjectRuntime * runtime
int to_index(const CCGKey &key) const
SubdivCCGNeighborCoords coords
BitGroupVector grid_hidden
Array< float > masks
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
void resize(int new_size)
Definition vector.hh:94