[Bf-blender-cvs] [168f5964b6c] functions: remove redundant information

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


Commit: 168f5964b6cc172f5ccf612537c072c3d589fad1
Author: Jacques Lucke
Date:   Thu Jul 18 13:37:04 2019 +0200
Branches: functions
https://developer.blender.org/rB168f5964b6cc172f5ccf612537c072c3d589fad1

remove redundant information

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

M	source/blender/simulations/bparticles/core.cpp
M	source/blender/simulations/bparticles/core.hpp
M	source/blender/simulations/bparticles/events.cpp
M	source/blender/simulations/bparticles/simulate.cpp

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

diff --git a/source/blender/simulations/bparticles/core.cpp b/source/blender/simulations/bparticles/core.cpp
index 03321e3dfa4..04319249dab 100644
--- a/source/blender/simulations/bparticles/core.cpp
+++ b/source/blender/simulations/bparticles/core.cpp
@@ -319,13 +319,13 @@ void ParticleSets::fill_float3(StringRef name, float3 value)
  *****************************************/
 
 EventFilterInterface::EventFilterInterface(BlockStepData &step_data,
-                                           ParticleSet particles,
+                                           ArrayRef<uint> pindices,
                                            ArrayRef<float> known_min_time_factors,
                                            EventStorage &r_event_storage,
                                            SmallVector<uint> &r_filtered_pindices,
                                            SmallVector<float> &r_filtered_time_factors)
     : m_step_data(step_data),
-      m_particles(particles),
+      m_pindices(pindices),
       m_known_min_time_factors(known_min_time_factors),
       m_event_storage(r_event_storage),
       m_filtered_pindices(r_filtered_pindices),
diff --git a/source/blender/simulations/bparticles/core.hpp b/source/blender/simulations/bparticles/core.hpp
index 10fa06aac46..6ac297c0937 100644
--- a/source/blender/simulations/bparticles/core.hpp
+++ b/source/blender/simulations/bparticles/core.hpp
@@ -431,7 +431,7 @@ class EventStorage {
 class EventFilterInterface {
  private:
   BlockStepData &m_step_data;
-  ParticleSet m_particles;
+  ArrayRef<uint> m_pindices;
   ArrayRef<float> m_known_min_time_factors;
 
   EventStorage &m_event_storage;
@@ -443,7 +443,7 @@ class EventFilterInterface {
 
  public:
   EventFilterInterface(BlockStepData &step_data,
-                       ParticleSet particles,
+                       ArrayRef<uint> pindices,
                        ArrayRef<float> known_min_time_factors,
                        EventStorage &r_event_storage,
                        SmallVector<uint> &r_filtered_pindices,
@@ -452,7 +452,7 @@ class EventFilterInterface {
   /**
    * Return the particle set that should be checked.
    */
-  ParticleSet &particles();
+  ParticleSet particles();
 
   /**
    * Return the durations that should be checked for every particle.
@@ -777,9 +777,9 @@ inline uint EventStorage::max_element_size() const
 /* EventFilterInterface inline functions
  **********************************************/
 
-inline ParticleSet &EventFilterInterface::particles()
+inline ParticleSet EventFilterInterface::particles()
 {
-  return m_particles;
+  return ParticleSet(m_step_data.block, m_pindices);
 }
 
 inline ArrayRef<float> EventFilterInterface::durations()
diff --git a/source/blender/simulations/bparticles/events.cpp b/source/blender/simulations/bparticles/events.cpp
index 3613aa8fd08..0d8aa87ac58 100644
--- a/source/blender/simulations/bparticles/events.cpp
+++ b/source/blender/simulations/bparticles/events.cpp
@@ -69,7 +69,7 @@ uint MeshCollisionEvent::storage_size()
 
 void MeshCollisionEvent::filter(EventFilterInterface &interface)
 {
-  ParticleSet &particles = interface.particles();
+  ParticleSet particles = interface.particles();
   auto positions = particles.attributes().get_float3("Position");
   auto last_collision_times = particles.attributes().get_float(m_identifier);
   auto position_offsets = interface.attribute_offsets().get_float3("Position");
@@ -131,7 +131,7 @@ void MeshCollisionEvent::execute(EventExecuteInterface &interface)
 
 void CloseByPointsEvent::filter(EventFilterInterface &interface)
 {
-  ParticleSet &particles = interface.particles();
+  ParticleSet particles = interface.particles();
   auto positions = particles.attributes().get_float3("Position");
 
   for (uint pindex : particles.pindices()) {
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index e4090ace393..fe7457807c8 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -23,14 +23,14 @@ static uint get_max_event_storage_size(ArrayRef<Event *> events)
 }
 
 BLI_NOINLINE static void find_next_event_per_particle(BlockStepData &step_data,
-                                                      ParticleSet particles,
+                                                      ArrayRef<uint> pindices,
                                                       EventStorage &r_event_storage,
                                                       ArrayRef<int> r_next_event_indices,
                                                       ArrayRef<float> r_time_factors_to_next_event,
                                                       VectorAdaptor<uint> &r_pindices_with_event)
 {
-  r_next_event_indices.fill_indices(particles.pindices(), -1);
-  r_time_factors_to_next_event.fill_indices(particles.pindices(), 1.0f);
+  r_next_event_indices.fill_indices(pindices, -1);
+  r_time_factors_to_next_event.fill_indices(pindices, 1.0f);
 
   ArrayRef<Event *> events = step_data.particle_type.events();
 
@@ -40,7 +40,7 @@ BLI_NOINLINE static void find_next_event_per_particle(BlockStepData &step_data,
 
     Event *event = events[event_index];
     EventFilterInterface interface(step_data,
-                                   particles,
+                                   pindices,
                                    r_time_factors_to_next_event,
                                    r_event_storage,
                                    triggered_pindices,
@@ -57,7 +57,7 @@ BLI_NOINLINE static void find_next_event_per_particle(BlockStepData &step_data,
     }
   }
 
-  for (uint pindex : particles.pindices()) {
+  for (uint pindex : pindices) {
     if (r_next_event_indices[pindex] != -1) {
       r_pindices_with_event.append(pindex);
     }
@@ -191,7 +191,7 @@ BLI_NOINLINE static void simulate_to_next_event(BlockStepData &step_data,
   EventStorage event_storage(event_storage_array, max_event_storage_size);
 
   find_next_event_per_particle(step_data,
-                               particles,
+                               particles.pindices(),
                                event_storage,
                                next_event_indices,
                                time_factors_to_next_event,



More information about the Bf-blender-cvs mailing list