diff options
author | Jacques Lucke <mail@jlucke.com> | 2019-07-24 16:46:30 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2019-07-24 16:46:30 +0300 |
commit | 1cc5f8344261a237d1eb63268c5aec6b9fc51851 (patch) | |
tree | 5dd86a24665a971b213bf5205647ba7bcb38a79b /source/blender/simulations/bparticles/forces.cpp | |
parent | e468ca977e683aac8c30ed774029ced58c60a36d (diff) |
introduce force interface
Diffstat (limited to 'source/blender/simulations/bparticles/forces.cpp')
-rw-r--r-- | source/blender/simulations/bparticles/forces.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/simulations/bparticles/forces.cpp b/source/blender/simulations/bparticles/forces.cpp index 28d00e9355d..1f9081dbe23 100644 --- a/source/blender/simulations/bparticles/forces.cpp +++ b/source/blender/simulations/bparticles/forces.cpp @@ -8,8 +8,11 @@ Force::~Force() { } -void GravityForce::add_force(ParticlesBlock &block, ArrayRef<float3> r_force) +void GravityForce::add_force(ForceInterface &interface) { + ParticlesBlock &block = interface.block(); + ArrayRef<float3> destination = interface.combined_destination(); + FN_TUPLE_CALL_ALLOC_TUPLES(m_compute_acceleration_body, fn_in, fn_out); FN::ExecutionStack stack; @@ -20,12 +23,15 @@ void GravityForce::add_force(ParticlesBlock &block, ArrayRef<float3> r_force) float3 acceleration = fn_out.get<float3>(0); for (uint i = 0; i < block.active_amount(); i++) { - r_force[i] += acceleration; + destination[i] += acceleration; } }; -void TurbulenceForce::add_force(ParticlesBlock &block, ArrayRef<float3> r_force) +void TurbulenceForce::add_force(ForceInterface &interface) { + ParticlesBlock &block = interface.block(); + ArrayRef<float3> destination = interface.combined_destination(); + auto positions = block.attributes().get_float3("Position"); FN_TUPLE_CALL_ALLOC_TUPLES(m_compute_strength_body, fn_in, fn_out); @@ -40,7 +46,7 @@ void TurbulenceForce::add_force(ParticlesBlock &block, ArrayRef<float3> r_force) float x = (BLI_gNoise(0.5f, pos.x, pos.y, pos.z + 1000.0f, false, 1) - 0.5f) * strength.x; float y = (BLI_gNoise(0.5f, pos.x, pos.y + 1000.0f, pos.z, false, 1) - 0.5f) * strength.y; float z = (BLI_gNoise(0.5f, pos.x + 1000.0f, pos.y, pos.z, false, 1) - 0.5f) * strength.z; - r_force[pindex] += {x, y, z}; + destination[pindex] += {x, y, z}; } } |