[Bf-blender-cvs] [a6914c973f5] functions: introduce BlockStepData as container for data that would have to be passed into many functions

Jacques Lucke noreply at git.blender.org
Thu Jul 18 18:19:03 CEST 2019


Commit: a6914c973f51040f00f28e3319d5ef31eda75446
Author: Jacques Lucke
Date:   Thu Jul 18 12:16:10 2019 +0200
Branches: functions
https://developer.blender.org/rBa6914c973f51040f00f28e3319d5ef31eda75446

introduce BlockStepData as container for data that would have to be passed into many functions

===================================================================

M	source/blender/simulations/bparticles/simulate.cpp

===================================================================

diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index 960b6c2be09..a81a7255ec0 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -13,6 +13,16 @@ namespace BParticles {
 
 using BLI::VectorAdaptor;
 
+struct BlockStepData {
+  ArrayAllocator &array_allocator;
+  ParticleAllocator &particle_allocator;
+  ParticlesBlock █
+  ParticleType &particle_type;
+  AttributeArrays attribute_offsets;
+  ArrayRef<float> remaining_durations;
+  float step_end_time;
+};
+
 static uint get_max_event_storage_size(ArrayRef<Event *> events)
 {
   uint max_size = 0;
@@ -342,33 +352,33 @@ BLI_NOINLINE static void add_float3_arrays(ArrayRef<float3> base, ArrayRef<float
   }
 }
 
-BLI_NOINLINE static void apply_remaining_offsets(ParticleType &particle_type,
-                                                 ArrayAllocator &array_allocator,
-                                                 ParticleAllocator &particle_allocator,
-                                                 ParticleSet particles,
-                                                 AttributeArrays attribute_offsets,
-                                                 ArrayRef<float> durations,
-                                                 float step_end_time)
+BLI_NOINLINE static void apply_remaining_offsets(BlockStepData &step_data, ParticleSet particles)
 {
-  auto listeners = particle_type.forwarding_listeners();
+  auto listeners = step_data.particle_type.forwarding_listeners();
   if (listeners.size() > 0) {
-    ArrayAllocator::Array<float> time_factors(array_allocator);
+    ArrayAllocator::Array<float> time_factors(step_data.array_allocator);
     for (uint pindex : particles.pindices()) {
       time_factors[pindex] = 1.0f;
     }
 
-    ForwardingListenerInterface interface(
-        particles, particle_allocator, attribute_offsets, step_end_time, durations, time_factors);
-    for (ForwardingListener *listener : particle_type.forwarding_listeners()) {
+    ForwardingListenerInterface interface(particles,
+                                          step_data.particle_allocator,
+                                          step_data.attribute_offsets,
+                                          step_data.step_end_time,
+                                          step_data.remaining_durations,
+                                          time_factors);
+    for (ForwardingListener *listener : step_data.particle_type.forwarding_listeners()) {
       listener->listen(interface);
     }
   }
 
-  for (uint attribute_index : attribute_offsets.info().float3_attributes()) {
-    StringRef name = attribute_offsets.info().name_of(attribute_index);
+  auto atribute_offsets = step_data.attribute_offsets;
+
+  for (uint attribute_index : atribute_offsets.info().float3_attributes()) {
+    StringRef name = atribute_offsets.info().name_of(attribute_index);
 
     auto values = particles.attributes().get_float3(name);
-    auto offsets = attribute_offsets.get_float3(attribute_index);
+    auto offsets = atribute_offsets.get_float3(attribute_index);
 
     if (particles.indices_are_trivial()) {
       add_float3_arrays(values.take_front(particles.size()), offsets.take_front(particles.size()));
@@ -400,15 +410,17 @@ BLI_NOINLINE static void simulate_block(ArrayAllocator &array_allocator,
   IntegratorInterface interface(block, remaining_durations, array_allocator, attribute_offsets);
   integrator.integrate(interface);
 
+  BlockStepData step_data = {array_allocator,
+                             particle_allocator,
+                             block,
+                             particle_type,
+                             attribute_offsets,
+                             remaining_durations,
+                             end_time};
+
   if (particle_type.events().size() == 0) {
     ParticleSet all_particles_in_block(block, block.active_range().as_array_ref());
-    apply_remaining_offsets(particle_type,
-                            array_allocator,
-                            particle_allocator,
-                            all_particles_in_block,
-                            attribute_offsets,
-                            remaining_durations,
-                            end_time);
+    apply_remaining_offsets(step_data, all_particles_in_block);
   }
   else {
     auto indices_array = array_allocator.allocate_scoped<uint>();
@@ -427,13 +439,7 @@ BLI_NOINLINE static void simulate_block(ArrayAllocator &array_allocator,
     /* Not sure yet, if this really should be done. */
     if (unfinished_pindices.size() > 0) {
       ParticleSet remaining_particles(block, unfinished_pindices);
-      apply_remaining_offsets(particle_type,
-                              array_allocator,
-                              particle_allocator,
-                              remaining_particles,
-                              attribute_offsets,
-                              remaining_durations,
-                              end_time);
+      apply_remaining_offsets(step_data, remaining_particles);
     }
   }



More information about the Bf-blender-cvs mailing list