[Bf-blender-cvs] [647503ec476] functions: remove specialized step function for new particles

Jacques Lucke noreply at git.blender.org
Tue Jun 18 18:25:45 CEST 2019


Commit: 647503ec47626172f3b82ff7aeeb2f975506182c
Author: Jacques Lucke
Date:   Tue Jun 18 15:18:31 2019 +0200
Branches: functions
https://developer.blender.org/rB647503ec47626172f3b82ff7aeeb2f975506182c

remove specialized step function for new particles

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

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

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

diff --git a/source/blender/simulations/bparticles/playground_solver.cpp b/source/blender/simulations/bparticles/playground_solver.cpp
index 974d432591e..a3b5e7e1d8f 100644
--- a/source/blender/simulations/bparticles/playground_solver.cpp
+++ b/source/blender/simulations/bparticles/playground_solver.cpp
@@ -129,20 +129,18 @@ class SimpleSolver : public Solver {
     ParticlesBlock *block = data->blocks[index];
     AttributeArrays attributes = block->slice_active();
 
-    data->solver->step_slice(data->state,
-                             attributes,
-                             Range<uint>(0, attributes.size()).to_small_vector(),
-                             data->elapsed_seconds);
+    SmallVector<float> time_diffs(attributes.size());
+    time_diffs.fill(data->elapsed_seconds);
+
+    data->solver->step_slice(
+        data->state, attributes, Range<uint>(0, attributes.size()).to_small_vector(), time_diffs);
   }
 
   BLI_NOINLINE void step_slice(MyState &state,
                                AttributeArrays attributes,
                                ArrayRef<uint> indices_mask,
-                               float elapsed_seconds)
+                               ArrayRef<float> time_diffs)
   {
-    SmallVector<float> time_diffs(attributes.size());
-    time_diffs.fill(elapsed_seconds);
-
     SmallVector<float3> position_offsets(attributes.size());
     SmallVector<float3> velocity_offsets(attributes.size());
 
@@ -209,23 +207,6 @@ class SimpleSolver : public Solver {
     }
   }
 
-  BLI_NOINLINE void step_new_particles(AttributeArrays attributes, MyState &state)
-  {
-    auto positions = attributes.get_float3("Position");
-    auto velocities = attributes.get_float3("Velocity");
-    auto birth_times = attributes.get_float("Birth Time");
-
-    SmallVector<float3> combined_force(attributes.size());
-    this->compute_combined_force(
-        attributes, Range<uint>(0, attributes.size()).to_small_vector(), combined_force);
-
-    for (uint i = 0; i < attributes.size(); i++) {
-      float seconds_since_birth = state.seconds_since_start - birth_times[i];
-      positions[i] += velocities[i] * seconds_since_birth;
-      velocities[i] += combined_force[i] * seconds_since_birth;
-    }
-  }
-
   BLI_NOINLINE void delete_dead_particles(ArrayRef<ParticlesBlock *> blocks)
   {
     for (auto block : blocks) {
@@ -296,8 +277,15 @@ class SimpleSolver : public Solver {
         float fac = (rand() % 1000) / 1000.0f;
         birth_time = state.seconds_since_start - elapsed_seconds * fac;
       }
+
+      SmallVector<float> time_steps;
+      for (float birth_time : birth_times) {
+        time_steps.append(state.seconds_since_start - birth_time);
+      }
+
       block->active_amount() += target.emitted_amount();
-      this->step_new_particles(emitted_data, state);
+      this->step_slice(
+          state, emitted_data, Range<uint>(0, emitted_data.size()).to_small_vector(), time_steps);
     }
   }



More information about the Bf-blender-cvs mailing list