[Bf-blender-cvs] [6f069a03d1a] functions: new integrator interface

Jacques Lucke noreply at git.blender.org
Mon Jul 1 13:44:11 CEST 2019


Commit: 6f069a03d1aec3b233d6eacf6c5550864a75a29b
Author: Jacques Lucke
Date:   Mon Jul 1 12:20:55 2019 +0200
Branches: functions
https://developer.blender.org/rB6f069a03d1aec3b233d6eacf6c5550864a75a29b

new integrator interface

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

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

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

diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index 4415ca7c4e6..45d22955a66 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -77,10 +77,12 @@ class EulerIntegrator : public Integrator {
     return m_offset_attributes_info;
   }
 
-  void integrate(ParticlesBlock &block,
-                 ArrayRef<float> durations,
-                 AttributeArrays r_offsets) override
+  void integrate(IntegratorInterface &interface) override
   {
+    ParticlesBlock &block = interface.block();
+    AttributeArrays r_offsets = interface.offset_targets();
+    ArrayRef<float> durations = interface.durations();
+
     uint amount = block.active_amount();
     BLI_assert(amount == r_offsets.size());
 
diff --git a/source/blender/simulations/bparticles/core.cpp b/source/blender/simulations/bparticles/core.cpp
index 886d12e276d..e6609f863bf 100644
--- a/source/blender/simulations/bparticles/core.cpp
+++ b/source/blender/simulations/bparticles/core.cpp
@@ -340,4 +340,14 @@ EventExecuteInterface::EventExecuteInterface(ParticleSet particles,
 {
 }
 
+/* IntegratorInterface
+ ***************************************************/
+
+IntegratorInterface::IntegratorInterface(ParticlesBlock &block,
+                                         ArrayRef<float> durations,
+                                         AttributeArrays r_offsets)
+    : m_block(block), m_durations(durations), m_offsets(r_offsets)
+{
+}
+
 }  // namespace BParticles
diff --git a/source/blender/simulations/bparticles/core.hpp b/source/blender/simulations/bparticles/core.hpp
index 073289b4fab..d9ca1a9ac29 100644
--- a/source/blender/simulations/bparticles/core.hpp
+++ b/source/blender/simulations/bparticles/core.hpp
@@ -20,6 +20,7 @@ namespace BParticles {
 class EventFilterInterface;
 class EventExecuteInterface;
 class EmitterInterface;
+class IntegratorInterface;
 
 /* Main API for the particle simulation. These classes have to be subclassed to define how the
  * particles should behave.
@@ -105,9 +106,7 @@ class Integrator {
    * Compute the offsets for all integrated attributes. Those are not applied immediately, because
    * there might be events that modify the attributes within a time step.
    */
-  virtual void integrate(ParticlesBlock &block,
-                         ArrayRef<float> durations,
-                         AttributeArrays r_offsets) = 0;
+  virtual void integrate(IntegratorInterface &interface) = 0;
 };
 
 /**
@@ -399,6 +398,22 @@ class EventExecuteInterface {
   AttributeArrays attribute_offsets();
 };
 
+class IntegratorInterface {
+ private:
+  ParticlesBlock &m_block;
+  ArrayRef<float> m_durations;
+
+  AttributeArrays m_offsets;
+
+ public:
+  IntegratorInterface(ParticlesBlock &block, ArrayRef<float> durations, AttributeArrays r_offsets);
+
+  ParticlesBlock &block();
+  ArrayRef<float> durations();
+
+  AttributeArrays offset_targets();
+};
+
 /* ParticlesState inline functions
  ********************************************/
 
@@ -631,4 +646,22 @@ inline AttributeArrays EventExecuteInterface::attribute_offsets()
   return m_attribute_offsets;
 }
 
+/* IntegratorInterface inline functions
+ *********************************************/
+
+inline ParticlesBlock &IntegratorInterface::block()
+{
+  return m_block;
+}
+
+inline ArrayRef<float> IntegratorInterface::durations()
+{
+  return m_durations;
+}
+
+inline AttributeArrays IntegratorInterface::offset_targets()
+{
+  return m_offsets;
+}
+
 }  // namespace BParticles
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index 2e22373084f..d3228752907 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -437,7 +437,8 @@ BLI_NOINLINE static void simulate_block(FixedArrayAllocator &array_allocator,
       offsets_info, array_allocator);
   AttributeArrays attribute_offsets = attribute_offsets_core.slice_all().slice(0, amount);
 
-  integrator.integrate(block, durations, attribute_offsets);
+  IntegratorInterface interface(block, durations, attribute_offsets);
+  integrator.integrate(interface);
 
   ArrayRef<Event *> events = particle_type.events();



More information about the Bf-blender-cvs mailing list