[Bf-blender-cvs] [b0f2b24160d] functions: cleanup
Jacques Lucke
noreply at git.blender.org
Fri Jun 28 16:04:39 CEST 2019
Commit: b0f2b24160d60a8fc17b3992f82a432f405b66d8
Author: Jacques Lucke
Date: Fri Jun 28 15:12:42 2019 +0200
Branches: functions
https://developer.blender.org/rBb0f2b24160d60a8fc17b3992f82a432f405b66d8
cleanup
===================================================================
M source/blender/simulations/bparticles/simulate.cpp
===================================================================
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index 52e09145738..4f637317f7c 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -39,7 +39,8 @@ BLI_NOINLINE static void find_next_event_per_particle(ParticleSet particles,
ArrayRef<Event *> events,
ArrayRef<float> last_event_times,
ArrayRef<int> r_next_event_indices,
- ArrayRef<float> r_time_factors_to_next_event)
+ ArrayRef<float> r_time_factors_to_next_event,
+ SmallVector<uint> &r_indices_with_event)
{
r_next_event_indices.fill(-1);
r_time_factors_to_next_event.fill(1.0f);
@@ -68,6 +69,12 @@ BLI_NOINLINE static void find_next_event_per_particle(ParticleSet particles,
}
}
}
+
+ for (uint i = 0; i < r_next_event_indices.size(); i++) {
+ if (r_next_event_indices[i] != -1) {
+ r_indices_with_event.append(i);
+ }
+ }
}
BLI_NOINLINE static void forward_particles_to_next_event_or_end(
@@ -84,6 +91,18 @@ BLI_NOINLINE static void forward_particles_to_next_event_or_end(
}
}
+BLI_NOINLINE static void update_ideal_offsets_for_particles_with_events(
+ ArrayRef<uint> indices_with_events,
+ ArrayRef<float> time_factors_to_next_event,
+ IdealOffsets &ideal_offsets)
+{
+ for (uint i : indices_with_events) {
+ float factor = 1.0f - time_factors_to_next_event[i];
+ ideal_offsets.position_offsets[i] *= factor;
+ ideal_offsets.velocity_offsets[i] *= factor;
+ }
+}
+
BLI_NOINLINE static void find_particles_per_event(
ArrayRef<uint> indices_with_events,
ArrayRef<uint> particle_indices,
@@ -215,6 +234,7 @@ BLI_NOINLINE static void simulate_to_next_event(BlockAllocator &block_allocator,
SmallVector<int> next_event_indices(particles.size());
SmallVector<float> time_factors_to_next_event(particles.size());
+ SmallVector<uint> indices_with_event;
find_next_event_per_particle(particles,
ideal_offsets,
@@ -223,16 +243,12 @@ BLI_NOINLINE static void simulate_to_next_event(BlockAllocator &block_allocator,
particle_type.events(),
last_event_times,
next_event_indices,
- time_factors_to_next_event);
-
- SmallVector<uint> indices_with_event;
- for (uint i = 0; i < next_event_indices.size(); i++) {
- if (next_event_indices[i] != -1) {
- indices_with_event.append(i);
- }
- }
+ time_factors_to_next_event,
+ indices_with_event);
forward_particles_to_next_event_or_end(particles, ideal_offsets, time_factors_to_next_event);
+ update_ideal_offsets_for_particles_with_events(
+ indices_with_event, time_factors_to_next_event, ideal_offsets);
SmallVector<SmallVector<uint>> particles_per_event(particle_type.events().size());
find_particles_per_event(
More information about the Bf-blender-cvs
mailing list