[Bf-blender-cvs] [e66cc7d8b77] greasepencil-refactor: GPencil: Update child transform when parent is transformed

Antonio Vazquez noreply at git.blender.org
Wed Jan 29 13:18:06 CET 2020


Commit: e66cc7d8b77bb4a7ac00cd591135ce68441f1482
Author: Antonio Vazquez
Date:   Wed Jan 29 13:17:57 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBe66cc7d8b77bb4a7ac00cd591135ce68441f1482

GPencil: Update child transform when parent is transformed

Now, if you move the parent object, the child moves too.

===================================================================

M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/makesrna/intern/rna_gpencil.c

===================================================================

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 5214fdbd246..a126f179ac6 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -2149,6 +2149,15 @@ void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata)
           add_relation(material_key, geometry_key, "Material -> GP Data");
         }
       }
+
+      /* Layer parenting need react to the parent object transformation. */
+      LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+        if (gpl->parent != NULL) {
+          ComponentKey transform_key(&gpl->parent->id, NodeType::TRANSFORM);
+          ComponentKey gpd_geom_key(&gpd->id, NodeType::GEOMETRY);
+          add_relation(transform_key, gpd_geom_key, "GPencil Parent Layer");
+        }
+      }
       break;
     }
     default:
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 91d3b9c1345..ec344d99414 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -141,6 +141,7 @@ static EnumPropertyItem rna_enum_gpencil_caps_modes_items[] = {
 #  include "BKE_icons.h"
 
 #  include "DEG_depsgraph.h"
+#  include "DEG_depsgraph_build.h"
 
 static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
 {
@@ -148,6 +149,16 @@ static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe
   WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
 }
 
+static void rna_GPencil_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
+{
+  DEG_id_tag_update(ptr->owner_id, ID_RECALC_TRANSFORM);
+  DEG_relations_tag_update(bmain);
+  WM_main_add_notifier(NC_OBJECT | ND_PARENT, ptr->owner_id);
+
+  DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY);
+  WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
+}
+
 static void rna_GPencil_uv_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
 {
   /* Force to recalc the UVs. */
@@ -1566,7 +1577,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
   RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
   RNA_def_property_ui_text(prop, "Parent", "Parent Object");
-  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_dependency_update");
 
   /* parent type */
   prop = RNA_def_property(srna, "parent_type", PROP_ENUM, PROP_NONE);



More information about the Bf-blender-cvs mailing list