[Bf-blender-cvs] [aa030d34599] blender-v2.92-release: Fix: Unable to animate nodes modifier exposed properties

Hans Goudey noreply at git.blender.org
Mon Jan 25 18:47:04 CET 2021


Commit: aa030d34599387aa560da7db38b0e119c06f1530
Author: Hans Goudey
Date:   Mon Jan 25 11:46:55 2021 -0600
Branches: blender-v2.92-release
https://developer.blender.org/rBaa030d34599387aa560da7db38b0e119c06f1530

Fix: Unable to animate nodes modifier exposed properties

The RNA path used for animating the settings passed to the node tree
is incorrect. Currently it's just `settings.property_name`, but it's
the path from the ID, not the modifier, so it should be
`modifiers[modifier_name].settings.property_name`.

However, the "Settings" struct is separated in RNA and DNA, which means
that the callback to get the RNA path does not know about the modifier's
name in order to fill the above path, so some reference to the modifier
in the "Settings" struct would be necessary, which would create a
convoluted layout in the `ModifierData` struct.

Instead, this commit simply removes the "Settings" struct from RNA,
which isn't as elegant from the point of view of the Python API,
but otherwise it's a nice simplification. Note that we don't remove the
"Settings" struct from DNA, because it would break reading old files.

Differential Revision: https://developer.blender.org/D10175

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

M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_nodes.cc

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

diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 6a018ab270e..35b174f0da8 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -574,7 +574,6 @@ extern StructRNA RNA_SimpleDeformModifier;
 extern StructRNA RNA_SimplifyGpencilModifier;
 extern StructRNA RNA_Simulation;
 extern StructRNA RNA_NodesModifier;
-extern StructRNA RNA_NodesModifierSettings;
 extern StructRNA RNA_GeometryNode;
 extern StructRNA RNA_GeometryNodeTree;
 extern StructRNA RNA_SkinModifier;
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 88953e8fddf..e02e47745b0 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -1617,21 +1617,16 @@ static void rna_NodesModifier_node_group_update(Main *bmain, Scene *scene, Point
   MOD_nodes_update_interface(object, nmd);
 }
 
-static IDProperty *rna_NodesModifierSettings_properties(PointerRNA *ptr, bool create)
+static IDProperty *rna_NodesModifier_properties(PointerRNA *ptr, bool create)
 {
-  NodesModifierSettings *settings = ptr->data;
+  NodesModifierData *nmd = ptr->data;
+  NodesModifierSettings *settings = &nmd->settings;
   if (create && settings->properties == NULL) {
     IDPropertyTemplate val = {0};
     settings->properties = IDP_New(IDP_GROUP, &val, "Nodes Modifier Settings");
   }
   return settings->properties;
 }
-
-static char *rna_NodesModifierSettings_path(PointerRNA *UNUSED(ptr))
-{
-  return BLI_strdup("settings");
-}
-
 #else
 
 static void rna_def_property_subdivision_common(StructRNA *srna)
@@ -6960,18 +6955,6 @@ static void rna_def_modifier_weightednormal(BlenderRNA *brna)
   RNA_define_lib_overridable(false);
 }
 
-static void rna_def_modifier_nodes_settings(BlenderRNA *brna)
-{
-  StructRNA *srna;
-
-  srna = RNA_def_struct(brna, "NodesModifierSettings", NULL);
-  RNA_def_struct_nested(brna, srna, "NodesModifier");
-  RNA_def_struct_path_func(srna, "rna_NodesModifierSettings_path");
-  RNA_def_struct_ui_text(
-      srna, "Nodes Modifier Settings", "Settings that are passed into the node group");
-  RNA_def_struct_idprops_func(srna, "rna_NodesModifierSettings_properties");
-}
-
 static void rna_def_modifier_nodes(BlenderRNA *brna)
 {
   StructRNA *srna;
@@ -6980,6 +6963,7 @@ static void rna_def_modifier_nodes(BlenderRNA *brna)
   srna = RNA_def_struct(brna, "NodesModifier", "Modifier");
   RNA_def_struct_ui_text(srna, "Nodes Modifier", "");
   RNA_def_struct_sdna(srna, "NodesModifierData");
+  RNA_def_struct_idprops_func(srna, "rna_NodesModifier_properties");
   RNA_def_struct_ui_icon(srna, ICON_NODETREE);
 
   RNA_define_lib_overridable(true);
@@ -6990,13 +6974,7 @@ static void rna_def_modifier_nodes(BlenderRNA *brna)
   RNA_def_property_flag(prop, PROP_EDITABLE);
   RNA_def_property_update(prop, 0, "rna_NodesModifier_node_group_update");
 
-  prop = RNA_def_property(srna, "settings", PROP_POINTER, PROP_NONE);
-  RNA_def_property_flag(prop, PROP_NEVER_NULL);
-  RNA_def_property_ui_text(prop, "Settings", "Settings that are passed into the node group");
-
   RNA_define_lib_overridable(false);
-
-  rna_def_modifier_nodes_settings(brna);
 }
 
 static void rna_def_modifier_mesh_to_volume(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index 5ef17aeddd1..f3d6cf49dd6 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -1053,7 +1053,7 @@ static void modifyGeometrySet(ModifierData *md,
  * the correct label displayed in the UI.  */
 static void draw_property_for_socket(uiLayout *layout,
                                      PointerRNA *bmain_ptr,
-                                     PointerRNA *settings_ptr,
+                                     PointerRNA *md_ptr,
                                      const IDProperty *modifier_props,
                                      const bNodeSocket &socket)
 {
@@ -1081,12 +1081,12 @@ static void draw_property_for_socket(uiLayout *layout,
     switch (socket.type) {
       case SOCK_OBJECT: {
         uiItemPointerR(
-            layout, settings_ptr, rna_path, bmain_ptr, "objects", socket.name, ICON_OBJECT_DATA);
+            layout, md_ptr, rna_path, bmain_ptr, "objects", socket.name, ICON_OBJECT_DATA);
         break;
       }
       case SOCK_COLLECTION: {
         uiItemPointerR(layout,
-                       settings_ptr,
+                       md_ptr,
                        rna_path,
                        bmain_ptr,
                        "collections",
@@ -1095,7 +1095,7 @@ static void draw_property_for_socket(uiLayout *layout,
         break;
       }
       default:
-        uiItemR(layout, settings_ptr, rna_path, 0, socket.name, ICON_NONE);
+        uiItemR(layout, md_ptr, rna_path, 0, socket.name, ICON_NONE);
     }
   }
 }
@@ -1109,8 +1109,7 @@ static void panel_draw(const bContext *C, Panel *panel)
   NodesModifierData *nmd = static_cast<NodesModifierData *>(ptr->data);
 
   uiLayoutSetPropSep(layout, true);
-  /* This should be removed, but animation currently doesn't work with the IDProperties. */
-  uiLayoutSetPropDecorate(layout, false);
+  uiLayoutSetPropDecorate(layout, true);
 
   uiTemplateID(layout,
                C,
@@ -1124,15 +1123,11 @@ static void panel_draw(const bContext *C, Panel *panel)
                nullptr);
 
   if (nmd->node_group != nullptr && nmd->settings.properties != nullptr) {
-    PointerRNA settings_ptr;
-    RNA_pointer_create(ptr->owner_id, &RNA_NodesModifierSettings, &nmd->settings, &settings_ptr);
-
     PointerRNA bmain_ptr;
     RNA_main_pointer_create(bmain, &bmain_ptr);
 
     LISTBASE_FOREACH (bNodeSocket *, socket, &nmd->node_group->inputs) {
-      draw_property_for_socket(
-          layout, &bmain_ptr, &settings_ptr, nmd->settings.properties, *socket);
+      draw_property_for_socket(layout, &bmain_ptr, ptr, nmd->settings.properties, *socket);
     }
   }



More information about the Bf-blender-cvs mailing list