GPv3: Hide points overlay in stroke selection mode

This makes sure that we only show the point selection if the
selection domain is `ATTR_DOMAIN_POINT`.
This commit is contained in:
Falk David 2023-10-16 15:12:05 +02:00
parent d03d03402b
commit 97c5cb19d1
4 changed files with 26 additions and 16 deletions

View File

@ -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)

View File

@ -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<GreasePencil *>(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<GreasePencil *>(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<GreasePencil *>(object->data);
Span<GreasePencilDrawingBase *> 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;

View File

@ -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);
/** \} */

View File

@ -1188,7 +1188,8 @@ static bool do_lasso_select_grease_pencil(ViewContext *vc,
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(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<GreasePencil *>(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<GreasePencil *>(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(