[Bf-blender-cvs] [ac5bf8e4f9e] functions: initial age output in particle info node
Jacques Lucke
noreply at git.blender.org
Mon Jul 29 17:57:34 CEST 2019
Commit: ac5bf8e4f9ed846dbd45cf7fb187f186f00a487f
Author: Jacques Lucke
Date: Mon Jul 29 14:50:19 2019 +0200
Branches: functions
https://developer.blender.org/rBac5bf8e4f9ed846dbd45cf7fb187f186f00a487f
initial age output in particle info node
===================================================================
M release/scripts/startup/nodes/bparticle_nodes/particle_info.py
M source/blender/simulations/bparticles/force_interface.hpp
M source/blender/simulations/bparticles/integrator.cpp
M source/blender/simulations/bparticles/integrator.hpp
M source/blender/simulations/bparticles/particle_function.cpp
M source/blender/simulations/bparticles/particle_function.hpp
M source/blender/simulations/bparticles/particle_function_builder.cpp
M source/blender/simulations/bparticles/simulate.cpp
M source/blender/simulations/bparticles/step_description_interfaces.cpp
M source/blender/simulations/bparticles/step_description_interfaces.hpp
===================================================================
diff --git a/release/scripts/startup/nodes/bparticle_nodes/particle_info.py b/release/scripts/startup/nodes/bparticle_nodes/particle_info.py
index 0ed94d2549e..683a881b503 100644
--- a/release/scripts/startup/nodes/bparticle_nodes/particle_info.py
+++ b/release/scripts/startup/nodes/bparticle_nodes/particle_info.py
@@ -11,3 +11,4 @@ class ParticleInfoNode(bpy.types.Node, BParticlesNode):
builder.fixed_output("position", "Position", "Vector")
builder.fixed_output("velocity", "Velocity", "Vector")
builder.fixed_output("birth_time", "Birth Time", "Float")
+ builder.fixed_output("age", "Age", "Float")
diff --git a/source/blender/simulations/bparticles/force_interface.hpp b/source/blender/simulations/bparticles/force_interface.hpp
index c89a4b2a2f5..8195d7ac676 100644
--- a/source/blender/simulations/bparticles/force_interface.hpp
+++ b/source/blender/simulations/bparticles/force_interface.hpp
@@ -8,13 +8,21 @@ class ForceInterface {
private:
ParticlesBlock &m_block;
ArrayAllocator &m_array_allocator;
+ ArrayRef<float> m_remaining_durations;
+ float m_step_end_time;
ArrayRef<float3> m_destination;
public:
ForceInterface(ParticlesBlock &block,
ArrayAllocator &array_allocator,
+ ArrayRef<float> remaining_durations,
+ float step_end_time,
ArrayRef<float3> destination)
- : m_block(block), m_array_allocator(array_allocator), m_destination(destination)
+ : m_block(block),
+ m_array_allocator(array_allocator),
+ m_remaining_durations(remaining_durations),
+ m_step_end_time(step_end_time),
+ m_destination(destination)
{
}
@@ -32,6 +40,16 @@ class ForceInterface {
{
return m_destination;
}
+
+ ArrayRef<float> remaining_durations()
+ {
+ return m_remaining_durations;
+ }
+
+ float step_end_time()
+ {
+ return m_step_end_time;
+ }
};
} // namespace BParticles
diff --git a/source/blender/simulations/bparticles/integrator.cpp b/source/blender/simulations/bparticles/integrator.cpp
index 01a9652e1d9..806e0803df3 100644
--- a/source/blender/simulations/bparticles/integrator.cpp
+++ b/source/blender/simulations/bparticles/integrator.cpp
@@ -19,7 +19,7 @@ void ConstantVelocityIntegrator::integrate(IntegratorInterface &interface)
ParticlesBlock &block = interface.block();
auto velocities = block.attributes().get_float3("Velocity");
auto position_offsets = interface.offsets().get_float3("Position");
- auto durations = interface.durations();
+ auto durations = interface.remaining_durations();
for (uint pindex = 0; pindex < block.active_amount(); pindex++) {
position_offsets[pindex] = velocities[pindex] * durations[pindex];
@@ -50,10 +50,14 @@ void EulerIntegrator::integrate(IntegratorInterface &interface)
{
ParticlesBlock &block = interface.block();
AttributeArrays r_offsets = interface.offsets();
- ArrayRef<float> durations = interface.durations();
+ ArrayRef<float> durations = interface.remaining_durations();
ArrayAllocator::Array<float3> combined_force(interface.array_allocator());
- this->compute_combined_force(block, interface.array_allocator(), combined_force);
+ this->compute_combined_force(block,
+ interface.array_allocator(),
+ interface.remaining_durations(),
+ interface.step_end_time(),
+ combined_force);
auto last_velocities = block.attributes().get_float3("Velocity");
@@ -65,11 +69,13 @@ void EulerIntegrator::integrate(IntegratorInterface &interface)
BLI_NOINLINE void EulerIntegrator::compute_combined_force(ParticlesBlock &block,
ArrayAllocator &array_allocator,
+ ArrayRef<float> remaining_durations,
+ float step_end_time,
ArrayRef<float3> r_force)
{
r_force.fill({0, 0, 0});
- ForceInterface interface(block, array_allocator, r_force);
+ ForceInterface interface(block, array_allocator, remaining_durations, step_end_time, r_force);
for (Force *force : m_forces) {
force->add_force(interface);
diff --git a/source/blender/simulations/bparticles/integrator.hpp b/source/blender/simulations/bparticles/integrator.hpp
index fb9c36bbdca..ec8759e5492 100644
--- a/source/blender/simulations/bparticles/integrator.hpp
+++ b/source/blender/simulations/bparticles/integrator.hpp
@@ -30,6 +30,8 @@ class EulerIntegrator : public Integrator {
private:
void compute_combined_force(ParticlesBlock &block,
ArrayAllocator &array_allocator,
+ ArrayRef<float> remaining_durations,
+ float step_end_time,
ArrayRef<float3> r_force);
void compute_offsets(ArrayRef<float> durations,
diff --git a/source/blender/simulations/bparticles/particle_function.cpp b/source/blender/simulations/bparticles/particle_function.cpp
index be4438e2e9a..26255d0cf6f 100644
--- a/source/blender/simulations/bparticles/particle_function.cpp
+++ b/source/blender/simulations/bparticles/particle_function.cpp
@@ -42,13 +42,20 @@ ParticleFunction::~ParticleFunction()
std::unique_ptr<ParticleFunctionResult> ParticleFunction::compute(ActionInterface &interface)
{
- return this->compute(interface.array_allocator(), interface.particles(), &interface.context());
+ return this->compute(interface.array_allocator(),
+ interface.particles(),
+ ParticleTimes::FromCurrentTimes(interface.current_times()),
+ &interface.context());
}
std::unique_ptr<ParticleFunctionResult> ParticleFunction::compute(
OffsetHandlerInterface &interface)
{
- return this->compute(interface.array_allocator(), interface.particles(), nullptr);
+ return this->compute(
+ interface.array_allocator(),
+ interface.particles(),
+ ParticleTimes::FromDurationsAndEnd(interface.durations(), interface.step_end_time()),
+ nullptr);
}
std::unique_ptr<ParticleFunctionResult> ParticleFunction::compute(ForceInterface &interface)
@@ -56,16 +63,23 @@ std::unique_ptr<ParticleFunctionResult> ParticleFunction::compute(ForceInterface
ParticlesBlock &block = interface.block();
return this->compute(interface.array_allocator(),
ParticleSet(block, block.active_range().as_array_ref()),
+ ParticleTimes::FromDurationsAndEnd(interface.remaining_durations(),
+ interface.step_end_time()),
nullptr);
}
std::unique_ptr<ParticleFunctionResult> ParticleFunction::compute(EventFilterInterface &interface)
{
- return this->compute(interface.array_allocator(), interface.particles(), nullptr);
+ return this->compute(
+ interface.array_allocator(),
+ interface.particles(),
+ ParticleTimes::FromDurationsAndEnd(interface.durations(), interface.end_time()),
+ nullptr);
}
std::unique_ptr<ParticleFunctionResult> ParticleFunction::compute(ArrayAllocator &array_allocator,
ParticleSet particles,
+ ParticleTimes particle_times,
ActionContext *action_context)
{
uint parameter_amount = m_parameter_depends_on_particle.size();
@@ -80,7 +94,7 @@ std::unique_ptr<ParticleFunctionResult> ParticleFunction::compute(ArrayAllocator
result->m_output_indices = m_output_indices;
this->init_without_deps(result, array_allocator);
- this->init_with_deps(result, array_allocator, particles, action_context);
+ this->init_with_deps(result, array_allocator, particles, particle_times, action_context);
return std::unique_ptr<ParticleFunctionResult>(result);
}
@@ -119,6 +133,7 @@ void ParticleFunction::init_without_deps(ParticleFunctionResult *result,
void ParticleFunction::init_with_deps(ParticleFunctionResult *result,
ArrayAllocator &array_allocator,
ParticleSet particles,
+ ParticleTimes particle_times,
ActionContext *action_context)
{
if (m_fn_with_deps->output_amount() == 0) {
@@ -134,7 +149,7 @@ void ParticleFunction::init_with_deps(ParticleFunctionResult *result,
for (uint i = 0; i < m_fn_with_deps->input_amount(); i++) {
auto *provider = m_input_providers[i];
- InputProviderInterface interface(array_allocator, particles, action_context);
+ InputProviderInterface interface(array_allocator, particles, particle_times, action_context);
auto array = provider->get(interface);
BLI_assert(array.buffer != nullptr);
BLI_assert(array.stride > 0);
diff --git a/source/blender/simulations/bparticles/particle_function.hpp b/source/blender/simulations/bparticles/particle_function.hpp
index 0cacb0146a5..4f0f1cce76b 100644
--- a/source/blender/simulations/bparticles/particle_function.hpp
+++ b/source/blender/simulations/bparticles/particle_function.hpp
@@ -85,18 +85,80 @@ struct ParticleFunctionInputArray {
}
};
+struct ParticleTimes {
+ public:
+ enum Type {
+ Current,
+ DurationAndEnd,
+ };
+
+ private:
+ Type m_type;
+ ArrayRef<float> m_current_times;
+ ArrayRef<float> m_remaining_durations;
+ float m_end_time;
+
+ ParticleTimes(Type type,
+ ArrayRef<float> current_times,
+ ArrayRef<float> remaining_durations,
+ float end_time)
+ : m_type(type),
+ m_current_times(current_times),
+ m_remaining_durations(remaining_durations),
+ m_end_time(end_time)
+ {
+ }
+
+ public:
+ static ParticleTimes FromCurrentTimes(ArrayRef<float> current_times)
+ {
+ return ParticleTimes(Type::Current, current_times, {}, 0);
+ }
+
+ static ParticleTimes FromDurationsAndEnd(Ar
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list