[Bf-blender-cvs] [bcc877e180a] functions: compress blocks after each simulation step
Jacques Lucke
noreply at git.blender.org
Thu Jun 20 15:51:17 CEST 2019
Commit: bcc877e180ae3e079021f0363b4489ce9577178d
Author: Jacques Lucke
Date: Thu Jun 20 12:51:07 2019 +0200
Branches: functions
https://developer.blender.org/rBbcc877e180ae3e079021f0363b4489ce9577178d
compress blocks after each simulation step
===================================================================
M source/blender/simulations/bparticles/c_wrapper.cpp
M source/blender/simulations/bparticles/simulate.cpp
===================================================================
diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index cc3ab14ca11..9e4e0b27975 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -123,6 +123,9 @@ void BParticles_simulate_modifier(NodeParticlesModifierData *UNUSED(npmd),
description.m_emitters.append(EMITTER_point({1, 1, 1}).release());
description.m_influences.m_forces.append(FORCE_directional({0, 0, -2}).release());
simulate_step(state, description);
+
+ std::cout << "Active Blocks: " << state.m_container->active_blocks().size() << "\n";
+ std::cout << " Particle Amount: " << BParticles_state_particle_count(state_c) << "\n";
}
uint BParticles_state_particle_count(BParticlesState state_c)
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index ae48fd917e6..ef549c3ba4d 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -141,6 +141,21 @@ static void emit_new_particles_from_emitters(ParticlesContainer &container,
}
}
+/* Compress particle blocks.
+ **************************************************/
+
+static void compress_all_blocks(ParticlesContainer &particles)
+{
+ SmallVector<ParticlesBlock *> blocks = particles.active_blocks().to_small_vector();
+ ParticlesBlock::Compress(blocks);
+
+ for (ParticlesBlock *block : blocks) {
+ if (block->is_empty()) {
+ particles.release_block(block);
+ }
+ }
+}
+
/* Main Entry Point
**************************************************/
@@ -167,6 +182,8 @@ void simulate_step(ParticlesState &state, StepDescription &description)
emit_new_particles_from_emitters(
particles, description.emitters(), description.influences(), time_span);
+
+ compress_all_blocks(particles);
}
} // namespace BParticles
More information about the Bf-blender-cvs
mailing list