Blender V5.3
editface.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
10#include "BLI_math_matrix_c.hh"
11#include "BLI_math_vector.hh"
12#include "BLI_math_vector_c.hh"
13#include "BLI_task.hh"
14#include "BLI_vector_set.hh"
15
16#include "DNA_mesh_types.h"
17#include "DNA_meshdata_types.h"
18#include "DNA_object_types.h"
19
20#include "BKE_attribute.hh"
21#include "BKE_context.hh"
22#include "BKE_customdata.hh"
23#include "BKE_mesh.hh"
24#include "BKE_mesh_mapping.hh"
25#include "BKE_object.hh"
26
27#include "ED_mesh.hh"
28#include "ED_screen.hh"
29#include "ED_select_utils.hh"
30#include "ED_view3d.hh"
31
32#include "WM_api.hh"
33#include "WM_types.hh"
34
35#include "DEG_depsgraph.hh"
37
38namespace blender {
39
40/* own include */
41
43 Object *ob,
44 const bool flush_selection,
45 const bool flush_hidden)
46{
48 const int *index_array = nullptr;
49
50 BLI_assert(flush_selection || flush_hidden);
51
52 if (mesh == nullptr) {
53 return;
54 }
55
56 /* NOTE: call #BKE_mesh_flush_hidden_from_verts_ex first when changing hidden flags. */
57
58 /* we could call this directly in all areas that change selection,
59 * since this could become slow for realtime updates (circle-select for eg) */
60 if (flush_selection) {
62 }
63
64 Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
65 Object *ob_eval = DEG_get_evaluated(depsgraph, ob);
66
67 if (ob_eval == nullptr) {
68 return;
69 }
70
71 bke::AttributeAccessor attributes_me = mesh->attributes();
72 Mesh *me_orig = id_cast<Mesh *>(ob_eval->runtime->data_orig);
73 bke::MutableAttributeAccessor attributes_orig = me_orig->attributes_for_write();
74 Mesh *mesh_eval = id_cast<Mesh *>(ob_eval->runtime->data_eval);
75 bke::MutableAttributeAccessor attributes_eval = mesh_eval->attributes_for_write();
76 bool updated = false;
77
78 if (me_orig != nullptr && mesh_eval != nullptr && me_orig->faces_num == mesh->faces_num) {
79 /* Update the evaluated copy of the mesh. */
80 if (flush_hidden) {
81 const VArray<bool> hide_poly_me = *attributes_me.lookup_or_default<bool>(
82 ".hide_poly", bke::AttrDomain::Face, false);
83 bke::SpanAttributeWriter<bool> hide_poly_orig =
84 attributes_orig.lookup_or_add_for_write_only_span<bool>(".hide_poly",
86 hide_poly_me.materialize(hide_poly_orig.span);
87 hide_poly_orig.finish();
88 }
89 if (flush_selection) {
90 const VArray<bool> select_poly_me = *attributes_me.lookup_or_default<bool>(
91 ".select_poly", bke::AttrDomain::Face, false);
92 bke::SpanAttributeWriter<bool> select_poly_orig =
93 attributes_orig.lookup_or_add_for_write_only_span<bool>(".select_poly",
95 select_poly_me.materialize(select_poly_orig.span);
96 select_poly_orig.finish();
97 }
98
99 /* Mesh faces => Final derived faces */
100 if ((index_array = static_cast<const int *>(
102 {
103 if (flush_hidden) {
104 const VArray<bool> hide_poly_orig = *attributes_orig.lookup_or_default<bool>(
105 ".hide_poly", bke::AttrDomain::Face, false);
106 bke::SpanAttributeWriter<bool> hide_poly_eval =
107 attributes_eval.lookup_or_add_for_write_only_span<bool>(".hide_poly",
109 for (const int i : IndexRange(mesh_eval->faces_num)) {
110 const int orig_face_index = index_array[i];
111 if (orig_face_index != ORIGINDEX_NONE) {
112 hide_poly_eval.span[i] = hide_poly_orig[orig_face_index];
113 }
114 }
115 hide_poly_eval.finish();
116 }
117 if (flush_selection) {
118 const VArray<bool> select_poly_orig = *attributes_orig.lookup_or_default<bool>(
119 ".select_poly", bke::AttrDomain::Face, false);
120 bke::SpanAttributeWriter<bool> select_poly_eval =
121 attributes_eval.lookup_or_add_for_write_only_span<bool>(".select_poly",
123 for (const int i : IndexRange(mesh_eval->faces_num)) {
124 const int orig_face_index = index_array[i];
125 if (orig_face_index != ORIGINDEX_NONE) {
126 select_poly_eval.span[i] = select_poly_orig[orig_face_index];
127 }
128 }
129 select_poly_eval.finish();
130 }
131
132 updated = true;
133 }
134 }
135
136 if (updated) {
137 if (flush_hidden) {
139 }
140 else {
142 }
143
145 }
146 else {
148 }
149
151}
152
153void paintface_hide(bContext *C, Object *ob, const bool unselected)
154{
156 if (mesh == nullptr || mesh->faces_num == 0) {
157 return;
158 }
159
160 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
162 ".hide_poly", bke::AttrDomain::Face);
164 ".select_poly", bke::AttrDomain::Face);
165
166 for (int i = 0; i < mesh->faces_num; i++) {
167 if (!hide_poly.span[i]) {
168 if (!select_poly.span[i] == unselected) {
169 hide_poly.span[i] = true;
170 }
171 }
172
173 if (hide_poly.span[i]) {
174 select_poly.span[i] = false;
175 }
176 }
177
178 hide_poly.finish();
179 select_poly.finish();
180
182
183 paintface_flush_flags(C, ob, true, true);
184}
185
186void paintface_reveal(bContext *C, Object *ob, const bool select)
187{
189 if (mesh == nullptr || mesh->faces_num == 0) {
190 return;
191 }
192
193 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
194
195 if (select) {
196 const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
197 ".hide_poly", bke::AttrDomain::Face, false);
199 ".select_poly", bke::AttrDomain::Face);
200 for (const int i : hide_poly.index_range()) {
201 if (hide_poly[i]) {
202 select_poly.span[i] = true;
203 }
204 }
205 select_poly.finish();
206 }
207
208 attributes.remove(".hide_poly");
209
211
212 paintface_flush_flags(C, ob, true, true);
213}
214
222 Mesh &mesh,
223 const bool skip_seams = true)
224{
225 const OffsetIndices faces = mesh.faces();
226 const Span<int> corner_edges = mesh.corner_edges();
227
228 const bke::AttributeAccessor attributes = mesh.attributes();
229 const VArray<bool> uv_seams = *attributes.lookup_or_default<bool>(
230 "uv_seam", bke::AttrDomain::Edge, false);
231 const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
232 ".hide_poly", bke::AttrDomain::Face, false);
233
234 /* Faces are connected if they share edges. By connecting all edges of a loop (as long as they
235 * are not a seam) we can find connected faces. */
236 threading::parallel_for(faces.index_range(), 1024, [&](const IndexRange range) {
237 for (const int face_index : range) {
238 if (hide_poly[face_index]) {
239 continue;
240 }
241 const Span<int> face_edges = corner_edges.slice(faces[face_index]);
242
243 for (const int poly_loop_index : face_edges.index_range()) {
244 const int outer_edge = face_edges[poly_loop_index];
245 if (skip_seams && uv_seams[outer_edge]) {
246 continue;
247 }
248
249 for (const int inner_edge :
250 face_edges.slice(poly_loop_index, face_edges.size() - poly_loop_index))
251 {
252 if (outer_edge == inner_edge) {
253 continue;
254 }
255 if (skip_seams && uv_seams[inner_edge]) {
256 continue;
257 }
258 islands.join(inner_edge, outer_edge);
259 }
260 }
261 }
262 });
263}
264
265/* Select faces connected to the given face_indices. Seams are treated as separation. */
267 const Span<int> face_indices,
268 const bool select)
269{
270 AtomicDisjointSet islands(mesh.edges_num);
272
273 const OffsetIndices faces = mesh.faces();
274 const Span<int> corner_edges = mesh.corner_edges();
275
276 bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
277 const VArray<bool> uv_seams = *attributes.lookup_or_default<bool>(
278 "uv_seam", bke::AttrDomain::Edge, false);
280 ".select_poly", bke::AttrDomain::Face);
281
282 Set<int> selected_roots;
283 for (const int i : face_indices) {
284 for (const int edge : corner_edges.slice(faces[i])) {
285 if (uv_seams[edge]) {
286 continue;
287 }
288 const int root = islands.find_root(edge);
289 selected_roots.add(root);
290 }
291 }
292
293 threading::parallel_for(select_poly.span.index_range(), 1024, [&](const IndexRange range) {
294 for (const int face_index : range) {
295 for (const int edge : corner_edges.slice(faces[face_index])) {
296 const int root = islands.find_root(edge);
297 if (selected_roots.contains(root)) {
298 select_poly.span[face_index] = select;
299 break;
300 }
301 }
302 }
303 });
304
305 select_poly.finish();
306}
307
308void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const bool select)
309{
311 if (mesh == nullptr || mesh->faces_num == 0) {
312 return;
313 }
314
315 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
317 ".select_poly", bke::AttrDomain::Face);
318
319 Vector<int> indices;
320 if (mval) {
321 uint index = uint(-1);
323 select_poly.finish();
324 return;
325 }
326 /* Since paintface_select_linked_faces might not select the face under the cursor, select it
327 * here. */
328 select_poly.span[index] = true;
329 indices.append(index);
330 }
331
332 else {
333 for (const int i : select_poly.span.index_range()) {
334 if (!select_poly.span[i]) {
335 continue;
336 }
337 indices.append(i);
338 }
339 }
340
341 select_poly.finish();
342
344 paintface_flush_flags(C, ob, true, false);
345}
346
348 const Span<int> corner_edges,
349 const int current_edge_index)
350{
351 const int index_in_poly = corner_edges.slice(face).first_index(current_edge_index);
352 /* Assumes that edge index of opposing face edge is always off by 2 on quads. */
353 if (index_in_poly >= 2) {
354 return corner_edges[face[index_in_poly - 2]];
355 }
356 /* Cannot be out of bounds because of the preceding if statement: if i < 2 then i+2 < 4. */
357 return corner_edges[face[index_in_poly + 2]];
358}
359
364static bool follow_face_loop(const int face_start_index,
365 const int edge_start_index,
366 const OffsetIndices<int> faces,
367 const VArray<bool> &hide_poly,
368 const Span<int> corner_edges,
369 const GroupedSpan<int> edge_to_face_map,
370 VectorSet<int> &r_loop_faces)
371{
372 int current_face_index = face_start_index;
373 int current_edge_index = edge_start_index;
374
375 while (current_edge_index > 0) {
376 int next_face_index = -1;
377
378 for (const int face_index : edge_to_face_map[current_edge_index]) {
379 if (face_index != current_face_index) {
380 next_face_index = face_index;
381 break;
382 }
383 }
384
385 /* Edge might only have 1 face connected. */
386 if (next_face_index == -1) {
387 return false;
388 }
389
390 /* Only works on quads. */
391 if (faces[next_face_index].size() != 4) {
392 return false;
393 }
394
395 /* Happens if we looped around the mesh. */
396 if (r_loop_faces.contains(next_face_index)) {
397 return true;
398 }
399
400 /* Hidden faces stop selection. */
401 if (hide_poly[next_face_index]) {
402 return false;
403 }
404
405 r_loop_faces.add(next_face_index);
406
407 const IndexRange next_face = faces[next_face_index];
408 current_edge_index = get_opposing_edge_index(next_face, corner_edges, current_edge_index);
409 current_face_index = next_face_index;
410 }
411 return false;
412}
413
414void paintface_select_loop(bContext *C, Object *ob, const int mval[2], const bool select)
415{
416 Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
419
420 Object *ob_eval = DEG_get_evaluated(depsgraph, ob);
421 if (!ob_eval) {
422 return;
423 }
424
425 uint closest_edge_index = uint(-1);
426 if (!ED_mesh_pick_edge(C, ob, mval, ED_MESH_PICK_DEFAULT_VERT_DIST, &closest_edge_index)) {
427 return;
428 }
429
430 if (closest_edge_index == -1) {
431 return;
432 }
433
434 ARegion *region = CTX_wm_region(C);
435 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
436 ED_view3d_init_mats_rv3d(ob_eval, rv3d);
437
439 const Span<int> corner_edges = mesh->corner_edges();
440 const OffsetIndices faces = mesh->faces();
441
442 Array<int> edge_to_face_offsets;
443 Array<int> edge_to_face_indices;
445 faces, corner_edges, mesh->edges_num, edge_to_face_offsets, edge_to_face_indices);
446
447 VectorSet<int> faces_to_select;
448
449 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
450 const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
451 ".hide_poly", bke::AttrDomain::Face, false);
452
453 const Span<int> faces_to_closest_edge = edge_to_face_map[closest_edge_index];
454
455 /* Picked edge may not be linked to a face (loose edge). */
456 if (faces_to_closest_edge.is_empty()) {
457 return;
458 }
459
460 const bool traced_full_loop = follow_face_loop(faces_to_closest_edge[0],
461 closest_edge_index,
462 faces,
463 hide_poly,
464 corner_edges,
465 edge_to_face_map,
466 faces_to_select);
467
468 if (!traced_full_loop && faces_to_closest_edge.size() > 1) {
469 /* Trace the other way. */
470 follow_face_loop(faces_to_closest_edge[1],
471 closest_edge_index,
472 faces,
473 hide_poly,
474 corner_edges,
475 edge_to_face_map,
476 faces_to_select);
477 }
478
480 ".select_poly", bke::AttrDomain::Face);
481
482 /* Toggling behavior. When one of the faces of the picked edge is already selected,
483 * it deselects the loop instead. */
484 bool any_adjacent_poly_selected = false;
485 for (const int i : faces_to_closest_edge) {
486 any_adjacent_poly_selected |= select_poly.span[i];
487 }
488 const bool select_toggle = select && !any_adjacent_poly_selected;
489 select_poly.span.fill_indices(faces_to_select.as_span(), select_toggle);
490
491 select_poly.finish();
492 paintface_flush_flags(C, ob, true, false);
493}
494
496 Span<int2> edges,
497 Span<bool> select_vert,
498 const bool face_step)
499{
500 for (const int edge_index : face_edges) {
501 const int2 &edge = edges[edge_index];
502 /* If a face is selected, all of its verts are selected too, meaning that neighboring faces
503 * will have some vertices selected. */
504 if (face_step) {
505 if (select_vert[edge[0]] || select_vert[edge[1]]) {
506 return true;
507 }
508 }
509 else {
510 if (select_vert[edge[0]] && select_vert[edge[1]]) {
511 return true;
512 }
513 }
514 }
515 return false;
516}
517
519{
520 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
522 ".select_poly", bke::AttrDomain::Face);
524 ".select_vert", bke::AttrDomain::Point);
525 const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
526 ".hide_poly", bke::AttrDomain::Face, false);
527
528 const OffsetIndices faces = mesh->faces();
529 const Span<int> corner_edges = mesh->corner_edges();
530 const Span<int2> edges = mesh->edges();
531
532 threading::parallel_for(select_poly.span.index_range(), 1024, [&](const IndexRange range) {
533 for (const int i : range) {
534 if (select_poly.span[i] || hide_poly[i]) {
535 continue;
536 }
537 const IndexRange face = faces[i];
538 if (poly_has_selected_neighbor(corner_edges.slice(face), edges, select_vert.span, face_step))
539 {
540 select_poly.span[i] = true;
541 }
542 }
543 });
544
545 select_poly.finish();
546 select_vert.finish();
547}
548
550 Span<int2> edges,
551 BitSpan verts_of_unselected_faces,
552 const bool face_step)
553{
554 for (const int edge_index : face_edges) {
555 const int2 &edge = edges[edge_index];
556 if (face_step) {
557 if (verts_of_unselected_faces[edge[0]] || verts_of_unselected_faces[edge[1]]) {
558 return true;
559 }
560 }
561 else {
562 if (verts_of_unselected_faces[edge[0]] && verts_of_unselected_faces[edge[1]]) {
563 return true;
564 }
565 }
566 }
567 return false;
568}
569
571{
572 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
574 ".select_poly", bke::AttrDomain::Face);
575 const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
576 ".hide_poly", bke::AttrDomain::Face, false);
577
578 const OffsetIndices faces = mesh->faces();
579 const Span<int> corner_verts = mesh->corner_verts();
580 const Span<int> corner_edges = mesh->corner_edges();
581 const Span<int2> edges = mesh->edges();
582
583 BitVector<> verts_of_unselected_faces(mesh->verts_num);
584
585 /* Find all vertices of unselected faces to help find neighboring faces after. */
586 for (const int i : faces.index_range()) {
587 if (select_poly.span[i]) {
588 continue;
589 }
590 const IndexRange face = faces[i];
591 for (const int vert : corner_verts.slice(face)) {
592 verts_of_unselected_faces[vert].set(true);
593 }
594 }
595
596 threading::parallel_for(faces.index_range(), 1024, [&](const IndexRange range) {
597 for (const int i : range) {
598 if (!select_poly.span[i] || hide_poly[i]) {
599 continue;
600 }
601 const IndexRange face = faces[i];
602 if (poly_has_unselected_neighbor(
603 corner_edges.slice(face), edges, verts_of_unselected_faces, face_step))
604 {
605 select_poly.span[i] = false;
606 }
607 }
608 });
609
610 select_poly.finish();
611}
612
613bool paintface_deselect_all_visible(bContext *C, Object *ob, int action, bool flush_flags)
614{
616 if (mesh == nullptr) {
617 return false;
618 }
619
620 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
621 const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
622 ".hide_poly", bke::AttrDomain::Face, false);
624 ".select_poly", bke::AttrDomain::Face);
625
626 if (action == SEL_TOGGLE) {
627 action = SEL_SELECT;
628
629 for (int i = 0; i < mesh->faces_num; i++) {
630 if (!hide_poly[i] && select_poly.span[i]) {
631 action = SEL_DESELECT;
632 break;
633 }
634 }
635 }
636
637 bool changed = false;
638
639 for (int i = 0; i < mesh->faces_num; i++) {
640 if (hide_poly[i]) {
641 continue;
642 }
643 const bool old_selection = select_poly.span[i];
644 switch (action) {
645 case SEL_SELECT:
646 select_poly.span[i] = true;
647 break;
648 case SEL_DESELECT:
649 select_poly.span[i] = false;
650 break;
651 case SEL_INVERT:
652 select_poly.span[i] = !select_poly.span[i];
653 changed = true;
654 break;
655 }
656 if (old_selection != select_poly.span[i]) {
657 changed = true;
658 }
659 }
660
661 select_poly.finish();
662
663 if (changed) {
664 if (flush_flags) {
665 paintface_flush_flags(C, ob, true, false);
666 }
667 }
668 return changed;
669}
670
671bool paintface_minmax(Object *ob, float r_min[3], float r_max[3])
672{
673 bool ok = false;
674 float vec[3], bmat[3][3];
675
676 const Mesh *mesh = BKE_mesh_from_object(ob);
677 if (!mesh) {
678 return ok;
679 }
680
681 copy_m3_m4(bmat, ob->object_to_world().ptr());
682
683 const Span<float3> positions = mesh->vert_positions();
684 const OffsetIndices faces = mesh->faces();
685 const Span<int> corner_verts = mesh->corner_verts();
686 bke::AttributeAccessor attributes = mesh->attributes();
687 const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
688 ".hide_poly", bke::AttrDomain::Face, false);
689 const VArray<bool> select_poly = *attributes.lookup_or_default<bool>(
690 ".select_poly", bke::AttrDomain::Face, false);
691
692 for (int i = 0; i < mesh->faces_num; i++) {
693 if (hide_poly[i] || !select_poly[i]) {
694 continue;
695 }
696
697 for (const int vert : corner_verts.slice(faces[i])) {
698 mul_v3_m3v3(vec, bmat, positions[vert]);
699 add_v3_v3v3(vec, vec, ob->object_to_world().location());
700 minmax_v3v3_v3(r_min, r_max, vec);
701 }
702
703 ok = true;
704 }
705
706 return ok;
707}
708
710 const int mval[2],
711 const SelectPick_Params &params,
712 Object *ob)
713{
714 uint index;
715 bool changed = false;
716 bool found = false;
717
718 /* Get the face under the cursor */
720
721 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
722 const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
723 ".hide_poly", bke::AttrDomain::Face, false);
724 bke::AttributeWriter<bool> select_poly = attributes.lookup_or_add_for_write<bool>(
725 ".select_poly", bke::AttrDomain::Face);
726
728 if (index < mesh->faces_num) {
729 if (!hide_poly[index]) {
730 found = true;
731 }
732 }
733 }
734
735 if (params.sel_op == SEL_OP_SET) {
736 if ((found && params.select_passthrough) && select_poly.varray[index]) {
737 found = false;
738 }
739 else if (found || params.deselect_all) {
740 /* Deselect everything. */
741 changed |= paintface_deselect_all_visible(C, ob, SEL_DESELECT, false);
742 }
743 }
744
745 if (found) {
746 mesh->act_face = int(index);
747
748 switch (params.sel_op) {
749 case SEL_OP_SET:
750 case SEL_OP_ADD:
751 select_poly.varray.set(index, true);
752 break;
753 case SEL_OP_SUB:
754 select_poly.varray.set(index, false);
755 break;
756 case SEL_OP_XOR:
757 select_poly.varray.set(index, !select_poly.varray[index]);
758 break;
759 case SEL_OP_AND:
760 BLI_assert_unreachable(); /* Doesn't make sense for picking. */
761 break;
762 }
763
764 /* image window redraw */
765
766 paintface_flush_flags(C, ob, true, false);
767 ED_region_tag_redraw(CTX_wm_region(C)); /* XXX: should redraw all 3D views. */
768 changed = true;
769 }
770 select_poly.finish();
771 return changed || found;
772}
773
775{
777 Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
778 if (mesh == nullptr) {
779 return;
780 }
781
782 /* we could call this directly in all areas that change selection,
783 * since this could become slow for realtime updates (circle-select for eg) */
785
786 if (mesh_eval == nullptr) {
787 return;
788 }
789
790 const bke::AttributeAccessor attributes_orig = mesh->attributes();
791 bke::MutableAttributeAccessor attributes_eval = mesh_eval->attributes_for_write();
792
793 const int *orig_indices = static_cast<const int *>(
795
796 const VArray<bool> hide_vert_orig = *attributes_orig.lookup_or_default<bool>(
797 ".hide_vert", bke::AttrDomain::Point, false);
798 bke::SpanAttributeWriter<bool> hide_vert_eval =
799 attributes_eval.lookup_or_add_for_write_only_span<bool>(".hide_vert",
801 if (orig_indices) {
802 for (const int i : hide_vert_eval.span.index_range()) {
803 if (orig_indices[i] != ORIGINDEX_NONE) {
804 hide_vert_eval.span[i] = hide_vert_orig[orig_indices[i]];
805 }
806 }
807 }
808 else {
809 hide_vert_orig.materialize(hide_vert_eval.span);
810 }
811 hide_vert_eval.finish();
812
813 const VArray<bool> select_vert_orig = *attributes_orig.lookup_or_default<bool>(
814 ".select_vert", bke::AttrDomain::Point, false);
815 bke::SpanAttributeWriter<bool> select_vert_eval =
816 attributes_eval.lookup_or_add_for_write_only_span<bool>(".select_vert",
818 if (orig_indices) {
819 for (const int i : select_vert_eval.span.index_range()) {
820 if (orig_indices[i] != ORIGINDEX_NONE) {
821 select_vert_eval.span[i] = select_vert_orig[orig_indices[i]];
822 }
823 }
824 }
825 else {
826 select_vert_orig.materialize(select_vert_eval.span);
827 }
828 select_vert_eval.finish();
829
831}
832
834 Object *ob,
835 const Span<int> vertex_indices,
836 const bool select)
837{
839 if (mesh == nullptr || mesh->faces_num == 0) {
840 return;
841 }
842
843 /* AtomicDisjointSet is used to store connection information in vertex indices. */
844 AtomicDisjointSet islands(mesh->verts_num);
845 const Span<int2> edges = mesh->edges();
846
847 /* By calling join() on the vertices of all edges, the AtomicDisjointSet contains information on
848 * which parts of the mesh are connected. */
849 threading::parallel_for(edges.index_range(), 1024, [&](const IndexRange range) {
850 for (const int2 &edge : edges.slice(range)) {
851 islands.join(edge[0], edge[1]);
852 }
853 });
854
855 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
856 bke::SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_span<bool>(
857 ".select_vert", bke::AttrDomain::Point);
858
859 Set<int> selected_roots;
860
861 for (const int i : vertex_indices) {
862 const int root = islands.find_root(i);
863 selected_roots.add(root);
864 }
865
866 threading::parallel_for(select_vert.span.index_range(), 1024, [&](const IndexRange range) {
867 for (const int i : range) {
868 const int root = islands.find_root(i);
869 if (selected_roots.contains(root)) {
870 select_vert.span[i] = select;
871 }
872 }
873 });
874
875 select_vert.finish();
876
879}
880
882 Object *ob,
883 const int region_coordinates[2],
884 const bool select)
885{
886 uint index = uint(-1);
887 if (!ED_mesh_pick_vert(C, ob, region_coordinates, ED_MESH_PICK_DEFAULT_VERT_DIST, true, &index))
888 {
889 return;
890 }
891
893}
894
896{
898 if (mesh == nullptr || mesh->faces_num == 0) {
899 return;
900 }
901
902 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
904 ".select_vert", bke::AttrDomain::Point);
905
906 Vector<int> indices;
907 for (const int i : select_vert.span.index_range()) {
908 if (!select_vert.span[i]) {
909 continue;
910 }
911 indices.append(i);
912 }
913 select_vert.finish();
914 paintvert_select_linked_vertices(C, ob, indices, true);
915}
916
918{
919 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
921 ".select_vert", bke::AttrDomain::Point);
922 const VArray<bool> hide_edge = *attributes.lookup_or_default<bool>(
923 ".hide_edge", bke::AttrDomain::Edge, false);
924 const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
925 ".hide_poly", bke::AttrDomain::Face, false);
926
927 const OffsetIndices faces = mesh->faces();
928 const Span<int> corner_edges = mesh->corner_edges();
929 const Span<int> corner_verts = mesh->corner_verts();
930 const Span<int2> edges = mesh->edges();
931
932 Array<int> edge_to_face_offsets;
933 Array<int> edge_to_face_indices;
934 GroupedSpan<int> edge_to_face_map;
935 if (face_step) {
936 edge_to_face_map = bke::mesh::build_edge_to_face_map(
937 faces, corner_edges, mesh->edges_num, edge_to_face_offsets, edge_to_face_indices);
938 }
939
940 /* Need a copy of the selected verts that we can read from and is not modified. */
941 BitVector<> select_vert_original(mesh->verts_num, false);
942 for (int i = 0; i < mesh->verts_num; i++) {
943 select_vert_original[i].set(select_vert.span[i]);
944 }
945
946 /* If we iterated over faces we wouldn't extend the selection through edges that have no face
947 * attached to them. */
948 for (const int i : edges.index_range()) {
949 const int2 &edge = edges[i];
950 if ((!select_vert_original[edge[0]] && !select_vert_original[edge[1]]) || hide_edge[i]) {
951 continue;
952 }
953 select_vert.span[edge[0]] = true;
954 select_vert.span[edge[1]] = true;
955 if (!face_step) {
956 continue;
957 }
958 const Span<int> neighbor_polys = edge_to_face_map[i];
959 for (const int face_i : neighbor_polys) {
960 if (hide_poly[face_i]) {
961 continue;
962 }
963 const IndexRange face = faces[face_i];
964 for (const int vert : corner_verts.slice(face)) {
965 select_vert.span[vert] = true;
966 }
967 }
968 }
969
970 select_vert.finish();
971}
972
974{
975 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
977 ".select_vert", bke::AttrDomain::Point);
978 const VArray<bool> hide_edge = *attributes.lookup_or_default<bool>(
979 ".hide_edge", bke::AttrDomain::Edge, false);
980 const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
981 ".hide_poly", bke::AttrDomain::Face, false);
982
983 const OffsetIndices faces = mesh->faces();
984 const Span<int> corner_edges = mesh->corner_edges();
985 const Span<int> corner_verts = mesh->corner_verts();
986 const Span<int2> edges = mesh->edges();
987
988 GroupedSpan<int> edge_to_face_map;
989 Array<int> edge_to_face_offsets;
990 Array<int> edge_to_face_indices;
991 if (face_step) {
992 edge_to_face_map = bke::mesh::build_edge_to_face_map(
993 faces, corner_edges, edges.size(), edge_to_face_offsets, edge_to_face_indices);
994 }
995
996 /* Need a copy of the selected verts that we can read from and is not modified. */
997 BitVector<> select_vert_original(mesh->verts_num);
998 for (int i = 0; i < mesh->verts_num; i++) {
999 select_vert_original[i].set(select_vert.span[i]);
1000 }
1001
1002 for (const int i : edges.index_range()) {
1003 const int2 &edge = edges[i];
1004 if ((select_vert_original[edge[0]] && select_vert_original[edge[1]]) && !hide_edge[i]) {
1005 continue;
1006 }
1007 select_vert.span[edge[0]] = false;
1008 select_vert.span[edge[1]] = false;
1009
1010 if (!face_step) {
1011 continue;
1012 }
1013 for (const int face_i : edge_to_face_map[i]) {
1014 if (hide_poly[face_i]) {
1015 continue;
1016 }
1017 const IndexRange face = faces[face_i];
1018 for (const int vert : corner_verts.slice(face)) {
1019 select_vert.span[vert] = false;
1020 }
1021 }
1022 }
1023 select_vert.finish();
1024}
1025
1031
1032bool paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)
1033{
1035 if (mesh == nullptr) {
1036 return false;
1037 }
1038
1039 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
1040 const VArray<bool> hide_vert = *attributes.lookup_or_default<bool>(
1041 ".hide_vert", bke::AttrDomain::Point, false);
1042 bke::SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_span<bool>(
1043 ".select_vert", bke::AttrDomain::Point);
1044
1045 if (action == SEL_TOGGLE) {
1046 action = SEL_SELECT;
1047
1048 for (int i = 0; i < mesh->verts_num; i++) {
1049 if (!hide_vert[i] && select_vert.span[i]) {
1050 action = SEL_DESELECT;
1051 break;
1052 }
1053 }
1054 }
1055
1056 bool changed = false;
1057 for (int i = 0; i < mesh->verts_num; i++) {
1058 if (hide_vert[i]) {
1059 continue;
1060 }
1061 const bool old_selection = select_vert.span[i];
1062 switch (action) {
1063 case SEL_SELECT:
1064 select_vert.span[i] = true;
1065 break;
1066 case SEL_DESELECT:
1067 select_vert.span[i] = false;
1068 break;
1069 case SEL_INVERT:
1070 select_vert.span[i] = !select_vert.span[i];
1071 break;
1072 }
1073 if (old_selection != select_vert.span[i]) {
1074 changed = true;
1075 }
1076 }
1077
1078 select_vert.finish();
1079
1080 if (changed) {
1081 /* handle mselect */
1082 if (action == SEL_SELECT) {
1083 /* pass */
1084 }
1085 else if (ELEM(action, SEL_DESELECT, SEL_INVERT)) {
1087 }
1088 else {
1090 }
1091
1092 if (flush_flags) {
1094 }
1095 }
1096 return changed;
1097}
1098
1099void paintvert_select_ungrouped(Object *ob, bool extend, bool flush_flags)
1100{
1102 if (mesh == nullptr) {
1103 return;
1104 }
1105 const Span<MDeformVert> dverts = mesh->deform_verts();
1106 if (dverts.is_empty()) {
1107 return;
1108 }
1109
1110 if (!extend) {
1112 }
1113
1114 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
1115 const VArray<bool> hide_vert = *attributes.lookup_or_default<bool>(
1116 ".hide_vert", bke::AttrDomain::Point, false);
1117 bke::SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_span<bool>(
1118 ".select_vert", bke::AttrDomain::Point);
1119
1120 for (const int i : select_vert.span.index_range()) {
1121 if (!hide_vert[i]) {
1122 if (dverts[i].dw == nullptr) {
1123 /* if null weight then not grouped */
1124 select_vert.span[i] = true;
1125 }
1126 }
1127 }
1128
1129 select_vert.finish();
1130
1131 if (flush_flags) {
1133 }
1134}
1135
1136void paintvert_hide(bContext *C, Object *ob, const bool unselected)
1137{
1139 if (mesh == nullptr || mesh->verts_num == 0) {
1140 return;
1141 }
1142
1143 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
1145 ".hide_vert", bke::AttrDomain::Point);
1146 bke::SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_span<bool>(
1147 ".select_vert", bke::AttrDomain::Point);
1148
1149 for (const int i : hide_vert.span.index_range()) {
1150 if (!hide_vert.span[i]) {
1151 if (!select_vert.span[i] == unselected) {
1152 hide_vert.span[i] = true;
1153 }
1154 }
1155
1156 if (hide_vert.span[i]) {
1157 select_vert.span[i] = false;
1158 }
1159 }
1160 hide_vert.finish();
1161 select_vert.finish();
1162
1164
1167}
1168
1169void paintvert_reveal(bContext *C, Object *ob, const bool select)
1170{
1172 if (mesh == nullptr || mesh->verts_num == 0) {
1173 return;
1174 }
1175
1176 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
1177 const VArray<bool> hide_vert = *attributes.lookup_or_default<bool>(
1178 ".hide_vert", bke::AttrDomain::Point, false);
1179 bke::SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_span<bool>(
1180 ".select_vert", bke::AttrDomain::Point);
1181
1182 for (const int i : select_vert.span.index_range()) {
1183 if (hide_vert[i]) {
1184 select_vert.span[i] = select;
1185 }
1186 }
1187
1188 select_vert.finish();
1189
1190 /* Remove the hide attribute to reveal all vertices. */
1191 attributes.remove(".hide_vert");
1192
1194
1197}
1198
1199/* Walk along an edge loop (Vertex based).
1200 * Return true if closed loop found. */
1201static bool follow_edge_loop(const int edge_start_index,
1202 const int vert_start_index,
1203 const Span<int2> edges,
1204 const VArray<bool> &hide_vert,
1205 const GroupedSpan<int> vert_to_edge_map,
1206 const GroupedSpan<int> edge_to_face_map,
1207 VectorSet<int> &r_loop_edges)
1208{
1209 int current_edge_index = edge_start_index;
1210 int current_vert_index = vert_start_index;
1211
1212 /* Loop runs until we hit a boundary or closed loop found. */
1213 while (true) {
1214
1215 /* Stop if vertex is hidden. */
1216 if (hide_vert[current_vert_index]) {
1217 return false;
1218 }
1219
1220 /* Stop at poles (Valence != 4). */
1221 const Span<int> connected_edges = vert_to_edge_map[current_vert_index];
1222 if (connected_edges.size() != 4) {
1223 return false;
1224 }
1225
1226 /* Find the opposite edge. */
1227 int next_edge_index = -1;
1228 const Span<int> current_edge_faces = edge_to_face_map[current_edge_index];
1229
1230 for (const int edge_index : connected_edges) {
1231 if (edge_index == current_edge_index) {
1232 continue;
1233 }
1234
1235 /* Check if this candidate edge shares any face with the current edge. */
1236 const Span<int> other_edge_faces = edge_to_face_map[edge_index];
1237
1238 /* If no faces overlap, it means the edge is on the opposite side. */
1239 if (!current_edge_faces.intersects__linear_search(other_edge_faces)) {
1240 next_edge_index = edge_index;
1241 break;
1242 }
1243 }
1244
1245 if (next_edge_index == -1) {
1246 return false;
1247 }
1248
1249 /* Check for closed loop. */
1250 if (r_loop_edges.contains(next_edge_index)) {
1251 return true;
1252 }
1253
1254 r_loop_edges.add(next_edge_index);
1255
1256 /* Advance to the next vertex. */
1257 const int2 next_edge_verts = edges[next_edge_index];
1258 current_vert_index = bke::mesh::edge_other_vert(next_edge_verts, current_vert_index);
1259 current_edge_index = next_edge_index;
1260 }
1261 return false;
1262}
1263
1264void paintvert_select_loop(bContext *C, Object *ob, const int mval[2], const bool select)
1265{
1266 Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
1267 ViewContext vc = ED_view3d_viewcontext_init(C, depsgraph);
1269
1270 Object *ob_eval = DEG_get_evaluated(depsgraph, ob);
1271 if (!ob_eval) {
1272 return;
1273 }
1274
1275 uint closest_edge_index = uint(-1);
1276 if (!ED_mesh_pick_edge(C, ob, mval, ED_MESH_PICK_DEFAULT_VERT_DIST, &closest_edge_index)) {
1277 return;
1278 }
1279 if (closest_edge_index == uint(-1)) {
1280 return;
1281 }
1282
1284 const Span<int2> edges = mesh->edges();
1285 const Span<int> corner_edges = mesh->corner_edges();
1286 const OffsetIndices faces = mesh->faces();
1287
1288 /* Build Topology Maps. */
1289 Array<int> edge_to_face_offsets;
1290 Array<int> edge_to_face_indices;
1291 const GroupedSpan<int> edge_to_face_map = bke::mesh::build_edge_to_face_map(
1292 faces, corner_edges, mesh->edges_num, edge_to_face_offsets, edge_to_face_indices);
1293
1294 Array<int> vert_to_edge_offsets;
1295 Array<int> vert_to_edge_indices;
1296 const GroupedSpan<int> vert_to_edge_map = bke::mesh::build_vert_to_edge_map(
1297 edges, mesh->verts_num, vert_to_edge_offsets, vert_to_edge_indices);
1298
1299 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
1300 const VArray<bool> hide_vert = *attributes.lookup_or_default<bool>(
1301 ".hide_vert", bke::AttrDomain::Point, false);
1302
1303 VectorSet<int> edges_in_loop;
1304
1305 edges_in_loop.add(closest_edge_index);
1306
1307 /* Trace both directions. */
1308 const int2 start_verts = edges[closest_edge_index];
1309
1310 const bool full_loop = follow_edge_loop(closest_edge_index,
1311 start_verts[0],
1312 edges,
1313 hide_vert,
1314 vert_to_edge_map,
1315 edge_to_face_map,
1316 edges_in_loop);
1317
1318 if (!full_loop) {
1319 follow_edge_loop(closest_edge_index,
1320 start_verts[1],
1321 edges,
1322 hide_vert,
1323 vert_to_edge_map,
1324 edge_to_face_map,
1325 edges_in_loop);
1326 }
1327
1328 bke::SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_span<bool>(
1329 ".select_vert", bke::AttrDomain::Point);
1330
1331 VectorSet<int> verts_to_select;
1332 for (int e_idx : edges_in_loop) {
1333 verts_to_select.add(edges[e_idx][0]);
1334 verts_to_select.add(edges[e_idx][1]);
1335 }
1336
1337 const bool any_vert_selected = std::any_of(
1338 verts_to_select.begin(), verts_to_select.end(), [&](const int vert) {
1339 return select_vert.span[vert];
1340 });
1341 const bool select_toggle = select && !any_vert_selected;
1342 select_vert.span.fill_indices(verts_to_select.as_span(), select_toggle);
1343
1344 select_vert.finish();
1345
1348}
1349
1350} // namespace blender
CustomData interface, see also DNA_customdata_types.h.
#define ORIGINDEX_NONE
General operations, lookup, etc. for blender objects.
Object is a sort of wrapper for general info.
#define ED_MESH_PICK_DEFAULT_VERT_DIST
Definition ED_mesh.hh:666
#define ED_MESH_PICK_DEFAULT_FACE_DIST
Definition ED_mesh.hh:667
#define C
Definition RandGen.cpp:29
#define NC_GEOM
Definition WM_types.hh:406
#define ND_SELECT
Definition WM_types.hh:551
#define BLI_assert_unreachable()
#define ELEM(...)
constexpr IndexRange()=default
constexpr Span slice(int64_t start, int64_t size) const
Definition BLI_span.hh:141
constexpr int64_t first_index(const T &search_value) const
Definition BLI_span.hh:381
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
constexpr bool intersects__linear_search(Span other) const
Definition BLI_span.hh:362
IndexRange index_range() const
void materialize(MutableSpan< T > r_span) const
bool add(const Key &key)
bool contains(const Key &key) const
Span< Key > as_span() const
GAttributeReader lookup_or_default(StringRef name, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GAttributeWriter lookup_or_add_for_write(StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef name, AttrDomain domain, AttrType data_type)
#define index(i)
int edge_other_vert(const int2 edge, const int vert)
Definition BKE_mesh.hh:370
GroupedSpan< int > build_edge_to_face_map(OffsetIndices< int > faces, Span< int > corner_edges, int edges_num, Array< int > &r_offsets, Array< int > &r_indices)
GroupedSpan< int > build_vert_to_edge_map(Span< int2 > edges, int verts_num, Array< int > &r_offsets, Array< int > &r_indices)
void mesh_select_vert_flush(Mesh &mesh)
void mesh_hide_vert_flush(Mesh &mesh)
void mesh_hide_face_flush(Mesh &mesh)
void mesh_select_face_flush(Mesh &mesh)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
Definition BLI_task.hh:69
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void paintface_hide(bContext *C, Object *ob, bool unselected)
Definition editface.cc:153
void paintvert_hide(bContext *C, Object *ob, bool unselected)
Definition editface.cc:1136
ViewContext ED_view3d_viewcontext_init(bContext *C, Depsgraph *depsgraph)
static bool follow_edge_loop(const int edge_start_index, const int vert_start_index, const Span< int2 > edges, const VArray< bool > &hide_vert, const GroupedSpan< int > vert_to_edge_map, const GroupedSpan< int > edge_to_face_map, VectorSet< int > &r_loop_edges)
Definition editface.cc:1201
unsigned int uint
Definition BKE_text.h:55
void paintvert_tag_select_update(bContext *C, Object *ob)
Definition editface.cc:1026
void copy_m3_m4(float m1[3][3], const float m2[4][4])
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
static void paintvert_select_linked_vertices(bContext *C, Object *ob, const Span< int > vertex_indices, const bool select)
Definition editface.cc:833
void BKE_mesh_mselect_clear(Mesh *mesh)
static void build_poly_connections(AtomicDisjointSet &islands, Mesh &mesh, const bool skip_seams=true)
Definition editface.cc:221
void paintface_select_less(Mesh *mesh, bool face_step)
Definition editface.cc:570
bool paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)
Definition editface.cc:1032
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:681
void paintvert_select_loop(bContext *C, Object *ob, const int mval[2], const bool select)
Definition editface.cc:1264
void paintface_select_more(Mesh *mesh, bool face_step)
Definition editface.cc:518
void paintface_reveal(bContext *C, Object *ob, bool select)
Definition editface.cc:186
VecBase< int32_t, 2 > int2
bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index)
Definition meshtools.cc:561
void paintvert_select_more(Mesh *mesh, bool face_step)
Definition editface.cc:917
bool paintface_minmax(Object *ob, float r_min[3], float r_max[3])
Definition editface.cc:671
void DEG_id_tag_update(ID *id, unsigned int flags)
static void paintface_select_linked_faces(Mesh &mesh, const Span< int > face_indices, const bool select)
Definition editface.cc:266
void BKE_mesh_mselect_validate(Mesh *mesh)
Mesh * BKE_mesh_from_object(Object *ob)
void BKE_mesh_batch_cache_dirty_tag(Mesh *mesh, eMeshBatchDirtyMode mode)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
static bool follow_face_loop(const int face_start_index, const int edge_start_index, const OffsetIndices< int > faces, const VArray< bool > &hide_poly, const Span< int > corner_edges, const GroupedSpan< int > edge_to_face_map, VectorSet< int > &r_loop_faces)
Definition editface.cc:364
bool ED_mesh_pick_edge(bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index)
Definition meshtools.cc:695
bool paintface_deselect_all_visible(bContext *C, Object *ob, int action, bool flush_flags)
Definition editface.cc:613
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
void ED_view3d_init_mats_rv3d(const Object *ob, RegionView3D *rv3d)
static int get_opposing_edge_index(const IndexRange face, const Span< int > corner_edges, const int current_edge_index)
Definition editface.cc:347
void paintvert_flush_flags(Object *ob)
Definition editface.cc:774
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void ED_view3d_select_id_validate(const ViewContext *vc)
void paintvert_select_linked(bContext *C, Object *ob)
Definition editface.cc:895
void paintface_select_loop(bContext *C, Object *ob, const int mval[2], bool select)
Definition editface.cc:414
void paintface_select_linked(bContext *C, Object *ob, const int mval[2], bool select)
Definition editface.cc:308
@ ID_RECALC_SELECT
Definition DNA_ID.h:1101
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
void paintvert_select_ungrouped(Object *ob, bool extend, bool flush_flags)
Definition editface.cc:1099
void paintface_flush_flags(bContext *C, Object *ob, bool flush_selection, bool flush_hidden)
Definition editface.cc:42
static bool poly_has_selected_neighbor(Span< int > face_edges, Span< int2 > edges, Span< bool > select_vert, const bool face_step)
Definition editface.cc:495
bool paintface_mouse_select(bContext *C, const int mval[2], const SelectPick_Params &params, Object *ob)
Definition editface.cc:709
bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], uint dist_px, bool use_zbuf, uint *r_index)
Definition meshtools.cc:774
@ BKE_MESH_BATCH_DIRTY_ALL
Definition BKE_mesh.h:48
@ BKE_MESH_BATCH_DIRTY_SELECT_PAINT
Definition BKE_mesh.h:50
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3])
void paintvert_reveal(bContext *C, Object *ob, bool select)
Definition editface.cc:1169
static bool poly_has_unselected_neighbor(Span< int > face_edges, Span< int2 > edges, BitSpan verts_of_unselected_faces, const bool face_step)
Definition editface.cc:549
void paintvert_select_linked_pick(bContext *C, Object *ob, const int region_coordinates[2], bool select)
Definition editface.cc:881
void paintvert_select_less(Mesh *mesh, bool face_step)
Definition editface.cc:973
ARegion * CTX_wm_region(const bContext *C)
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
Definition object.cc:4436
static BMFace * face_step(BMEdge *edge, BMFace *f)
CustomData face_data
CustomData vert_data
bke::ObjectRuntime * runtime