[Bf-blender-cvs] [93e38f5f6bc] functions: cleanup stepping a slice of particles
Jacques Lucke
noreply at git.blender.org
Sun Jun 9 13:52:40 CEST 2019
Commit: 93e38f5f6bc260ead81ba2c4c6381f90587e38e8
Author: Jacques Lucke
Date: Sun Jun 9 12:45:24 2019 +0200
Branches: functions
https://developer.blender.org/rB93e38f5f6bc260ead81ba2c4c6381f90587e38e8
cleanup stepping a slice of 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 fa95cb05c50..e189cdfd16e 100644
--- a/source/blender/simulations/bparticles/playground_solver.cpp
+++ b/source/blender/simulations/bparticles/playground_solver.cpp
@@ -62,26 +62,25 @@ class SimpleSolver : public Solver {
}
}
- BLI_NOINLINE void step_block(ParticlesBlock *block, float elapsed_seconds)
+ BLI_NOINLINE void step_slice(ParticlesBlockSlice slice, float elapsed_seconds)
{
- uint active_amount = block->active_amount();
-
- Vec3 *positions = block->vec3_buffer("Position");
- Vec3 *velocities = block->vec3_buffer("Velocity");
-
- for (uint i = 0; i < active_amount; i++) {
- positions[i] += velocities[i] * elapsed_seconds;
- }
+ auto positions = slice.vec3_buffer("Position");
+ auto velocities = slice.vec3_buffer("Velocity");
- ParticlesBlockSlice slice = block->slice_active();
- SmallVector<Vec3> combined_force(active_amount);
+ SmallVector<Vec3> combined_force(slice.size());
this->compute_combined_force(slice, combined_force);
- for (uint i = 0; i < active_amount; i++) {
+ for (uint i = 0; i < slice.size(); i++) {
+ positions[i] += velocities[i] * elapsed_seconds;
velocities[i] += combined_force[i] * elapsed_seconds;
}
}
+ BLI_NOINLINE void step_block(ParticlesBlock *block, float elapsed_seconds)
+ {
+ this->step_slice(block->slice_active(), elapsed_seconds);
+ }
+
BLI_NOINLINE void compute_combined_force(ParticlesBlockSlice &slice, ArrayRef<Vec3> dst)
{
BLI_assert(slice.size() == dst.size());
More information about the Bf-blender-cvs
mailing list