[Bf-blender-cvs] [8eb57698c47] functions: cleanup running action from event

Jacques Lucke noreply at git.blender.org
Thu Jul 11 17:15:24 CEST 2019


Commit: 8eb57698c47cafa5096ebc1ed1cc56ec2e7bdc0a
Author: Jacques Lucke
Date:   Thu Jul 11 12:36:09 2019 +0200
Branches: functions
https://developer.blender.org/rB8eb57698c47cafa5096ebc1ed1cc56ec2e7bdc0a

cleanup running action from event

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

M	source/blender/simulations/bparticles/action_interface.hpp
M	source/blender/simulations/bparticles/events.cpp

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

diff --git a/source/blender/simulations/bparticles/action_interface.hpp b/source/blender/simulations/bparticles/action_interface.hpp
index a520ce6f1cf..881ceae018f 100644
--- a/source/blender/simulations/bparticles/action_interface.hpp
+++ b/source/blender/simulations/bparticles/action_interface.hpp
@@ -84,6 +84,9 @@ class ActionInterface {
                              ParticleSets &particle_sets,
                              EmitterInterface &emitter_interface,
                              EventInfo *event_info = nullptr);
+  static void RunFromEvent(std::unique_ptr<Action> &action,
+                           EventExecuteInterface &event_interface,
+                           EventInfo *event_info = nullptr);
 
   EventInfo &event_info();
 
@@ -124,7 +127,7 @@ inline ActionInterface::ActionInterface(ParticleAllocator &particle_allocator,
 {
 }
 
-class EmptyEventinfo : public EventInfo {
+class EmptyEventInfo : public EventInfo {
   void *get_info_array(StringRef UNUSED(name))
   {
     return nullptr;
@@ -140,7 +143,7 @@ inline void ActionInterface::RunFromEmitter(std::unique_ptr<Action> &action,
   AttributeArraysCore offsets_core(info, {}, 0);
   AttributeArrays offsets = offsets_core.slice_all();
 
-  EmptyEventinfo empty_event_info;
+  EmptyEventInfo empty_event_info;
   EventInfo &used_event_info = (event_info == nullptr) ? empty_event_info : *event_info;
 
   for (ParticleSet particles : particle_sets.sets()) {
@@ -157,6 +160,23 @@ inline void ActionInterface::RunFromEmitter(std::unique_ptr<Action> &action,
   }
 }
 
+inline void ActionInterface::RunFromEvent(std::unique_ptr<Action> &action,
+                                          EventExecuteInterface &event_interface,
+                                          EventInfo *event_info)
+{
+  EmptyEventInfo empty_event_info;
+  EventInfo &used_event_info = (event_info == nullptr) ? empty_event_info : *event_info;
+
+  ActionInterface action_interface(event_interface.particle_allocator(),
+                                   event_interface.array_allocator(),
+                                   event_interface.particles(),
+                                   event_interface.attribute_offsets(),
+                                   event_interface.current_times(),
+                                   event_interface.remaining_times(),
+                                   used_event_info);
+  action->execute(action_interface);
+}
+
 inline EventInfo &ActionInterface::event_info()
 {
   return m_event_info;
diff --git a/source/blender/simulations/bparticles/events.cpp b/source/blender/simulations/bparticles/events.cpp
index 903ed38f4ea..9e45b2c56e7 100644
--- a/source/blender/simulations/bparticles/events.cpp
+++ b/source/blender/simulations/bparticles/events.cpp
@@ -8,13 +8,6 @@
 
 namespace BParticles {
 
-class EmptyEventInfo : public EventInfo {
-  void *get_info_array(StringRef UNUSED(name)) override
-  {
-    return nullptr;
-  }
-};
-
 class AgeReachedEvent : public Event {
  private:
   std::string m_identifier;
@@ -85,15 +78,7 @@ class AgeReachedEvent : public Event {
       was_activated_before[pindex] = true;
     }
 
-    EmptyEventInfo event_info;
-    ActionInterface action_interface(interface.particle_allocator(),
-                                     interface.array_allocator(),
-                                     particles,
-                                     interface.attribute_offsets(),
-                                     interface.current_times(),
-                                     interface.remaining_times(),
-                                     event_info);
-    m_action->execute(action_interface);
+    ActionInterface::RunFromEvent(m_action, interface);
   }
 };
 
@@ -215,14 +200,7 @@ class MeshCollisionEventFilter : public Event {
     }
 
     CollisionEventInfo event_info(normals);
-    ActionInterface action_interface(interface.particle_allocator(),
-                                     interface.array_allocator(),
-                                     particles,
-                                     interface.attribute_offsets(),
-                                     interface.current_times(),
-                                     interface.remaining_times(),
-                                     event_info);
-    m_action->execute(action_interface);
+    ActionInterface::RunFromEvent(m_action, interface, &event_info);
   }
 };



More information about the Bf-blender-cvs mailing list