[Bf-blender-cvs] [6704c822934] functions: new ActionInterface class

Jacques Lucke noreply at git.blender.org
Wed Jun 26 18:19:14 CEST 2019


Commit: 6704c822934ac33b08563963b2bec1487560e12e
Author: Jacques Lucke
Date:   Wed Jun 26 14:12:12 2019 +0200
Branches: functions
https://developer.blender.org/rB6704c822934ac33b08563963b2bec1487560e12e

new ActionInterface class

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

M	source/blender/simulations/bparticles/actions.cpp
M	source/blender/simulations/bparticles/core.hpp
M	source/blender/simulations/bparticles/simulate.cpp

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

diff --git a/source/blender/simulations/bparticles/actions.cpp b/source/blender/simulations/bparticles/actions.cpp
index cd81b14e665..aebfb128fc5 100644
--- a/source/blender/simulations/bparticles/actions.cpp
+++ b/source/blender/simulations/bparticles/actions.cpp
@@ -3,8 +3,10 @@
 namespace BParticles {
 
 class KillAction : public Action {
-  void execute(ParticleSet particles) override
+  void execute(ActionInterface &interface) override
   {
+    ParticleSet &particles = interface.particles();
+
     auto kill_states = particles.attributes().get_byte("Kill State");
     for (uint pindex : particles.indices()) {
       kill_states[pindex] = 1;
@@ -21,10 +23,11 @@ class MoveAction : public BParticles::Action {
   {
   }
 
-  void execute(ParticleSet particles) override
+  void execute(ActionInterface &interface) override
   {
-    auto positions = particles.attributes().get_float3("Position");
+    ParticleSet &particles = interface.particles();
 
+    auto positions = particles.attributes().get_float3("Position");
     for (uint pindex : particles.indices()) {
       positions[pindex] += m_offset;
     }
diff --git a/source/blender/simulations/bparticles/core.hpp b/source/blender/simulations/bparticles/core.hpp
index d26f1e4e33d..44fa355743f 100644
--- a/source/blender/simulations/bparticles/core.hpp
+++ b/source/blender/simulations/bparticles/core.hpp
@@ -144,11 +144,26 @@ class Event {
   virtual void filter(EventInterface &interface) = 0;
 };
 
+class ActionInterface {
+ private:
+  ParticleSet m_particles;
+
+ public:
+  ActionInterface(ParticleSet particles) : m_particles(particles)
+  {
+  }
+
+  ParticleSet &particles()
+  {
+    return m_particles;
+  }
+};
+
 class Action {
  public:
   virtual ~Action();
 
-  virtual void execute(ParticleSet particles) = 0;
+  virtual void execute(ActionInterface &interface) = 0;
 };
 
 class EmitterTarget {
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index 8f5851a7f2b..86efb0ed4bd 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -118,7 +118,9 @@ BLI_NOINLINE static void run_actions(AttributeArrays attributes,
   for (uint event_index = 0; event_index < events.size(); event_index++) {
     Action *action = action_per_event[event_index];
     ParticleSet particles(attributes, particles_per_event[event_index]);
-    action->execute(particles);
+
+    ActionInterface interface(particles);
+    action->execute(interface);
   }
 }



More information about the Bf-blender-cvs mailing list