Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonioya <blendergit@gmail.com>2019-06-25 14:59:59 +0300
committerAntonioya <blendergit@gmail.com>2019-06-25 15:00:34 +0300
commitc186cfe419baa6f715544353b0861c374150b87b (patch)
treeb8b57da7414a9dd127c507cb89fd816b6817348b /source/blender/editors/gpencil/gpencil_data.c
parent30bf48c9caee40ce457d58b5bfe7fc398b7e9891 (diff)
GPencil: Add Lattice modifier when use Ctrl+P to Lattice Deform
When parent a Grease Pencil object to Lattice, automatically a Lattice modifier is added.
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_data.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index a7072facf36..941c7645dc0 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -2895,3 +2895,45 @@ void GPENCIL_OT_color_select(wmOperatorType *ot)
ot->prop = RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Unselect strokes");
RNA_def_property_flag(ot->prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
+
+/* Parent GPencil object to Lattice */
+bool ED_gpencil_add_lattice_modifier(const bContext *C,
+ ReportList *reports,
+ Object *ob,
+ Object *ob_latt)
+{
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+
+ if (ob == NULL) {
+ return false;
+ }
+
+ /* if no lattice modifier, add a new one */
+ GpencilModifierData *md = BKE_gpencil_modifiers_findByType(ob, eGpencilModifierType_Lattice);
+ if (md == NULL) {
+ md = ED_object_gpencil_modifier_add(
+ reports, bmain, scene, ob, "Lattice", eGpencilModifierType_Lattice);
+ if (md == NULL) {
+ BKE_report(reports, RPT_ERROR, "Unable to add a new Lattice modifier to object");
+ return false;
+ }
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ }
+
+ /* verify lattice */
+ LatticeGpencilModifierData *mmd = (LatticeGpencilModifierData *)md;
+ if (mmd->object == NULL) {
+ mmd->object = ob_latt;
+ }
+ else {
+ if (ob_latt != mmd->object) {
+ BKE_report(reports,
+ RPT_ERROR,
+ "The existing Lattice modifier is already using a different Lattice object");
+ return false;
+ }
+ }
+
+ return true;
+}