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:
-rw-r--r--source/blender/simulations/bparticles/action_interface.hpp8
-rw-r--r--source/blender/simulations/bparticles/force_interface.hpp12
-rw-r--r--source/blender/simulations/bparticles/forces.cpp10
-rw-r--r--source/blender/simulations/bparticles/integrator.cpp10
-rw-r--r--source/blender/simulations/bparticles/particle_allocator.cpp2
-rw-r--r--source/blender/simulations/bparticles/particle_function.cpp3
-rw-r--r--source/blender/simulations/bparticles/particle_set.hpp20
-rw-r--r--source/blender/simulations/bparticles/simulate.cpp12
-rw-r--r--source/blender/simulations/bparticles/step_description_interfaces.cpp3
-rw-r--r--source/blender/simulations/bparticles/step_description_interfaces.hpp31
10 files changed, 61 insertions, 50 deletions
diff --git a/source/blender/simulations/bparticles/action_interface.hpp b/source/blender/simulations/bparticles/action_interface.hpp
index bd6122b43ff..ae27995f628 100644
--- a/source/blender/simulations/bparticles/action_interface.hpp
+++ b/source/blender/simulations/bparticles/action_interface.hpp
@@ -97,7 +97,7 @@ inline void Action::execute_from_emitter(ParticleSets &particle_sets,
*action_context;
for (ParticleSet particles : particle_sets.sets()) {
- uint min_array_size = particles.block().capacity();
+ uint min_array_size = particles.attributes().size();
AttributeArrays offsets(info, buffers, 0, min_array_size);
TemporaryArray<float> durations(min_array_size);
durations.fill_indices(particles.pindices(), 0);
@@ -130,7 +130,7 @@ inline void Action::execute_from_event(EventExecuteInterface &event_interface,
inline void Action::execute_for_subset(ArrayRef<uint> pindices, ActionInterface &action_interface)
{
ActionInterface sub_interface(action_interface.particle_allocator(),
- ParticleSet(action_interface.particles().block(), pindices),
+ ParticleSet(action_interface.particles().attributes(), pindices),
action_interface.attribute_offsets(),
action_interface.current_times(),
action_interface.remaining_durations(),
@@ -148,7 +148,7 @@ inline void Action::execute_for_new_particles(ParticleSets &particle_sets,
EmptyEventInfo empty_context;
for (ParticleSet particles : particle_sets.sets()) {
- uint min_array_size = particles.block().capacity();
+ uint min_array_size = particles.attributes().size();
AttributeArrays offsets(info, buffers, 0, min_array_size);
TemporaryArray<float> durations(min_array_size);
durations.fill_indices(particles.pindices(), 0);
@@ -171,7 +171,7 @@ inline void Action::execute_for_new_particles(ParticleSets &particle_sets,
EmptyEventInfo empty_context;
for (ParticleSet particles : particle_sets.sets()) {
- uint min_array_size = particles.block().capacity();
+ uint min_array_size = particles.attributes().size();
AttributeArrays offsets(info, buffers, 0, min_array_size);
TemporaryArray<float> durations(min_array_size);
durations.fill_indices(particles.pindices(), 0);
diff --git a/source/blender/simulations/bparticles/force_interface.hpp b/source/blender/simulations/bparticles/force_interface.hpp
index 26d863a7cb6..5ce7e37b22a 100644
--- a/source/blender/simulations/bparticles/force_interface.hpp
+++ b/source/blender/simulations/bparticles/force_interface.hpp
@@ -6,14 +6,22 @@ namespace BParticles {
class ForceInterface : public BlockStepDataAccess {
private:
+ ArrayRef<uint> m_pindices;
MutableArrayRef<float3> m_destination;
public:
- ForceInterface(BlockStepData &step_data, MutableArrayRef<float3> destination)
- : BlockStepDataAccess(step_data), m_destination(destination)
+ ForceInterface(BlockStepData &step_data,
+ ArrayRef<uint> pindices,
+ MutableArrayRef<float3> destination)
+ : BlockStepDataAccess(step_data), m_pindices(pindices), m_destination(destination)
{
}
+ ParticleSet particles()
+ {
+ return ParticleSet(this->attributes(), m_pindices);
+ }
+
MutableArrayRef<float3> combined_destination()
{
return m_destination;
diff --git a/source/blender/simulations/bparticles/forces.cpp b/source/blender/simulations/bparticles/forces.cpp
index 51b88d2efdf..c7efe2395be 100644
--- a/source/blender/simulations/bparticles/forces.cpp
+++ b/source/blender/simulations/bparticles/forces.cpp
@@ -10,12 +10,12 @@ Force::~Force()
void GravityForce::add_force(ForceInterface &interface)
{
- ParticlesBlock &block = interface.block();
+ ParticleSet particles = interface.particles();
MutableArrayRef<float3> destination = interface.combined_destination();
auto inputs = m_compute_inputs->compute(interface);
- for (uint pindex = 0; pindex < block.active_amount(); pindex++) {
+ for (uint pindex : particles.pindices()) {
float3 acceleration = inputs->get<float3>("Direction", 0, pindex);
destination[pindex] += acceleration;
}
@@ -23,14 +23,14 @@ void GravityForce::add_force(ForceInterface &interface)
void TurbulenceForce::add_force(ForceInterface &interface)
{
- ParticlesBlock &block = interface.block();
+ ParticleSet particles = interface.particles();
MutableArrayRef<float3> destination = interface.combined_destination();
- auto positions = block.attributes().get<float3>("Position");
+ auto positions = particles.attributes().get<float3>("Position");
auto inputs = m_compute_inputs->compute(interface);
- for (uint pindex = 0; pindex < block.active_amount(); pindex++) {
+ for (uint pindex : particles.pindices()) {
float3 pos = positions[pindex];
float3 strength = inputs->get<float3>("Strength", 0, pindex);
float x = (BLI_gNoise(0.5f, pos.x, pos.y, pos.z + 1000.0f, false, 1) - 0.5f) * strength.x;
diff --git a/source/blender/simulations/bparticles/integrator.cpp b/source/blender/simulations/bparticles/integrator.cpp
index c715dc2449e..8a5de745657 100644
--- a/source/blender/simulations/bparticles/integrator.cpp
+++ b/source/blender/simulations/bparticles/integrator.cpp
@@ -16,12 +16,12 @@ AttributesInfo &ConstantVelocityIntegrator::offset_attributes_info()
void ConstantVelocityIntegrator::integrate(IntegratorInterface &interface)
{
- ParticlesBlock &block = interface.block();
- auto velocities = block.attributes().get<float3>("Velocity");
+ ParticleSet particles = interface.particles();
+ auto velocities = particles.attributes().get<float3>("Velocity");
auto position_offsets = interface.attribute_offsets().get<float3>("Position");
auto durations = interface.remaining_durations();
- for (uint pindex = 0; pindex < block.active_amount(); pindex++) {
+ for (uint pindex : particles.pindices()) {
position_offsets[pindex] = velocities[pindex] * durations[pindex];
}
}
@@ -54,7 +54,7 @@ void EulerIntegrator::integrate(IntegratorInterface &interface)
TemporaryArray<float3> combined_force(interface.array_size());
this->compute_combined_force(interface, combined_force);
- auto last_velocities = interface.block().attributes().get<float3>("Velocity");
+ auto last_velocities = interface.attributes().get<float3>("Velocity");
auto position_offsets = r_offsets.get<float3>("Position");
auto velocity_offsets = r_offsets.get<float3>("Velocity");
@@ -67,7 +67,7 @@ BLI_NOINLINE void EulerIntegrator::compute_combined_force(IntegratorInterface &i
{
r_force.fill({0, 0, 0});
- ForceInterface force_interface(interface.step_data(), r_force);
+ ForceInterface force_interface(interface.step_data(), interface.particles().pindices(), r_force);
for (Force *force : m_forces) {
force->add_force(force_interface);
diff --git a/source/blender/simulations/bparticles/particle_allocator.cpp b/source/blender/simulations/bparticles/particle_allocator.cpp
index 46d01622d81..2f03933477f 100644
--- a/source/blender/simulations/bparticles/particle_allocator.cpp
+++ b/source/blender/simulations/bparticles/particle_allocator.cpp
@@ -81,7 +81,7 @@ ParticleSets ParticleAllocator::request(StringRef particle_type_name, uint size)
Vector<ParticleSet> sets;
for (uint i = 0; i < blocks.size(); i++) {
- sets.append(ParticleSet(*blocks[i], ranges[i].as_array_ref()));
+ sets.append(ParticleSet(blocks[i]->attributes(), ranges[i].as_array_ref()));
}
return ParticleSets(particle_type_name, attributes_info, sets);
diff --git a/source/blender/simulations/bparticles/particle_function.cpp b/source/blender/simulations/bparticles/particle_function.cpp
index 3e3af1ac1cf..9e13c42cfc9 100644
--- a/source/blender/simulations/bparticles/particle_function.cpp
+++ b/source/blender/simulations/bparticles/particle_function.cpp
@@ -65,8 +65,7 @@ std::unique_ptr<ParticleFunctionResult> ParticleFunction::compute(
std::unique_ptr<ParticleFunctionResult> ParticleFunction::compute(ForceInterface &interface)
{
- ParticlesBlock &block = interface.block();
- return this->compute(ParticleSet(block, block.active_range().as_array_ref()),
+ return this->compute(interface.particles(),
ParticleTimes::FromDurationsAndEnd(interface.remaining_durations(),
interface.step_end_time()),
nullptr);
diff --git a/source/blender/simulations/bparticles/particle_set.hpp b/source/blender/simulations/bparticles/particle_set.hpp
index f4c84f93b0f..4ca996a7ab0 100644
--- a/source/blender/simulations/bparticles/particle_set.hpp
+++ b/source/blender/simulations/bparticles/particle_set.hpp
@@ -9,7 +9,7 @@ namespace BParticles {
*/
struct ParticleSet {
private:
- ParticlesBlock *m_block;
+ AttributeArrays m_attributes;
/* Indices into the attribute arrays.
* Invariants:
@@ -18,12 +18,7 @@ struct ParticleSet {
ArrayRef<uint> m_pindices;
public:
- ParticleSet(ParticlesBlock &block, ArrayRef<uint> pindices);
-
- /**
- * Return the block that contains the particles of this set.
- */
- ParticlesBlock &block();
+ ParticleSet(AttributeArrays attributes, ArrayRef<uint> pindices);
/**
* Access the attributes of particles in the block on this set.
@@ -117,19 +112,14 @@ class ParticleSets {
/* ParticleSet inline functions
*******************************************/
-inline ParticleSet::ParticleSet(ParticlesBlock &block, ArrayRef<uint> pindices)
- : m_block(&block), m_pindices(pindices)
-{
-}
-
-inline ParticlesBlock &ParticleSet::block()
+inline ParticleSet::ParticleSet(AttributeArrays attributes, ArrayRef<uint> pindices)
+ : m_attributes(attributes), m_pindices(pindices)
{
- return *m_block;
}
inline AttributeArrays ParticleSet::attributes()
{
- return m_block->attributes();
+ return m_attributes;
}
inline ArrayRef<uint> ParticleSet::pindices()
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index 018eec5e3ba..87007439a08 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -79,7 +79,7 @@ BLI_NOINLINE static void forward_particles_to_next_event_or_end(
handler->execute(interface);
}
- ParticleSet particles(step_data.block, pindices);
+ ParticleSet particles(step_data.attributes, pindices);
auto attribute_offsets = step_data.attribute_offsets;
for (uint attribute_index : attribute_offsets.info().attribute_indices()) {
@@ -230,7 +230,7 @@ BLI_NOINLINE static void simulate_to_next_event(BlockStepData &step_data,
find_unfinished_particles(pindices_with_event,
time_factors_to_next_event,
- step_data.block.attributes().get<uint8_t>("Kill State"),
+ step_data.attributes.get<uint8_t>("Kill State"),
r_unfinished_pindices);
}
@@ -242,7 +242,7 @@ BLI_NOINLINE static void simulate_with_max_n_events(BlockStepData &step_data,
TemporaryArray<uint> pindices_A(step_data.array_size());
TemporaryArray<uint> pindices_B(step_data.array_size());
- uint amount_left = step_data.block.active_amount();
+ uint amount_left = step_data.attributes.size();
{
/* Handle first event separately to be able to use the static number range. */
@@ -309,7 +309,7 @@ BLI_NOINLINE static void apply_remaining_offsets(BlockStepData &step_data,
}
auto attribute_offsets = step_data.attribute_offsets;
- ParticleSet particles(step_data.block, pindices);
+ ParticleSet particles(step_data.attributes, pindices);
for (uint attribute_index : attribute_offsets.info().attribute_indices()) {
StringRef name = attribute_offsets.info().name_of(attribute_index);
@@ -348,9 +348,9 @@ BLI_NOINLINE static void simulate_block(ParticleAllocator &particle_allocator,
AttributeArrays attribute_offsets(offsets_info, offset_buffers, 0, amount);
BlockStepData step_data = {
- particle_allocator, block, attribute_offsets, remaining_durations, end_time};
+ particle_allocator, block.attributes(), attribute_offsets, remaining_durations, end_time};
- IntegratorInterface interface(step_data);
+ IntegratorInterface interface(step_data, block.active_range().as_array_ref());
integrator.integrate(interface);
if (type_info.events.size() == 0) {
diff --git a/source/blender/simulations/bparticles/step_description_interfaces.cpp b/source/blender/simulations/bparticles/step_description_interfaces.cpp
index 6c74ab7fd7d..cc63fe0152e 100644
--- a/source/blender/simulations/bparticles/step_description_interfaces.cpp
+++ b/source/blender/simulations/bparticles/step_description_interfaces.cpp
@@ -33,7 +33,8 @@ EventExecuteInterface::EventExecuteInterface(BlockStepData &step_data,
{
}
-IntegratorInterface::IntegratorInterface(BlockStepData &step_data) : BlockStepDataAccess(step_data)
+IntegratorInterface::IntegratorInterface(BlockStepData &step_data, ArrayRef<uint> pindices)
+ : BlockStepDataAccess(step_data), m_pindices(pindices)
{
}
diff --git a/source/blender/simulations/bparticles/step_description_interfaces.hpp b/source/blender/simulations/bparticles/step_description_interfaces.hpp
index c2747d9a2bc..03510608c1f 100644
--- a/source/blender/simulations/bparticles/step_description_interfaces.hpp
+++ b/source/blender/simulations/bparticles/step_description_interfaces.hpp
@@ -7,14 +7,14 @@ namespace BParticles {
struct BlockStepData {
ParticleAllocator &particle_allocator;
- ParticlesBlock &block;
+ AttributeArrays attributes;
AttributeArrays attribute_offsets;
MutableArrayRef<float> remaining_durations;
float step_end_time;
uint array_size()
{
- return this->block.capacity();
+ return this->remaining_durations.size();
}
};
@@ -29,7 +29,7 @@ class BlockStepDataAccess {
uint array_size() const
{
- return m_step_data.block.capacity();
+ return m_step_data.array_size();
}
BlockStepData &step_data()
@@ -42,9 +42,9 @@ class BlockStepDataAccess {
return m_step_data.particle_allocator;
}
- ParticlesBlock &block()
+ AttributeArrays attributes()
{
- return m_step_data.block;
+ return m_step_data.attributes;
}
AttributeArrays attribute_offsets()
@@ -196,8 +196,13 @@ class EventExecuteInterface : public BlockStepDataAccess {
* Interface between the Integrator->integrate() function and the core simulation code.
*/
class IntegratorInterface : public BlockStepDataAccess {
+ private:
+ ArrayRef<uint> m_pindices;
+
public:
- IntegratorInterface(BlockStepData &step_data);
+ IntegratorInterface(BlockStepData &step_data, ArrayRef<uint> pindices);
+
+ ParticleSet particles();
};
class OffsetHandlerInterface : public BlockStepDataAccess {
@@ -259,7 +264,7 @@ inline uint EventStorage::max_element_size() const
inline ParticleSet EventFilterInterface::particles()
{
- return ParticleSet(m_step_data.block, m_pindices);
+ return ParticleSet(m_step_data.attributes, m_pindices);
}
inline void EventFilterInterface::trigger_particle(uint pindex, float time_factor)
@@ -298,7 +303,7 @@ inline EventStorage &EventExecuteInterface::event_storage()
inline ParticleSet EventExecuteInterface::particles()
{
- return ParticleSet(m_step_data.block, m_pindices);
+ return ParticleSet(m_step_data.attributes, m_pindices);
}
inline ArrayRef<float> EventExecuteInterface::current_times()
@@ -318,7 +323,7 @@ template<typename T> inline T &EventExecuteInterface::get_storage(uint pindex)
inline ParticleSet OffsetHandlerInterface::particles()
{
- return ParticleSet(m_step_data.block, m_pindices);
+ return ParticleSet(m_step_data.attributes, m_pindices);
}
inline ArrayRef<float> OffsetHandlerInterface::time_factors()
@@ -326,4 +331,12 @@ inline ArrayRef<float> OffsetHandlerInterface::time_factors()
return m_time_factors;
}
+/* IntegratorInterface inline functions
+ **********************************************/
+
+inline ParticleSet IntegratorInterface::particles()
+{
+ return ParticleSet(m_step_data.attributes, m_pindices);
+}
+
}; // namespace BParticles