[Bf-blender-cvs] [2c8e8d547fc] functions: add speed input to explode node

Jacques Lucke noreply at git.blender.org
Fri Jul 5 17:38:47 CEST 2019


Commit: 2c8e8d547fcbdebf891b7d36bed772942866ca44
Author: Jacques Lucke
Date:   Fri Jul 5 14:42:54 2019 +0200
Branches: functions
https://developer.blender.org/rB2c8e8d547fcbdebf891b7d36bed772942866ca44

add speed input to explode node

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

M	release/scripts/startup/nodes/bparticle_nodes/explode_particle.py
M	source/blender/simulations/bparticles/actions.cpp
M	source/blender/simulations/bparticles/c_wrapper.cpp

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

diff --git a/release/scripts/startup/nodes/bparticle_nodes/explode_particle.py b/release/scripts/startup/nodes/bparticle_nodes/explode_particle.py
index b425b14d8f7..454f8f3c621 100644
--- a/release/scripts/startup/nodes/bparticle_nodes/explode_particle.py
+++ b/release/scripts/startup/nodes/bparticle_nodes/explode_particle.py
@@ -12,6 +12,7 @@ class ExplodeParticleNode(bpy.types.Node, BParticlesNode):
     def declaration(self, builder : SocketBuilder):
         builder.control_flow_input("control_in", "(In)")
         builder.fixed_input("amount", "Amount", "Integer")
+        builder.fixed_input("speed", "Speed", "Float")
         builder.control_flow_output("control_out", "(Out)")
 
     def draw(self, layout):
diff --git a/source/blender/simulations/bparticles/actions.cpp b/source/blender/simulations/bparticles/actions.cpp
index 5d284dc7187..00328f0699e 100644
--- a/source/blender/simulations/bparticles/actions.cpp
+++ b/source/blender/simulations/bparticles/actions.cpp
@@ -155,6 +155,7 @@ class ExplodeAction : public Action {
     m_compute_amount_body->call(fn_in, fn_out, execution_context);
 
     uint parts_amount = std::max(0, fn_out.get<int>(0));
+    float speed = fn_out.get<float>(1);
     for (uint i : particles.range()) {
       uint pindex = particles.get_particle_index(i);
 
@@ -162,7 +163,7 @@ class ExplodeAction : public Action {
       original_indices.append_n_times(i, parts_amount);
 
       for (uint j = 0; j < parts_amount; j++) {
-        new_velocities.append(random_direction() * 4);
+        new_velocities.append(random_direction() * speed);
       }
     }
 
diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index a4a20139065..a2767df8129 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -297,10 +297,9 @@ static Action *build_action(SocketWithNode start,
                                                 step_description));
   }
   else if (STREQ(bnode->idname, "bp_ExplodeParticleNode")) {
-    bNodeSocket *amount_socket = bSocketList(bnode->inputs).get(1);
-
-    FN::DFGraphSocket amount_input = data_graph.lookup_socket(amount_socket);
-    FN::FunctionGraph function_graph(data_graph.graph(), {}, {amount_input});
+    FN::DFGraphSocket amount_input = data_graph.lookup_socket(bSocketList(bnode->inputs).get(1));
+    FN::DFGraphSocket speed_input = data_graph.lookup_socket(bSocketList(bnode->inputs).get(2));
+    FN::FunctionGraph function_graph(data_graph.graph(), {}, {amount_input, speed_input});
     SharedFunction compute_amount_fn = function_graph.new_function("Compute Amount");
     FN::fgraph_add_TupleCallBody(compute_amount_fn, function_graph);



More information about the Bf-blender-cvs mailing list