[Bf-blender-cvs] [85b8376829a] functions: pass array allocator to emitter and execute event interface
Jacques Lucke
noreply at git.blender.org
Wed Jul 10 17:17:57 CEST 2019
Commit: 85b8376829a8f65b3588fe846b7081cc6279f39b
Author: Jacques Lucke
Date: Wed Jul 10 14:56:44 2019 +0200
Branches: functions
https://developer.blender.org/rB85b8376829a8f65b3588fe846b7081cc6279f39b
pass array allocator to emitter and execute event interface
===================================================================
M source/blender/simulations/bparticles/action_interface.cpp
M source/blender/simulations/bparticles/action_interface.hpp
M source/blender/simulations/bparticles/core.cpp
M source/blender/simulations/bparticles/core.hpp
M source/blender/simulations/bparticles/events.cpp
M source/blender/simulations/bparticles/simulate.cpp
===================================================================
diff --git a/source/blender/simulations/bparticles/action_interface.cpp b/source/blender/simulations/bparticles/action_interface.cpp
index 2c19e91cb74..7fd077cc262 100644
--- a/source/blender/simulations/bparticles/action_interface.cpp
+++ b/source/blender/simulations/bparticles/action_interface.cpp
@@ -18,6 +18,7 @@ void ActionInterface::execute_action_for_subset(ArrayRef<uint> indices,
ParticleSet sub_particles(m_particles.block(), particle_indices);
ActionInterface sub_interface(m_particle_allocator,
+ m_array_allocator,
sub_particles,
m_attribute_offsets,
sub_current_times,
diff --git a/source/blender/simulations/bparticles/action_interface.hpp b/source/blender/simulations/bparticles/action_interface.hpp
index b65fe4b2f6b..8b106abeaf8 100644
--- a/source/blender/simulations/bparticles/action_interface.hpp
+++ b/source/blender/simulations/bparticles/action_interface.hpp
@@ -64,6 +64,7 @@ class ParticleFunction {
class ActionInterface {
private:
ParticleAllocator &m_particle_allocator;
+ ArrayAllocator &m_array_allocator;
ParticleSet m_particles;
AttributeArrays m_attribute_offsets;
EventInfo &m_event_info;
@@ -72,6 +73,7 @@ class ActionInterface {
public:
ActionInterface(ParticleAllocator &particle_allocator,
+ ArrayAllocator &array_allocator,
ParticleSet particles,
AttributeArrays attribute_offsets,
ArrayRef<float> current_times,
@@ -87,6 +89,7 @@ class ActionInterface {
void kill(ArrayRef<uint> particle_indices);
void execute_action_for_subset(ArrayRef<uint> indices, std::unique_ptr<Action> &action);
ParticleAllocator &particle_allocator();
+ ArrayAllocator &array_allocator();
};
class Action {
@@ -100,12 +103,14 @@ class Action {
*******************************************/
inline ActionInterface::ActionInterface(ParticleAllocator &particle_allocator,
+ ArrayAllocator &array_allocator,
ParticleSet particles,
AttributeArrays attribute_offsets,
ArrayRef<float> current_times,
float step_end_time,
EventInfo &event_info)
: m_particle_allocator(particle_allocator),
+ m_array_allocator(array_allocator),
m_particles(particles),
m_attribute_offsets(attribute_offsets),
m_current_times(current_times),
@@ -152,4 +157,9 @@ inline ParticleAllocator &ActionInterface::particle_allocator()
return m_particle_allocator;
}
+inline ArrayAllocator &ActionInterface::array_allocator()
+{
+ return m_array_allocator;
+}
+
} // namespace BParticles
diff --git a/source/blender/simulations/bparticles/core.cpp b/source/blender/simulations/bparticles/core.cpp
index 19044811a2c..a230f54904e 100644
--- a/source/blender/simulations/bparticles/core.cpp
+++ b/source/blender/simulations/bparticles/core.cpp
@@ -108,8 +108,12 @@ ParticleSets ParticleAllocator::request(StringRef particle_type_name, uint size)
/* Emitter Interface
******************************************/
-EmitterInterface::EmitterInterface(ParticleAllocator &particle_allocator, TimeSpan time_span)
- : m_particle_allocator(particle_allocator), m_time_span(time_span)
+EmitterInterface::EmitterInterface(ParticleAllocator &particle_allocator,
+ ArrayAllocator &array_allocator,
+ TimeSpan time_span)
+ : m_particle_allocator(particle_allocator),
+ m_array_allocator(array_allocator),
+ m_time_span(time_span)
{
}
@@ -261,12 +265,14 @@ EventFilterInterface::EventFilterInterface(ParticleSet particles,
EventExecuteInterface::EventExecuteInterface(ParticleSet particles,
ParticleAllocator &particle_allocator,
+ ArrayAllocator &array_allocator,
ArrayRef<float> current_times,
EventStorage &event_storage,
AttributeArrays attribute_offsets,
float step_end_time)
: m_particles(particles),
m_particle_allocator(particle_allocator),
+ m_array_allocator(array_allocator),
m_current_times(current_times),
m_event_storage(event_storage),
m_attribute_offsets(attribute_offsets),
diff --git a/source/blender/simulations/bparticles/core.hpp b/source/blender/simulations/bparticles/core.hpp
index 41612317284..60c3707bc17 100644
--- a/source/blender/simulations/bparticles/core.hpp
+++ b/source/blender/simulations/bparticles/core.hpp
@@ -349,13 +349,17 @@ class ParticleAllocator {
class EmitterInterface {
private:
ParticleAllocator &m_particle_allocator;
+ ArrayAllocator &m_array_allocator;
TimeSpan m_time_span;
public:
- EmitterInterface(ParticleAllocator &particle_allocator, TimeSpan time_span);
+ EmitterInterface(ParticleAllocator &particle_allocator,
+ ArrayAllocator &array_allocator,
+ TimeSpan time_span);
~EmitterInterface() = default;
ParticleAllocator &particle_allocator();
+ ArrayAllocator &array_allocator();
/**
* Time span that new particles should be emitted in.
@@ -460,6 +464,7 @@ class EventExecuteInterface {
private:
ParticleSet m_particles;
ParticleAllocator &m_particle_allocator;
+ ArrayAllocator &m_array_allocator;
ArrayRef<float> m_current_times;
EventStorage &m_event_storage;
AttributeArrays m_attribute_offsets;
@@ -468,6 +473,7 @@ class EventExecuteInterface {
public:
EventExecuteInterface(ParticleSet particles,
ParticleAllocator &particle_allocator,
+ ArrayAllocator &array_allocator,
ArrayRef<float> current_times,
EventStorage &event_storage,
AttributeArrays attribute_offsets,
@@ -506,6 +512,8 @@ class EventExecuteInterface {
*/
ParticleAllocator &particle_allocator();
+ ArrayAllocator &array_allocator();
+
/**
* Get the entire event storage.
*/
@@ -655,6 +663,11 @@ inline ParticleAllocator &EmitterInterface::particle_allocator()
return m_particle_allocator;
}
+inline ArrayAllocator &EmitterInterface::array_allocator()
+{
+ return m_array_allocator;
+}
+
inline TimeSpan EmitterInterface::time_span()
{
return m_time_span;
@@ -798,6 +811,11 @@ inline ParticleAllocator &EventExecuteInterface::particle_allocator()
return m_particle_allocator;
}
+inline ArrayAllocator &EventExecuteInterface::array_allocator()
+{
+ return m_array_allocator;
+}
+
inline EventStorage &EventExecuteInterface::event_storage()
{
return m_event_storage;
diff --git a/source/blender/simulations/bparticles/events.cpp b/source/blender/simulations/bparticles/events.cpp
index ca142a58a15..537bd1e3554 100644
--- a/source/blender/simulations/bparticles/events.cpp
+++ b/source/blender/simulations/bparticles/events.cpp
@@ -87,7 +87,13 @@ class AgeReachedEvent : public Event {
}
EmptyEventInfo event_info;
- ActionInterface action_interface(interface, event_info);
+ ActionInterface action_interface(interface.particle_allocator(),
+ interface.array_allocator(),
+ particles,
+ interface.attribute_offsets(),
+ interface.current_times(),
+ interface.step_end_time(),
+ event_info);
m_action->execute(action_interface);
}
};
@@ -213,7 +219,13 @@ class MeshCollisionEventFilter : public Event {
}
CollisionEventInfo event_info(normals);
- ActionInterface action_interface(interface, event_info);
+ ActionInterface action_interface(interface.particle_allocator(),
+ interface.array_allocator(),
+ particles,
+ interface.attribute_offsets(),
+ interface.current_times(),
+ interface.step_end_time(),
+ event_info);
m_action->execute(action_interface);
}
};
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index 4c327724ad2..abb23f0c7ac 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -175,6 +175,7 @@ BLI_NOINLINE static void find_unfinished_particles(
}
BLI_NOINLINE static void execute_events(ParticleAllocator &particle_allocator,
+ ArrayAllocator &array_allocator,
ParticlesBlock &block,
ArrayRef<SmallVector<uint>> particle_indices_per_event,
ArrayRef<SmallVector<float>> current_time_per_particle,
@@ -195,6 +196,7 @@ BLI_NOINLINE static void execute_events(ParticleAllocator &particle_allocator,
EventExecuteInterface interface(particles,
particle_allocator,
+ array_allocator,
current_time_per_particle[event_index],
event_storage,
attribute_offsets,
@@ -256,6 +258,7 @@ BLI_NOINLINE static void simulate_to_next_event(ArrayAllocator &array_allocator,
current_time_per_particle);
execute_events(particle_allocator,
+ array_allocator,
particles.block(),
particles_per_event,
current_time_per_particle,
@@ -681,9 +684,10 @@ BLI_NOINLI
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list