57 for (const int src_point : src_points) {
58 screen_space_positions[src_point] = ED_view3d_project_float_v2_m4(
59 ®ion, deformation.positions[src_point], projection);
67 for (const int src_curve : src_curves) {
68 rcti *bbox = &screen_space_bbox[src_curve];
69 BLI_rcti_init_minmax(bbox);
71 const IndexRange src_points = src_points_by_curve[src_curve];
72 for (const int src_point : src_points) {
73 BLI_rcti_do_minmax_v(bbox, int2(screen_space_positions[src_point]));
77 BLI_rcti_pad(bbox, BBOX_PADDING, BBOX_PADDING);
90 obact, drawing, layer_index, memory);
93 if (!
BLI_rcti_isect(&bbox_lasso, &screen_space_bbox[src_curve],
nullptr)) {
99 for (
const int src_point : src_points_by_curve[src_curve]) {
103 int(screen_space_positions[src_point].
x),
104 int(screen_space_positions[src_point].
y),
108 selected_curves.
append(src_curve);
110 selected_points.
append(src_point);
114 selected_points_in_curves.
append(std::move(selected_points));
125 bke::CurvesGeometry cut_strokes = ed::greasepencil::trim::trim_curve_segments(
127 screen_space_positions,
130 selected_points_in_curves,
134 drawing.strokes_for_write() = std::move(cut_strokes);
135 drawing.tag_topology_changed();
161 std::atomic<bool> changed =
false;
163 bool inserted_keyframe =
false;
164 if (active_layer_only) {
166 if (!grease_pencil.has_active_layer()) {
171 if (!layer.is_editable()) {
196 if (layer->is_editable()) {
198 *scene, grease_pencil, *layer,
true, inserted_keyframe);
226 if (inserted_keyframe) {
251 ot->name =
"Grease Pencil Trim";
252 ot->idname =
"GREASE_PENCIL_OT_stroke_trim";
253 ot->description =
"Delete stroke points in between intersecting strokes";
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)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
@ 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)
BPy_StructRNA * depsgraph
static IndexMask from_indices(Span< T > indices, IndexMaskMemory &memory)
void append(const T &value)
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
float4x4 to_world_space(const Object &object) const
void foreach_index(Fn &&fn) const
void GREASE_PENCIL_OT_stroke_trim(wmOperatorType *ot)
GeometryDeformation get_evaluated_grease_pencil_drawing_deformation(const Object *ob_eval, const Object &ob_orig, const bke::greasepencil::Drawing &drawing_orig)
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 blender::bke::greasepencil::Layer &layer)
static wmOperatorStatus grease_pencil_stroke_trim_exec(bContext *C, wmOperator *op)
static constexpr int BBOX_PADDING
static bool execute_trim_on_drawing(const int layer_index, const Object &ob_eval, Object &obact, const ARegion ®ion, 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)
void parallel_for_each(Range &&range, const Function &function)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
MatBase< float, 4, 4 > float4x4
struct BrushGpencilSettings * gpencil_settings
bke::greasepencil::Drawing & drawing
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
Array< int2 > WM_gesture_lasso_path_to_array(bContext *, wmOperator *op)
wmOperatorStatus WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
void WM_gesture_lasso_cancel(bContext *C, wmOperator *op)
wmOperatorStatus WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void WM_operator_properties_gesture_lasso(wmOperatorType *ot)