[Bf-blender-cvs] [866894454f7] functions: use IndexMask in more places
Jacques Lucke
noreply at git.blender.org
Sun Dec 22 14:25:50 CET 2019
Commit: 866894454f7171476f18532ea55ac62218476579
Author: Jacques Lucke
Date: Sun Dec 22 12:32:43 2019 +0100
Branches: functions
https://developer.blender.org/rB866894454f7171476f18532ea55ac62218476579
use IndexMask in more places
===================================================================
M source/blender/simulations/bparticles/force_interface.hpp
M source/blender/simulations/bparticles/forces.cpp
M source/blender/simulations/bparticles/integrator.cpp
M source/blender/simulations/bparticles/integrator.hpp
M source/blender/simulations/bparticles/integrator_interface.hpp
===================================================================
diff --git a/source/blender/simulations/bparticles/force_interface.hpp b/source/blender/simulations/bparticles/force_interface.hpp
index 595ac0534f0..e5c0ec91a35 100644
--- a/source/blender/simulations/bparticles/force_interface.hpp
+++ b/source/blender/simulations/bparticles/force_interface.hpp
@@ -1,27 +1,28 @@
#pragma once
+#include "BLI_index_mask.h"
+
#include "block_step_data.hpp"
namespace BParticles {
using BLI::float3;
+using BLI::IndexMask;
class ForceInterface : public BlockStepDataAccess {
private:
- ArrayRef<uint> m_pindices;
+ IndexMask m_mask;
MutableArrayRef<float3> m_destination;
public:
- ForceInterface(BlockStepData &step_data,
- ArrayRef<uint> pindices,
- MutableArrayRef<float3> destination)
- : BlockStepDataAccess(step_data), m_pindices(pindices), m_destination(destination)
+ ForceInterface(BlockStepData &step_data, IndexMask mask, MutableArrayRef<float3> destination)
+ : BlockStepDataAccess(step_data), m_mask(mask), m_destination(destination)
{
}
- ArrayRef<uint> pindices()
+ IndexMask mask()
{
- return m_pindices;
+ return m_mask;
}
MutableArrayRef<float3> combined_destination()
diff --git a/source/blender/simulations/bparticles/forces.cpp b/source/blender/simulations/bparticles/forces.cpp
index 0bc6e0f59ca..f7544171b3a 100644
--- a/source/blender/simulations/bparticles/forces.cpp
+++ b/source/blender/simulations/bparticles/forces.cpp
@@ -12,10 +12,10 @@ void CustomForce::add_force(ForceInterface &interface)
{
MutableArrayRef<float3> dst = interface.combined_destination();
- ParticleFunctionEvaluator inputs{m_inputs_fn, interface.pindices(), interface.attributes()};
+ ParticleFunctionEvaluator inputs{m_inputs_fn, interface.mask(), interface.attributes()};
inputs.compute();
- for (uint pindex : interface.pindices()) {
+ for (uint pindex : interface.mask()) {
dst[pindex] += inputs.get_single<float3>("Force", 0, pindex);
}
}
diff --git a/source/blender/simulations/bparticles/integrator.cpp b/source/blender/simulations/bparticles/integrator.cpp
index 8ae8279d4bd..dda578f87c9 100644
--- a/source/blender/simulations/bparticles/integrator.cpp
+++ b/source/blender/simulations/bparticles/integrator.cpp
@@ -22,7 +22,7 @@ void ConstantVelocityIntegrator::integrate(IntegratorInterface &interface)
auto position_offsets = interface.attribute_offsets().get<float3>("Position");
auto durations = interface.remaining_durations();
- for (uint pindex : interface.pindices()) {
+ for (uint pindex : interface.mask()) {
position_offsets[pindex] = velocities[pindex] * durations[pindex];
}
}
@@ -56,8 +56,12 @@ void EulerIntegrator::integrate(IntegratorInterface &interface)
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);
+ this->compute_offsets(interface.mask(),
+ durations,
+ last_velocities,
+ combined_force,
+ position_offsets,
+ velocity_offsets);
}
BLI_NOINLINE void EulerIntegrator::compute_combined_force(IntegratorInterface &interface,
@@ -65,21 +69,21 @@ BLI_NOINLINE void EulerIntegrator::compute_combined_force(IntegratorInterface &i
{
r_force.fill({0, 0, 0});
- ForceInterface force_interface(interface.step_data(), interface.pindices(), r_force);
+ ForceInterface force_interface(interface.step_data(), interface.mask(), r_force);
for (Force *force : m_forces) {
force->add_force(force_interface);
}
}
-BLI_NOINLINE void EulerIntegrator::compute_offsets(ArrayRef<float> durations,
+BLI_NOINLINE void EulerIntegrator::compute_offsets(IndexMask mask,
+ ArrayRef<float> durations,
ArrayRef<float3> last_velocities,
ArrayRef<float3> combined_force,
MutableArrayRef<float3> r_position_offsets,
MutableArrayRef<float3> r_velocity_offsets)
{
- uint amount = durations.size();
- for (uint pindex = 0; pindex < amount; pindex++) {
+ for (uint pindex : mask) {
float mass = 1.0f;
float duration = durations[pindex];
diff --git a/source/blender/simulations/bparticles/integrator.hpp b/source/blender/simulations/bparticles/integrator.hpp
index 2b297c8589c..3a2f1cb6041 100644
--- a/source/blender/simulations/bparticles/integrator.hpp
+++ b/source/blender/simulations/bparticles/integrator.hpp
@@ -30,7 +30,8 @@ class EulerIntegrator : public Integrator {
private:
void compute_combined_force(IntegratorInterface &interface, MutableArrayRef<float3> r_force);
- void compute_offsets(ArrayRef<float> durations,
+ void compute_offsets(IndexMask mask,
+ ArrayRef<float> durations,
ArrayRef<float3> last_velocities,
ArrayRef<float3> combined_force,
MutableArrayRef<float3> r_position_offsets,
diff --git a/source/blender/simulations/bparticles/integrator_interface.hpp b/source/blender/simulations/bparticles/integrator_interface.hpp
index bd5cb635924..95caf5cdb88 100644
--- a/source/blender/simulations/bparticles/integrator_interface.hpp
+++ b/source/blender/simulations/bparticles/integrator_interface.hpp
@@ -1,25 +1,29 @@
#pragma once
+#include "BLI_index_mask.h"
+
#include "block_step_data.hpp"
namespace BParticles {
+using BLI::IndexMask;
+
/**
* Interface between the Integrator->integrate() function and the core simulation code.
*/
class IntegratorInterface : public BlockStepDataAccess {
private:
- ArrayRef<uint> m_pindices;
+ IndexMask m_mask;
public:
- IntegratorInterface(BlockStepData &step_data, ArrayRef<uint> pindices)
- : BlockStepDataAccess(step_data), m_pindices(pindices)
+ IntegratorInterface(BlockStepData &step_data, IndexMask mask)
+ : BlockStepDataAccess(step_data), m_mask(mask)
{
}
- ArrayRef<uint> pindices()
+ IndexMask mask()
{
- return m_pindices;
+ return m_mask;
}
};
More information about the Bf-blender-cvs
mailing list