[Bf-blender-cvs] [169bdd890f9] functions: extract method
Jacques Lucke
noreply at git.blender.org
Thu Jan 2 16:38:11 CET 2020
Commit: 169bdd890f99d7379388c4ccf6db585d64c7eb1f
Author: Jacques Lucke
Date: Thu Jan 2 14:43:46 2020 +0100
Branches: functions
https://developer.blender.org/rB169bdd890f99d7379388c4ccf6db585d64c7eb1f
extract method
===================================================================
M source/blender/simulations/bparticles/simulate.cpp
===================================================================
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index cf8b2136701..6330e841965 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -409,6 +409,36 @@ BLI_NOINLINE static void simulate_particles_from_birth_to_end_of_step(
end_time);
}
+BLI_NOINLINE static void simulate_existing_particles(
+ SimulationState &simulation_state,
+ ParticleAllocator &particle_allocator,
+ StringMap<ParticleSystemInfo> &systems_to_simulate)
+{
+ FloatInterval simulation_time_span = simulation_state.time().current_update_time();
+
+ Vector<std::string> name_vector;
+ Vector<ParticleSet *> particles_vector;
+ simulation_state.particles().particle_containers().foreach_key_value_pair(
+ [&](StringRef name, ParticleSet *particles) {
+ name_vector.append(name);
+ particles_vector.append(particles);
+ });
+
+ parallel_for(name_vector.index_iterator(), [&](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());
+ });
+}
+
BLI_NOINLINE static void create_particles_from_emitters(SimulationState &simulation_state,
ParticleAllocator &particle_allocator,
ArrayRef<Emitter *> emitters,
@@ -434,30 +464,9 @@ void simulate_particles(SimulationState &simulation_state,
MultiMap<std::string, ParticleSet *> newly_created_particles;
{
ParticleAllocator particle_allocator(particles_state);
-
parallel_invoke(
[&]() {
- Vector<std::string> name_vector;
- Vector<ParticleSet *> particles_vector;
- particles_state.particle_containers().foreach_key_value_pair(
- [&](StringRef name, ParticleSet *particles) {
- name_vector.append(name);
- particles_vector.append(particles);
- });
-
- parallel_for(name_vector.index_iterator(), [&](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());
- });
+ simulate_existing_particles(simulation_state, particle_allocator, systems_to_simulate);
},
[&]() {
create_particles_from_emitters(
@@ -500,6 +509,6 @@ void simulate_particles(SimulationState &simulation_state,
delete_tagged_particles_and_reorder(main_set);
});
-}
+} // namespace BParticles
} // namespace BParticles
More information about the Bf-blender-cvs
mailing list