diff options
author | Jacques Lucke <jacques@blender.org> | 2020-07-20 16:30:12 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-07-20 16:31:05 +0300 |
commit | 4f4af0cbe17fe9781aeaefb7e0d2f554bdb9c1a5 (patch) | |
tree | e8765dd53aee71b6a84420d692526b33157e5896 /source/blender/simulation/intern/simulation_solver.hh | |
parent | 9016a29f194194085acfd937f31b80be0f1b0c8e (diff) |
Particles: support removing particles during the simulation
This still cannot be controlled by the user. Currently, all particles are
killed after two seconds
Diffstat (limited to 'source/blender/simulation/intern/simulation_solver.hh')
-rw-r--r-- | source/blender/simulation/intern/simulation_solver.hh | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/source/blender/simulation/intern/simulation_solver.hh b/source/blender/simulation/intern/simulation_solver.hh index 7b37ed0583d..b5e42b53846 100644 --- a/source/blender/simulation/intern/simulation_solver.hh +++ b/source/blender/simulation/intern/simulation_solver.hh @@ -57,14 +57,51 @@ class SimulationSolveContext { Simulation &simulation_; Depsgraph &depsgraph_; const SimulationInfluences &influences_; + TimeInterval solve_interval_; public: SimulationSolveContext(Simulation &simulation, Depsgraph &depsgraph, - const SimulationInfluences &influences) - : simulation_(simulation), depsgraph_(depsgraph), influences_(influences) + const SimulationInfluences &influences, + TimeInterval solve_interval) + : simulation_(simulation), + depsgraph_(depsgraph), + influences_(influences), + solve_interval_(solve_interval) { } + + TimeInterval solve_interval() const + { + return solve_interval_; + } + + const SimulationInfluences &influences() const + { + return influences_; + } +}; + +class ParticleAllocators { + private: + Map<std::string, std::unique_ptr<ParticleAllocator>> &allocators_; + + public: + ParticleAllocators(Map<std::string, std::unique_ptr<ParticleAllocator>> &allocators) + : allocators_(allocators) + { + } + + ParticleAllocator *try_get_allocator(StringRef particle_simulation_name) + { + auto *ptr = allocators_.lookup_ptr_as(particle_simulation_name); + if (ptr != nullptr) { + return ptr->get(); + } + else { + return nullptr; + } + } }; class ParticleChunkContext { @@ -97,12 +134,12 @@ class ParticleChunkContext { class ParticleEmitterContext { private: SimulationSolveContext &solve_context_; - Map<std::string, std::unique_ptr<ParticleAllocator>> &particle_allocators_; + ParticleAllocators &particle_allocators_; TimeInterval simulation_time_interval_; public: ParticleEmitterContext(SimulationSolveContext &solve_context, - Map<std::string, std::unique_ptr<ParticleAllocator>> &particle_allocators, + ParticleAllocators &particle_allocators, TimeInterval simulation_time_interval) : solve_context_(solve_context), particle_allocators_(particle_allocators), @@ -112,13 +149,7 @@ class ParticleEmitterContext { ParticleAllocator *try_get_particle_allocator(StringRef particle_simulation_name) { - auto *ptr = particle_allocators_.lookup_ptr_as(particle_simulation_name); - if (ptr != nullptr) { - return ptr->get(); - } - else { - return nullptr; - } + return particle_allocators_.try_get_allocator(particle_simulation_name); } TimeInterval simulation_time_interval() const |