diff options
author | Antonio Vazquez <antoniov> | 2021-04-29 18:45:46 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2021-04-29 18:58:18 +0300 |
commit | 41820e8a8e7065ad770ad031b3663b3ddcd2a11c (patch) | |
tree | 960ac672d1ff5657f30db01fe825ae9b3cb2514c /source | |
parent | c9d1143b334527d5b9dfb886f8fdba986bd1ec53 (diff) |
GPencil: Add "Convert Text to Gpencil"
Currently when you try to convert a Text-object to Grease pencil from the Object-menu or via the operator in some other way, the Text-object is only converted to a Curve.
This commit converts that curve to a Grease pencil object.
Differential Revision: https://developer.blender.org/D11117
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/object/object_add.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 3751e62dbe0..840fd97cc48 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -2628,6 +2628,7 @@ static int object_convert_exec(bContext *C, wmOperator *op) int a, mballConverted = 0; bool gpencilConverted = false; + bool gpencilCurveConverted = false; /* don't forget multiple users! */ @@ -2912,6 +2913,16 @@ static int object_convert_exec(bContext *C, wmOperator *op) /* meshes doesn't use displist */ BKE_object_free_curve_cache(newob); } + else if (target == OB_GPENCIL) { + ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0; + Object *ob_gpencil = ED_gpencil_add_object(C, newob->loc, local_view_bits); + copy_v3_v3(ob_gpencil->rot, newob->rot); + copy_v3_v3(ob_gpencil->scale, newob->scale); + BKE_gpencil_convert_curve(bmain, scene, ob_gpencil, newob, false, 1.0f, 0.0f); + gpencilConverted = true; + gpencilCurveConverted = true; + basen = NULL; + } } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { ob->flag |= OB_DONE; @@ -3093,6 +3104,17 @@ static int object_convert_exec(bContext *C, wmOperator *op) FOREACH_SCENE_OBJECT_END; } } + else { + /* Remove Text curves converted to Grease Pencil object to avoid duplicated curves. */ + if (gpencilCurveConverted) { + FOREACH_SCENE_OBJECT_BEGIN (scene, ob_delete) { + if (ELEM(ob_delete->type, OB_CURVE) && (ob_delete->flag & OB_DONE)) { + ED_object_base_free_and_unlink(bmain, scene, ob_delete); + } + } + FOREACH_SCENE_OBJECT_END; + } + } // XXX ED_object_editmode_enter(C, 0); // XXX exit_editmode(C, EM_FREEDATA|); /* freedata, but no undo */ |