Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2019-07-24 16:46:30 +0300
committerJacques Lucke <mail@jlucke.com>2019-07-24 16:46:30 +0300
commit1cc5f8344261a237d1eb63268c5aec6b9fc51851 (patch)
tree5dd86a24665a971b213bf5205647ba7bcb38a79b /source/blender/simulations/bparticles/forces.cpp
parente468ca977e683aac8c30ed774029ced58c60a36d (diff)
introduce force interface
Diffstat (limited to 'source/blender/simulations/bparticles/forces.cpp')
-rw-r--r--source/blender/simulations/bparticles/forces.cpp14
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};
}
}