[Bf-blender-cvs] [0f26e995179] functions: bring back loop to simulate n events
Jacques Lucke
noreply at git.blender.org
Sat Jun 29 16:25:43 CEST 2019
Commit: 0f26e9951799df745dab6543a2b86337747136b5
Author: Jacques Lucke
Date: Sat Jun 29 13:08:48 2019 +0200
Branches: functions
https://developer.blender.org/rB0f26e9951799df745dab6543a2b86337747136b5
bring back loop to simulate n events
===================================================================
M source/blender/simulations/bparticles/particles_container.hpp
M source/blender/simulations/bparticles/simulate.cpp
===================================================================
diff --git a/source/blender/simulations/bparticles/particles_container.hpp b/source/blender/simulations/bparticles/particles_container.hpp
index 817ed18741c..2c5c7264a3b 100644
--- a/source/blender/simulations/bparticles/particles_container.hpp
+++ b/source/blender/simulations/bparticles/particles_container.hpp
@@ -60,6 +60,7 @@ class ParticlesBlock {
public:
ParticlesBlock(ParticlesContainer &container, AttributeArraysCore &attributes_core);
+ Range<uint> active_range();
uint &active_amount();
uint inactive_amount();
bool is_full();
@@ -118,6 +119,11 @@ inline bool operator==(const ParticlesContainer &a, const ParticlesContainer &b)
/* Particles Block
****************************************/
+inline Range<uint> ParticlesBlock::active_range()
+{
+ return Range<uint>(0, m_active_amount);
+}
+
inline uint &ParticlesBlock::active_amount()
{
return m_active_amount;
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index e2471f8047c..8a6939da144 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -278,7 +278,7 @@ BLI_NOINLINE static void simulate_to_next_event(BlockAllocator &block_allocator,
}
BLI_NOINLINE static void simulate_with_max_n_events(
- uint UNUSED(max_events),
+ uint max_events,
BlockAllocator &block_allocator,
ParticlesBlock &block,
IdealOffsets ideal_offsets,
@@ -289,49 +289,41 @@ BLI_NOINLINE static void simulate_with_max_n_events(
{
SmallVector<float> last_event_times;
- ParticleSet particles(block, static_number_range_ref(0, block.active_amount()));
- SmallVector<uint> unfinished_particle_indices_after_1;
- SmallVector<float> remaining_durations_after_1;
+ /* Handle first event separately to be able to use the static number range. */
+ ParticleSet particles_to_simulate(block, static_number_range_ref(block.active_range()));
+ SmallVector<uint> unfinished_particle_indices;
+ SmallVector<float> remaining_durations;
simulate_to_next_event(block_allocator,
- particles,
+ particles_to_simulate,
ideal_offsets,
durations,
end_time,
particle_type,
last_event_times,
- unfinished_particle_indices_after_1,
- remaining_durations_after_1);
-
- particles = ParticleSet(block, unfinished_particle_indices_after_1);
- SmallVector<uint> unfinished_particle_indices_after_2;
- SmallVector<float> remaining_durations_after_2;
+ unfinished_particle_indices,
+ remaining_durations);
- simulate_to_next_event(block_allocator,
- particles,
- ideal_offsets,
- remaining_durations_after_1,
- end_time,
- particle_type,
- last_event_times,
- unfinished_particle_indices_after_2,
- remaining_durations_after_2);
+ for (uint iteration = 0; iteration < max_events - 1; iteration++) {
+ particles_to_simulate = ParticleSet(block, unfinished_particle_indices);
+ SmallVector<uint> unfinished_particle_indices_after;
+ SmallVector<float> remaining_durations_after;
- particles = ParticleSet(block, unfinished_particle_indices_after_2);
- SmallVector<uint> unfinished_particle_indices_after_3;
- SmallVector<float> remaining_durations_after_3;
+ simulate_to_next_event(block_allocator,
+ particles_to_simulate,
+ ideal_offsets,
+ remaining_durations,
+ end_time,
+ particle_type,
+ last_event_times,
+ unfinished_particle_indices_after,
+ remaining_durations_after);
- simulate_to_next_event(block_allocator,
- particles,
- ideal_offsets,
- remaining_durations_after_2,
- end_time,
- particle_type,
- last_event_times,
- unfinished_particle_indices_after_3,
- remaining_durations_after_3);
+ unfinished_particle_indices = std::move(unfinished_particle_indices_after);
+ remaining_durations = std::move(remaining_durations_after);
+ }
- r_unfinished_particle_indices = unfinished_particle_indices_after_3;
+ r_unfinished_particle_indices = std::move(unfinished_particle_indices);
}
BLI_NOINLINE static void apply_remaining_offsets(ParticleSet particles, IdealOffsets ideal_offsets)
More information about the Bf-blender-cvs
mailing list