[Bf-blender-cvs] [1f9186c2701] functions: store remaining durations instead of end times

Jacques Lucke noreply at git.blender.org
Wed Jul 10 17:17:59 CEST 2019


Commit: 1f9186c27015ddf600363e7078e83750aef0354f
Author: Jacques Lucke
Date:   Wed Jul 10 15:17:56 2019 +0200
Branches: functions
https://developer.blender.org/rB1f9186c27015ddf600363e7078e83750aef0354f

store remaining durations instead of end times

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

M	source/blender/simulations/bparticles/action_interface.cpp
M	source/blender/simulations/bparticles/action_interface.hpp
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/action_interface.cpp b/source/blender/simulations/bparticles/action_interface.cpp
index 7fd077cc262..664cf50c3f6 100644
--- a/source/blender/simulations/bparticles/action_interface.cpp
+++ b/source/blender/simulations/bparticles/action_interface.cpp
@@ -10,10 +10,12 @@ void ActionInterface::execute_action_for_subset(ArrayRef<uint> indices,
                                                 std::unique_ptr<Action> &action)
 {
   SmallVector<float> sub_current_times;
+  SmallVector<float> sub_remaining_times;
   SmallVector<uint> particle_indices;
   for (uint i : indices) {
     particle_indices.append(m_particles.get_particle_index(i));
     sub_current_times.append(m_current_times[i]);
+    sub_remaining_times.append(m_remaining_times[i]);
   }
 
   ParticleSet sub_particles(m_particles.block(), particle_indices);
@@ -22,7 +24,7 @@ void ActionInterface::execute_action_for_subset(ArrayRef<uint> indices,
                                 sub_particles,
                                 m_attribute_offsets,
                                 sub_current_times,
-                                m_step_end_time,
+                                sub_remaining_times,
                                 m_event_info);
   action->execute(sub_interface);
 }
diff --git a/source/blender/simulations/bparticles/action_interface.hpp b/source/blender/simulations/bparticles/action_interface.hpp
index 8b106abeaf8..5e0bd335199 100644
--- a/source/blender/simulations/bparticles/action_interface.hpp
+++ b/source/blender/simulations/bparticles/action_interface.hpp
@@ -67,9 +67,9 @@ class ActionInterface {
   ArrayAllocator &m_array_allocator;
   ParticleSet m_particles;
   AttributeArrays m_attribute_offsets;
-  EventInfo &m_event_info;
   ArrayRef<float> m_current_times;
-  float m_step_end_time;
+  ArrayRef<float> m_remaining_times;
+  EventInfo &m_event_info;
 
  public:
   ActionInterface(ParticleAllocator &particle_allocator,
@@ -77,7 +77,7 @@ class ActionInterface {
                   ParticleSet particles,
                   AttributeArrays attribute_offsets,
                   ArrayRef<float> current_times,
-                  float step_end_time,
+                  ArrayRef<float> remaining_times,
                   EventInfo &event_info);
 
   EventInfo &event_info();
@@ -107,14 +107,14 @@ inline ActionInterface::ActionInterface(ParticleAllocator &particle_allocator,
                                         ParticleSet particles,
                                         AttributeArrays attribute_offsets,
                                         ArrayRef<float> current_times,
-                                        float step_end_time,
+                                        ArrayRef<float> remaining_times,
                                         EventInfo &event_info)
     : m_particle_allocator(particle_allocator),
       m_array_allocator(array_allocator),
       m_particles(particles),
       m_attribute_offsets(attribute_offsets),
       m_current_times(current_times),
-      m_step_end_time(step_end_time),
+      m_remaining_times(remaining_times),
       m_event_info(event_info)
 {
 }
@@ -136,7 +136,7 @@ inline AttributeArrays ActionInterface::attribute_offsets()
 
 inline float ActionInterface::remaining_time_in_step(uint index)
 {
-  return m_step_end_time - m_current_times[index];
+  return m_remaining_times[index];
 }
 
 inline ArrayRef<float> ActionInterface::current_times()
diff --git a/source/blender/simulations/bparticles/core.cpp b/source/blender/simulations/bparticles/core.cpp
index a230f54904e..e8f6b574fa7 100644
--- a/source/blender/simulations/bparticles/core.cpp
+++ b/source/blender/simulations/bparticles/core.cpp
@@ -267,16 +267,16 @@ EventExecuteInterface::EventExecuteInterface(ParticleSet particles,
                                              ParticleAllocator &particle_allocator,
                                              ArrayAllocator &array_allocator,
                                              ArrayRef<float> current_times,
+                                             ArrayRef<float> remaining_times,
                                              EventStorage &event_storage,
-                                             AttributeArrays attribute_offsets,
-                                             float step_end_time)
+                                             AttributeArrays attribute_offsets)
     : m_particles(particles),
       m_particle_allocator(particle_allocator),
       m_array_allocator(array_allocator),
       m_current_times(current_times),
+      m_remaining_times(remaining_times),
       m_event_storage(event_storage),
-      m_attribute_offsets(attribute_offsets),
-      m_step_end_time(step_end_time)
+      m_attribute_offsets(attribute_offsets)
 {
 }
 
diff --git a/source/blender/simulations/bparticles/core.hpp b/source/blender/simulations/bparticles/core.hpp
index 60c3707bc17..e0fddd4e815 100644
--- a/source/blender/simulations/bparticles/core.hpp
+++ b/source/blender/simulations/bparticles/core.hpp
@@ -466,18 +466,18 @@ class EventExecuteInterface {
   ParticleAllocator &m_particle_allocator;
   ArrayAllocator &m_array_allocator;
   ArrayRef<float> m_current_times;
+  ArrayRef<float> m_remaining_times;
   EventStorage &m_event_storage;
   AttributeArrays m_attribute_offsets;
-  float m_step_end_time;
 
  public:
   EventExecuteInterface(ParticleSet particles,
                         ParticleAllocator &particle_allocator,
                         ArrayAllocator &array_allocator,
                         ArrayRef<float> current_times,
+                        ArrayRef<float> remaining_times,
                         EventStorage &event_storage,
-                        AttributeArrays attribute_offsets,
-                        float step_end_time);
+                        AttributeArrays attribute_offsets);
 
   ~EventExecuteInterface() = default;
 
@@ -491,10 +491,7 @@ class EventExecuteInterface {
    */
   ArrayRef<float> current_times();
 
-  /**
-   * Get the end time of the current step.
-   */
-  float step_end_time();
+  ArrayRef<float> remaining_times();
 
   /**
    * Get the data stored in the Event->filter() function for a particle index.
@@ -831,9 +828,9 @@ inline ArrayRef<float> EventExecuteInterface::current_times()
   return m_current_times;
 }
 
-inline float EventExecuteInterface::step_end_time()
+inline ArrayRef<float> EventExecuteInterface::remaining_times()
 {
-  return m_step_end_time;
+  return m_remaining_times;
 }
 
 template<typename T> inline T &EventExecuteInterface::get_storage(uint pindex)
diff --git a/source/blender/simulations/bparticles/events.cpp b/source/blender/simulations/bparticles/events.cpp
index 537bd1e3554..ac1f76b5d37 100644
--- a/source/blender/simulations/bparticles/events.cpp
+++ b/source/blender/simulations/bparticles/events.cpp
@@ -92,7 +92,7 @@ class AgeReachedEvent : public Event {
                                      particles,
                                      interface.attribute_offsets(),
                                      interface.current_times(),
-                                     interface.step_end_time(),
+                                     interface.remaining_times(),
                                      event_info);
     m_action->execute(action_interface);
   }
@@ -224,7 +224,7 @@ class MeshCollisionEventFilter : public Event {
                                      particles,
                                      interface.attribute_offsets(),
                                      interface.current_times(),
-                                     interface.step_end_time(),
+                                     interface.remaining_times(),
                                      event_info);
     m_action->execute(action_interface);
   }
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index abb23f0c7ac..6bc247985ff 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -140,13 +140,15 @@ BLI_NOINLINE static void compute_current_time_per_particle(
     float end_time,
     ArrayRef<int> next_event_indices,
     ArrayRef<float> time_factors_to_next_event,
-    ArrayRef<SmallVector<float>> r_current_time_per_particle)
+    ArrayRef<SmallVector<float>> r_current_time_per_particle,
+    ArrayRef<SmallVector<float>> r_remaining_time_per_particle)
 {
   for (uint i : indices_with_events) {
     int event_index = next_event_indices[i];
     BLI_assert(event_index >= 0);
-    r_current_time_per_particle[event_index].append(
-        end_time - durations[i] * (1.0f - time_factors_to_next_event[i]));
+    float remaining_duration = durations[i] * (1.0f - time_factors_to_next_event[i]);
+    r_current_time_per_particle[event_index].append(end_time - remaining_duration);
+    r_remaining_time_per_particle[event_index].append(remaining_duration);
   }
 }
 
@@ -179,10 +181,10 @@ BLI_NOINLINE static void execute_events(ParticleAllocator &particle_allocator,
                                         ParticlesBlock &block,
                                         ArrayRef<SmallVector<uint>> particle_indices_per_event,
                                         ArrayRef<SmallVector<float>> current_time_per_particle,
+                                        ArrayRef<SmallVector<float>> remaining_time_per_particle,
                                         ArrayRef<Event *> events,
                                         EventStorage &event_storage,
-                                        AttributeArrays attribute_offsets,
-                                        float end_time)
+                                        AttributeArrays attribute_offsets)
 {
   BLI_assert(events.size() == particle_indices_per_event.size());
   BLI_assert(events.size() == current_time_per_particle.size());
@@ -198,9 +200,9 @@ BLI_NOINLINE static void execute_events(ParticleAllocator &particle_allocator,
                                     particle_allocator,
                                     array_allocator,
                                     current_time_per_particle[event_index],
+ 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list