[Bf-blender-cvs] [cf59daf62fd] functions: fix killing particles

Jacques Lucke noreply at git.blender.org
Tue Feb 4 16:49:03 CET 2020


Commit: cf59daf62fd472b8c042538ea8be59f94685befc
Author: Jacques Lucke
Date:   Tue Feb 4 16:48:46 2020 +0100
Branches: functions
https://developer.blender.org/rBcf59daf62fd472b8c042538ea8be59f94685befc

fix killing particles

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

M	source/blender/blenlib/BLI_parallel.h
M	source/blender/simulations/bparticles/simulate.cpp

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

diff --git a/source/blender/blenlib/BLI_parallel.h b/source/blender/blenlib/BLI_parallel.h
index b7de28167ba..dc3f9328f03 100644
--- a/source/blender/blenlib/BLI_parallel.h
+++ b/source/blender/blenlib/BLI_parallel.h
@@ -134,6 +134,19 @@ void parallel_map_items(const StringMap<ValueT> &string_map, const FuncT &func)
   });
 }
 
+template<typename ValueT, typename FuncT>
+void parallel_map_keys(const StringMap<ValueT> &string_map, const FuncT &func)
+{
+  ScopedVector<StringRefNull> key_vector;
+
+  string_map.foreach_item([&](StringRefNull key, const ValueT &value) { key_vector.append(key); });
+
+  parallel_for(key_vector.index_range(), [&](uint index) {
+    StringRefNull key = key_vector[index];
+    func(key);
+  });
+}
+
 }  // namespace BLI
 
 #endif /* __BLI_PARALLEL_H__ */
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index e05b4baa4d9..26fbc32e806 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -484,9 +484,12 @@ void simulate_particles(SimulationState &simulation_state,
                               main_set.add_particles(*set);
                               delete set;
                             }
-
-                            delete_tagged_particles_and_reorder(main_set);
                           });
+
+  BLI::parallel_map_keys(systems_to_simulate, [&](StringRef name) {
+    ParticleSet &particles = particles_state.particle_container(name);
+    delete_tagged_particles_and_reorder(particles);
+  });
 }
 
 }  // namespace BParticles



More information about the Bf-blender-cvs mailing list