Blender V5.3
grease_pencil_select.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
9#include "BKE_attribute.hh"
10#include "BKE_context.hh"
11#include "BKE_curves.hh"
12#include "BKE_curves_utils.hh"
13#include "BKE_grease_pencil.hh"
15#include "BKE_object.hh"
16
18#include "BLI_generic_array.hh"
20#include "BLI_index_mask.hh"
21#include "BLI_offset_indices.hh"
22#include "BLI_task.hh"
23
24#include "DNA_object_types.h"
25
26#include "DEG_depsgraph.hh"
28
29#include "ED_curves.hh"
30#include "ED_grease_pencil.hh"
31#include "ED_screen.hh"
32#include "ED_select_utils.hh"
33#include "ED_view3d.hh"
34
35#include "RNA_access.hh"
36#include "RNA_define.hh"
37#include "RNA_enum_types.hh"
38
39#include "WM_api.hh"
40
41namespace blender {
42
43namespace ed::greasepencil {
44
45/* -------------------------------------------------------------------- */
48
49inline int clamp_range(const IndexRange range, const int index)
50{
51 BLI_assert(!range.is_empty());
52 return std::clamp(index, int(range.first()), int(range.last()));
53}
54
62template<typename Fn>
63static int foreach_curve_segment(const CurveSegmentsData &segment_data,
64 const int curve_index,
65 const IndexRange points,
66 Fn &&fn)
67{
68 if (points.is_empty()) {
69 return 0;
70 }
71
72 const OffsetIndices segments_by_curve = OffsetIndices<int>(segment_data.segment_offsets);
73 const IndexRange segments = segments_by_curve[curve_index];
74
75 for (const int segment_i : segments) {
76 const int segment_point_i = segment_data.segment_start_points[segment_i];
77 const float segment_fraction = segment_data.segment_start_fractions[segment_i];
78
79 if (segment_i < segments.last()) {
80 const int next_segment_i = segment_i + 1;
81 const int next_segment_point_i = segment_data.segment_start_points[next_segment_i];
82 const float next_segment_fraction = segment_data.segment_start_fractions[next_segment_i];
83
84 /* Start point with zero fraction is included. */
85 const int first_point_i = (segment_fraction == 0.0f ?
86 segment_point_i :
87 clamp_range(points, segment_point_i + 1));
88 const int next_first_point_i = (next_segment_fraction == 0.0f ?
89 next_segment_point_i :
90 clamp_range(points, next_segment_point_i + 1));
91 const IndexRange points_range = IndexRange::from_begin_end(first_point_i,
92 next_first_point_i);
93 fn(segment_i, points_range, IndexRange());
94 }
95 else {
96 const int first_segment_point_i = segment_data.segment_start_points[segments.first()];
97 const float first_segment_fraction = segment_data.segment_start_fractions[segments.first()];
98 /* Start point with zero fraction is included. */
99 const int first_point_i = (segment_fraction == 0.0f ?
100 segment_point_i :
101 clamp_range(points, segment_point_i + 1));
102 /* End point with zero fraction is excluded. */
103 const int next_first_point_i = (first_segment_fraction == 0.0f ?
104 first_segment_point_i :
105 clamp_range(points, first_segment_point_i + 1));
106 const IndexRange points_range1 = IndexRange::from_begin_end(points.first(),
107 next_first_point_i);
108 const IndexRange points_range2 = IndexRange::from_begin_end_inclusive(first_point_i,
109 points.last());
110
111 fn(segment_i, points_range1, points_range2);
112 }
113 }
114 return segments.size();
115}
116
118 const IndexMask &selection_mask,
119 const bke::AttrDomain selection_domain,
120 const StringRef attribute_name,
121 const eSelectOp sel_op)
122{
123 if (selection_mask.is_empty()) {
124 return false;
125 }
126
127 if (selection_domain == bke::AttrDomain::Curve) {
128 const Span<StringRef> selection_attribute_names =
130 for (const StringRef selection_attribute_name : selection_attribute_names) {
132 curves, selection_domain, bke::AttrType::Bool, selection_attribute_name);
133
134 selection_mask.foreach_index(
135 [&](const int64_t element_i) {
136 ed::curves::apply_selection_operation_at_index(writer.span, element_i, sel_op);
137 },
139
140 writer.finish();
141 }
142 }
143 else {
145 curves, selection_domain, bke::AttrType::Bool, attribute_name);
146
147 selection_mask.foreach_index(
148 [&](const int64_t element_i) {
149 ed::curves::apply_selection_operation_at_index(writer.span, element_i, sel_op);
150 },
152
153 writer.finish();
154 }
155
156 return true;
157}
158
160 const IndexMask &point_selection_mask,
161 const StringRef attribute_name,
162 const Curves2DBVHTree &tree_data,
163 const IndexRange tree_data_range,
164 const eSelectOp sel_op)
165{
166 /* Use regular selection for anything other than the ".selection" attribute. */
167 if (attribute_name != ".selection") {
169 curves, point_selection_mask, bke::AttrDomain::Point, attribute_name, sel_op);
170 }
171
172 if (point_selection_mask.is_empty()) {
173 return false;
174 }
175 IndexMaskMemory memory;
176
177 const OffsetIndices points_by_curve = curves.points_by_curve();
178 const IndexMask changed_curve_mask = bke::curves::point_to_curve_selection(
179 points_by_curve, point_selection_mask, memory);
180
181 const Span<float2> screen_space_positions = tree_data.start_positions.as_span().slice(
182 tree_data_range);
183
185 curves, changed_curve_mask, screen_space_positions, tree_data, tree_data_range);
186
187 const OffsetIndices<int> segments_by_curve = OffsetIndices<int>(segment_data.segment_offsets);
190
191 /* Find all segments that have changed points and fill them. */
192 Array<bool> changed_points(curves.points_num());
193 point_selection_mask.to_bools(changed_points);
194
195 auto test_points_range = [&](const IndexRange range) -> bool {
196 for (const int point_i : range) {
197 if (changed_points[point_i]) {
198 return true;
199 }
200 }
201 return false;
202 };
203 auto update_points_range = [&](const IndexRange range) {
204 for (const int point_i : range) {
205 ed::curves::apply_selection_operation_at_index(attribute_writer.span, point_i, sel_op);
206 }
207 };
208
209 threading::parallel_for(segments_by_curve.index_range(), 2048, [&](const IndexRange range) {
210 for (const int curve_i : range) {
211 const IndexRange points = points_by_curve[curve_i];
212
213 const int num_segments = foreach_curve_segment(
214 segment_data,
215 curve_i,
216 points,
217 [&](const int /*segment_i*/, const IndexRange points1, const IndexRange points2) {
218 if (test_points_range(points1) || test_points_range(points2)) {
219 update_points_range(points1);
220 update_points_range(points2);
221 }
222 });
223 if (num_segments == 0 && test_points_range(points)) {
224 /* Cyclic curve without cuts, select all. */
225 update_points_range(points);
226 }
227 }
228 });
229
230 attribute_writer.finish();
231 return true;
232}
233
235 const eSelectOp sel_op,
236 SelectionUpdateFunc select_operation)
237{
238 Object *object = (vc->obedit ? vc->obedit : vc->obact);
239 const Object *ob_eval = DEG_get_evaluated(vc->depsgraph, object);
240 GreasePencil &grease_pencil = *id_cast<GreasePencil *>(object->data);
241
242 /* Get selection domain from tool settings. */
244 vc->scene->toolsettings, object);
245 const bool use_segment_selection = ED_grease_pencil_segment_selection_enabled(
246 vc->scene->toolsettings, object);
247
248 bool changed = false;
251
252 for (const Span<ed::greasepencil::MutableDrawingInfo> drawings : drawings_by_frame) {
253 if (drawings.is_empty()) {
254 continue;
255 }
256 const int frame_number = drawings.first().frame_number;
257
258 /* Construct BVH tree for all drawings on the same frame. */
261 if (use_segment_selection) {
263 *vc, *ob_eval, grease_pencil, drawings, frame_number);
264 }
265 OffsetIndices tree_data_by_drawing = OffsetIndices<int>(tree_data.drawing_offsets);
266
267 for (const int i_drawing : drawings.index_range()) {
268 // TODO optimize by lazy-initializing the tree data ONLY IF the changed_element_mask is not
269 // empty.
270
271 const ed::greasepencil::MutableDrawingInfo &info = drawings[i_drawing];
273 const Span<StringRef> selection_attribute_names =
275
276 IndexMaskMemory memory;
278 *object, info, selection_domain, memory);
279 if (elements.is_empty()) {
280 continue;
281 }
282
283 /* Modes that un-set all elements not in the mask. */
284 if (ELEM(sel_op, SEL_OP_SET, SEL_OP_AND)) {
285 for (const StringRef attribute_name : selection_attribute_names) {
286 if (bke::SpanAttributeWriter<bool> selection =
287 curves.attributes_for_write().lookup_or_add_for_write_span<bool>(
288 attribute_name, selection_domain))
289 {
290 ed::curves::fill_selection_false(selection.span);
291 changed = true;
292 selection.finish();
293 }
294 }
295 }
296
297 for (const StringRef attribute_name : selection_attribute_names) {
298 IndexMask changed_element_mask = select_operation(info, elements, attribute_name, memory);
299
300 /* Select fills. */
301 if (selection_domain == bke::AttrDomain::Curve) {
302 changed_element_mask = bke::greasepencil::selected_mask_to_fills(
303 changed_element_mask, curves, selection_domain, memory);
304 }
305
306 if (use_segment_selection) {
307 /* Range of points in tree data matching this curve, for re-using screen space
308 * positions. */
309 const IndexRange tree_data_range = tree_data_by_drawing[i_drawing];
311 curves, changed_element_mask, attribute_name, tree_data, tree_data_range, sel_op);
312 }
313 else {
315 curves, changed_element_mask, selection_domain, attribute_name, sel_op);
316 }
317 }
318 }
319 }
320
321 if (changed) {
322 /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a
323 * generic attribute for now. */
326 }
327
328 return changed;
329}
330
332
334{
335 int action = RNA_enum_get(op->ptr, "action");
336 Scene *scene = CTX_data_scene(C);
338 GreasePencil &grease_pencil = *id_cast<GreasePencil *>(object->data);
340 object);
341
343 threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) {
344 IndexMaskMemory memory;
345 const IndexMask selectable_elements = retrieve_editable_elements(
346 *object, info, selection_domain, memory);
347 if (selectable_elements.is_empty()) {
348 return;
349 }
350 if (action == SEL_TOGGLE) {
351 action = ed::curves::has_anything_selected(info.drawing.strokes(), selection_domain) ?
354 }
356 info.drawing.strokes_for_write(), selectable_elements, selection_domain, action);
357 });
358
359 /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
360 * attribute for now. */
363
364 return OPERATOR_FINISHED;
365}
366
368{
369 ot->name = "(De)select All Strokes";
370 ot->idname = "GREASE_PENCIL_OT_select_all";
371 ot->description = "(De)select all visible strokes";
372
373 ot->exec = select_all_exec;
375
377
379}
380
382{
384 GreasePencil &grease_pencil = *id_cast<GreasePencil *>(object->data);
386
390 const IndexMask & /*universe*/,
391 StringRef attribute_name,
392 IndexMaskMemory &memory) {
394 info.drawing.strokes(), attribute_name, false, memory);
395 });
396
397 /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
398 * attribute for now. */
401
402 return OPERATOR_FINISHED;
403}
404
406{
407 ot->name = "Select More";
408 ot->idname = "GREASE_PENCIL_OT_select_more";
409 ot->description = "Grow the selection by one point";
410
413
415}
416
418{
420 GreasePencil &grease_pencil = *id_cast<GreasePencil *>(object->data);
422
426 const IndexMask & /*universe*/,
427 StringRef attribute_name,
428 IndexMaskMemory &memory) {
430 info.drawing.strokes(), attribute_name, true, memory);
431 });
432
433 /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
434 * attribute for now. */
437
438 return OPERATOR_FINISHED;
439}
440
442{
443 ot->name = "Select Less";
444 ot->idname = "GREASE_PENCIL_OT_select_less";
445 ot->description = "Shrink the selection by one point";
446
449
451}
452
454{
455 Scene *scene = CTX_data_scene(C);
457 GreasePencil &grease_pencil = *id_cast<GreasePencil *>(object->data);
458 const bool unselect = RNA_boolean_get(op->ptr, "deselect");
459
461 threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) {
462 IndexMaskMemory memory;
464 *object, info.drawing, info.layer_index, memory);
465 if (selectable_strokes.is_empty()) {
466 return;
467 }
468 ed::curves::select_linked(info.drawing.strokes_for_write(), selectable_strokes, unselect);
469 });
470
471 /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
472 * attribute for now. */
475
476 return OPERATOR_FINISHED;
477}
478
480{
481 ot->name = "Select Linked";
482 ot->idname = "GREASE_PENCIL_OT_select_linked";
483 ot->description = "Select all points in curves with any point selection";
484
487
489
491 ot->srna, "deselect", false, "Deselect linked", "Deselect linked strokes");
493}
494
496{
497 const float ratio = RNA_float_get(op->ptr, "ratio");
499 Scene *scene = CTX_data_scene(C);
501 GreasePencil &grease_pencil = *id_cast<GreasePencil *>(object->data);
503 object);
505
506 /* Note: For segment selection this doesn't work very well, because it is based on random point
507 * selection. A segment has a high probability of getting at least one selected point and be
508 * itself selected.
509 * For better distribution the random value must be generated per segment and possibly weighted
510 * by segment length.
511 */
513 &vc,
516 const IndexMask & /*universe*/,
517 StringRef /*attribute_name*/,
518 IndexMaskMemory &memory) -> IndexMask {
519 const IndexMask selectable_elements = retrieve_editable_elements(
520 *object, info, selection_domain, memory);
521 if (selectable_elements.is_empty()) {
522 return {};
523 }
524 return random_mask(selectable_elements,
525 info.drawing.strokes().points_num(),
527 ratio,
528 memory);
529 });
530
531 /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
532 * attribute for now. */
535
536 return OPERATOR_FINISHED;
537}
538
540{
541 ot->name = "Select Random";
542 ot->idname = "GREASE_PENCIL_OT_select_random";
543 ot->description = "Selects random points from the current strokes selection";
544
547
549
551}
552
554{
555 const bool deselect_ends = RNA_boolean_get(op->ptr, "deselect_ends");
556 Scene *scene = CTX_data_scene(C);
558 GreasePencil &grease_pencil = *id_cast<GreasePencil *>(object->data);
559
561 threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) {
563 });
564
565 /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
566 * attribute for now. */
569
570 return OPERATOR_FINISHED;
571}
572
574{
575 ot->name = "Select Alternate";
576 ot->idname = "GREASE_PENCIL_OT_select_alternate";
577 ot->description = "Select alternated points in strokes with already selected points";
578
581
583
585 "deselect_ends",
586 false,
587 "Deselect Ends",
588 "(De)select the first and last point of each stroke");
589}
590
598
600 {int(SelectSimilarMode::LAYER), "LAYER", 0, "Layer", ""},
601 {int(SelectSimilarMode::MATERIAL), "MATERIAL", 0, "Material", ""},
602 {int(SelectSimilarMode::VERTEX_COLOR), "VERTEX_COLOR", 0, "Vertex Color", ""},
603 {int(SelectSimilarMode::RADIUS), "RADIUS", 0, "Radius", ""},
604 {int(SelectSimilarMode::OPACITY), "OPACITY", 0, "Opacity", ""},
605 {0, nullptr, 0, nullptr, nullptr},
606};
607
608template<typename T>
610 const MutableDrawingInfo &info,
611 const bke::AttrDomain domain,
612 const StringRef name,
613 const eHandleDisplay handle_display,
614 Set<T> &r_value_set)
615{
616 T default_value;
617 CPPType::get<T>().default_construct(&default_value);
618
620 const bke::AttributeAccessor attributes = curves.attributes();
621 const VArraySpan<T> values = *attributes.lookup_or_default<T>(name, domain, default_value);
622
624 IndexMaskMemory memory;
625 if (domain == bke::AttrDomain::Point) {
627 *object, info.drawing, info.layer_index, handle_display, memory);
628 points.foreach_index(
629 [&](const int index) {
630 Set<T> &local_value_set = value_set_by_thread.local();
631 local_value_set.add(values[index]);
632 },
634 }
635 else if (domain == bke::AttrDomain::Curve) {
637 *object, info.drawing, info.layer_index, memory);
638
639 strokes.foreach_index(
640 [&](const int index) {
641 Set<T> &local_value_set = value_set_by_thread.local();
642 local_value_set.add(values[index]);
643 },
645 }
646 else {
648 }
649
650 for (const Set<T> &local_value_set : value_set_by_thread) {
651 /* TODO is there a union function that can do this more efficiently? */
652 for (const T &key : local_value_set) {
653 r_value_set.add(key);
654 }
655 }
656}
657
658template<typename T, typename DistanceFn>
660 Object *object,
662 const bke::AttrDomain selection_domain,
663 const StringRef name,
664 const eHandleDisplay handle_display,
665 float threshold,
666 DistanceFn distance_fn)
667{
668 using namespace blender::ed::greasepencil;
669
670 T default_value;
671 CPPType::get<T>().default_construct(&default_value);
672
674
675 Set<T> selected_values;
676 for (const MutableDrawingInfo &info : drawings) {
677 insert_selected_values(object, info, selection_domain, name, handle_display, selected_values);
678 }
679
680 threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) {
681 IndexMaskMemory memory;
683 *object, info, selection_domain, memory);
685 const VArraySpan<T> values = *curves.attributes().lookup_or_default<T>(
686 name, selection_domain, default_value);
687
689 curves);
690 for (const int i : selection_attribute_names.index_range()) {
692 curves, selection_domain, bke::AttrType::Bool, selection_attribute_names[i]);
693 MutableSpan<bool> selection = selection_writer.span.typed<bool>();
694
695 elements.foreach_index(
696 [&](const int index) {
697 if (selection[index]) {
698 return;
699 }
700 for (const T &test_value : selected_values) {
701 if (distance_fn(values[index], test_value) <= threshold) {
702 selection[index] = true;
703 }
704 }
705 },
707
708 selection_writer.finish();
709 }
710 });
711}
712
714 Object *object,
716 bke::AttrDomain domain)
717{
719
720 Set<int> selected_layers;
721 /* Layer is selected if any point is selected. */
722 for (const MutableDrawingInfo &info : drawings) {
723 const VArraySpan<bool> selection =
724 *info.drawing.strokes().attributes().lookup_or_default<bool>(".selection", domain, true);
725 for (const int i : selection.index_range()) {
726 if (selection[i]) {
727 selected_layers.add(info.layer_index);
728 break;
729 }
730 }
731 }
732
733 threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) {
734 if (!selected_layers.contains(info.layer_index)) {
735 return;
736 }
737
738 IndexMaskMemory memory;
739 const IndexMask editable_elements = retrieve_editable_elements(*object, info, domain, memory);
740 if (editable_elements.is_empty()) {
741 return;
742 }
744 info.drawing.strokes_for_write(), editable_elements, domain, SEL_SELECT);
745 });
746}
747
749{
750 const SelectSimilarMode mode = SelectSimilarMode(RNA_enum_get(op->ptr, "mode"));
751 const float threshold = RNA_float_get(op->ptr, "threshold");
752 Scene *scene = CTX_data_scene(C);
753 View3D *v3d = CTX_wm_view3d(C);
755 GreasePencil &grease_pencil = *id_cast<GreasePencil *>(object->data);
757 object);
759
760 switch (mode) {
762 select_similar_by_layer(scene, object, grease_pencil, selection_domain);
763 break;
766 scene,
767 object,
769 selection_domain,
770 "material_index",
771 handle_display,
772 threshold,
773 [](const int a, const int b) -> float { return float(math::distance(a, b)); });
774 break;
777 scene,
778 object,
780 selection_domain,
781 "vertex_color",
782 handle_display,
783 threshold,
784 [](const ColorGeometry4f &a, const ColorGeometry4f &b) -> float {
785 return math::distance(float4(a), float4(b));
786 });
787 break;
790 scene,
791 object,
793 selection_domain,
794 "radius",
795 handle_display,
796 threshold,
797 [](const float a, const float b) -> float { return math::distance(a, b); });
798 break;
801 scene,
802 object,
804 selection_domain,
805 "opacity",
806 handle_display,
807 threshold,
808 [](const float a, const float b) -> float { return math::distance(a, b); });
809 break;
810 }
811
814
815 return OPERATOR_FINISHED;
816}
817
819{
820 ot->name = "Select Similar";
821 ot->idname = "GREASE_PENCIL_OT_select_similar";
822 ot->description = "Select all strokes with similar characteristics";
823
827
829
830 ot->prop = RNA_def_enum(
831 ot->srna, "mode", select_similar_mode_items, int(SelectSimilarMode::LAYER), "Mode", "");
832
833 RNA_def_float(ot->srna, "threshold", 0.1f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 10.0f);
834}
835
837{
838 const int amount_start = RNA_int_get(op->ptr, "amount_start");
839 const int amount_end = RNA_int_get(op->ptr, "amount_end");
841 GreasePencil &grease_pencil = *id_cast<GreasePencil *>(object->data);
843
845 &vc,
848 const IndexMask & /*universe*/,
849 StringRef /*attribute_name*/,
850 IndexMaskMemory &memory) {
852 *object, info.drawing, info.layer_index, memory);
854 info.drawing.strokes(), selectable_strokes, amount_start, amount_end, false, memory);
855 });
856
857 /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
858 * attribute for now. */
861
862 return OPERATOR_FINISHED;
863}
864
866{
867 ot->name = "Select Ends";
868 ot->idname = "GREASE_PENCIL_OT_select_ends";
869 ot->description = "Select end points of strokes";
870
873
875
876 RNA_def_int(ot->srna,
877 "amount_start",
878 0,
879 0,
880 INT32_MAX,
881 "Amount Start",
882 "Number of points to select from the start",
883 0,
884 INT32_MAX);
885 RNA_def_int(ot->srna,
886 "amount_end",
887 1,
888 0,
889 INT32_MAX,
890 "Amount End",
891 "Number of points to select from the end",
892 0,
893 INT32_MAX);
894}
895
897{
898 Scene *scene = CTX_data_scene(C);
900 GreasePencil &grease_pencil = *blender::id_cast<GreasePencil *>(object->data);
902 scene->toolsettings, object);
903
905 threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) {
906 IndexMaskMemory memory;
908 *object, info.drawing, info.layer_index, memory);
909 if (selected_strokes.is_empty()) {
910 return;
911 }
912
914 bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
915 const VArray<int> fill_ids = *attributes.lookup<int>("fill_id", bke::AttrDomain::Curve);
916
917 /* If the attribute does not exist then each curves is its own fill. */
918 if (!fill_ids) {
920 *object, info.drawing, info.layer_index, memory);
922 return;
923 }
924
925 VectorSet<int> selected_fill_ids;
926 selected_strokes.foreach_index([&](const int64_t curve_i) {
927 const int fill_id = fill_ids[curve_i];
928 if (fill_id != 0) {
929 selected_fill_ids.add(fill_id);
930 }
931 });
932
933 Array<bool> selected_curves(curves.curves_num());
934 selected_strokes.to_bools(selected_curves);
935
936 const IndexMask strokes = IndexMask::from_predicate(
937 curves.curves_range(), memory, [&](const int64_t curve_i) {
938 const int fill_id = fill_ids[curve_i];
939 if (fill_id == 0) {
940 return selected_curves[curve_i];
941 }
942 return selected_fill_ids.contains(fill_id);
943 });
944
945 const OffsetIndices<int> points_by_curve = curves.points_by_curve();
946 const Span<StringRef> selection_attribute_names =
948
949 for (const int i : selection_attribute_names.index_range()) {
951 curves, selection_domain, bke::AttrType::Bool, selection_attribute_names[i]);
952 switch (selection_domain) {
954 ed::curves::fill_selection_true(selection.span, strokes);
955 break;
956 }
958 strokes.foreach_index(
959 [&](const int curve) {
960 const IndexRange points = points_by_curve[curve];
961 ed::curves::fill_selection_true(selection.span.slice(points));
962 },
964 break;
965 }
966 default:
968 }
969 selection.finish();
970 }
971 });
972
973 /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
974 * attribute for now. */
977
978 return OPERATOR_FINISHED;
979}
980
982{
983 ot->name = "Select Fill";
984 ot->idname = "GREASE_PENCIL_OT_select_fill";
985 ot->description = "Select all curves in a fill";
986
989
991}
992
994{
995 bool changed = false;
996
997 /* Convert all drawings of the active GP to the new selection domain. */
999 GreasePencil &grease_pencil = *id_cast<GreasePencil *>(object->data);
1000 Span<GreasePencilDrawingBase *> drawings = grease_pencil.drawings();
1001
1002 for (const int index : drawings.index_range()) {
1003 GreasePencilDrawingBase *drawing_base = drawings[index];
1004 if (drawing_base->type != GP_DRAWING) {
1005 continue;
1006 }
1007
1008 GreasePencilDrawing *drawing = reinterpret_cast<GreasePencilDrawing *>(drawing_base);
1009 bke::CurvesGeometry &curves = drawing->wrap().strokes_for_write();
1010 if (curves.is_empty()) {
1011 continue;
1012 }
1013
1014 bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
1015 const std::optional<bke::AttributeMetaData> meta_data = attributes.lookup_meta_data(
1016 ".selection");
1017
1018 /* Skip curve when the selection domain already matches, or when there is no selection
1019 * attribute (all/none selected). */
1020 if ((!meta_data) || (meta_data->domain == domain)) {
1021 continue;
1022 }
1023
1024 /* When the selection domain is 'curve', ensure all *fills* with a point selection
1025 * are selected. */
1026 if (domain == bke::AttrDomain::Curve) {
1027 IndexMaskMemory memory;
1028 if (meta_data->domain == bke::AttrDomain::Point) {
1029 const IndexMask selected_points = ed::curves::retrieve_selected_points(curves, memory);
1031 selected_points, curves, bke::AttrDomain::Point, memory);
1032
1033 for (const StringRef selection_attribute_name :
1035 {
1037 curves, bke::AttrDomain::Point, bke::AttrType::Bool, selection_attribute_name);
1038 curves::fill_selection_true(selection_writer.span, selected_mask);
1039
1040 selection_writer.finish();
1041 }
1042 }
1043 else {
1044 BLI_assert(meta_data->domain == bke::AttrDomain::Curve);
1045
1046 const IndexMask selected_curves = ed::curves::retrieve_selected_curves(curves, memory);
1048 selected_curves, curves, bke::AttrDomain::Curve, memory);
1049
1050 for (const StringRef selection_attribute_name :
1052 {
1054 curves, bke::AttrDomain::Curve, bke::AttrType::Bool, selection_attribute_name);
1055 curves::fill_selection_true(selection_writer.span, selected_mask);
1056
1057 selection_writer.finish();
1058 }
1059 }
1060
1061 changed |= true;
1062 }
1063
1064 for (const StringRef selection_attribute_name :
1066 {
1067 /* Convert selection domain. */
1068 const GVArray src = *attributes.lookup(selection_attribute_name, domain);
1069 if (src) {
1070 auto *dst = new ImplicitSharedValue<GArray<>>(src.type(), src.size(), NoInitialization());
1071 src.materialize_to_uninitialized(dst->data.data());
1072
1073 attributes.remove(selection_attribute_name);
1074 attributes.add(selection_attribute_name,
1075 domain,
1076 bke::cpp_type_to_attribute_type(dst->data.type()),
1077 bke::AttributeInitShared(dst->data.data(), *dst));
1078 dst->remove_user_and_delete_if_last();
1079
1080 changed = true;
1081
1082 /* TODO: expand point selection to segments when in 'segment' mode. */
1083 }
1084 }
1085 }
1086
1087 return changed;
1088}
1089
1091{
1092 using namespace blender::bke::greasepencil;
1093
1094 /* Set new selection mode. */
1095 const int mode_new = RNA_enum_get(op->ptr, "mode");
1098
1099 bool changed = false;
1101 changed = (mode_new != ts->gpencil_selectmode_edit);
1103 }
1105 changed = (mode_new != ts->gpencil_selectmode_sculpt);
1107 }
1109 changed = (mode_new != ts->gpencil_selectmode_vertex);
1111 }
1112
1113 changed |= ensure_selection_domain(ts, ob);
1114
1115 if (changed) {
1116 /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
1117 * attribute for now. */
1118 GreasePencil &grease_pencil = *id_cast<GreasePencil *>(ob->data);
1121
1123 }
1124
1125 return OPERATOR_FINISHED;
1126}
1127
1129{
1130 PropertyRNA *prop;
1131
1132 ot->name = "Select Mode";
1133 ot->idname = __func__;
1134 ot->description = "Change the selection mode for Grease Pencil strokes";
1135
1138
1140
1141 ot->prop = prop = RNA_def_enum(
1142 ot->srna, "mode", rna_enum_grease_pencil_selectmode_items, 0, "Mode", "");
1144}
1145
1147{
1148 const Scene *scene = CTX_data_scene(C);
1149 Object *object = CTX_data_active_object(C);
1151 GreasePencil &grease_pencil = *id_cast<GreasePencil *>(object->data);
1152 const bool select = !RNA_boolean_get(op->ptr, "deselect");
1153 const int material_index = object->actcol - 1;
1154 const bke::AttrDomain domain = ED_grease_pencil_selection_domain_get(ts, object);
1155
1156 if (material_index == -1) {
1157 return OPERATOR_CANCELLED;
1158 }
1159
1161 threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) {
1163
1164 IndexMaskMemory memory;
1166 *object, info.drawing, material_index, memory);
1167 if (strokes.is_empty()) {
1168 return;
1169 }
1170
1171 const OffsetIndices<int> points_by_curve = curves.points_by_curve();
1172 const Span<StringRef> selection_attribute_names =
1174
1175 for (const int i : selection_attribute_names.index_range()) {
1177 curves, domain, bke::AttrType::Bool, selection_attribute_names[i]);
1178 switch (domain) {
1180 index_mask::masked_fill(selection.span.typed<bool>(), select, strokes);
1181 break;
1182 }
1184 strokes.foreach_index([&](const int curve_index) {
1185 const IndexRange points = points_by_curve[curve_index];
1186 ed::curves::fill_selection(selection.span.slice(points), select);
1187 });
1188 break;
1189 }
1190 default:
1192 }
1193 selection.finish();
1194 }
1195 });
1196
1199
1200 return OPERATOR_FINISHED;
1201}
1202
1204{
1205 /* identifiers */
1206 ot->name = "Select Material";
1207 ot->idname = "GREASE_PENCIL_OT_material_select";
1208 ot->description = "Select/Deselect all Grease Pencil strokes using current material";
1209
1210 /* callbacks. */
1213
1214 /* flags. */
1216
1217 /* props */
1218 ot->prop = RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Unselect strokes");
1220}
1221
1222namespace {
1223enum class StrokeType : int8_t { Stroke, Fill };
1224}
1225
1227{
1228 Scene *scene = CTX_data_scene(C);
1229 Object *object = CTX_data_active_object(C);
1231 GreasePencil &grease_pencil = *id_cast<GreasePencil *>(object->data);
1232
1233 const bke::AttrDomain selection_domain = ED_grease_pencil_selection_domain_get(ts, object);
1234
1235 const StrokeType stroke_type = StrokeType(RNA_enum_get(op->ptr, "type"));
1236 const bool select = !RNA_boolean_get(op->ptr, "deselect");
1237 const int action = select ? SEL_SELECT : SEL_DESELECT;
1238
1239 std::atomic<bool> changed = false;
1241 threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) {
1242 IndexMaskMemory memory;
1243 const IndexMask selectable_strokes = ed::greasepencil::retrieve_editable_strokes(
1244 *object, info.drawing, info.layer_index, memory);
1245 if (selectable_strokes.is_empty()) {
1246 return;
1247 }
1248
1249 const bke::CurvesGeometry &curves = info.drawing.strokes();
1250 if (stroke_type == StrokeType::Stroke) {
1251 if (const VArray<bool> hide_stroke = *curves.attributes().lookup<bool>(
1252 "hide_stroke", bke::AttrDomain::Curve))
1253 {
1254 IndexMask mask = IndexMask::from_bools_inverse(selectable_strokes, hide_stroke, memory);
1255 if (selection_domain == bke::AttrDomain::Point) {
1256 mask = IndexMask::from_ranges(curves.points_by_curve(), mask, memory);
1257 }
1258 ed::curves::select_all(info.drawing.strokes_for_write(), mask, selection_domain, action);
1259 }
1260 else {
1261 ed::curves::select_all(info.drawing.strokes_for_write(), selection_domain, action);
1262 }
1263 changed.store(true, std::memory_order_relaxed);
1264 }
1265 else if (stroke_type == StrokeType::Fill) {
1266 if (const VArray<int> fill_id = *curves.attributes().lookup<int>("fill_id",
1268 {
1270 selectable_strokes, memory, [&](const int index) { return fill_id[index] != 0; });
1271 if (selection_domain == bke::AttrDomain::Point) {
1272 mask = IndexMask::from_ranges(curves.points_by_curve(), mask, memory);
1273 }
1274 ed::curves::select_all(info.drawing.strokes_for_write(), mask, selection_domain, action);
1275 changed.store(true, std::memory_order_relaxed);
1276 }
1277 }
1278 });
1279
1280 if (changed) {
1281 /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
1282 * attribute for now. */
1285 }
1286
1287 return OPERATOR_FINISHED;
1288}
1289
1291 {int(StrokeType::Stroke), "STROKE", 0, "Stroke", ""},
1292 {int(StrokeType::Fill), "FILL", 0, "Fill", ""},
1293 {0, nullptr, 0, nullptr, nullptr},
1294};
1295
1297{
1298 PropertyRNA *prop;
1299
1300 ot->name = "Select By Stroke Type";
1301 ot->idname = "GREASE_PENCIL_OT_select_by_stroke_type";
1302 ot->description = "Select/Deselect all strokes or fills";
1303
1306
1308
1309 ot->prop = RNA_def_enum(ot->srna, "type", select_by_stroke_type_items, 0, "Type", "");
1311
1312 prop = RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Unselect strokes");
1314}
1315
1316} // namespace ed::greasepencil
1317
1319{
1320 switch (tool_settings->gpencil_selectmode_edit) {
1327 }
1329}
1330
1332{
1333 const int selectmode = tool_settings->gpencil_selectmode_sculpt;
1336 }
1337 if (selectmode & (GP_SCULPT_MASK_SELECTMODE_STROKE)) {
1339 }
1341}
1342
1344{
1345 const int selectmode = tool_settings->gpencil_selectmode_vertex;
1348 }
1349 if (selectmode & (GP_VERTEX_MASK_SELECTMODE_STROKE)) {
1351 }
1353}
1354
1356 const Object *object)
1357{
1358 if (object->mode & OB_MODE_EDIT) {
1359 return ED_grease_pencil_edit_selection_domain_get(tool_settings);
1360 }
1363 }
1366 }
1367 if (object->mode & OB_MODE_PAINT_GREASE_PENCIL) {
1368 /* Always use curve selection in Draw Mode. */
1370 }
1372}
1373
1375{
1376 const int selectmode = tool_settings->gpencil_selectmode_vertex;
1379 {
1380 return true;
1381 }
1382 return false;
1383}
1384
1386{
1387 return tool_settings->gpencil_selectmode_edit == GP_SELECTMODE_SEGMENT;
1388}
1389
1394
1399
1401 const Object *object)
1402{
1403 if (object->mode & OB_MODE_EDIT) {
1405 }
1408 }
1411 }
1412 return false;
1413}
1414
1431
1432} // namespace blender
Low-level operations for curves.
Low-level operations for curves.
Low-level operations for grease pencil.
General operations, lookup, etc. for blender objects.
#define INT32_MAX
#define BLI_SCOPED_DEFER(function_to_defer)
Object is a sort of wrapper for general info.
#define C
Definition RandGen.cpp:29
#define NC_GEOM
Definition WM_types.hh:406
#define ND_DATA
Definition WM_types.hh:552
#define NA_EDITED
Definition WM_types.hh:634
#define ND_SPACE_VIEW3D
Definition WM_types.hh:571
#define NC_SPACE
Definition WM_types.hh:405
#define BLI_assert_unreachable()
#define ELEM(...)
static const CPPType & get()
void default_construct(void *ptr) const
GMutableSpan slice(const int64_t start, int64_t size) const
MutableSpan< T > typed() const
void materialize_to_uninitialized(void *dst) const
static IndexMask from_predicate(const IndexMask &universe, LinearAllocator<> &memory, Fn &&predicate, exec_mode::Mode mode=exec_mode::parallel)
static IndexMask from_ranges(OffsetIndices< T > offsets, const IndexMask &mask, LinearAllocator<> &memory)
static IndexMask from_bools_inverse(Span< bool > bools, LinearAllocator<> &memory)
constexpr int64_t first() const
constexpr int64_t last(const int64_t n=0) const
constexpr int64_t size() const
constexpr bool is_empty() const
static constexpr IndexRange from_begin_end(const int64_t begin, const int64_t end)
constexpr IndexRange()=default
static constexpr IndexRange from_begin_end_inclusive(const int64_t begin, const int64_t last)
bool contains(const Key &key) const
Definition BLI_set.hh:310
bool add(const Key &key)
Definition BLI_set.hh:248
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
bool add(const Key &key)
bool contains(const Key &key) const
GAttributeReader lookup_or_default(StringRef name, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
std::optional< AttributeMetaData > lookup_meta_data(StringRef name) const
GAttributeReader lookup(const StringRef name) const
bool add(const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
bke::CurvesGeometry & strokes_for_write()
const bke::CurvesGeometry & strokes() const
constexpr IndexRange index_range() const
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
void to_bools(MutableSpan< bool > r_bools) const
#define FLT_MAX
#define T
IndexMask point_to_curve_selection(OffsetIndices< int > points_by_curve, const IndexMask &point_mask, LinearAllocator<> &memory)
IndexMask selected_mask_to_fills(const IndexMask &selected_mask, const CurvesGeometry &curves, AttrDomain selection_domain, IndexMaskMemory &memory)
AttrType cpp_type_to_attribute_type(const CPPType &type)
bool has_anything_selected(const VArray< bool > &varray, const IndexRange range_to_check)
void apply_selection_operation_at_index(GMutableSpan selection, const int index, const eSelectOp sel_op)
void select_linked(bke::CurvesGeometry &curves, const IndexMask &curves_mask, const bool unselect)
void select_all(bke::CurvesGeometry &curves, const IndexMask &mask, const bke::AttrDomain selection_domain, int action)
IndexMask retrieve_selected_points(const bke::CurvesGeometry &curves, LinearAllocator<> &memory)
void select_alternate(bke::CurvesGeometry &curves, const IndexMask &curves_mask, const bool deselect_ends)
void fill_selection_false(GMutableSpan selection)
IndexMask select_adjacent_mask(const bke::CurvesGeometry &curves, const IndexMask &curves_mask, const StringRef attribute_name, const bool deselect, IndexMaskMemory &memory)
IndexMask retrieve_selected_curves(const bke::CurvesGeometry &curves, LinearAllocator<> &memory)
void fill_selection_true(GMutableSpan selection)
Span< StringRef > get_curves_selection_attribute_names(const bke::CurvesGeometry &curves)
void fill_selection(GMutableSpan selection, bool value)
IndexMask end_points(const bke::CurvesGeometry &curves, const IndexMask &curves_mask, const int amount_start, const int amount_end, const bool inverted, IndexMaskMemory &memory)
bke::GSpanAttributeWriter ensure_selection_attribute(bke::CurvesGeometry &curves, bke::AttrDomain selection_domain, bke::AttrType create_type, StringRef attribute_name)
static void GREASE_PENCIL_OT_select_linked(wmOperatorType *ot)
static void select_similar_by_value(Scene *scene, Object *object, GreasePencil &grease_pencil, const bke::AttrDomain selection_domain, const StringRef name, const eHandleDisplay handle_display, float threshold, DistanceFn distance_fn)
IndexMask retrieve_editable_and_selected_strokes(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, IndexMaskMemory &memory)
static wmOperatorStatus select_fill_exec(bContext *C, wmOperator *)
static wmOperatorStatus select_ends_exec(bContext *C, wmOperator *op)
FunctionRef< IndexMask(const ed::greasepencil::MutableDrawingInfo &info, const IndexMask &universe, StringRef attribute_name, IndexMaskMemory &memory)> SelectionUpdateFunc
static const EnumPropertyItem select_by_stroke_type_items[]
bool apply_mask_as_selection(bke::CurvesGeometry &curves, const IndexMask &selection_mask, const bke::AttrDomain selection_domain, const StringRef attribute_name, const eSelectOp sel_op)
static void GREASE_PENCIL_OT_select_more(wmOperatorType *ot)
static wmOperatorStatus select_set_mode_exec(bContext *C, wmOperator *op)
bool selection_update(const ViewContext *vc, const eSelectOp sel_op, SelectionUpdateFunc select_operation)
bool ensure_selection_domain(ToolSettings *ts, Object *object)
static wmOperatorStatus select_more_exec(bContext *C, wmOperator *)
bool editable_grease_pencil_point_selection_poll(bContext *C)
IndexMask retrieve_editable_elements(Object &object, const MutableDrawingInfo &info, const bke::AttrDomain selection_domain, IndexMaskMemory &memory)
void free_curves_2d_bvh_data(Curves2DBVHTree &data)
static const EnumPropertyItem select_similar_mode_items[]
CurveSegmentsData find_curve_segments(const bke::CurvesGeometry &curves, const IndexMask &curve_mask, const Span< float2 > screen_space_positions, const Curves2DBVHTree &tree_data, const IndexRange tree_data_range)
static wmOperatorStatus select_alternate_exec(bContext *C, wmOperator *op)
static void select_similar_by_layer(Scene *scene, Object *object, GreasePencil &grease_pencil, bke::AttrDomain domain)
IndexMask retrieve_editable_strokes_by_material(Object &object, const bke::greasepencil::Drawing &drawing, const int mat_i, IndexMaskMemory &memory)
static wmOperatorStatus select_all_exec(bContext *C, wmOperator *op)
static wmOperatorStatus select_random_exec(bContext *C, wmOperator *op)
int clamp_range(const IndexRange range, const int index)
bool editable_grease_pencil_poll(bContext *C)
static wmOperatorStatus select_similar_exec(bContext *C, wmOperator *op)
static int foreach_curve_segment(const CurveSegmentsData &segment_data, const int curve_index, const IndexRange points, Fn &&fn)
static void GREASE_PENCIL_OT_select_less(wmOperatorType *ot)
IndexMask retrieve_editable_and_all_selected_points(Object &object, const bke::greasepencil::Drawing &drawing, const int layer_index, const eHandleDisplay handle_display, IndexMaskMemory &memory)
bool apply_mask_as_segment_selection(bke::CurvesGeometry &curves, const IndexMask &point_selection_mask, const StringRef attribute_name, const Curves2DBVHTree &tree_data, const IndexRange tree_data_range, const eSelectOp sel_op)
static void GREASE_PENCIL_OT_select_all(wmOperatorType *ot)
static void GREASE_PENCIL_OT_select_alternate(wmOperatorType *ot)
static void GREASE_PENCIL_OT_select_ends(wmOperatorType *ot)
eHandleDisplay view3d_handle_type_or_default(const View3D *v3d)
static void GREASE_PENCIL_OT_select_similar(wmOperatorType *ot)
IndexMask retrieve_editable_strokes(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, IndexMaskMemory &memory)
static wmOperatorStatus select_less_exec(bContext *C, wmOperator *)
Vector< MutableDrawingInfo > retrieve_editable_drawings(const Scene &scene, GreasePencil &grease_pencil)
Curves2DBVHTree build_curves_2d_bvh_from_visible(const ViewContext &vc, const Object &object, const GreasePencil &grease_pencil, Span< MutableDrawingInfo > drawings, const int frame_number)
void insert_selected_values(Object *object, const MutableDrawingInfo &info, const bke::AttrDomain domain, const StringRef name, const eHandleDisplay handle_display, Set< T > &r_value_set)
static void GREASE_PENCIL_OT_select_random(wmOperatorType *ot)
static wmOperatorStatus grease_pencil_material_select_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_material_select(wmOperatorType *ot)
static void GREASE_PENCIL_OT_set_selection_mode(wmOperatorType *ot)
static wmOperatorStatus grease_pencil_select_by_stroke_type_exec(bContext *C, wmOperator *op)
Array< Vector< MutableDrawingInfo > > retrieve_editable_drawings_grouped_per_frame(const Scene &scene, GreasePencil &grease_pencil)
static void GREASE_PENCIL_OT_select_by_stroke_type(wmOperatorType *ot)
static void GREASE_PENCIL_OT_select_fill(wmOperatorType *ot)
static wmOperatorStatus select_linked_exec(bContext *C, wmOperator *op)
constexpr ParallelGrainSize grain_size(int grain_size)
void masked_fill(MutableSpan< T > data, const T &value, const IndexMask &mask)
T distance(const T &a, const T &b)
void parallel_for_each(Range &&range, const Function &function)
Definition BLI_task.hh:31
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.
void WM_main_add_notifier(uint type, void *reference)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
wmOperatorStatus WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
__int64 int64_t
Definition BKE_text.h:90
int RNA_enum_get(PointerRNA *ptr, const char *name)
void WM_operator_properties_select_random(wmOperatorType *ot)
ViewContext ED_view3d_viewcontext_init(bContext *C, Depsgraph *depsgraph)
@ GP_SCULPT_MASK_SELECTMODE_POINT
@ GP_SCULPT_MASK_SELECTMODE_STROKE
@ GP_SCULPT_MASK_SELECTMODE_SEGMENT
bool ED_grease_pencil_vertex_segment_selection_enabled(const ToolSettings *tool_settings)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
int WM_operator_properties_select_random_seed_increment_get(wmOperator *op)
bool ED_grease_pencil_segment_selection_enabled(const ToolSettings *tool_settings, const Object *object)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void ED_operatortypes_grease_pencil_select()
int RNA_int_get(PointerRNA *ptr, const char *name)
void WM_operator_properties_select_all(wmOperatorType *ot)
VecBase< float, 4 > float4
bke::AttrDomain ED_grease_pencil_sculpt_selection_domain_get(const ToolSettings *tool_settings)
@ GP_VERTEX_MASK_SELECTMODE_STROKE
@ GP_VERTEX_MASK_SELECTMODE_POINT
@ GP_VERTEX_MASK_SELECTMODE_SEGMENT
void DEG_id_tag_update(ID *id, unsigned int flags)
@ OB_MODE_VERTEX_GREASE_PENCIL
@ OB_MODE_SCULPT_GREASE_PENCIL
@ OB_MODE_PAINT_GREASE_PENCIL
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
bke::AttrDomain ED_grease_pencil_edit_selection_domain_get(const ToolSettings *tool_settings)
ToolSettings * CTX_data_tool_settings(const bContext *C)
bool ED_grease_pencil_any_vertex_mask_selection(const ToolSettings *tool_settings)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
bke::AttrDomain ED_grease_pencil_selection_domain_get(const ToolSettings *tool_settings, const Object *object)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
bool ED_grease_pencil_edit_segment_selection_enabled(const ToolSettings *tool_settings)
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)
const EnumPropertyItem rna_enum_grease_pencil_selectmode_items[]
Definition rna_scene.cc:698
bool ED_grease_pencil_sculpt_segment_selection_enabled(const ToolSettings *tool_settings)
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
@ PROP_HIDDEN
Definition RNA_types.hh:408
bke::AttrDomain ED_grease_pencil_vertex_selection_domain_get(const ToolSettings *tool_settings)
Scene * CTX_data_scene(const bContext *C)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
@ 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)
bool BKE_object_is_mode_compat(const Object *ob, eObjectMode object_mode)
Definition object.cc:2058
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
Object * CTX_data_active_object(const bContext *C)
constexpr uint64_t get_default_hash(const T &v, const Args &...args)
Definition BLI_hash.hh:252
float RNA_float_get(PointerRNA *ptr, const char *name)
View3D * CTX_wm_view3d(const bContext *C)
signed char int8_t
Definition BKE_text.h:76
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
struct ToolSettings * toolsettings
eGP_Sculpt_SelectMaskFlag gpencil_selectmode_sculpt
eGPencil_Selectmode_types gpencil_selectmode_edit
eGP_Vertex_SelectMaskFlag gpencil_selectmode_vertex
Depsgraph * depsgraph
Definition ED_view3d.hh:78
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
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141