[Bf-blender-cvs] [a687c1d70fe] builtin-simulation-nodes: make simulation node groups work

Jacques Lucke noreply at git.blender.org
Mon Mar 2 13:06:10 CET 2020


Commit: a687c1d70fee6e888c99a8e5547b84e97b5865db
Author: Jacques Lucke
Date:   Mon Mar 2 13:05:32 2020 +0100
Branches: builtin-simulation-nodes
https://developer.blender.org/rBa687c1d70fee6e888c99a8e5547b84e97b5865db

make simulation node groups work

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

M	release/scripts/startup/nodeitems_builtins.py
M	source/blender/blenkernel/intern/node.c
M	source/blender/editors/include/ED_node.h
M	source/blender/editors/space_node/node_edit.c
M	source/blender/editors/space_node/node_group.c
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/nodes/CMakeLists.txt
M	source/blender/nodes/NOD_common.h
M	source/blender/nodes/NOD_simulation.h
M	source/blender/nodes/intern/node_common.h
M	source/blender/nodes/intern/node_util.h
M	source/blender/nodes/simulation/node_sim_util.cc
M	source/blender/nodes/simulation/node_sim_util.h
A	source/blender/nodes/simulation/nodes/node_sim_common.cc

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

diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index 040f4ed330c..107b9682c7b 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -76,7 +76,7 @@ node_tree_group_type = {
     'CompositorNodeTree': 'CompositorNodeGroup',
     'ShaderNodeTree': 'ShaderNodeGroup',
     'TextureNodeTree': 'TextureNodeGroup',
-    # TODO: simulation node group
+    'SimulationNodeTree' : 'SimulationNodeGroup',
 }
 
 
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index a8026cac972..7d09595bdf2 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -4119,6 +4119,8 @@ static void registerTextureNodes(void)
 
 static void registerSimulationNodes(void)
 {
+  register_node_type_sim_group();
+
   register_node_type_sim_particle_simulation();
 }
 
diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h
index de7d2e1a395..d79ce880a47 100644
--- a/source/blender/editors/include/ED_node.h
+++ b/source/blender/editors/include/ED_node.h
@@ -90,6 +90,7 @@ void ED_node_set_tree_type(struct SpaceNode *snode, struct bNodeTreeType *typein
 bool ED_node_is_compositor(struct SpaceNode *snode);
 bool ED_node_is_shader(struct SpaceNode *snode);
 bool ED_node_is_texture(struct SpaceNode *snode);
+bool ED_node_is_simulation(struct SpaceNode *snode);
 
 void ED_node_shader_default(const struct bContext *C, struct ID *id);
 void ED_node_composit_default(const struct bContext *C, struct Scene *scene);
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 21e68c0b600..345fbb29f16 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -71,6 +71,7 @@
 #include "NOD_composite.h"
 #include "NOD_shader.h"
 #include "NOD_texture.h"
+#include "NOD_simulation.h"
 
 #define USE_ESC_COMPO
 
@@ -438,6 +439,11 @@ bool ED_node_is_texture(struct SpaceNode *snode)
   return STREQ(snode->tree_idname, ntreeType_Texture->idname);
 }
 
+bool ED_node_is_simulation(struct SpaceNode *snode)
+{
+  return STREQ(snode->tree_idname, ntreeType_Simulation->idname);
+}
+
 /* assumes nothing being done in ntree yet, sets the default in/out node */
 /* called from shading buttons or header */
 void ED_node_shader_default(const bContext *C, ID *id)
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c
index 64e8358c23c..38981cb75e7 100644
--- a/source/blender/editors/space_node/node_group.c
+++ b/source/blender/editors/space_node/node_group.c
@@ -85,7 +85,8 @@ static bool node_group_operator_editable(bContext *C)
      * Disabled otherwise to allow pynodes define their own operators
      * with same keymap.
      */
-    if (ED_node_is_shader(snode) || ED_node_is_compositor(snode) || ED_node_is_texture(snode)) {
+    if (ED_node_is_shader(snode) || ED_node_is_compositor(snode) || ED_node_is_texture(snode) ||
+        ED_node_is_simulation(snode)) {
       return true;
     }
   }
@@ -111,6 +112,9 @@ static const char *group_node_idname(bContext *C)
   else if (ED_node_is_texture(snode)) {
     return "TextureNodeGroup";
   }
+  else if (ED_node_is_simulation(snode)) {
+    return "SimulationNodeGroup";
+  }
 
   return "";
 }
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 23d665ee5e1..be58cd60903 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -9678,12 +9678,13 @@ void RNA_def_nodetree(BlenderRNA *brna)
    */
 #  include "../../nodes/NOD_static_types.h"
 
-  /* Node group types need to be defined for shader, compositor, texture nodes individually.
-   * Cannot use the static types header for this, since they share the same int id.
+  /* Node group types need to be defined for shader, compositor, texture, simulation nodes
+   * individually. Cannot use the static types header for this, since they share the same int id.
    */
   define_specific_node(brna, "ShaderNodeGroup", "ShaderNode", "Group", "", def_group);
   define_specific_node(brna, "CompositorNodeGroup", "CompositorNode", "Group", "", def_group);
   define_specific_node(brna, "TextureNodeGroup", "TextureNode", "Group", "", def_group);
+  define_specific_node(brna, "SimulationNodeGroup", "SimulationNode", "Group", "", def_group);
   def_custom_group(brna,
                    "ShaderNodeCustomGroup",
                    "ShaderNode",
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 264949896ea..893054ad523 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -221,6 +221,7 @@ set(SRC
   shader/node_shader_tree.c
   shader/node_shader_util.c
 
+  simulation/nodes/node_sim_common.cc
   simulation/nodes/node_sim_particle_simulation.cc
   simulation/node_sim_tree.cc
   simulation/node_sim_util.cc
diff --git a/source/blender/nodes/NOD_common.h b/source/blender/nodes/NOD_common.h
index 26c78eab4ec..dcc4f4d0b76 100644
--- a/source/blender/nodes/NOD_common.h
+++ b/source/blender/nodes/NOD_common.h
@@ -26,6 +26,10 @@
 
 #include "BKE_node.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void register_node_type_frame(void);
 void register_node_type_reroute(void);
 
@@ -42,4 +46,8 @@ struct bNodeSocket *node_group_output_find_socket(struct bNode *node, const char
 void node_group_input_update(struct bNodeTree *ntree, struct bNode *node);
 void node_group_output_update(struct bNodeTree *ntree, struct bNode *node);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __NOD_COMMON_H__ */
diff --git a/source/blender/nodes/NOD_simulation.h b/source/blender/nodes/NOD_simulation.h
index 93ae1faedd8..0edfa1a1b9f 100644
--- a/source/blender/nodes/NOD_simulation.h
+++ b/source/blender/nodes/NOD_simulation.h
@@ -9,6 +9,8 @@ extern struct bNodeTreeType *ntreeType_Simulation;
 
 void register_node_tree_type_sim(void);
 
+void register_node_type_sim_group(void);
+
 void register_node_type_sim_particle_simulation(void);
 
 #ifdef __cplusplus
diff --git a/source/blender/nodes/intern/node_common.h b/source/blender/nodes/intern/node_common.h
index c3314ae3c28..7810e9f1f14 100644
--- a/source/blender/nodes/intern/node_common.h
+++ b/source/blender/nodes/intern/node_common.h
@@ -26,6 +26,10 @@
 
 #include "DNA_listBase.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct bNodeTree;
 
 void node_group_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen);
@@ -33,4 +37,8 @@ bool node_group_poll_instance(struct bNode *node, struct bNodeTree *nodetree);
 
 void ntree_update_reroute_nodes(struct bNodeTree *ntree);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/source/blender/nodes/intern/node_util.h b/source/blender/nodes/intern/node_util.h
index a7f09d24a70..61f8fe6809d 100644
--- a/source/blender/nodes/intern/node_util.h
+++ b/source/blender/nodes/intern/node_util.h
@@ -38,6 +38,10 @@
 
 #include "RNA_access.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct bNode;
 struct bNodeTree;
 
@@ -103,4 +107,8 @@ void node_socket_set_vector(struct bNodeTree *ntree,
                             struct bNodeSocket *sock,
                             const float *value);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/source/blender/nodes/simulation/node_sim_util.cc b/source/blender/nodes/simulation/node_sim_util.cc
index c6da8b0951a..0e1e2e15f8d 100644
--- a/source/blender/nodes/simulation/node_sim_util.cc
+++ b/source/blender/nodes/simulation/node_sim_util.cc
@@ -12,4 +12,9 @@ void sim_node_type_base(bNodeType *ntype, int type, const char *name, short ncla
   };
 }
 
+bool sim_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
+{
+  return STREQ(ntree->idname, "SimulationNodeTree");
+}
+
 #endif /* __NODE_SIMULATION_UTIL_H__ */
\ No newline at end of file
diff --git a/source/blender/nodes/simulation/node_sim_util.h b/source/blender/nodes/simulation/node_sim_util.h
index 09d014940ef..f6bc7bd808d 100644
--- a/source/blender/nodes/simulation/node_sim_util.h
+++ b/source/blender/nodes/simulation/node_sim_util.h
@@ -13,7 +13,10 @@
 
 #include "BLT_translation.h"
 
+#include "node_util.h"
+
 void sim_node_type_base(
     struct bNodeType *ntype, int type, const char *name, short nclass, short flag);
+bool sim_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree);
 
 #endif /* __NODE_SHADER_UTIL_H__ */
\ No newline at end of file
diff --git a/source/blender/nodes/simulation/nodes/node_sim_common.cc b/source/blender/nodes/simulation/nodes/node_sim_common.cc
new file mode 100644
index 00000000000..4de1348bc9f
--- /dev/null
+++ b/source/blender/nodes/simulation/nodes/node_sim_common.cc
@@ -0,0 +1,30 @@
+#include "BKE_node.h"
+
+#include "NOD_simulation.h"
+
+#include "node_sim_util.h"
+#include "NOD_common.h"
+#include "node_common.h"
+
+void register_node_type_sim_group(void)
+{
+  static bNodeType ntype;
+
+  node_type_base_custom(
+      &ntype, "SimulationNodeGroup", "Group", NODE_CLASS_GROUP, NODE_CONST_OUTPUT);
+  ntype.type = NODE_GROUP;
+  ntype.poll = sim_node_poll_default;
+  ntype.poll_instance = node_group_poll_instance;
+  ntype.insert_link = node_insert_link_default;
+  ntype.update_internal_links = node_update_internal_links_default;
+  ntype.ext.srna = RNA_struct_find("SimulationNodeGroup");
+  BLI_assert(ntype.ext.srna != NULL);
+  RNA_struct_blender_type_set(ntype.ext.srna, &ntype);
+
+  node_type_socket_templates(&ntype, NULL, NULL);
+  node_type_size(&ntype, 140, 60, 400);
+  node_type_label(&ntype, node_group_label);
+  node_type_group_update(&ntype, node_group_update);
+
+  nodeRegisterType(&ntype);
+}
\ No newline at end of file



More information about the Bf-blender-cvs mailing list