[Bf-blender-cvs] [c9bdeef488b] temp-test-point-cloud-simulation-depsgraph-integration: core particle simulation nodes

Jacques Lucke noreply at git.blender.org
Wed Apr 15 18:27:14 CEST 2020


Commit: c9bdeef488b322f998c7cd6beb0f33bc13ca6ba2
Author: Jacques Lucke
Date:   Thu Apr 9 12:34:12 2020 +0200
Branches: temp-test-point-cloud-simulation-depsgraph-integration
https://developer.blender.org/rBc9bdeef488b322f998c7cd6beb0f33bc13ca6ba2

core particle simulation nodes

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

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..17b4005220d 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_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_FUNCTION_INPUTS", "Function Inputs", items=[
+        NodeItem("SimulationNodeSimulationTime"),
+        NodeItem("SimulationNodeParticleAttribute"),
+    ]),
     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..6c5cb09dae8 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_SIMULATION_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..64c292298a7 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_simulation_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..16249ed8c5a 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -3125,8 +3125,40 @@ 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_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_set_butfunc(bNodeType *ntype)
+{
+  switch (ntype->type) {
+    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;
+  }
 }
 
 /* ****** 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..6a3aae77fb2 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1400,4 +1400,10 @@ 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;
+
 #endif
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 51bcb608db0..9d4aa6b32a5 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,61 @@ 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 rna_def_shader_node(BlenderRNA *brna)
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 59a0ee808f5..84c82c84fd0 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -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

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list