[Bf-blender-cvs] [700c2c823ac] functions: keep track of newly allocated blocks

Jacques Lucke noreply at git.blender.org
Thu Jun 27 16:22:24 CEST 2019


Commit: 700c2c823ac7da8a53f56f3e6d2a6951bd4d05cf
Author: Jacques Lucke
Date:   Thu Jun 27 16:21:29 2019 +0200
Branches: functions
https://developer.blender.org/rB700c2c823ac7da8a53f56f3e6d2a6951bd4d05cf

keep track of newly allocated blocks

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

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

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

diff --git a/source/blender/simulations/bparticles/core.cpp b/source/blender/simulations/bparticles/core.cpp
index 848f0dcb3c3..0ff727bc4a6 100644
--- a/source/blender/simulations/bparticles/core.cpp
+++ b/source/blender/simulations/bparticles/core.cpp
@@ -45,20 +45,21 @@ ParticlesBlock &BlockAllocator::get_non_full_block(uint particle_type_id)
   ParticlesContainer &container = m_state.particle_container(particle_type_id);
 
   uint index = 0;
-  while (index < m_block_cache.size()) {
-    if (m_block_cache[index]->inactive_amount() == 0) {
-      m_block_cache.remove_and_reorder(index);
+  while (index < m_non_full_cache.size()) {
+    if (m_non_full_cache[index]->inactive_amount() == 0) {
+      m_non_full_cache.remove_and_reorder(index);
       continue;
     }
 
-    if (m_block_cache[index]->container() == container) {
-      return *m_block_cache[index];
+    if (m_non_full_cache[index]->container() == container) {
+      return *m_non_full_cache[index];
     }
     index++;
   }
 
   ParticlesBlock &block = container.new_block();
-  m_block_cache.append(&block);
+  m_non_full_cache.append(&block);
+  m_allocated_blocks.append(&block);
   return block;
 }
 
diff --git a/source/blender/simulations/bparticles/core.hpp b/source/blender/simulations/bparticles/core.hpp
index b1d3ff15452..2e784ae9cc6 100644
--- a/source/blender/simulations/bparticles/core.hpp
+++ b/source/blender/simulations/bparticles/core.hpp
@@ -56,7 +56,8 @@ class ParticlesState {
 class BlockAllocator {
  private:
   ParticlesState &m_state;
-  SmallVector<ParticlesBlock *> m_block_cache;
+  SmallVector<ParticlesBlock *> m_non_full_cache;
+  SmallVector<ParticlesBlock *> m_allocated_blocks;
 
  public:
   BlockAllocator(ParticlesState &state);
@@ -67,6 +68,11 @@ class BlockAllocator {
   {
     return m_state;
   }
+
+  ArrayRef<ParticlesBlock *> allocated_blocks()
+  {
+    return m_allocated_blocks;
+  }
 };
 
 class EmitTarget {



More information about the Bf-blender-cvs mailing list