diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_ops.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_ops.cc index f827e594361..1ffaa1dc21d 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_ops.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_ops.cc @@ -60,11 +60,11 @@ static int select_all_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *object = CTX_data_active_object(C); GreasePencil &grease_pencil = *static_cast(object->data); - eAttrDomain domain = ED_view3d_grease_pencil_selection_domain_get(C); + eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(C); grease_pencil.foreach_editable_drawing( - scene->r.cfra, [action, domain](int /*drawing_index*/, GreasePencilDrawing &drawing) { - blender::ed::curves::select_all(drawing.geometry.wrap(), domain, action); + scene->r.cfra, [&](int /*drawing_index*/, GreasePencilDrawing &drawing) { + blender::ed::curves::select_all(drawing.geometry.wrap(), selection_domain, action); }); /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic @@ -97,7 +97,6 @@ static int select_more_exec(bContext *C, wmOperator * /*op*/) grease_pencil.foreach_editable_drawing( scene->r.cfra, [](int /*drawing_index*/, GreasePencilDrawing &drawing) { - /* TODO: Support different selection domains. */ blender::ed::curves::select_adjacent(drawing.geometry.wrap(), false); }); @@ -129,7 +128,6 @@ static int select_less_exec(bContext *C, wmOperator * /*op*/) grease_pencil.foreach_editable_drawing( scene->r.cfra, [](int /*drawing_index*/, GreasePencilDrawing &drawing) { - /* TODO: Support different selection domains. */ blender::ed::curves::select_adjacent(drawing.geometry.wrap(), true); }); @@ -161,7 +159,6 @@ static int select_linked_exec(bContext *C, wmOperator * /*op*/) grease_pencil.foreach_editable_drawing( scene->r.cfra, [](int /*drawing_index*/, GreasePencilDrawing &drawing) { - /* TODO: Support different selection domains. */ blender::ed::curves::select_linked(drawing.geometry.wrap()); }); @@ -192,12 +189,12 @@ static int select_random_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *object = CTX_data_active_object(C); GreasePencil &grease_pencil = *static_cast(object->data); + eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(C); grease_pencil.foreach_editable_drawing( scene->r.cfra, [&](int drawing_index, GreasePencilDrawing &drawing) { - // TODO: Support different selection domains. blender::ed::curves::select_random(drawing.geometry.wrap(), - ATTR_DOMAIN_POINT, + selection_domain, blender::get_default_hash_2(seed, drawing_index), ratio); }); @@ -283,6 +280,25 @@ static void keymap_grease_pencil_editing(wmKeyConfig *keyconf) } } // namespace blender::ed::greasepencil + +eAttrDomain ED_grease_pencil_selection_domain_get(bContext *C) +{ + ToolSettings *ts = CTX_data_tool_settings(C); + + switch (ts->gpencil_selectmode_edit) { + case GP_SELECTMODE_POINT: + return ATTR_DOMAIN_POINT; + break; + case GP_SELECTMODE_STROKE: + return ATTR_DOMAIN_CURVE; + break; + case GP_SELECTMODE_SEGMENT: + return ATTR_DOMAIN_POINT; + break; + } + return ATTR_DOMAIN_POINT; +} + void ED_operatortypes_grease_pencil(void) { using namespace blender::ed::greasepencil; diff --git a/source/blender/editors/include/ED_grease_pencil.h b/source/blender/editors/include/ED_grease_pencil.h index 0f90af7cab9..3d843764940 100644 --- a/source/blender/editors/include/ED_grease_pencil.h +++ b/source/blender/editors/include/ED_grease_pencil.h @@ -25,6 +25,10 @@ extern "C" { void ED_operatortypes_grease_pencil(void); void ED_keymap_grease_pencil(struct wmKeyConfig *keyconf); +/** + * Get the selection mode for Grease Pencil selection operators: point, stroke, segment. + */ +eAttrDomain ED_grease_pencil_selection_domain_get(struct bContext *C); #ifdef __cplusplus } diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index e5b0449e3d5..ca23f3ac664 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -996,10 +996,6 @@ void ED_view3d_viewcontext_init(struct bContext *C, * So object-mode specific values should remain cleared when initialized with another object. */ void ED_view3d_viewcontext_init_object(struct ViewContext *vc, struct Object *obact); -/** - * Get the selection mode for Grease Pencil selection operators: point, stroke, segment. - */ -eAttrDomain ED_view3d_grease_pencil_selection_domain_get(struct bContext *C); /** * Use this call when executing an operator, * event system doesn't set for each event the OpenGL drawing context. diff --git a/source/blender/editors/space_view3d/view3d_select.cc b/source/blender/editors/space_view3d/view3d_select.cc index be25d14a008..36d04904e4c 100644 --- a/source/blender/editors/space_view3d/view3d_select.cc +++ b/source/blender/editors/space_view3d/view3d_select.cc @@ -75,6 +75,7 @@ #include "ED_curve.h" #include "ED_curves.h" #include "ED_gpencil_legacy.h" +#include "ED_grease_pencil.h" #include "ED_lattice.h" #include "ED_mball.h" #include "ED_mesh.h" @@ -141,24 +142,6 @@ void ED_view3d_viewcontext_init_object(ViewContext *vc, Object *obact) } } -eAttrDomain ED_view3d_grease_pencil_selection_domain_get(bContext *C) -{ - ToolSettings *ts = CTX_data_tool_settings(C); - - switch (ts->gpencil_selectmode_edit) { - case GP_SELECTMODE_POINT: - return ATTR_DOMAIN_POINT; - break; - case GP_SELECTMODE_STROKE: - return ATTR_DOMAIN_CURVE; - break; - case GP_SELECTMODE_SEGMENT: - return ATTR_DOMAIN_POINT; - break; - } - return ATTR_DOMAIN_POINT; -} - /** \} */ /* -------------------------------------------------------------------- */ @@ -1201,7 +1184,7 @@ static bool do_lasso_select_grease_pencil(ViewContext *vc, GreasePencil &grease_pencil = *static_cast(vc->obedit->data); /* Get selection domain from tool settings. */ - const eAttrDomain selection_domain = ED_view3d_grease_pencil_selection_domain_get(vc->C); + const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(vc->C); bool changed = false; grease_pencil.foreach_editable_drawing( @@ -3191,7 +3174,7 @@ static bool ed_grease_pencil_select_pick(bContext *C, }); /* Get selection domain from tool settings. */ - const eAttrDomain selection_domain = ED_view3d_grease_pencil_selection_domain_get(C); + const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(C); const ClosestGreasePencilDrawing closest = threading::parallel_reduce( drawings.index_range(), @@ -4207,7 +4190,7 @@ static bool do_grease_pencil_box_select(ViewContext *vc, const rcti *rect, const GreasePencil &grease_pencil = *static_cast(vc->obedit->data); /* Get selection domain from tool settings. */ - const eAttrDomain selection_domain = ED_view3d_grease_pencil_selection_domain_get(vc->C); + const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(vc->C); bool changed = false; grease_pencil.foreach_editable_drawing(