Simulations: UI for core particle nodes
authorJacques Lucke <jacques@blender.org>
Mon, 20 Apr 2020 12:47:13 +0000 (14:47 +0200)
committerJacques Lucke <jacques@blender.org>
Mon, 20 Apr 2020 12:47:13 +0000 (14:47 +0200)
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

21 files changed:
release/scripts/startup/nodeitems_builtins.py
source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/intern/node.c
source/blender/editors/space_node/drawnode.c
source/blender/makesdna/DNA_node_types.h
source/blender/makesrna/intern/rna_nodetree.c
source/blender/nodes/CMakeLists.txt
source/blender/nodes/NOD_simulation.h
source/blender/nodes/NOD_static_types.h
source/blender/nodes/simulation/nodes/node_sim_emit_particles.cc [new file with mode: 0644]
source/blender/nodes/simulation/nodes/node_sim_execute_condition.cc [new file with mode: 0644]
source/blender/nodes/simulation/nodes/node_sim_force.cc [new file with mode: 0644]
source/blender/nodes/simulation/nodes/node_sim_multi_execute.cc [new file with mode: 0644]
source/blender/nodes/simulation/nodes/node_sim_particle_attribute.cc [new file with mode: 0644]
source/blender/nodes/simulation/nodes/node_sim_particle_birth_event.cc [new file with mode: 0644]
source/blender/nodes/simulation/nodes/node_sim_particle_mesh_collision_event.cc [new file with mode: 0644]
source/blender/nodes/simulation/nodes/node_sim_particle_mesh_emitter.cc [new file with mode: 0644]
source/blender/nodes/simulation/nodes/node_sim_particle_simulation.cc [new file with mode: 0644]
source/blender/nodes/simulation/nodes/node_sim_particle_time_step_event.cc [new file with mode: 0644]
source/blender/nodes/simulation/nodes/node_sim_set_particle_attribute.cc [new file with mode: 0644]
source/blender/nodes/simulation/nodes/node_sim_simulation_time.cc [new file with mode: 0644]

index 4396e00dfd3d5101c12c789b243c197c274fdd05..722974b52f6575a9f1d2272144222321e7aa4276 100644 (file)
@@ -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"),
index 9d7caeb845f7889fb693c2524521ad7e5decbd4a..38bf3d828f73e5d02809f22091c18809cc08b250 100644 (file)
@@ -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);
 
index 4af87a3f5007abf20403d4c7614c02e58eaea2b2..2237d061fe11f5cd231fe1572fa1e59dcbca79a6 100644 (file)
@@ -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)
index 24b0bfd831f7105c0f1cf431c8113b38e7384254..4670f0fc6f645f5a78f198ad307ed675985becf0 100644 (file)
@@ -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 ************ */
index d8c8b5a8a29a224b44ac4fcabca83914367a7c4e..81911116b66ed968b3373f4ceb8e9a7839a65997 100644 (file)
@@ -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
index 51bcb608db02463ea7c359e9fa981c44bc1ca0c8..0c4583983a80d21596f887b06af58229e8c0da2d 100644 (file)
@@ -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_items);
+  RNA_def_property_ui_text(
+      prop,
+      "Data Type",
+      "Expected type of the attribute. Nothing is done if the type is not correct");
+  RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_SimulationNode_socket_update");
+}
+
+static void def_sim_time(StructRNA *srna)
+{
+  static const EnumPropertyItem mode_items[] = {
+      {NODE_SIM_INPUT_SIMULATION_TIME,
+       "SIMULATION_TIME",
+       0,
+       "Simulation Time",
+       "Time since start of simulation"},
+      {NODE_SIM_INPUT_SCENE_TIME, "SCENE_TIME", 0, "Scene Time", "Time shown in the timeline"},
+      {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", "The time to output");
+  RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_SimulationNode_socket_update");
+}
+
 /* -------------------------------------------------------------------------- */
 
 static void rna_def_shader_node(BlenderRNA *brna)
index 59a0ee808f56c5cdef43b52cd4a8cd41a1f05828..84c82c84fd01c56b0bbecc5a6077dbbdc975ec62 100644 (file)
@@ -222,6 +222,18 @@ set(SRC
   shader/node_shader_util.c
 
   simulation/nodes/node_sim_common.cc
+  simulation/nodes/node_sim_emit_particles.cc
+  simulation/nodes/node_sim_execute_condition.cc
+  simulation/nodes/node_sim_force.cc
+  simulation/nodes/node_sim_multi_execute.cc
+  simulation/nodes/node_sim_particle_attribute.cc
+  simulation/nodes/node_sim_particle_birth_event.cc
+  simulation/nodes/node_sim_particle_mesh_collision_event.cc
+  simulation/nodes/node_sim_particle_mesh_emitter.cc
+  simulation/nodes/node_sim_particle_simulation.cc
+  simulation/nodes/node_sim_particle_time_step_event.cc
+  simulation/nodes/node_sim_set_particle_attribute.cc
+  simulation/nodes/node_sim_simulation_time.cc
   simulation/node_simulation_tree.cc
   simulation/node_simulation_util.cc
 
index 835f742b17a29a3c0bec1fbad6eaf507348e5f66..2947d38fe83f450f83754ef547ad56d5daa23868 100644 (file)
@@ -27,6 +27,19 @@ void register_node_tree_type_sim(void);
 
 void register_node_type_sim_group(void);
 
+void register_node_type_sim_particle_simulation(void);
+void register_node_type_sim_force(void);
+void register_node_type_sim_set_particle_attribute(void);
+void register_node_type_sim_particle_birth_event(void);
+void register_node_type_sim_particle_time_step_event(void);
+void register_node_type_sim_execute_condition(void);
+void register_node_type_sim_multi_execute(void);
+void register_node_type_sim_particle_mesh_emitter(void);
+void register_node_type_sim_particle_mesh_collision_event(void);
+void register_node_type_sim_emit_particles(void);
+void register_node_type_sim_time(void);
+void register_node_type_sim_particle_attribute(void);
+
 #ifdef __cplusplus
 }
 #endif
index 7fec3324aab17522cca60ade7a6bb391b8b5df04..bf484133afa71edd62fbd27023e1981c67ccce49 100644 (file)
@@ -258,6 +258,19 @@ DefNode(TextureNode,    TEX_NODE_PROC+TEX_NOISE, 0,                      "TEX_NO
 DefNode(TextureNode,    TEX_NODE_PROC+TEX_STUCCI, 0,                     "TEX_STUCCI",     TexStucci,        "Stucci",            ""              )
 DefNode(TextureNode,    TEX_NODE_PROC+TEX_DISTNOISE, 0,                  "TEX_DISTNOISE",  TexDistNoise,     "Distorted Noise",   ""              )
 
+DefNode(SimulationNode, SIM_NODE_PARTICLE_SIMULATION, 0,                 "PARTICLE_SIMULATION", ParticleSimulation, "Particle Simulation", "")
+DefNode(SimulationNode, SIM_NODE_FORCE,        0,                        "FORCE",               Force,              "Force",               "")
+DefNode(SimulationNode, SIM_NODE_SET_PARTICLE_ATTRIBUTE, def_sim_set_particle_attribute, "SET_PARTICLE_ATTRIBUTE", SetParticleAttribute, "Set Particle Attribute", "")
+DefNode(SimulationNode, SIM_NODE_PARTICLE_BIRTH_EVENT,   0,              "PARTICLE_BIRTH_EVENT",   ParticleBirthEvent,   "Particle Birth Event",   "")
+DefNode(SimulationNode, SIM_NODE_PARTICLE_TIME_STEP_EVENT, def_sim_particle_time_step_event, "PARTICLE_TIME_STEP_EVENT", ParticleTimeStepEvent, "Particle Time Step Event", "")
+DefNode(SimulationNode, SIM_NODE_EXECUTE_CONDITION,   0,                 "EXECUTE_CONDITION",   ExecuteCondition,   "Execute Condition",    "")
+DefNode(SimulationNode, SIM_NODE_MULTI_EXECUTE,       0,                 "MULTI_EXECUTE",       MultiExecute,       "Multi Execute",        "")
+DefNode(SimulationNode, SIM_NODE_PARTICLE_MESH_EMITTER,  0,              "PARTICLE_MESH_EMITTER",  ParticleMeshEmitter,  "Particle Mesh Emitter", "")
+DefNode(SimulationNode, SIM_NODE_PARTICLE_MESH_COLLISION_EVENT, 0,       "PARTICLE_MESH_COLLISION_EVENT", ParticleMeshCollisionEvent, "Particle Mesh Collision Event", "")
+DefNode(SimulationNode, SIM_NODE_EMIT_PARTICLES, 0,                      "EMIT_PARTICLES",      EmitParticles,      "Emit Particles",       "")
+DefNode(SimulationNode, SIM_NODE_TIME,           def_sim_time,           "TIME",                Time,               "Time",                 "")
+DefNode(SimulationNode, SIM_NODE_PARTICLE_ATTRIBUTE, def_sim_particle_attribute, "PARTICLE_ATTRIBUTE",  ParticleAttribute,  "Particle Attribute",   "")
+
 /* undefine macros */
 #undef DefNode
 
diff --git a/source/blender/nodes/simulation/nodes/node_sim_emit_particles.cc b/source/blender/nodes/simulation/nodes/node_sim_emit_particles.cc
new file mode 100644 (file)
index 0000000..e23984d
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_simulation_util.h"
+
+static bNodeSocketTemplate sim_node_emit_particle_in[] = {
+    {SOCK_INT, N_("Amount"), 10, 0, 0, 0, 0, 10000000},
+    {SOCK_CONTROL_FLOW, N_("Execute")},
+    {-1, ""},
+};
+
+static bNodeSocketTemplate sim_node_emit_particle_out[] = {
+    {SOCK_CONTROL_FLOW, N_("Execute")},
+    {SOCK_EMITTERS, N_("Emitter")},
+    {-1, ""},
+};
+
+void register_node_type_sim_emit_particles()
+{
+  static bNodeType ntype;
+
+  sim_node_type_base(&ntype, SIM_NODE_EMIT_PARTICLES, "Emit Particles", 0, 0);
+  node_type_socket_templates(&ntype, sim_node_emit_particle_in, sim_node_emit_particle_out);
+  nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/simulation/nodes/node_sim_execute_condition.cc b/source/blender/nodes/simulation/nodes/node_sim_execute_condition.cc
new file mode 100644 (file)
index 0000000..69f30d1
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_simulation_util.h"
+
+static bNodeSocketTemplate sim_node_execute_condition_in[] = {
+    {SOCK_BOOLEAN, N_("Condition")},
+    {SOCK_CONTROL_FLOW, N_("If True")},
+    {SOCK_CONTROL_FLOW, N_("If False")},
+    {-1, ""},
+};
+
+static bNodeSocketTemplate sim_node_execute_condition_out[] = {
+    {SOCK_CONTROL_FLOW, N_("Execute")},
+    {-1, ""},
+};
+
+void register_node_type_sim_execute_condition()
+{
+  static bNodeType ntype;
+
+  sim_node_type_base(&ntype, SIM_NODE_EXECUTE_CONDITION, "Execute Condition", 0, 0);
+  node_type_socket_templates(
+      &ntype, sim_node_execute_condition_in, sim_node_execute_condition_out);
+  nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/simulation/nodes/node_sim_force.cc b/source/blender/nodes/simulation/nodes/node_sim_force.cc
new file mode 100644 (file)
index 0000000..eccd2e4
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_simulation_util.h"
+
+static bNodeSocketTemplate sim_node_force_in[] = {
+    {SOCK_VECTOR, N_("Force"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
+    {-1, ""},
+};
+
+static bNodeSocketTemplate sim_node_force_out[] = {
+    {SOCK_FORCES, N_("Force")},
+    {-1, ""},
+};
+
+void register_node_type_sim_force()
+{
+  static bNodeType ntype;
+
+  sim_node_type_base(&ntype, SIM_NODE_FORCE, "Force", 0, 0);
+  node_type_socket_templates(&ntype, sim_node_force_in, sim_node_force_out);
+  nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/simulation/nodes/node_sim_multi_execute.cc b/source/blender/nodes/simulation/nodes/node_sim_multi_execute.cc
new file mode 100644 (file)
index 0000000..5944db7
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_simulation_util.h"
+
+static bNodeSocketTemplate sim_node_multi_execute_in[] = {
+    {SOCK_CONTROL_FLOW, "1"},
+    {SOCK_CONTROL_FLOW, "2"},
+    {SOCK_CONTROL_FLOW, "3"},
+    {-1, ""},
+};
+
+static bNodeSocketTemplate sim_node_multi_execute_out[] = {
+    {SOCK_CONTROL_FLOW, N_("Execute")},
+    {-1, ""},
+};
+
+void register_node_type_sim_multi_execute()
+{
+  static bNodeType ntype;
+
+  sim_node_type_base(&ntype, SIM_NODE_MULTI_EXECUTE, "Multi Execute", 0, 0);
+  node_type_socket_templates(&ntype, sim_node_multi_execute_in, sim_node_multi_execute_out);
+  nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/simulation/nodes/node_sim_particle_attribute.cc b/source/blender/nodes/simulation/nodes/node_sim_particle_attribute.cc
new file mode 100644 (file)
index 0000000..b6b67ee
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "BLI_listbase.h"
+#include "node_simulation_util.h"
+
+static bNodeSocketTemplate sim_node_particle_attribute_in[] = {
+    {SOCK_STRING, N_("Name")},
+    {-1, ""},
+};
+
+static bNodeSocketTemplate sim_node_particle_attribute_out[] = {
+    {SOCK_FLOAT, N_("Float")},
+    {SOCK_INT, N_("Int")},
+    {SOCK_BOOLEAN, N_("Boolean")},
+    {SOCK_VECTOR, N_("Vector")},
+    {SOCK_RGBA, N_("Color")},
+    {SOCK_OBJECT, N_("Object")},
+    {SOCK_IMAGE, N_("Image")},
+    {-1, ""},
+};
+
+static void sim_node_particle_attribute_update(bNodeTree *UNUSED(ntree), bNode *node)
+{
+  LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
+    nodeSetSocketAvailability(sock, sock->type == node->custom1);
+  }
+}
+
+void register_node_type_sim_particle_attribute()
+{
+  static bNodeType ntype;
+
+  sim_node_type_base(&ntype, SIM_NODE_PARTICLE_ATTRIBUTE, "Particle Attribute", 0, 0);
+  node_type_socket_templates(
+      &ntype, sim_node_particle_attribute_in, sim_node_particle_attribute_out);
+  node_type_update(&ntype, sim_node_particle_attribute_update);
+  nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/simulation/nodes/node_sim_particle_birth_event.cc b/source/blender/nodes/simulation/nodes/node_sim_particle_birth_event.cc
new file mode 100644 (file)
index 0000000..8332a3e
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_simulation_util.h"
+
+static bNodeSocketTemplate sim_node_particle_birth_event_in[] = {
+    {SOCK_CONTROL_FLOW, N_("Execute")},
+    {-1, ""},
+};
+
+static bNodeSocketTemplate sim_node_particle_birth_event_out[] = {
+    {SOCK_EVENTS, N_("Event")},
+    {-1, ""},
+};
+
+void register_node_type_sim_particle_birth_event()
+{
+  static bNodeType ntype;
+
+  sim_node_type_base(&ntype, SIM_NODE_PARTICLE_BIRTH_EVENT, "Particle Birth Event", 0, 0);
+  node_type_socket_templates(
+      &ntype, sim_node_particle_birth_event_in, sim_node_particle_birth_event_out);
+  nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/simulation/nodes/node_sim_particle_mesh_collision_event.cc b/source/blender/nodes/simulation/nodes/node_sim_particle_mesh_collision_event.cc
new file mode 100644 (file)
index 0000000..4867117
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_simulation_util.h"
+
+static bNodeSocketTemplate sim_node_particle_mesh_collision_event_in[] = {
+    {SOCK_OBJECT, N_("Object")},
+    {SOCK_CONTROL_FLOW, N_("Execute")},
+    {-1, ""},
+};
+
+static bNodeSocketTemplate sim_node_particle_mesh_collision_event_out[] = {
+    {SOCK_EVENTS, N_("Event")},
+    {-1, ""},
+};
+
+void register_node_type_sim_particle_mesh_collision_event()
+{
+  static bNodeType ntype;
+
+  sim_node_type_base(
+      &ntype, SIM_NODE_PARTICLE_MESH_COLLISION_EVENT, "Particle Mesh Collision Event", 0, 0);
+  node_type_socket_templates(&ntype,
+                             sim_node_particle_mesh_collision_event_in,
+                             sim_node_particle_mesh_collision_event_out);
+  nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/simulation/nodes/node_sim_particle_mesh_emitter.cc b/source/blender/nodes/simulation/nodes/node_sim_particle_mesh_emitter.cc
new file mode 100644 (file)
index 0000000..2de7be2
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_simulation_util.h"
+
+#include "float.h"
+
+static bNodeSocketTemplate sim_node_particle_mesh_emitter_in[] = {
+    {SOCK_OBJECT, N_("Object")},
+    {SOCK_FLOAT, N_("Rate"), 10.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX},
+    {-1, ""},
+};
+
+static bNodeSocketTemplate sim_node_particle_mesh_emitter_out[] = {
+    {SOCK_EMITTERS, N_("Emitter")},
+    {-1, ""},
+};
+
+void register_node_type_sim_particle_mesh_emitter()
+{
+  static bNodeType ntype;
+
+  sim_node_type_base(&ntype, SIM_NODE_PARTICLE_MESH_EMITTER, "Mesh Emitter", 0, 0);
+  node_type_socket_templates(
+      &ntype, sim_node_particle_mesh_emitter_in, sim_node_particle_mesh_emitter_out);
+  nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/simulation/nodes/node_sim_particle_simulation.cc b/source/blender/nodes/simulation/nodes/node_sim_particle_simulation.cc
new file mode 100644 (file)
index 0000000..159c9b2
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_simulation_util.h"
+
+static bNodeSocketTemplate sim_node_particle_simulation_in[] = {
+    {SOCK_EMITTERS, N_("Emitters")},
+    {SOCK_EVENTS, N_("Events")},
+    {SOCK_FORCES, N_("Forces")},
+    {-1, ""},
+};
+
+static bNodeSocketTemplate sim_node_particle_simulation_out[] = {
+    {-1, ""},
+};
+
+void register_node_type_sim_particle_simulation()
+{
+  static bNodeType ntype;
+
+  sim_node_type_base(
+      &ntype, SIM_NODE_PARTICLE_SIMULATION, "Particle Simulation", NODE_CLASS_OUTPUT, 0);
+  node_type_socket_templates(
+      &ntype, sim_node_particle_simulation_in, sim_node_particle_simulation_out);
+  nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/simulation/nodes/node_sim_particle_time_step_event.cc b/source/blender/nodes/simulation/nodes/node_sim_particle_time_step_event.cc
new file mode 100644 (file)
index 0000000..cda8dde
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_simulation_util.h"
+
+static bNodeSocketTemplate sim_node_particle_time_step_event_in[] = {
+    {SOCK_CONTROL_FLOW, N_("Execute")},
+    {-1, ""},
+};
+
+static bNodeSocketTemplate sim_node_particle_time_step_event_out[] = {
+    {SOCK_EVENTS, N_("Event")},
+    {-1, ""},
+};
+
+void register_node_type_sim_particle_time_step_event()
+{
+  static bNodeType ntype;
+
+  sim_node_type_base(&ntype, SIM_NODE_PARTICLE_TIME_STEP_EVENT, "Particle Time Step Event", 0, 0);
+  node_type_socket_templates(
+      &ntype, sim_node_particle_time_step_event_in, sim_node_particle_time_step_event_out);
+  nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/simulation/nodes/node_sim_set_particle_attribute.cc b/source/blender/nodes/simulation/nodes/node_sim_set_particle_attribute.cc
new file mode 100644 (file)
index 0000000..8696dbe
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "BLI_listbase.h"
+#include "node_simulation_util.h"
+
+static bNodeSocketTemplate sim_node_set_particle_attribute_in[] = {
+    {SOCK_STRING, N_("Name")},
+    {SOCK_FLOAT, N_("Float"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
+    {SOCK_INT, N_("Int"), 0, 0, 0, 0, -10000, 10000},
+    {SOCK_BOOLEAN, N_("Boolean")},
+    {SOCK_VECTOR, N_("Vector")},
+    {SOCK_RGBA, N_("Color")},
+    {SOCK_OBJECT, N_("Object")},
+    {SOCK_IMAGE, N_("Image")},
+    {-1, ""},
+};
+
+static bNodeSocketTemplate sim_node_set_particle_attribute_out[] = {
+    {SOCK_CONTROL_FLOW, N_("Execute")},
+    {-1, ""},
+};
+
+static void sim_node_set_particle_attribute_update(bNodeTree *UNUSED(ntree), bNode *node)
+{
+  int index = 0;
+  LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
+    if (index >= 1) {
+      nodeSetSocketAvailability(sock, sock->type == node->custom1);
+    }
+    index++;
+  }
+}
+
+void register_node_type_sim_set_particle_attribute()
+{
+  static bNodeType ntype;
+
+  sim_node_type_base(&ntype, SIM_NODE_SET_PARTICLE_ATTRIBUTE, "Set Particle Attribute", 0, 0);
+  node_type_socket_templates(
+      &ntype, sim_node_set_particle_attribute_in, sim_node_set_particle_attribute_out);
+  node_type_update(&ntype, sim_node_set_particle_attribute_update);
+  nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/simulation/nodes/node_sim_simulation_time.cc b/source/blender/nodes/simulation/nodes/node_sim_simulation_time.cc
new file mode 100644 (file)
index 0000000..40e1c43
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_simulation_util.h"
+
+static bNodeSocketTemplate sim_node_time_out[] = {
+    {SOCK_FLOAT, N_("Time")},
+    {-1, ""},
+};
+
+void register_node_type_sim_time()
+{
+  static bNodeType ntype;
+
+  sim_node_type_base(&ntype, SIM_NODE_TIME, "Time", 0, 0);
+  node_type_socket_templates(&ntype, nullptr, sim_node_time_out);
+  nodeRegisterType(&ntype);
+}