Commit: 9f7bea6e83966dbe4e8393bd6ec811f9c54da178
Author: Jacques Lucke
Date:   Mon Apr 20 14:47:13 2020 +0200
Branches: master
https://developer.blender.org/rB9f7bea6e83966dbe4e8393bd6ec811f9c54da178

Simulations: UI for core particle nodes

This commit adds the initial set of particles nodes. These are fairly
low level and are expected to be put into groups that we ship with Blender.

See D7384 for a description of the individual nodes.

Reviewers: brecht

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

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

M       release/scripts/startup/nodeitems_builtins.py
M       source/blender/blenkernel/BKE_node.h
M       source/blender/blenkernel/intern/node.c
M       source/blender/editors/space_node/drawnode.c
M       source/blender/makesdna/DNA_node_types.h
M       source/blender/makesrna/intern/rna_nodetree.c
M       source/blender/nodes/CMakeLists.txt
M       source/blender/nodes/NOD_simulation.h
M       source/blender/nodes/NOD_static_types.h
A       source/blender/nodes/simulation/nodes/node_sim_emit_particles.cc
A       source/blender/nodes/simulation/nodes/node_sim_execute_condition.cc
A       source/blender/nodes/simulation/nodes/node_sim_force.cc
A       source/blender/nodes/simulation/nodes/node_sim_multi_execute.cc
A       source/blender/nodes/simulation/nodes/node_sim_particle_attribute.cc
A       source/blender/nodes/simulation/nodes/node_sim_particle_birth_event.cc
A       
source/blender/nodes/simulation/nodes/node_sim_particle_mesh_collision_event.cc
A       source/blender/nodes/simulation/nodes/node_sim_particle_mesh_emitter.cc
A       source/blender/nodes/simulation/nodes/node_sim_particle_simulation.cc
A       
source/blender/nodes/simulation/nodes/node_sim_particle_time_step_event.cc
A       source/blender/nodes/simulation/nodes/node_sim_set_particle_attribute.cc
A       source/blender/nodes/simulation/nodes/node_sim_simulation_time.cc

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

diff --git a/release/scripts/startup/nodeitems_builtins.py 
b/release/scripts/startup/nodeitems_builtins.py
index 4396e00dfd3..722974b52f6 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -477,6 +477,30 @@ texture_node_categories = [
 
 simulation_node_categories = [
     # Simulation Nodes
+    SimulationNodeCategory("SIM_OUTPUT", "Output", items=[
+        NodeItem("SimulationNodeParticleSimulation"),
+    ]),
+    SimulationNodeCategory("SIM_INPUTS", "Input", items=[
+        NodeItem("SimulationNodeTime"),
+        NodeItem("SimulationNodeParticleAttribute"),
+    ]),
+    SimulationNodeCategory("SIM_EMITTERS", "Emitters", items=[
+        NodeItem("SimulationNodeParticleMeshEmitter"),
+        NodeItem("SimulationNodeEmitParticles"),
+    ]),
+    SimulationNodeCategory("SIM_EVENTS", "Events", items=[
+        NodeItem("SimulationNodeParticleBirthEvent"),
+        NodeItem("SimulationNodeParticleTimeStepEvent"),
+        NodeItem("SimulationNodeParticleMeshCollisionEvent"),
+    ]),
+    SimulationNodeCategory("SIM_FORCES", "Forces", items=[
+        NodeItem("SimulationNodeForce"),
+    ]),
+    SimulationNodeCategory("SIM_EXECUTE", "Execute", items=[
+        NodeItem("SimulationNodeSetParticleAttribute"),
+        NodeItem("SimulationNodeExecuteCondition"),
+        NodeItem("SimulationNodeMultiExecute"),
+    ]),
     SimulationNodeCategory("SIM_GROUP", "Group", items=node_group_items),
     SimulationNodeCategory("SIM_LAYOUT", "Layout", items=[
         NodeItem("NodeFrame"),
diff --git a/source/blender/blenkernel/BKE_node.h 
b/source/blender/blenkernel/BKE_node.h
index 9d7caeb845f..38bf3d828f7 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1283,6 +1283,25 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
                      struct MTex *mtex);
 /** \} */
 
+/* -------------------------------------------------------------------- */
+/** \name Simulation Nodes
+ * \{ */
+
+#define SIM_NODE_PARTICLE_SIMULATION 1000
+#define SIM_NODE_FORCE 1001
+#define SIM_NODE_SET_PARTICLE_ATTRIBUTE 1002
+#define SIM_NODE_PARTICLE_BIRTH_EVENT 1003
+#define SIM_NODE_PARTICLE_TIME_STEP_EVENT 1004
+#define SIM_NODE_EXECUTE_CONDITION 1005
+#define SIM_NODE_MULTI_EXECUTE 1006
+#define SIM_NODE_PARTICLE_MESH_EMITTER 1007
+#define SIM_NODE_PARTICLE_MESH_COLLISION_EVENT 1008
+#define SIM_NODE_EMIT_PARTICLES 1009
+#define SIM_NODE_TIME 1010
+#define SIM_NODE_PARTICLE_ATTRIBUTE 1011
+
+/** \} */
+
 void init_nodesystem(void);
 void free_nodesystem(void);
 
diff --git a/source/blender/blenkernel/intern/node.c 
b/source/blender/blenkernel/intern/node.c
index 4af87a3f500..2237d061fe1 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -4227,6 +4227,19 @@ static void registerTextureNodes(void)
 static void registerSimulationNodes(void)
 {
   register_node_type_sim_group();
+
+  register_node_type_sim_particle_simulation();
+  register_node_type_sim_force();
+  register_node_type_sim_set_particle_attribute();
+  register_node_type_sim_particle_birth_event();
+  register_node_type_sim_particle_time_step_event();
+  register_node_type_sim_execute_condition();
+  register_node_type_sim_multi_execute();
+  register_node_type_sim_particle_mesh_emitter();
+  register_node_type_sim_particle_mesh_collision_event();
+  register_node_type_sim_emit_particles();
+  register_node_type_sim_time();
+  register_node_type_sim_particle_attribute();
 }
 
 void init_nodesystem(void)
diff --git a/source/blender/editors/space_node/drawnode.c 
b/source/blender/editors/space_node/drawnode.c
index 24b0bfd831f..4670f0fc6f6 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -3125,8 +3125,58 @@ static void node_texture_set_butfunc(bNodeType *ntype)
 
 /* ****************** BUTTON CALLBACKS FOR SIMULATION NODES ***************** 
*/
 
-static void node_simulation_set_butfunc(bNodeType *UNUSED(ntype))
+static void node_simulation_buts_particle_simulation(uiLayout *layout,
+                                                     bContext *UNUSED(C),
+                                                     PointerRNA *ptr)
 {
+  uiItemR(layout, ptr, "name", 0, "", ICON_NONE);
+}
+
+static void node_simulation_buts_particle_time_step_event(uiLayout *layout,
+                                                          bContext *UNUSED(C),
+                                                          PointerRNA *ptr)
+{
+  uiItemR(layout, ptr, "mode", 0, "", ICON_NONE);
+}
+
+static void node_simulation_buts_particle_attribute(uiLayout *layout,
+                                                    bContext *UNUSED(C),
+                                                    PointerRNA *ptr)
+{
+  uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE);
+}
+
+static void node_simulation_buts_set_particle_attribute(uiLayout *layout,
+                                                        bContext *UNUSED(C),
+                                                        PointerRNA *ptr)
+{
+  uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE);
+}
+
+static void node_simulation_buts_time(uiLayout *layout, bContext *UNUSED(C), 
PointerRNA *ptr)
+{
+  uiItemR(layout, ptr, "mode", 0, "", ICON_NONE);
+}
+
+static void node_simulation_set_butfunc(bNodeType *ntype)
+{
+  switch (ntype->type) {
+    case SIM_NODE_PARTICLE_SIMULATION:
+      ntype->draw_buttons = node_simulation_buts_particle_simulation;
+      break;
+    case SIM_NODE_PARTICLE_TIME_STEP_EVENT:
+      ntype->draw_buttons = node_simulation_buts_particle_time_step_event;
+      break;
+    case SIM_NODE_PARTICLE_ATTRIBUTE:
+      ntype->draw_buttons = node_simulation_buts_particle_attribute;
+      break;
+    case SIM_NODE_SET_PARTICLE_ATTRIBUTE:
+      ntype->draw_buttons = node_simulation_buts_set_particle_attribute;
+      break;
+    case SIM_NODE_TIME:
+      ntype->draw_buttons = node_simulation_buts_time;
+      break;
+  }
 }
 
 /* ****** init draw callbacks for all tree types, only called in usiblender.c, 
once ************ */
diff --git a/source/blender/makesdna/DNA_node_types.h 
b/source/blender/makesdna/DNA_node_types.h
index d8c8b5a8a29..81911116b66 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1400,4 +1400,16 @@ typedef enum NodeShaderOutputTarget {
   SHD_OUTPUT_CYCLES = 2,
 } NodeShaderOutputTarget;
 
+/* Particle Time Step Event node */
+typedef enum NodeSimParticleTimeStepEventType {
+  NODE_PARTICLE_TIME_STEP_EVENT_BEGIN = 0,
+  NODE_PARTICLE_TIME_STEP_EVENT_END = 1,
+} NodeSimParticleTimeStepEventType;
+
+/* Simulation Time node */
+typedef enum NodeSimInputTimeType {
+  NODE_SIM_INPUT_SIMULATION_TIME = 0,
+  NODE_SIM_INPUT_SCENE_TIME = 1,
+} NodeSimInputTimeType;
+
 #endif
diff --git a/source/blender/makesrna/intern/rna_nodetree.c 
b/source/blender/makesrna/intern/rna_nodetree.c
index 51bcb608db0..0c4583983a8 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -90,6 +90,17 @@ static const EnumPropertyItem node_socket_type_items[] = {
     {0, NULL, 0, NULL, NULL},
 };
 
+static const EnumPropertyItem particle_attribute_socket_type_items[] = {
+    {SOCK_FLOAT, "FLOAT", 0, "Float", ""},
+    {SOCK_INT, "INT", 0, "Int", ""},
+    {SOCK_BOOLEAN, "BOOLEAN", 0, "Boolean", ""},
+    {SOCK_VECTOR, "VECTOR", 0, "Vector", ""},
+    {SOCK_RGBA, "RGBA", 0, "Color", ""},
+    {SOCK_OBJECT, "OBJECT", 0, "Object", ""},
+    {SOCK_IMAGE, "IMAGE", 0, "Image", ""},
+    {0, NULL, 0, NULL, NULL},
+};
+
 static const EnumPropertyItem node_quality_items[] = {
     {NTREE_QUALITY_HIGH, "HIGH", 0, "High", "High quality"},
     {NTREE_QUALITY_MEDIUM, "MEDIUM", 0, "Medium", "Medium quality"},
@@ -3632,6 +3643,15 @@ static void rna_CompositorNodeScale_update(Main *bmain, 
Scene *scene, PointerRNA
   rna_Node_update(bmain, scene, ptr);
 }
 
+static void rna_SimulationNode_socket_update(Main *bmain, Scene *scene, 
PointerRNA *ptr)
+{
+  bNodeTree *ntree = (bNodeTree *)ptr->owner_id;
+  bNode *node = (bNode *)ptr->data;
+
+  nodeUpdate(ntree, node);
+  rna_Node_update(bmain, scene, ptr);
+}
+
 static PointerRNA rna_ShaderNodePointDensity_psys_get(PointerRNA *ptr)
 {
   bNode *node = ptr->data;
@@ -7941,6 +7961,82 @@ static void def_tex_bricks(StructRNA *srna)
   RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 }
 
+/* -- Simulation Nodes 
--------------------------------------------------------- */
+
+static void def_sim_particle_time_step_event(StructRNA *srna)
+{
+  static const EnumPropertyItem mode_items[] = {
+      {NODE_PARTICLE_TIME_STEP_EVENT_BEGIN,
+       "BEGIN",
+       0,
+       "Begin",
+       "Execute for every particle at the beginning of each time step"},
+      {NODE_PARTICLE_TIME_STEP_EVENT_END,
+       "END",
+       0,
+       "End",
+       "Execute for every particle at the end of each time step"},
+      {0, NULL, 0, NULL, NULL},
+  };
+
+  PropertyRNA *prop;
+
+  prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "custom1");
+  RNA_def_property_enum_items(prop, mode_items);
+  RNA_def_property_ui_text(prop, "Mode", "When in each time step is the event 
triggered");
+  RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+}
+
+static void def_sim_particle_attribute(StructRNA *srna)
+{
+  PropertyRNA *prop;
+
+  prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "custom1");
+  RNA_def_property_enum_items(prop, particle_attribute_socket_type_items);
+  RNA_def_property_ui_text(
+      prop,
+      "Data Type",
+      "Expected type of the attribute. A default value is returned if the type 
is not correct");
+  RNA_def_property_update(prop, NC_NODE | NA_EDITED, 
"rna_SimulationNode_socket_update");
+}
+
+static void def_sim_set_particle_attribute(StructRNA *srna)
+{
+  PropertyRNA *prop;
+
+  prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "custom1");
+  RNA_def_property_enum_items(prop, particle_attribute_socket_type_i

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to