[Bf-blender-cvs] [d51f6b010df] functions: add execute input to initial grid emitter

Jacques Lucke noreply at git.blender.org
Mon Sep 16 17:00:48 CEST 2019


Commit: d51f6b010df61c5f8c753536ce54ce51ef9e8817
Author: Jacques Lucke
Date:   Mon Sep 16 16:56:00 2019 +0200
Branches: functions
https://developer.blender.org/rBd51f6b010df61c5f8c753536ce54ce51ef9e8817

add execute input to initial grid emitter

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

M	release/scripts/startup/nodes/bparticle_nodes/initial_grid_emitter.py
M	source/blender/simulations/bparticles/action_interface.hpp
M	source/blender/simulations/bparticles/emitters.cpp
M	source/blender/simulations/bparticles/emitters.hpp
M	source/blender/simulations/bparticles/node_frontend.cpp

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

diff --git a/release/scripts/startup/nodes/bparticle_nodes/initial_grid_emitter.py b/release/scripts/startup/nodes/bparticle_nodes/initial_grid_emitter.py
index afefa21ad37..66ef9680c9e 100644
--- a/release/scripts/startup/nodes/bparticle_nodes/initial_grid_emitter.py
+++ b/release/scripts/startup/nodes/bparticle_nodes/initial_grid_emitter.py
@@ -7,10 +7,13 @@ class InitialGridEmitterNode(bpy.types.Node, BParticlesNode):
     bl_idname = "bp_InitialGridEmitterNode"
     bl_label = "Initial Grid Emitter"
 
+    execute_on_birth__prop: NodeBuilder.ExecuteInputProperty()
+
     def declaration(self, builder: NodeBuilder):
         builder.fixed_input("amount_x", "Amount X", "Integer", default=50)
         builder.fixed_input("amount_y", "Amount Y", "Integer", default=50)
         builder.fixed_input("step_x", "Step X", "Float", default=0.2)
         builder.fixed_input("step_y", "Step Y", "Float", default=0.2)
         builder.fixed_input("size", "Size", "Float", default=0.01)
+        builder.execute_input("execute_on_birth", "Execute on Birth", "execute_on_birth__prop")
         builder.influences_output("emitter", "Emitter")
diff --git a/source/blender/simulations/bparticles/action_interface.hpp b/source/blender/simulations/bparticles/action_interface.hpp
index 3a7d616af7d..31f6674d39b 100644
--- a/source/blender/simulations/bparticles/action_interface.hpp
+++ b/source/blender/simulations/bparticles/action_interface.hpp
@@ -91,6 +91,8 @@ class Action {
   void execute_from_emitter(AttributesRefGroup &new_particles,
                             EmitterInterface &emitter_interface,
                             const BuildContextF &build_context);
+  void execute_from_emitter(AttributesRefGroup &new_particles,
+                            EmitterInterface &emitter_interface);
   void execute_from_event(EventExecuteInterface &event_interface,
                           ActionContext *action_context = nullptr);
   void execute_from_offset_handler(OffsetHandlerInterface &offset_handler_interface,
@@ -161,6 +163,15 @@ inline void Action::execute_from_emitter(AttributesRefGroup &new_particles,
   }
 }
 
+inline void Action::execute_from_emitter(AttributesRefGroup &new_particles,
+                                         EmitterInterface &emitter_interface)
+{
+  this->execute_from_emitter<EmptyActionContext>(
+      new_particles, emitter_interface, [](IndexRange UNUSED(range), void *dst) {
+        new (dst) EmptyActionContext();
+      });
+}
+
 inline void Action::execute_from_event(EventExecuteInterface &event_interface,
                                        ActionContext *action_context)
 {
diff --git a/source/blender/simulations/bparticles/emitters.cpp b/source/blender/simulations/bparticles/emitters.cpp
index b7f0a745653..588fc4342e4 100644
--- a/source/blender/simulations/bparticles/emitters.cpp
+++ b/source/blender/simulations/bparticles/emitters.cpp
@@ -335,6 +335,8 @@ void InitialGridEmitter::emit(EmitterInterface &interface)
     new_particles.set<float3>("Position", new_positions);
     new_particles.fill<float>("Birth Time", interface.time_span().start());
     new_particles.fill<float>("Size", m_size);
+
+    m_action->execute_from_emitter(new_particles, interface);
   }
 }
 
diff --git a/source/blender/simulations/bparticles/emitters.hpp b/source/blender/simulations/bparticles/emitters.hpp
index ee9bf562dbe..adb03f8d1c6 100644
--- a/source/blender/simulations/bparticles/emitters.hpp
+++ b/source/blender/simulations/bparticles/emitters.hpp
@@ -71,6 +71,7 @@ class InitialGridEmitter : public Emitter {
   float m_step_x;
   float m_step_y;
   float m_size;
+  Action *m_action;
 
  public:
   InitialGridEmitter(ArrayRef<std::string> systems_to_emit,
@@ -78,13 +79,15 @@ class InitialGridEmitter : public Emitter {
                      uint amount_y,
                      float step_x,
                      float step_y,
-                     float size)
+                     float size,
+                     Action *action)
       : m_systems_to_emit(systems_to_emit),
         m_amount_x(amount_x),
         m_amount_y(amount_y),
         m_step_x(step_x),
         m_step_y(step_y),
-        m_size(size)
+        m_size(size),
+        m_action(action)
   {
   }
 
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp
index 5b8e66d4ed7..979750239b3 100644
--- a/source/blender/simulations/bparticles/node_frontend.cpp
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -546,6 +546,8 @@ static void PARSE_initial_grid_emitter(InfluencesCollector &collector,
     return;
   }
 
+  Action *action = vtree_data.build_action_list(vnode, "Execute on Birth");
+
   ArrayRef<std::string> system_names = vtree_data.find_target_system_names(
       vnode->output(0, "Emitter"));
   Emitter *emitter = new InitialGridEmitter(std::move(system_names),
@@ -553,7 +555,8 @@ static void PARSE_initial_grid_emitter(InfluencesCollector &collector,
                                             std::max(0, inputs->get<int>(1, "Amount Y")),
                                             inputs->get<float>(2, "Step X"),
                                             inputs->get<float>(3, "Step Y"),
-                                            inputs->get<float>(4, "Size"));
+                                            inputs->get<float>(4, "Size"),
+                                            action);
   collector.m_emitters.append(emitter);
 }



More information about the Bf-blender-cvs mailing list