[Bf-blender-cvs] [2ec577c75e1] functions: separate methods of integrator
Jacques Lucke
noreply at git.blender.org
Sun Jun 30 16:00:44 CEST 2019
Commit: 2ec577c75e141d4f609e59de6d91207e1cf448b0
Author: Jacques Lucke
Date: Sun Jun 30 10:40:08 2019 +0200
Branches: functions
https://developer.blender.org/rB2ec577c75e141d4f609e59de6d91207e1cf448b0
separate methods of integrator
===================================================================
M source/blender/simulations/bparticles/c_wrapper.cpp
===================================================================
diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index a333cec3b4a..3ee19466cf8 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -85,24 +85,43 @@ class EulerIntegrator : public Integrator {
BLI_assert(amount == r_offsets.size());
SmallVector<float3> combined_force(amount);
- combined_force.fill({0, 0, 0});
-
- for (Force *force : m_forces) {
- force->add_force(block, combined_force);
- }
+ this->compute_combined_force(block, combined_force);
auto last_velocities = block.slice_active().get_float3("Velocity");
auto position_offsets = r_offsets.get_float3("Position");
auto velocity_offsets = r_offsets.get_float3("Velocity");
+ this->compute_offsets(
+ durations, last_velocities, combined_force, position_offsets, velocity_offsets);
+ }
+
+ BLI_NOINLINE void compute_combined_force(ParticlesBlock &block, ArrayRef<float3> r_force)
+ {
+ SCOPED_TIMER_STATS(__func__);
+
+ r_force.fill({0, 0, 0});
+
+ for (Force *force : m_forces) {
+ force->add_force(block, r_force);
+ }
+ }
+
+ BLI_NOINLINE void compute_offsets(ArrayRef<float> durations,
+ ArrayRef<float3> last_velocities,
+ ArrayRef<float3> combined_force,
+ ArrayRef<float3> r_position_offsets,
+ ArrayRef<float3> r_velocity_offsets)
+ {
+ SCOPED_TIMER_STATS(__func__);
+ uint amount = durations.size();
for (uint pindex = 0; pindex < amount; pindex++) {
float mass = 1.0f;
float duration = durations[pindex];
- velocity_offsets[pindex] = duration * combined_force[pindex] / mass;
- position_offsets[pindex] = duration *
- (last_velocities[pindex] + velocity_offsets[pindex] * 0.5f);
+ r_velocity_offsets[pindex] = duration * combined_force[pindex] / mass;
+ r_position_offsets[pindex] = duration *
+ (last_velocities[pindex] + r_velocity_offsets[pindex] * 0.5f);
}
}
};
More information about the Bf-blender-cvs
mailing list