Blender V5.3
grease_pencil_trim.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLI_array.hh"
10#include "BLI_bounds.hh"
11#include "BLI_lasso_2d.hh"
12#include "BLI_rect.hh"
13#include "BLI_task.hh"
14
15#include "DNA_brush_types.h"
16
17#include "BKE_brush.hh"
18#include "BKE_context.hh"
19#include "BKE_crazyspace.hh"
20#include "BKE_curves.hh"
21#include "BKE_paint.hh"
22
24
25#include "ED_grease_pencil.hh"
26#include "ED_view3d.hh"
27
28#include "RNA_access.hh"
29
30#include "WM_api.hh"
31
33
34namespace blender {
35
36namespace ed::greasepencil {
37
38namespace trim {
39
40using namespace segment;
41
43 const int2 &pos_b,
44 const Span<int2> mcoords)
45{
46 Bounds<int2> bbox_ab{math::min(pos_a, pos_b), math::max(pos_a, pos_b)};
47 bbox_ab.pad(BBOX_PADDING);
48
49 /* Check the lasso bounding box first as an optimization. */
50 if (bbox_ab.intersects_segment(pos_a, pos_b) &&
51 BLI_lasso_is_edge_inside(mcoords, pos_a.x, pos_a.y, pos_b.x, pos_b.y, IS_CLIPPED))
52 {
53 return true;
54 }
55 return false;
56}
57
58static void check_segments_in_lasso(const Span<float2> screen_space_positions,
59 const Span<Bounds<float2>> screen_space_bbox,
60 const Span<int2> mcoords,
61 const Span<Segment> all_segments,
62 const IndexMask &editable_curves,
63 const OffsetIndices<int> segments_by_curve,
64 MutableSpan<bool> segments_to_keep)
65{
66 const Bounds<int2> bbox_lasso_int = *bounds::min_max(mcoords);
67 const Bounds<float2> bbox_lasso{float2(bbox_lasso_int.min), float2(bbox_lasso_int.max)};
68
69 editable_curves.foreach_index(
70 [&](const int curve_i) {
71 /* To speed things up: Do a bounding box check on the curve and the lasso area. */
72 if (!bounds::intersect(bbox_lasso, screen_space_bbox[curve_i]).has_value()) {
73 return;
74 }
75
76 const IndexRange &segment_range = segments_by_curve[curve_i];
77 for (const int segment_i : segment_range) {
78 const Segment &segment = all_segments[segment_i];
79
80 const IndexRange point_range = segment.point_range();
81
82 if (point_range.is_empty()) {
83 const float start_factor = segment.intersection_factor[Side::Start];
84 const int2 start_edge = segment.edge(Side::Start);
85 const float end_factor = segment.intersection_factor[Side::End];
86 const int2 end_edge = segment.edge(Side::End);
87 const float2 pos_1 = math::interpolate(screen_space_positions[start_edge.x],
88 screen_space_positions[start_edge.y],
89 start_factor);
90 const float2 pos_2 = math::interpolate(screen_space_positions[end_edge.x],
91 screen_space_positions[end_edge.y],
92 end_factor);
93
94 if (check_line_segment_lasso_intersection(int2(pos_1), int2(pos_2), mcoords)) {
95 segments_to_keep[segment_i] = false;
96 }
97
98 continue;
99 }
100
101 for (const int64_t i : point_range.drop_back(1)) {
102 const int point_i1 = segment.wrap_index(i);
103 const int point_i2 = segment.wrap_index(i + 1);
104
105 const float2 pos_1 = screen_space_positions[point_i1];
106 const float2 pos_2 = screen_space_positions[point_i2];
107
108 if (check_line_segment_lasso_intersection(int2(pos_1), int2(pos_2), mcoords)) {
109 segments_to_keep[segment_i] = false;
110 continue;
111 }
112 }
113
114 if (segment_range.size() == 1 && segment.is_loop()) {
115 const float2 pos_1 = screen_space_positions[segment.wrap_index(point_range.first())];
116 const float2 pos_2 = screen_space_positions[segment.wrap_index(point_range.last())];
117
118 if (check_line_segment_lasso_intersection(int2(pos_1), int2(pos_2), mcoords)) {
119 segments_to_keep[segment_i] = false;
120 continue;
121 }
122 }
123 else {
124 if (segment.has_intersection(Side::Start)) {
125 const float start_factor = segment.intersection_factor[Side::Start];
126 const int2 start_edge = segment.edge(Side::Start);
127 const float2 pos_1 = math::interpolate(screen_space_positions[start_edge.x],
128 screen_space_positions[start_edge.y],
129 start_factor);
130 const float2 pos_2 = screen_space_positions[segment.wrap_index(point_range.first())];
131
132 if (check_line_segment_lasso_intersection(int2(pos_1), int2(pos_2), mcoords)) {
133 segments_to_keep[segment_i] = false;
134 continue;
135 }
136 }
137
138 if (segment.has_intersection(Side::End)) {
139 const float end_factor = segment.intersection_factor[Side::End];
140 const int2 end_edge = segment.edge(Side::End);
141 const float2 pos_1 = screen_space_positions[segment.wrap_index(point_range.last())];
142 const float2 pos_2 = math::interpolate(screen_space_positions[end_edge.x],
143 screen_space_positions[end_edge.y],
144 end_factor);
145
146 if (check_line_segment_lasso_intersection(int2(pos_1), int2(pos_2), mcoords)) {
147 segments_to_keep[segment_i] = false;
148 continue;
149 }
150 }
151 }
152 }
153 },
155}
156
158 const Span<Segment> segments,
159 const Span<bool> segment_reversed,
160 const Span<bool> cyclic,
161 const OffsetIndices<int> segment_offsets)
162{
163 struct InterpolatePoint {
164 int src_point_1;
165 int src_point_2;
166 float factor;
167 };
168
169 Array<int> point_offsets(segment_offsets.size() + 1);
170 Vector<InterpolatePoint> point_to_interpolate;
171
172 for (const int curve_i : segment_offsets.index_range()) {
173 point_offsets[curve_i] = point_to_interpolate.size();
174
175 const IndexRange segment_range = segment_offsets[curve_i];
176 for (const int seg_i : segment_range) {
177 const Segment &segment = segments[seg_i];
178 const bool reversed = segment_reversed[seg_i];
179 const Side start_side = reversed ? Side::End : Side::Start;
180 const Side end_side = reversed ? Side::Start : Side::End;
181
182 if (segment.has_intersection(start_side) && !segment.is_loop()) {
183 const float start_factor = segment.intersection_factor[start_side];
184 const int2 start_edge = segment.edge(start_side);
185
186 point_to_interpolate.append({start_edge.x, start_edge.y, start_factor});
187 }
188
189 segment.foreach_point(
190 [&](const int index) { point_to_interpolate.append({index, index, 0.0f}); });
191
192 if (reversed) {
193 point_to_interpolate.as_mutable_span().take_back(segment.points_num()).reverse();
194 }
195
196 if (seg_i == segment_range.last() && segment.has_intersection(end_side) && !cyclic[curve_i])
197 {
198 const float end_factor = segment.intersection_factor[end_side];
199 const int2 end_edge = segment.edge(end_side);
200
201 point_to_interpolate.append({end_edge.x, end_edge.y, end_factor});
202 }
203 }
204 }
205
206 point_offsets.last() = point_to_interpolate.size();
207 const OffsetIndices<int> dst_points_by_curve = OffsetIndices<int>(point_offsets);
208
209 if (dst_points_by_curve.total_size() == 0) {
210 return bke::CurvesGeometry();
211 }
212
213 bke::CurvesGeometry dst_curves(dst_points_by_curve.total_size(), dst_points_by_curve.size());
214 bke::MutableAttributeAccessor dst_attributes = dst_curves.attributes_for_write();
215
216 dst_curves.offsets_for_write().copy_from(dst_points_by_curve.data());
217 dst_curves.cyclic_for_write().copy_from(cyclic);
218
219 Array<int> old_by_new_map(dst_points_by_curve.size());
220
221 threading::parallel_for(dst_points_by_curve.index_range(), 4096, [&](const IndexRange points) {
222 for (const int i : points) {
223 const IndexRange segment_range = segment_offsets[i];
224 old_by_new_map[i] = segments[segment_range.first()].curve;
225 }
226 });
227
228 const bke::AttributeAccessor src_attributes = src.attributes();
229 bke::gather_attributes(src_attributes,
233 old_by_new_map,
234 dst_attributes);
235
236 /* Copy/Interpolate point attributes. */
238 src_attributes, dst_attributes, {bke::AttrDomain::Point}, {}))
239 {
240 bke::attribute_math::to_static_type(attribute.dst.span.type(), [&]<typename T>() {
241 if constexpr (!std::is_same_v<T, std::string>) {
242 const Span<T> src_attr = attribute.src.typed<T>();
243 MutableSpan<T> dst_attr = attribute.dst.span.typed<T>();
244
245 threading::parallel_for(
246 point_to_interpolate.index_range(), 4096, [&](const IndexRange points) {
247 for (const int i : points) {
248 const InterpolatePoint &int_point = point_to_interpolate[i];
249
250 if (int_point.factor == 0.0f) {
251 dst_attr[i] = src_attr[int_point.src_point_1];
252 }
253 else if (int_point.factor == 1.0f) {
254 dst_attr[i] = src_attr[int_point.src_point_2];
255 }
256 else {
257 dst_attr[i] = bke::attribute_math::mix2<T>(int_point.factor,
258 src_attr[int_point.src_point_1],
259 src_attr[int_point.src_point_2]);
260 }
261 }
262 });
263 }
264 });
265
266 attribute.dst.finish();
267 }
268
269 return dst_curves;
270}
271
273 const Span<float2> screen_space_positions,
274 const Span<int2> mcoords,
275 const IndexMask &editable_curves,
276 const IndexMask &visible_curves,
277 const bool keep_caps)
278{
279 if (src.is_empty()) {
280 return src;
281 }
282
283 const OffsetIndices<int> src_points_by_curve = src.points_by_curve();
284 const VArray<bool> is_cyclic = src.cyclic();
285
286 Array<Bounds<float2>> screen_space_bbox(src.curves_num());
287 compute_bounding_boxes(src_points_by_curve, screen_space_positions, screen_space_bbox);
288
289 Vector<IntersectionPoint> intersections;
290 Array<int> all_segment_offset_data(src_points_by_curve.size() + 1);
291 Vector<Segment> all_segments;
292
293 Array<Vector<int>> inters_per_curves(src_points_by_curve.size());
294 find_intersections_between_all_curves(screen_space_positions,
295 screen_space_bbox,
296 src_points_by_curve,
297 is_cyclic,
298 visible_curves,
299 inters_per_curves,
300 intersections);
301 create_segments_from_intersections(inters_per_curves,
302 src_points_by_curve,
303 intersections,
304 is_cyclic,
305 all_segments,
306 all_segment_offset_data.as_mutable_span().drop_back(1));
307 store_segment_map_on_intersections(all_segments, intersections);
309 all_segment_offset_data);
310
311 Array<bool> segments_to_keep(all_segments.size(), true);
312 check_segments_in_lasso(screen_space_positions,
313 screen_space_bbox,
314 mcoords,
315 all_segments,
316 editable_curves,
317 segments_by_curve,
318 segments_to_keep.as_mutable_span());
319
320 Array<SegmentConnections> segment_connections(all_segments.size(),
323 segments_by_curve, segments_to_keep, is_cyclic, segment_connections.as_mutable_span());
324
325 Vector<Segment> segments;
326 Vector<int> segment_offset_data;
327 Vector<bool> segment_reversed;
328 Vector<bool> cyclic;
329 follow_segment_connections(all_segments,
330 segments_to_keep,
331 segment_connections,
332 segments,
333 segment_offset_data,
334 segment_reversed,
335 cyclic);
336 const OffsetIndices<int> segment_offsets = OffsetIndices<int>(segment_offset_data);
337
339 src, segments, segment_reversed, cyclic, segment_offsets);
340
341 if (!keep_caps) {
342 cut_caps(dst, segments, segment_reversed, cyclic, segment_offsets);
343 }
344
345 return dst;
346}
347
349 const Span<float2> screen_space_positions,
350 const IndexMask &editable_curves,
351 const IndexMask &visible_curves,
352 const bool keep_caps)
353{
354 if (src.is_empty()) {
355 return src;
356 }
357
358 const OffsetIndices<int> src_points_by_curve = src.points_by_curve();
359 /* Consider all curves to be non-cyclical when trimming curve ends. */
360 const VArray<bool> is_cyclic = VArray<bool>::from_single(false, src_points_by_curve.size());
361
362 Array<Bounds<float2>> screen_space_bbox(src.curves_num());
363 compute_bounding_boxes(src_points_by_curve, screen_space_positions, screen_space_bbox);
364
365 Vector<IntersectionPoint> intersections;
366 Array<int> all_segment_offset_data(src_points_by_curve.size() + 1);
367 Vector<Segment> all_segments;
368
369 Array<Vector<int>> inters_per_curves(src_points_by_curve.size());
370 find_intersections_between_all_curves(screen_space_positions,
371 screen_space_bbox,
372 src_points_by_curve,
373 is_cyclic,
374 visible_curves,
375 inters_per_curves,
376 intersections);
377 create_segments_from_intersections(inters_per_curves,
378 src_points_by_curve,
379 intersections,
380 is_cyclic,
381 all_segments,
382 all_segment_offset_data.as_mutable_span().drop_back(1));
383 store_segment_map_on_intersections(all_segments, intersections);
385 all_segment_offset_data);
386
387 Array<bool> segments_to_keep(all_segments.size(), true);
388 /* Remove the end segments unless that would delete the whole curve. */
389 editable_curves.foreach_index(
390 [&](const int curve_i) {
391 const IndexRange segment_range = segments_by_curve[curve_i];
392
393 if (segment_range.size() > 2) {
394 segments_to_keep[segment_range.first()] = false;
395 segments_to_keep[segment_range.last()] = false;
396 }
397 },
399
400 Array<SegmentConnections> segment_connections(all_segments.size(),
403 segments_by_curve, segments_to_keep, is_cyclic, segment_connections.as_mutable_span());
404
405 Vector<Segment> segments;
406 Vector<int> segment_offset_data;
407 Vector<bool> segment_reversed;
408 Vector<bool> cyclic;
409 follow_segment_connections(all_segments,
410 segments_to_keep,
411 segment_connections,
412 segments,
413 segment_offset_data,
414 segment_reversed,
415 cyclic);
416 const OffsetIndices<int> segment_offsets = OffsetIndices<int>(segment_offset_data);
417
419 src, segments, segment_reversed, cyclic, segment_offsets);
420
421 if (!keep_caps) {
422 cut_caps(dst, segments, segment_reversed, cyclic, segment_offsets);
423 }
424
425 return dst;
426}
427
428} // namespace trim
429
433static bool execute_trim_on_drawing(const int layer_index,
434 const Object &ob_eval,
435 Object &obact,
436 const ARegion &region,
437 const float4x4 &projection,
438 const Span<int2> mcoords,
439 const bool keep_caps,
441{
442 const bke::CurvesGeometry &src = drawing.strokes();
443
444 /* Get evaluated geometry. */
447
448 /* Compute screen space positions. */
449 Array<float2> screen_space_positions(src.points_num());
450 threading::parallel_for(src.points_range(), 4096, [&](const IndexRange src_points) {
451 for (const int src_point : src_points) {
452 screen_space_positions[src_point] = ED_view3d_project_float_v2_m4(
453 &region, deformation.positions[src_point], projection);
454 }
455 });
456
457 IndexMaskMemory memory;
459 obact, drawing, layer_index, memory);
461 obact, drawing, memory);
462
463 /* Apply trim. */
465 src, screen_space_positions, mcoords, editable_strokes, visible_strokes, keep_caps);
466
467 /* Set the new geometry. */
468 drawing.strokes_for_write() = std::move(cut_strokes);
469 drawing.tag_topology_changed();
470
471 return true;
472}
473
478{
479 const Scene *scene = CTX_data_scene(C);
480 const ARegion *region = CTX_wm_region(C);
481 const RegionView3D *rv3d = CTX_wm_region_view3d(C);
482 const Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
484 Object *ob_eval = DEG_get_evaluated(depsgraph, obact);
485
486 GreasePencil &grease_pencil = *id_cast<GreasePencil *>(obact->data);
487
490 if (brush->gpencil_settings == nullptr) {
492 }
493 const bool keep_caps = (brush->gpencil_settings->flag & GP_BRUSH_ERASER_KEEP_CAPS) != 0;
494 const bool active_layer_only = (brush->gpencil_settings->flag & GP_BRUSH_ACTIVE_LAYER_ONLY) != 0;
495 std::atomic<bool> changed = false;
496
497 bool inserted_keyframe = false;
498 if (active_layer_only) {
499 /* Apply trim on drawings of active layer. */
500 if (!grease_pencil.has_active_layer()) {
501 return OPERATOR_CANCELLED;
502 }
503
504 bke::greasepencil::Layer &layer = *grease_pencil.get_active_layer();
505 if (!layer.is_editable()) {
506 return OPERATOR_CANCELLED;
507 }
508
509 ensure_active_keyframe(*scene, grease_pencil, layer, true, inserted_keyframe);
510 const float4x4 layer_to_world = layer.to_world_space(*ob_eval);
511 const float4x4 projection = ED_view3d_ob_project_mat_get_from_obmat(rv3d, layer_to_world);
516 *ob_eval,
517 *obact,
518 *region,
519 projection,
520 mcoords,
521 keep_caps,
522 info.drawing))
523 {
524 changed = true;
525 }
526 });
527 }
528 else {
529 for (bke::greasepencil::Layer *layer : grease_pencil.layers_for_write()) {
530 if (layer->is_editable()) {
532 *scene, grease_pencil, *layer, true, inserted_keyframe);
533 }
534 }
535
536 /* Apply trim on every editable drawing. */
541 const float4x4 layer_to_world = layer.to_world_space(*ob_eval);
542 const float4x4 projection = ED_view3d_ob_project_mat_get_from_obmat(rv3d, layer_to_world);
544 *ob_eval,
545 *obact,
546 *region,
547 projection,
548 mcoords,
549 keep_caps,
550 info.drawing))
551 {
552 changed = true;
553 }
554 });
555 }
556
557 if (changed) {
560 if (inserted_keyframe) {
562 }
563 }
564
565 return OPERATOR_FINISHED;
566}
567
569{
570 const Array<int2> mcoords = WM_gesture_lasso_path_to_array(C, op);
571
572 if (mcoords.is_empty()) {
574 }
575
576 return stroke_trim_execute(C, mcoords);
577}
578
579} // namespace ed::greasepencil
580
582{
583 using namespace blender::ed::greasepencil;
584
585 ot->name = "Grease Pencil Trim";
586 ot->idname = "GREASE_PENCIL_OT_stroke_trim";
587 ot->description = "Delete stroke points in between intersecting strokes";
588
594
596
598}
599
600} // namespace blender
Low-level operations for curves.
#define IS_CLIPPED
Definition ED_view3d.hh:269
#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 NC_GPENCIL
Definition WM_types.hh:412
MutableSpan< T > as_mutable_span()
Definition BLI_array.hh:259
const T & last(const int64_t n=0) const
Definition BLI_array.hh:307
bool is_empty() const
Definition BLI_array.hh:275
constexpr int64_t first() const
constexpr IndexRange drop_back(int64_t n) const
constexpr int64_t last(const int64_t n=0) const
constexpr int64_t size() const
constexpr bool is_empty() const
static VArray from_single(T value, const int64_t size)
int64_t size() const
void append(const T &value)
MutableSpan< T > as_mutable_span()
VArray< bool > cyclic() const
MutableSpan< int > offsets_for_write()
IndexRange points_range() const
MutableSpan< bool > cyclic_for_write()
OffsetIndices< int > points_by_curve() const
MutableAttributeAccessor attributes_for_write()
const bke::CurvesGeometry & strokes() const
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
#define attribute(slot)
#define layer
#define T
void to_static_type(const CPPType &cpp_type, Fn &&fn)
GeometryDeformation get_evaluated_grease_pencil_drawing_deformation(const Object *ob_eval, const Object &ob_orig, const bke::greasepencil::Drawing &drawing_orig)
auto attribute_filter_from_skip_ref(const Span< StringRef > skip)
Vector< AttributeTransferData > retrieve_attributes_for_transfer(const AttributeAccessor src_attributes, MutableAttributeAccessor dst_attributes, Span< AttrDomain > domains, const AttributeFilter &attribute_filter={})
void gather_attributes(AttributeAccessor src_attributes, AttrDomain src_domain, AttrDomain dst_domain, const AttributeFilter &attribute_filter, const IndexMask &selection, MutableAttributeAccessor dst_attributes)
std::optional< Bounds< T > > min_max(const std::optional< Bounds< T > > &a, const T &b)
Definition BLI_bounds.hh:56
std::optional< Bounds< T > > intersect(const Bounds< T > &a, const Bounds< T > &b)
void cut_caps(bke::CurvesGeometry &dst, const Span< Segment > segments, const Span< bool > segment_reversed, const Span< bool > cyclic, const OffsetIndices< int > segment_offsets)
void compute_bounding_boxes(const OffsetIndices< int > src_points_by_curve, const Span< float2 > screen_space_positions, MutableSpan< Bounds< float2 > > screen_space_bbox)
void create_segments_from_intersections(const Span< Vector< int > > inters_per_curves, const OffsetIndices< int > points_by_curve, const Span< IntersectionPoint > &intersections, const VArray< bool > &cyclic, Vector< Segment > &all_segments, MutableSpan< int > segments_num_per_curve)
void store_segment_map_on_intersections(const Span< Segment > all_segments, MutableSpan< IntersectionPoint > intersections)
VecBase< EncodedConnection, 2 > SegmentConnections
void follow_segment_connections(const Span< Segment > all_segments, const Span< bool > segments_to_keep, const Span< SegmentConnections > segment_connections, Vector< Segment > &segments, Vector< int > &segment_offset_data, Vector< bool > &segment_reversed, Vector< bool > &cyclic)
void find_intersections_between_all_curves(const Span< float2 > screen_space_positions, const Span< Bounds< float2 > > screen_space_bbox, const OffsetIndices< int > points_by_curve, const VArray< bool > &cyclic, const IndexMask &visible_curves, Array< Vector< int > > &r_inters_per_curves, Vector< IntersectionPoint > &r_intersections)
void create_connections_from_curves(const OffsetIndices< int > segments_by_curve, const Span< bool > segments_to_keep, const VArray< bool > &is_cyclic, MutableSpan< SegmentConnections > segment_connections)
bke::CurvesGeometry trim_curve_segment_ends(const bke::CurvesGeometry &src, const Span< float2 > screen_space_positions, const IndexMask &editable_curves, const IndexMask &visible_curves, const bool keep_caps)
static bool check_line_segment_lasso_intersection(const int2 &pos_a, const int2 &pos_b, const Span< int2 > mcoords)
static void check_segments_in_lasso(const Span< float2 > screen_space_positions, const Span< Bounds< float2 > > screen_space_bbox, const Span< int2 > mcoords, const Span< Segment > all_segments, const IndexMask &editable_curves, const OffsetIndices< int > segments_by_curve, MutableSpan< bool > segments_to_keep)
bke::CurvesGeometry trim_curve_segments(const bke::CurvesGeometry &src, const Span< float2 > screen_space_positions, const Span< int2 > mcoords, const IndexMask &editable_curves, const IndexMask &visible_curves, const bool keep_caps)
static bke::CurvesGeometry create_curves_from_segments(const bke::CurvesGeometry &src, const Span< Segment > segments, const Span< bool > segment_reversed, const Span< bool > cyclic, const OffsetIndices< int > segment_offsets)
bool ensure_active_keyframe(const Scene &scene, GreasePencil &grease_pencil, bke::greasepencil::Layer &layer, const bool duplicate_previous_key, bool &r_inserted_keyframe)
Vector< MutableDrawingInfo > retrieve_editable_drawings_from_layer(const Scene &scene, GreasePencil &grease_pencil, const bke::greasepencil::Layer &layer)
IndexMask retrieve_visible_strokes(Object &object, const bke::greasepencil::Drawing &drawing, IndexMaskMemory &memory)
static wmOperatorStatus grease_pencil_stroke_trim_exec(bContext *C, wmOperator *op)
static bool execute_trim_on_drawing(const int layer_index, const Object &ob_eval, Object &obact, const ARegion &region, const float4x4 &projection, const Span< int2 > mcoords, const bool keep_caps, bke::greasepencil::Drawing &drawing)
static wmOperatorStatus stroke_trim_execute(const bContext *C, const Span< int2 > mcoords)
IndexMask retrieve_editable_strokes(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, IndexMaskMemory &memory)
Vector< MutableDrawingInfo > retrieve_editable_drawings(const Scene &scene, GreasePencil &grease_pencil)
bool grease_pencil_painting_poll(bContext *C)
constexpr ParallelGrainSize grain_size(int grain_size)
T min(const T &a, const T &b)
T interpolate(const T &a, const T &b, const FactorT &t)
T max(const T &a, const T &b)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
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.
__int64 int64_t
Definition BKE_text.h:90
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
void WM_gesture_lasso_cancel(bContext *C, wmOperator *op)
void GREASE_PENCIL_OT_stroke_trim(wmOperatorType *ot)
void BKE_brush_init_gpencil_settings(Brush *brush)
Definition brush.cc:719
wmOperatorStatus WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
MatBase< float, 4, 4 > float4x4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void DEG_id_tag_update(ID *id, unsigned int flags)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorStatus WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Paint * BKE_paint_get_active_from_context(const bContext *C)
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
Array< int2 > WM_gesture_lasso_path_to_array(bContext *, wmOperator *op)
float4x4 ED_view3d_ob_project_mat_get_from_obmat(const RegionView3D *rv3d, const float4x4 &obmat)
Brush * BKE_paint_brush(Paint *paint)
Scene * CTX_data_scene(const bContext *C)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ GP_BRUSH_ERASER_KEEP_CAPS
@ GP_BRUSH_ACTIVE_LAYER_ONLY
bool BLI_lasso_is_edge_inside(Span< int2 > mcoords, int x0, int y0, int x1, int y1, int error_value)
Definition lasso_2d.cc:56
Object * CTX_data_active_object(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
void WM_operator_properties_gesture_lasso(wmOperatorType *ot)
void pad(const PaddingT &padding)
bool intersects_segment(const T &start, const T &end) const
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
void(*) cancel(bContext *C, wmOperator *op)
Definition WM_types.hh:1149
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
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1157