diff --git a/source/blender/draw/engines/overlay/overlay_grease_pencil.cc b/source/blender/draw/engines/overlay/overlay_grease_pencil.cc index 231f41aeeff..958104f814f 100644 --- a/source/blender/draw/engines/overlay/overlay_grease_pencil.cc +++ b/source/blender/draw/engines/overlay/overlay_grease_pencil.cc @@ -8,6 +8,8 @@ #include "DRW_render.h" +#include "ED_grease_pencil.hh" + #include "BKE_grease_pencil.hh" #include "overlay_private.hh" @@ -16,6 +18,9 @@ void OVERLAY_edit_grease_pencil_cache_init(OVERLAY_Data *vedata) { OVERLAY_PassList *psl = vedata->psl; OVERLAY_PrivateData *pd = vedata->stl->pd; + const DRWContextState *draw_ctx = DRW_context_state_get(); + const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get( + draw_ctx->scene->toolsettings); GPUShader *sh; DRWShadingGroup *grp; @@ -28,9 +33,11 @@ void OVERLAY_edit_grease_pencil_cache_init(OVERLAY_Data *vedata) grp = pd->edit_grease_pencil_wires_grp = DRW_shgroup_create(sh, psl->edit_grease_pencil_ps); DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); - sh = OVERLAY_shader_edit_particle_point(); - grp = pd->edit_grease_pencil_points_grp = DRW_shgroup_create(sh, psl->edit_grease_pencil_ps); - DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); + if (selection_domain == ATTR_DOMAIN_POINT) { + sh = OVERLAY_shader_edit_particle_point(); + grp = pd->edit_grease_pencil_points_grp = DRW_shgroup_create(sh, psl->edit_grease_pencil_ps); + DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); + } } void OVERLAY_edit_grease_pencil_cache_populate(OVERLAY_Data *vedata, Object *ob) diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_select.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_select.cc index 007a255371c..54fd2325778 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_select.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_select.cc @@ -34,7 +34,7 @@ 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 selection_domain = ED_grease_pencil_selection_domain_get(C); + eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(scene->toolsettings); grease_pencil.foreach_editable_drawing( scene->r.cfra, [&](const int /*layer_index*/, blender::bke::greasepencil::Drawing &drawing) { @@ -164,7 +164,7 @@ 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); + eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(scene->toolsettings); grease_pencil.foreach_editable_drawing( scene->r.cfra, [&](const int layer_index, bke::greasepencil::Drawing &drawing) { @@ -327,14 +327,15 @@ static int select_set_mode_exec(bContext *C, wmOperator *op) /* Set new selection mode. */ const int mode_new = RNA_enum_get(op->ptr, "mode"); ToolSettings *ts = CTX_data_tool_settings(C); + + bool changed = (mode_new != ts->gpencil_selectmode_edit); ts->gpencil_selectmode_edit = mode_new; /* Convert all drawings of the active GP to the new selection domain. */ - const eAttrDomain domain = ED_grease_pencil_selection_domain_get(C); + const eAttrDomain domain = ED_grease_pencil_selection_domain_get(ts); Object *object = CTX_data_active_object(C); GreasePencil &grease_pencil = *static_cast(object->data); Span drawings = grease_pencil.drawings(); - bool changed = false; for (const int index : drawings.index_range()) { GreasePencilDrawingBase *drawing_base = drawings[index]; @@ -417,11 +418,9 @@ static void GREASE_PENCIL_OT_set_selection_mode(wmOperatorType *ot) } // namespace blender::ed::greasepencil -eAttrDomain ED_grease_pencil_selection_domain_get(bContext *C) +eAttrDomain ED_grease_pencil_selection_domain_get(const ToolSettings *tool_settings) { - ToolSettings *ts = CTX_data_tool_settings(C); - - switch (ts->gpencil_selectmode_edit) { + switch (tool_settings->gpencil_selectmode_edit) { case GP_SELECTMODE_POINT: return ATTR_DOMAIN_POINT; break; diff --git a/source/blender/editors/include/ED_grease_pencil.hh b/source/blender/editors/include/ED_grease_pencil.hh index 3ae9a37473b..2771e2ed8bf 100644 --- a/source/blender/editors/include/ED_grease_pencil.hh +++ b/source/blender/editors/include/ED_grease_pencil.hh @@ -22,6 +22,7 @@ struct Main; struct Object; struct KeyframeEditData; struct wmKeyConfig; +struct ToolSettings; enum { LAYER_REORDER_ABOVE, @@ -42,7 +43,7 @@ void ED_keymap_grease_pencil(wmKeyConfig *keyconf); /** * Get the selection mode for Grease Pencil selection operators: point, stroke, segment. */ -eAttrDomain ED_grease_pencil_selection_domain_get(bContext *C); +eAttrDomain ED_grease_pencil_selection_domain_get(const ToolSettings *tool_settings); /** \} */ diff --git a/source/blender/editors/space_view3d/view3d_select.cc b/source/blender/editors/space_view3d/view3d_select.cc index bbd7ff78108..0ae6a2e4acb 100644 --- a/source/blender/editors/space_view3d/view3d_select.cc +++ b/source/blender/editors/space_view3d/view3d_select.cc @@ -1188,7 +1188,8 @@ 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_grease_pencil_selection_domain_get(vc->C); + const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get( + vc->scene->toolsettings); bool changed = false; grease_pencil.foreach_editable_drawing( @@ -3179,7 +3180,8 @@ static bool ed_grease_pencil_select_pick(bContext *C, }); /* Get selection domain from tool settings. */ - const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(C); + const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get( + vc.scene->toolsettings); const ClosestGreasePencilDrawing closest = threading::parallel_reduce( drawings.index_range(), @@ -4190,7 +4192,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_grease_pencil_selection_domain_get(vc->C); + const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(scene->toolsettings); bool changed = false; grease_pencil.foreach_editable_drawing( @@ -5038,7 +5040,8 @@ static bool grease_pencil_circle_select(ViewContext *vc, GreasePencil &grease_pencil = *static_cast(vc->obedit->data); /* Get selection domain from tool settings. */ - const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(vc->C); + const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get( + vc->scene->toolsettings); bool changed = false; grease_pencil.foreach_editable_drawing(