[Bf-blender-cvs] [962a64aaaa2] functions: restructure simulation steps in solver
Jacques Lucke
noreply at git.blender.org
Tue Jun 18 12:39:09 CEST 2019
Commit: 962a64aaaa252fba59b7b8a42c2e64d303c776da
Author: Jacques Lucke
Date: Tue Jun 18 12:03:46 2019 +0200
Branches: functions
https://developer.blender.org/rB962a64aaaa252fba59b7b8a42c2e64d303c776da
restructure simulation steps in solver
===================================================================
M source/blender/simulations/bparticles/playground_solver.cpp
===================================================================
diff --git a/source/blender/simulations/bparticles/playground_solver.cpp b/source/blender/simulations/bparticles/playground_solver.cpp
index 8ac59b3fdab..4d99d179e75 100644
--- a/source/blender/simulations/bparticles/playground_solver.cpp
+++ b/source/blender/simulations/bparticles/playground_solver.cpp
@@ -70,11 +70,11 @@ class SimpleSolver : public Solver {
ParticlesContainer &particles = *state.particles;
- for (ParticlesBlock *block : particles.active_blocks()) {
- this->step_block(state, block, elapsed_seconds);
- this->delete_dead_particles(block);
- }
+ SmallVector<ParticlesBlock *> already_existing_blocks =
+ particles.active_blocks().to_small_vector();
+ this->step_blocks(state, already_existing_blocks, elapsed_seconds);
+ this->delete_dead_particles(already_existing_blocks);
this->emit_new_particles(state, elapsed_seconds);
this->compress_all_blocks(particles);
@@ -82,13 +82,17 @@ class SimpleSolver : public Solver {
std::cout << "Block amount: " << particles.active_blocks().size() << "\n";
}
- BLI_NOINLINE void step_block(MyState &state, ParticlesBlock *block, float elapsed_seconds)
+ BLI_NOINLINE void step_blocks(MyState &state,
+ ArrayRef<ParticlesBlock *> blocks,
+ float elapsed_seconds)
{
- AttributeArrays slice = block->slice_active();
- this->step_slice(state, slice, elapsed_seconds);
+ for (ParticlesBlock *block : blocks) {
+ AttributeArrays attributes = block->slice_active();
+ this->step_slice(state, attributes, elapsed_seconds);
+ }
}
- BLI_NOINLINE void step_slice(MyState &state, AttributeArrays &buffers, float elapsed_seconds)
+ BLI_NOINLINE void step_slice(MyState &state, AttributeArrays buffers, float elapsed_seconds)
{
auto positions = buffers.get_float3("Position");
auto velocities = buffers.get_float3("Velocity");
@@ -132,7 +136,7 @@ class SimpleSolver : public Solver {
}
}
- BLI_NOINLINE void compute_combined_force(AttributeArrays &slice, ArrayRef<float3> dst)
+ BLI_NOINLINE void compute_combined_force(AttributeArrays slice, ArrayRef<float3> dst)
{
BLI_assert(slice.size() == dst.size());
dst.fill({0, 0, 0});
@@ -141,7 +145,7 @@ class SimpleSolver : public Solver {
}
}
- BLI_NOINLINE void step_new_particles(AttributeArrays &slice, MyState &state)
+ BLI_NOINLINE void step_new_particles(AttributeArrays slice, MyState &state)
{
auto positions = slice.get_float3("Position");
auto velocities = slice.get_float3("Velocity");
@@ -157,6 +161,13 @@ class SimpleSolver : public Solver {
}
}
+ BLI_NOINLINE void delete_dead_particles(ArrayRef<ParticlesBlock *> blocks)
+ {
+ for (auto block : blocks) {
+ this->delete_dead_particles(block);
+ }
+ }
+
BLI_NOINLINE void delete_dead_particles(ParticlesBlock *block)
{
auto kill_states = block->slice_active().get_byte("Kill State");
More information about the Bf-blender-cvs
mailing list