[Bf-blender-cvs] [a4a69e605c0] functions: improve interface for killing particles
Jacques Lucke
noreply at git.blender.org
Fri Jun 28 16:04:28 CEST 2019
Commit: a4a69e605c082034871fc0bea6586162b7e235b9
Author: Jacques Lucke
Date: Fri Jun 28 14:11:06 2019 +0200
Branches: functions
https://developer.blender.org/rBa4a69e605c082034871fc0bea6586162b7e235b9
improve interface for killing particles
===================================================================
M source/blender/simulations/bparticles/actions.cpp
M source/blender/simulations/bparticles/core.hpp
===================================================================
diff --git a/source/blender/simulations/bparticles/actions.cpp b/source/blender/simulations/bparticles/actions.cpp
index b0531331268..c3dfa28acf6 100644
--- a/source/blender/simulations/bparticles/actions.cpp
+++ b/source/blender/simulations/bparticles/actions.cpp
@@ -5,12 +5,7 @@ namespace BParticles {
class KillAction : public Action {
void execute(ActionInterface &interface) override
{
- ParticleSet &particles = interface.particles();
-
- auto kill_states = particles.attributes().get_byte("Kill State");
- for (uint pindex : particles.indices()) {
- kill_states[pindex] = 1;
- }
+ interface.kill(interface.particles().indices());
}
};
@@ -70,18 +65,15 @@ class ExplodeAction : public Action {
ParticleSet &particles = interface.particles();
auto positions = particles.attributes().get_float3("Position");
- auto kill_states = particles.attributes().get_byte("Kill State");
SmallVector<float3> new_positions;
SmallVector<float3> new_velocities;
SmallVector<uint> original_indices;
uint parts_amount = 100;
-
for (uint i : particles.range()) {
uint pindex = particles.get_particle_index(i);
- kill_states[pindex] = 1;
new_positions.append_n_times(positions[pindex], parts_amount);
original_indices.append_n_times(i, parts_amount);
@@ -93,6 +85,8 @@ class ExplodeAction : public Action {
auto &target = interface.request_emit_target(1, original_indices);
target.set_float3("Position", new_positions);
target.set_float3("Velocity", new_velocities);
+
+ interface.kill(particles.indices());
}
};
diff --git a/source/blender/simulations/bparticles/core.hpp b/source/blender/simulations/bparticles/core.hpp
index 17676fa980a..e739a97827d 100644
--- a/source/blender/simulations/bparticles/core.hpp
+++ b/source/blender/simulations/bparticles/core.hpp
@@ -345,12 +345,16 @@ class ActionInterface {
BlockAllocator &m_block_allocator;
SmallVector<InstantEmitTarget *> m_emit_targets;
ArrayRef<float> m_current_times;
+ ArrayRef<uint8_t> m_kill_states;
public:
ActionInterface(ParticleSet particles,
BlockAllocator &block_allocator,
ArrayRef<float> current_times)
- : m_particles(particles), m_block_allocator(block_allocator), m_current_times(current_times)
+ : m_particles(particles),
+ m_block_allocator(block_allocator),
+ m_current_times(current_times),
+ m_kill_states(m_particles.attributes().get_byte("Kill State"))
{
}
@@ -368,6 +372,13 @@ class ActionInterface {
InstantEmitTarget &request_emit_target(uint particle_type_id, ArrayRef<uint> original_indices);
+ void kill(ArrayRef<uint> particle_indices)
+ {
+ for (uint pindex : particle_indices) {
+ m_kill_states[pindex] = 1;
+ }
+ }
+
ArrayRef<InstantEmitTarget *> emit_targets()
{
return m_emit_targets;
More information about the Bf-blender-cvs
mailing list