[Bf-blender-cvs] [1d28de57a47] geometry-nodes: Nodes: improve dependency between modifier and node group

Jacques Lucke noreply at git.blender.org
Wed Oct 21 13:16:28 CEST 2020


Commit: 1d28de57a4704c4bb70e4cdc41734e524b0052a5
Author: Jacques Lucke
Date:   Wed Oct 21 13:16:19 2020 +0200
Branches: geometry-nodes
https://developer.blender.org/rB1d28de57a4704c4bb70e4cdc41734e524b0052a5

Nodes: improve dependency between modifier and node group

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

M	release/scripts/startup/nodeitems_builtins.py
M	source/blender/depsgraph/DEG_depsgraph_build.h
M	source/blender/depsgraph/intern/depsgraph_build.cc
M	source/blender/editors/space_node/node_edit.c
M	source/blender/modifiers/intern/MOD_nodes.cc

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

diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index 2250137b6ef..4223b2ffb23 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -485,8 +485,11 @@ def not_implemented_node(idname):
 
 geometry_node_categories = [
     # Geometry Nodes
-    GeometryNodeCategory("SIM_GROUP", "Group", items=node_group_items),
-    GeometryNodeCategory("SIM_LAYOUT", "Layout", items=[
+    GeometryNodeCategory("GEO_CONVERTER", "Converter", items=[
+        NodeItem("ShaderNodeMath"),
+    ]),
+    GeometryNodeCategory("GEO_GROUP", "Group", items=node_group_items),
+    GeometryNodeCategory("GEO_LAYOUT", "Layout", items=[
         NodeItem("NodeFrame"),
         NodeItem("NodeReroute"),
     ]),
diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h
index 2147a584765..f894bdabba4 100644
--- a/source/blender/depsgraph/DEG_depsgraph_build.h
+++ b/source/blender/depsgraph/DEG_depsgraph_build.h
@@ -141,6 +141,9 @@ void DEG_add_object_relation(struct DepsNodeHandle *node_handle,
 void DEG_add_simulation_relation(struct DepsNodeHandle *node_handle,
                                  struct Simulation *simulation,
                                  const char *description);
+void DEG_add_node_tree_relation(struct DepsNodeHandle *node_handle,
+                                struct bNodeTree *node_tree,
+                                const char *description);
 void DEG_add_bone_relation(struct DepsNodeHandle *handle,
                            struct Object *object,
                            const char *bone_name,
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index 96c17ae4dc5..6717ba521f6 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -32,6 +32,7 @@
 #include "PIL_time_utildefines.h"
 
 #include "DNA_cachefile_types.h"
+#include "DNA_node_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_simulation_types.h"
@@ -116,6 +117,17 @@ void DEG_add_simulation_relation(DepsNodeHandle *node_handle,
   deg_node_handle->builder->add_node_handle_relation(operation_key, deg_node_handle, description);
 }
 
+void DEG_add_node_tree_relation(DepsNodeHandle *node_handle,
+                                bNodeTree *node_tree,
+                                const char *description)
+{
+  /* Using shading key, because that's the one that exists right now. Should use something else in
+   * the future. */
+  deg::ComponentKey shading_key(&node_tree->id, deg::NodeType::SHADING);
+  deg::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle);
+  deg_node_handle->builder->add_node_handle_relation(shading_key, deg_node_handle, description);
+}
+
 void DEG_add_object_cache_relation(DepsNodeHandle *node_handle,
                                    CacheFile *cache_file,
                                    eDepsObjectComponentType component,
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index edfc5d59673..49a598090f4 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -391,6 +391,7 @@ void snode_dag_update(bContext *C, SpaceNode *snode)
   }
 
   DEG_id_tag_update(snode->id, 0);
+  DEG_id_tag_update(&snode->nodetree->id, 0);
 }
 
 void snode_notify(bContext *C, SpaceNode *snode)
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index 1231bb9eaca..39ee9be6585 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -36,11 +36,11 @@
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_modifier_types.h"
+#include "DNA_node_types.h"
 #include "DNA_object_types.h"
 #include "DNA_pointcloud_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
-#include "DNA_simulation_types.h"
 
 #include "BKE_customdata.h"
 #include "BKE_lib_query.h"
@@ -74,19 +74,18 @@ static void initData(ModifierData *md)
   MEMCPY_STRUCT_AFTER(nmd, DNA_struct_default_get(NodesModifierData), modifier);
 }
 
-static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *UNUSED(ctx))
+static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
 {
   NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
-  UNUSED_VARS(nmd);
+  if (nmd->node_tree != nullptr) {
+    DEG_add_node_tree_relation(ctx->node, nmd->node_tree, "Nodes Modifier");
+  }
 }
 
-static void foreachIDLink(ModifierData *md,
-                          Object *UNUSED(ob),
-                          IDWalkFunc UNUSED(walk),
-                          void *UNUSED(userData))
+static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
 {
   NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
-  UNUSED_VARS(nmd);
+  walk(userData, ob, (ID **)&nmd->node_tree, IDWALK_CB_USER);
 }
 
 static bool isDisabled(const struct Scene *UNUSED(scene),
@@ -104,9 +103,18 @@ static PointCloud *modifyPointCloud(ModifierData *md,
 {
   NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
   UNUSED_VARS(nmd);
+  std::cout << __func__ << "\n";
   return pointcloud;
 }
 
+static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx), Mesh *mesh)
+{
+  NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
+  UNUSED_VARS(nmd);
+  std::cout << __func__ << "\n";
+  return mesh;
+}
+
 static void panel_draw(const bContext *UNUSED(C), Panel *panel)
 {
   uiLayout *layout = panel->layout;
@@ -163,8 +171,8 @@ ModifierTypeInfo modifierType_Nodes = {
 #else
     /* srna */ &RNA_Modifier,
 #endif
-    /* type */ eModifierTypeType_None,
-    /* flags */ (ModifierTypeFlag)0,
+    /* type */ eModifierTypeType_Constructive,
+    /* flags */ eModifierTypeFlag_AcceptsMesh,
     /* icon */ ICON_MESH_DATA, /* TODO: Use correct icon. */
 
     /* copyData */ copyData,
@@ -173,7 +181,7 @@ ModifierTypeInfo modifierType_Nodes = {
     /* deformMatrices */ NULL,
     /* deformVertsEM */ NULL,
     /* deformMatricesEM */ NULL,
-    /* modifyMesh */ NULL,
+    /* modifyMesh */ modifyMesh,
     /* modifyHair */ NULL,
     /* modifyPointCloud */ modifyPointCloud,
     /* modifyVolume */ NULL,



More information about the Bf-blender-cvs mailing list