Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2020-01-02 16:31:38 +0300
committerJacques Lucke <mail@jlucke.com>2020-01-02 16:31:38 +0300
commit1273af1bdd0780cdd2962ec908deac2e0322950e (patch)
tree93b1b0ec25dbfe4085afd8e8cd6c150baccbbc68 /source/blender/simulations/bparticles
parent3e325b42bbf9985ecf31af6aa5c230c806bf9ee7 (diff)
simulate particle systems in parallel
Diffstat (limited to 'source/blender/simulations/bparticles')
-rw-r--r--source/blender/simulations/bparticles/simulate.cpp37
1 files changed, 27 insertions, 10 deletions
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index 732939bd3d2..49cea166c7d 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -417,19 +417,36 @@ void simulate_particles(SimulationState &simulation_state,
MultiMap<std::string, ParticleSet *> newly_created_particles;
{
ParticleAllocator particle_allocator(particles_state);
+ Vector<std::string> name_vector;
+ Vector<ParticleSet *> particles_vector;
particles_state.particle_containers().foreach_key_value_pair(
[&](StringRef name, ParticleSet *particles) {
- ParticleSystemInfo *system_info = systems_to_simulate.lookup_ptr(name);
- if (system_info == nullptr) {
- return;
- }
-
- simulate_particles_for_time_span(simulation_state,
- particle_allocator,
- *system_info,
- simulation_time_span,
- particles->attributes());
+ name_vector.append(name);
+ particles_vector.append(particles);
});
+
+ auto func = [&](uint index) {
+ ParticleSystemInfo *system_info = systems_to_simulate.lookup_ptr(name_vector[index]);
+ ParticleSet *particles = particles_vector[index];
+ if (system_info == nullptr) {
+ return;
+ }
+
+ simulate_particles_for_time_span(simulation_state,
+ particle_allocator,
+ *system_info,
+ simulation_time_span,
+ particles->attributes());
+ };
+
+#ifdef WITH_TBB
+ tbb::parallel_for((uint)0, name_vector.size(), func);
+#else
+ for (uint i : name_vector.index_iterator()) {
+ func(i);
+ }
+#endif
+
create_particles_from_emitters(
simulation_state, particle_allocator, emitters, simulation_time_span);
newly_created_particles = particle_allocator.allocated_particles();