[Bf-blender-cvs] [d824cb4a7f2] functions: allow using array allocator in integrator

Jacques Lucke noreply at git.blender.org
Mon Jul 8 17:56:48 CEST 2019


Commit: d824cb4a7f2a898ef45d91b531c0d4b4a75b0053
Author: Jacques Lucke
Date:   Mon Jul 8 11:53:38 2019 +0200
Branches: functions
https://developer.blender.org/rBd824cb4a7f2a898ef45d91b531c0d4b4a75b0053

allow using array allocator in integrator

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

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 436308d7ccf..7cc407ea7c8 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -127,10 +127,7 @@ class EulerIntegrator : public Integrator {
     AttributeArrays r_offsets = interface.offset_targets();
     ArrayRef<float> durations = interface.durations();
 
-    uint amount = block.active_amount();
-    BLI_assert(amount == r_offsets.size());
-
-    SmallVector<float3> combined_force(amount);
+    ArrayAllocator::Array<float3> combined_force(interface.array_allocator());
     this->compute_combined_force(block, combined_force);
 
     auto last_velocities = block.attributes().get_float3("Velocity");
diff --git a/source/blender/simulations/bparticles/core.cpp b/source/blender/simulations/bparticles/core.cpp
index 70606e742bb..7b539d645c6 100644
--- a/source/blender/simulations/bparticles/core.cpp
+++ b/source/blender/simulations/bparticles/core.cpp
@@ -360,8 +360,12 @@ EventExecuteInterface::EventExecuteInterface(ParticleSet particles,
 
 IntegratorInterface::IntegratorInterface(ParticlesBlock &block,
                                          ArrayRef<float> durations,
+                                         ArrayAllocator &array_allocator,
                                          AttributeArrays r_offsets)
-    : m_block(block), m_durations(durations), m_offsets(r_offsets)
+    : m_block(block),
+      m_durations(durations),
+      m_array_allocator(array_allocator),
+      m_offsets(r_offsets)
 {
 }
 
diff --git a/source/blender/simulations/bparticles/core.hpp b/source/blender/simulations/bparticles/core.hpp
index b2691b5dcac..f67dd17f6a8 100644
--- a/source/blender/simulations/bparticles/core.hpp
+++ b/source/blender/simulations/bparticles/core.hpp
@@ -614,11 +614,15 @@ class IntegratorInterface {
  private:
   ParticlesBlock &m_block;
   ArrayRef<float> m_durations;
+  ArrayAllocator &m_array_allocator;
 
   AttributeArrays m_offsets;
 
  public:
-  IntegratorInterface(ParticlesBlock &block, ArrayRef<float> durations, AttributeArrays r_offsets);
+  IntegratorInterface(ParticlesBlock &block,
+                      ArrayRef<float> durations,
+                      ArrayAllocator &array_allocator,
+                      AttributeArrays r_offsets);
 
   /**
    * Get the block for which the attribute offsets should be computed.
@@ -630,6 +634,15 @@ class IntegratorInterface {
    */
   ArrayRef<float> durations();
 
+  /**
+   * Get an array allocator that creates arrays with the number of elements being >= the number of
+   * particles in the block.
+   */
+  ArrayAllocator &array_allocator()
+  {
+    return m_array_allocator;
+  }
+
   /**
    * Get the arrays that the offsets should be written into.
    */
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index d709877de88..5c666931e82 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -418,7 +418,7 @@ BLI_NOINLINE static void simulate_block(ArrayAllocator &array_allocator,
       offsets_info, array_allocator);
   AttributeArrays attribute_offsets = attribute_offsets_core.slice_all().slice(0, amount);
 
-  IntegratorInterface interface(block, durations, attribute_offsets);
+  IntegratorInterface interface(block, durations, array_allocator, attribute_offsets);
   integrator.integrate(interface);
 
   ArrayRef<Event *> events = particle_type.events();



More information about the Bf-blender-cvs mailing list