Commit: 1104d30f9e5b86ac54ff471e35cc2cfad243c120
Author: Jacques Lucke
Date:   Wed Jul 10 12:32:18 2019 +0200
Branches: functions
https://developer.blender.org/rB1104d30f9e5b86ac54ff471e35cc2cfad243c120

remove intermediate class

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

M       source/blender/simulations/bparticles/core.cpp
M       source/blender/simulations/bparticles/core.hpp
M       source/blender/simulations/bparticles/emitters.cpp

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

diff --git a/source/blender/simulations/bparticles/core.cpp 
b/source/blender/simulations/bparticles/core.cpp
index b129063af95..8bfe2199f21 100644
--- a/source/blender/simulations/bparticles/core.cpp
+++ b/source/blender/simulations/bparticles/core.cpp
@@ -89,11 +89,23 @@ AttributesInfo &BlockAllocator::attributes_info(StringRef 
particle_type_name)
   return m_state.particle_container(particle_type_name).attributes_info();
 }
 
+std::unique_ptr<EmitTargetBase> BlockAllocator::request(StringRef 
particle_type_name, uint size)
+{
+  SmallVector<ParticlesBlock *> blocks;
+  SmallVector<Range<uint>> ranges;
+  this->allocate_block_ranges(particle_type_name, size, blocks, ranges);
+
+  AttributesInfo &attributes_info = this->attributes_info(particle_type_name);
+
+  EmitTargetBase *target = new EmitTargetBase(particle_type_name, 
attributes_info, blocks, ranges);
+  return std::unique_ptr<EmitTargetBase>(target);
+}
+
 /* Emitter Interface
  ******************************************/
 
 EmitterInterface::EmitterInterface(BlockAllocator &block_allocator, TimeSpan 
time_span)
-    : m_emit_manager(block_allocator), m_time_span(time_span)
+    : m_block_allocator(block_allocator), m_time_span(time_span)
 {
 }
 
@@ -259,21 +271,6 @@ void EmitTargetBase::fill_float3(StringRef name, float3 
value)
   this->fill_float3(index, value);
 }
 
-/* EmitManager
- *****************************************/
-
-std::unique_ptr<EmitTargetBase> EmitManager::request(StringRef 
particle_type_name, uint size)
-{
-  SmallVector<ParticlesBlock *> blocks;
-  SmallVector<Range<uint>> ranges;
-  m_block_allocator.allocate_block_ranges(particle_type_name, size, blocks, 
ranges);
-
-  AttributesInfo &attributes_info = 
m_block_allocator.attributes_info(particle_type_name);
-
-  EmitTargetBase *target = new EmitTargetBase(particle_type_name, 
attributes_info, blocks, ranges);
-  return std::unique_ptr<EmitTargetBase>(target);
-}
-
 /* EventFilterInterface
  *****************************************/
 
diff --git a/source/blender/simulations/bparticles/core.hpp 
b/source/blender/simulations/bparticles/core.hpp
index d610b150cf0..1534b8ef84d 100644
--- a/source/blender/simulations/bparticles/core.hpp
+++ b/source/blender/simulations/bparticles/core.hpp
@@ -208,46 +208,6 @@ class ParticlesState {
   StringRefNull particle_container_id(ParticlesContainer &container);
 };
 
-/**
- * This class allows allocating new blocks from different particle containers.
- * A single instance is not thread safe, but multiple allocator instances can
- * be used by multiple threads at the same time.
- * It might hand out the same block more than once until it is full.
- */
-class BlockAllocator {
- private:
-  ParticlesState &m_state;
-  SmallVector<ParticlesBlock *> m_non_full_cache;
-  SmallVector<ParticlesBlock *> m_allocated_blocks;
-
- public:
-  BlockAllocator(ParticlesState &state);
-  BlockAllocator(BlockAllocator &other) = delete;
-
-  /**
-   * Return a block that can hold new particles. It might create an entirely 
new one or use a
-   * cached block.
-   */
-  ParticlesBlock &get_non_full_block(StringRef particle_type_name);
-
-  /**
-   * Allocate space for a given number of new particles. The attribute buffers 
might be distributed
-   * over multiple blocks.
-   */
-  void allocate_block_ranges(StringRef particle_type_name,
-                             uint size,
-                             SmallVector<ParticlesBlock *> &r_blocks,
-                             SmallVector<Range<uint>> &r_ranges);
-
-  AttributesInfo &attributes_info(StringRef particle_type_name);
-  ParticlesState &particles_state();
-
-  /**
-   * Access all blocks that have been allocated by this allocator.
-   */
-  ArrayRef<ParticlesBlock *> allocated_blocks();
-};
-
 /**
  * Base class for different kinds of emitters. It's main purpose is to make it 
easy to initialize
  * particle attributes.
@@ -330,16 +290,44 @@ class InstantEmitTarget : public EmitTargetBase {
                     ArrayRef<Range<uint>> ranges);
 };
 
-class EmitManager {
+/**
+ * This class allows allocating new blocks from different particle containers.
+ * A single instance is not thread safe, but multiple allocator instances can
+ * be used by multiple threads at the same time.
+ * It might hand out the same block more than once until it is full.
+ */
+class BlockAllocator {
  private:
-  BlockAllocator &m_block_allocator;
+  ParticlesState &m_state;
+  SmallVector<ParticlesBlock *> m_non_full_cache;
+  SmallVector<ParticlesBlock *> m_allocated_blocks;
 
  public:
-  EmitManager(BlockAllocator &block_allocator) : 
m_block_allocator(block_allocator)
-  {
-  }
-  EmitManager(EmitManager &other) = delete;
-  EmitManager(EmitManager &&other) = delete;
+  BlockAllocator(ParticlesState &state);
+  BlockAllocator(BlockAllocator &other) = delete;
+
+  /**
+   * Return a block that can hold new particles. It might create an entirely 
new one or use a
+   * cached block.
+   */
+  ParticlesBlock &get_non_full_block(StringRef particle_type_name);
+
+  /**
+   * Allocate space for a given number of new particles. The attribute buffers 
might be distributed
+   * over multiple blocks.
+   */
+  void allocate_block_ranges(StringRef particle_type_name,
+                             uint size,
+                             SmallVector<ParticlesBlock *> &r_blocks,
+                             SmallVector<Range<uint>> &r_ranges);
+
+  AttributesInfo &attributes_info(StringRef particle_type_name);
+  ParticlesState &particles_state();
+
+  /**
+   * Access all blocks that have been allocated by this allocator.
+   */
+  ArrayRef<ParticlesBlock *> allocated_blocks();
 
   std::unique_ptr<EmitTargetBase> request(StringRef particle_type_name, uint 
size);
 };
@@ -349,14 +337,14 @@ class EmitManager {
  */
 class EmitterInterface {
  private:
-  EmitManager m_emit_manager;
+  BlockAllocator &m_block_allocator;
   TimeSpan m_time_span;
 
  public:
   EmitterInterface(BlockAllocator &block_allocator, TimeSpan time_span);
   ~EmitterInterface() = default;
 
-  EmitManager &emit_manager();
+  BlockAllocator &block_allocator();
 
   /**
    * Time span that new particles should be emitted in.
@@ -736,9 +724,9 @@ inline StringRefNull EmitTargetBase::particle_type_name()
 /* EmitterInterface inline functions
  ***********************************************/
 
-inline EmitManager &EmitterInterface::emit_manager()
+inline BlockAllocator &EmitterInterface::block_allocator()
 {
-  return m_emit_manager;
+  return m_block_allocator;
 }
 
 inline TimeSpan EmitterInterface::time_span()
diff --git a/source/blender/simulations/bparticles/emitters.cpp 
b/source/blender/simulations/bparticles/emitters.cpp
index 66ed29755c8..ea35eac5c1f 100644
--- a/source/blender/simulations/bparticles/emitters.cpp
+++ b/source/blender/simulations/bparticles/emitters.cpp
@@ -30,7 +30,7 @@ class PointEmitter : public Emitter {
 
   void emit(EmitterInterface &interface) override
   {
-    auto target = interface.emit_manager().request(m_particle_type_name, 1);
+    auto target = interface.block_allocator().request(m_particle_type_name, 1);
     target->set_float3("Position", {m_point});
     target->set_float3("Velocity", {float3{-1, -1, 0}});
     target->fill_float("Birth Time", interface.time_span().end());
@@ -129,7 +129,7 @@ class SurfaceEmitter : public Emitter {
       sizes.append(size);
     }
 
-    auto target = interface.emit_manager().request(m_particle_type_name, 
positions.size());
+    auto target = interface.block_allocator().request(m_particle_type_name, 
positions.size());
     target->set_float3("Position", positions);
     target->set_float3("Velocity", velocities);
     target->set_float("Size", sizes);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to