diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-11-16 08:48:44 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-11-16 08:48:44 +0300 |
commit | 64ab084ca5fa171d39e799f143cff1d661267cf3 (patch) | |
tree | 30e232e915e8777542a0e0c38e8566ae09338235 /source/blender/editors/gpencil/gpencil_mesh.c | |
parent | a3a6d6a670f1074de3a83fef2f58c72bd66b270d (diff) |
Grease Pencil: adjust behavior of target object detection
First detect the other selected object, then check it can be written to.
Otherwise the target object could be the first one found when
looping over objects which is random from the user perspective.
Move the type check to the operator, which also checks the data isn't
library data which was being ignored.
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_mesh.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_mesh.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/source/blender/editors/gpencil/gpencil_mesh.c b/source/blender/editors/gpencil/gpencil_mesh.c index 2f3a4d747a7..84314202dfc 100644 --- a/source/blender/editors/gpencil/gpencil_mesh.c +++ b/source/blender/editors/gpencil/gpencil_mesh.c @@ -224,12 +224,22 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op) const int project_type = RNA_enum_get(op->ptr, "project_type"); eGP_TargetObjectMode target = RNA_enum_get(op->ptr, "target"); - /* Create a new grease pencil object in origin or resuse selected. */ + /* Create a new grease pencil object in origin or reuse selected. */ Object *ob_gpencil = NULL; bool newob = false; + if (target == GP_TARGET_OB_SELECTED) { - ob_gpencil = BKE_view_layer_first_selected_object_by_type( - CTX_data_view_layer(C), v3d, OB_GPENCIL); + ob_gpencil = BKE_view_layer_non_active_selected_object(CTX_data_view_layer(C), v3d); + if (ob_gpencil != NULL) { + if (ob_gpencil->type != OB_GPENCIL) { + BKE_report(op->reports, RPT_WARNING, "Target object not a grease pencil, ignoring!"); + ob_gpencil = NULL; + } + else if (BKE_object_obdata_is_libdata(ob_gpencil)) { + BKE_report(op->reports, RPT_WARNING, "Target object library-data, ignoring!"); + ob_gpencil = NULL; + } + } } if (ob_gpencil == NULL) { |