41 const int frame_number,
56 &ob_eval, obact, layer_index, frame_number);
61 for (const int src_point : src_points) {
62 screen_space_positions[src_point] = ED_view3d_project_float_v2_m4(
63 ®ion, deformation.positions[src_point], projection);
71 for (const int src_curve : src_curves) {
72 rcti *bbox = &screen_space_bbox[src_curve];
73 BLI_rcti_init_minmax(bbox);
75 const IndexRange src_points = src_points_by_curve[src_curve];
76 for (const int src_point : src_points) {
77 BLI_rcti_do_minmax_v(bbox, int2(screen_space_positions[src_point]));
81 BLI_rcti_pad(bbox, BBOX_PADDING, BBOX_PADDING);
94 obact, drawing, layer_index, memory);
97 if (!
BLI_rcti_isect(&bbox_lasso, &screen_space_bbox[src_curve],
nullptr)) {
102 Vector<int> selected_points;
103 for (
const int src_point : src_points_by_curve[src_curve]) {
107 int(screen_space_positions[src_point].x),
108 int(screen_space_positions[src_point].y),
111 if (selected_points.is_empty()) {
112 selected_curves.
append(src_curve);
114 selected_points.append(src_point);
117 if (!selected_points.is_empty()) {
118 selected_points_in_curves.
append(std::move(selected_points));
122 const IndexMask curve_selection = IndexMask::from_indices(selected_curves.
as_span(), memory);
124 if (curve_selection.is_empty()) {
129 bke::CurvesGeometry cut_strokes = ed::greasepencil::trim::trim_curve_segments(
131 screen_space_positions,
134 selected_points_in_curves,
138 drawing.strokes_for_write() = std::move(cut_strokes);
139 drawing.tag_topology_changed();
165 std::atomic<bool> changed =
false;
167 if (active_layer_only) {
169 if (!grease_pencil.has_active_layer()) {
173 const float4x4 layer_to_world = layer.to_world_space(*ob_eval);
176 ed::greasepencil::retrieve_editable_drawings_from_layer(*scene, grease_pencil, layer);
195 ed::greasepencil::retrieve_editable_drawings(*scene, grease_pencil);
198 const float4x4 layer_to_world = layer.to_world_space(*ob_eval);
240 ot->
name =
"Grease Pencil Trim";
241 ot->
idname =
"GREASE_PENCIL_OT_stroke_trim";
242 ot->
description =
"Delete stroke points in between intersecting strokes";
246 ot->
exec = grease_pencil_stroke_trim;
247 ot->
poll = grease_pencil_painting_poll;
void BKE_brush_init_gpencil_settings(Brush *brush)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
Low-level operations for curves.
Paint * BKE_paint_get_active_from_context(const bContext *C)
Brush * BKE_paint_brush(Paint *paint)
bool BLI_lasso_is_point_inside(blender::Span< blender::int2 > mcoords, int sx, int sy, int error_value)
void BLI_lasso_boundbox(rcti *rect, blender::Span< blender::int2 > mcoords)
bool BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2])
bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest)
void DEG_id_tag_update(ID *id, unsigned int flags)
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
@ GP_BRUSH_ERASER_KEEP_CAPS
@ GP_BRUSH_ACTIVE_LAYER_ONLY
blender::float4x4 ED_view3d_ob_project_mat_get_from_obmat(const RegionView3D *rv3d, const blender::float4x4 &obmat)
void append(const T &value)
Span< T > as_span() const
OffsetIndices< int > points_by_curve() const
IndexRange points_range() const
const bke::CurvesGeometry & strokes() const
void foreach_index(Fn &&fn) const
const Depsgraph * depsgraph
void GREASE_PENCIL_OT_stroke_trim(wmOperatorType *ot)
GeometryDeformation get_evaluated_grease_pencil_drawing_deformation(const Object *ob_eval, const Object &ob_orig, int layer_index, int frame)
static int grease_pencil_stroke_trim(bContext *C, wmOperator *op)
static int stroke_trim_execute(const bContext *C, const Span< int2 > mcoords)
static constexpr int BBOX_PADDING
IndexMask retrieve_editable_strokes(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, IndexMaskMemory &memory)
static bool execute_trim_on_drawing(const int layer_index, const int frame_number, const Object &ob_eval, Object &obact, const ARegion ®ion, const float4x4 &projection, const Span< int2 > mcoords, const bool keep_caps, bke::greasepencil::Drawing &drawing)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
struct BrushGpencilSettings * gpencil_settings
bke::greasepencil::Drawing & drawing
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* modal)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(* cancel)(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
Array< int2 > WM_gesture_lasso_path_to_array(bContext *, wmOperator *op)
int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
void WM_gesture_lasso_cancel(bContext *C, wmOperator *op)
int WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void WM_operator_properties_gesture_lasso(wmOperatorType *ot)