[Bf-blender-cvs] [41820e8a8e7] master: GPencil: Add "Convert Text to Gpencil"
Antonio Vazquez
noreply at git.blender.org
Thu Apr 29 17:59:09 CEST 2021
Commit: 41820e8a8e7065ad770ad031b3663b3ddcd2a11c
Author: Antonio Vazquez
Date: Thu Apr 29 17:45:46 2021 +0200
Branches: master
https://developer.blender.org/rB41820e8a8e7065ad770ad031b3663b3ddcd2a11c
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
===================================================================
M source/blender/editors/object/object_add.c
===================================================================
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 */
More information about the Bf-blender-cvs
mailing list