diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_edit.c | 20 | ||||
-rw-r--r-- | source/blender/editors/include/ED_gpencil.h | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_modes.c | 7 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_enums.h | 6 |
4 files changed, 32 insertions, 2 deletions
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 9588d4bb570..5459cd09e53 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -4515,3 +4515,23 @@ void GPENCIL_OT_stroke_cutter(wmOperatorType *ot) /* properties */ WM_operator_properties_gesture_lasso(ot); } + +bool ED_object_gpencil_exit(struct Main *bmain, Object *ob) +{ + bool ok = false; + if (ob) { + bGPdata *gpd = (bGPdata *)ob->data; + + gpd->flag &= ~(GP_DATA_STROKE_PAINTMODE | GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE | + GP_DATA_STROKE_WEIGHTMODE); + + ob->restore_mode = ob->mode; + ob->mode &= ~(OB_MODE_PAINT_GPENCIL | OB_MODE_EDIT_GPENCIL | OB_MODE_SCULPT_GPENCIL | + OB_MODE_WEIGHT_GPENCIL); + + /* Inform all CoW versions that we changed the mode. */ + DEG_id_tag_update_ex(bmain, &ob->id, ID_RECALC_COPY_ON_WRITE); + ok = true; + } + return ok; +} diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h index 73e239f0d33..0e3204b30c7 100644 --- a/source/blender/editors/include/ED_gpencil.h +++ b/source/blender/editors/include/ED_gpencil.h @@ -226,6 +226,7 @@ struct Object *ED_gpencil_add_object(struct bContext *C, void ED_gpencil_add_defaults(struct bContext *C, struct Object *ob); /* set object modes */ void ED_gpencil_setup_modes(struct bContext *C, struct bGPdata *gpd, int newmode); +bool ED_object_gpencil_exit(struct Main *bmain, struct Object *ob); void ED_gp_project_stroke_to_plane(const struct Scene *scene, const struct Object *ob, diff --git a/source/blender/editors/object/object_modes.c b/source/blender/editors/object/object_modes.c index 0f0d09c610b..0ec98e089a2 100644 --- a/source/blender/editors/object/object_modes.c +++ b/source/blender/editors/object/object_modes.c @@ -43,6 +43,7 @@ #include "DEG_depsgraph.h" #include "ED_armature.h" +#include "ED_gpencil.h" #include "ED_screen.h" #include "ED_object.h" /* own include */ @@ -287,6 +288,12 @@ static bool ed_object_mode_generic_exit_ex(struct Main *bmain, ED_object_posemode_exit_ex(bmain, ob); } } + else if ((ob->type == OB_GPENCIL) && ((ob->mode & OB_MODE_OBJECT) == 0)) { + if (only_test) { + return true; + } + ED_object_gpencil_exit(bmain, ob); + } else { if (only_test) { return false; diff --git a/source/blender/makesdna/DNA_object_enums.h b/source/blender/makesdna/DNA_object_enums.h index 44aeb5feaff..75fca117b06 100644 --- a/source/blender/makesdna/DNA_object_enums.h +++ b/source/blender/makesdna/DNA_object_enums.h @@ -49,9 +49,11 @@ typedef enum eObjectMode { /** Any mode that uses Object.sculpt. */ #define OB_MODE_ALL_SCULPT (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) -/** Any mode that has data we need to free when switching modes, +/** Any mode that has data or for Grease Pencil modes, we need to free when switching modes, * see: #ED_object_mode_generic_exit */ #define OB_MODE_ALL_MODE_DATA \ - (OB_MODE_EDIT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_SCULPT | OB_MODE_POSE) + (OB_MODE_EDIT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_SCULPT | OB_MODE_POSE | \ + OB_MODE_PAINT_GPENCIL | OB_MODE_EDIT_GPENCIL | OB_MODE_SCULPT_GPENCIL | \ + OB_MODE_WEIGHT_GPENCIL) #endif /* __DNA_OBJECT_ENUMS_H__ */ |