[Bf-blender-cvs] [fa9bf0c5b1a] functions: cleanup
Jacques Lucke
noreply at git.blender.org
Mon Jul 15 18:12:42 CEST 2019
Commit: fa9bf0c5b1af416bb01b12d11c0ea4d0d0403019
Author: Jacques Lucke
Date: Mon Jul 15 16:15:06 2019 +0200
Branches: functions
https://developer.blender.org/rBfa9bf0c5b1af416bb01b12d11c0ea4d0d0403019
cleanup
===================================================================
M source/blender/simulations/bparticles/actions.cpp
M source/blender/simulations/bparticles/actions.hpp
M source/blender/simulations/bparticles/inserters.cpp
===================================================================
diff --git a/source/blender/simulations/bparticles/actions.cpp b/source/blender/simulations/bparticles/actions.cpp
index 77fa1c1a4d7..d5e8b249359 100644
--- a/source/blender/simulations/bparticles/actions.cpp
+++ b/source/blender/simulations/bparticles/actions.cpp
@@ -10,48 +10,36 @@ class NoneAction : public Action {
}
};
-class ChangeDirectionAction : public Action {
- private:
- ParticleFunction m_compute_inputs;
- std::unique_ptr<Action> m_post_action;
-
- public:
- ChangeDirectionAction(ParticleFunction &compute_inputs, std::unique_ptr<Action> post_action)
- : m_compute_inputs(compute_inputs), m_post_action(std::move(post_action))
- {
- }
-
- void execute(ActionInterface &interface) override
- {
- ParticleSet particles = interface.particles();
- auto velocities = particles.attributes().get_float3("Velocity");
- auto position_offsets = interface.attribute_offsets().try_get_float3("Position");
- auto velocity_offsets = interface.attribute_offsets().try_get_float3("Velocity");
+void ChangeDirectionAction::execute(ActionInterface &interface)
+{
+ ParticleSet particles = interface.particles();
+ auto velocities = particles.attributes().get_float3("Velocity");
+ auto position_offsets = interface.attribute_offsets().try_get_float3("Position");
+ auto velocity_offsets = interface.attribute_offsets().try_get_float3("Velocity");
- auto caller = m_compute_inputs.get_caller(particles.attributes(), interface.event_info());
+ auto caller = m_compute_inputs.get_caller(particles.attributes(), interface.event_info());
- FN_TUPLE_CALL_ALLOC_TUPLES(caller.body(), fn_in, fn_out);
+ FN_TUPLE_CALL_ALLOC_TUPLES(caller.body(), fn_in, fn_out);
- FN::ExecutionStack stack;
- FN::ExecutionContext execution_context(stack);
+ FN::ExecutionStack stack;
+ FN::ExecutionContext execution_context(stack);
- for (uint pindex : particles.pindices()) {
- caller.call(fn_in, fn_out, execution_context, pindex);
- float3 direction = fn_out.get<float3>(0);
+ for (uint pindex : particles.pindices()) {
+ caller.call(fn_in, fn_out, execution_context, pindex);
+ float3 direction = fn_out.get<float3>(0);
- velocities[pindex] = direction;
+ velocities[pindex] = direction;
- if (position_offsets.has_value()) {
- position_offsets.value()[pindex] = direction * interface.remaining_time_in_step(pindex);
- }
- if (velocity_offsets.has_value()) {
- velocity_offsets.value()[pindex] = float3(0);
- }
+ if (position_offsets.has_value()) {
+ position_offsets.value()[pindex] = direction * interface.remaining_time_in_step(pindex);
+ }
+ if (velocity_offsets.has_value()) {
+ velocity_offsets.value()[pindex] = float3(0);
}
-
- m_post_action->execute(interface);
}
-};
+
+ m_post_action->execute(interface);
+}
class KillAction : public Action {
void execute(ActionInterface &interface) override
@@ -186,13 +174,6 @@ std::unique_ptr<Action> ACTION_none()
return std::unique_ptr<Action>(action);
}
-std::unique_ptr<Action> ACTION_change_direction(ParticleFunction &compute_inputs,
- std::unique_ptr<Action> post_action)
-{
- Action *action = new ChangeDirectionAction(compute_inputs, std::move(post_action));
- return std::unique_ptr<Action>(action);
-}
-
std::unique_ptr<Action> ACTION_kill()
{
Action *action = new KillAction();
diff --git a/source/blender/simulations/bparticles/actions.hpp b/source/blender/simulations/bparticles/actions.hpp
index ddc49f7466a..5ed43cbf9d5 100644
--- a/source/blender/simulations/bparticles/actions.hpp
+++ b/source/blender/simulations/bparticles/actions.hpp
@@ -4,9 +4,21 @@
namespace BParticles {
+class ChangeDirectionAction : public Action {
+ private:
+ ParticleFunction m_compute_inputs;
+ std::unique_ptr<Action> m_post_action;
+
+ public:
+ ChangeDirectionAction(ParticleFunction &compute_inputs, std::unique_ptr<Action> post_action)
+ : m_compute_inputs(compute_inputs), m_post_action(std::move(post_action))
+ {
+ }
+
+ void execute(ActionInterface &interface) override;
+};
+
std::unique_ptr<Action> ACTION_none();
-std::unique_ptr<Action> ACTION_change_direction(ParticleFunction &compute_inputs,
- std::unique_ptr<Action> post_action);
std::unique_ptr<Action> ACTION_kill();
std::unique_ptr<Action> ACTION_explode(StringRef new_particle_name,
ParticleFunction &compute_inputs,
diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp
index 98bbab3800f..a09fad5c8fc 100644
--- a/source/blender/simulations/bparticles/inserters.cpp
+++ b/source/blender/simulations/bparticles/inserters.cpp
@@ -120,7 +120,10 @@ static std::unique_ptr<Action> BUILD_ACTION_change_direction(BuildContext &ctx,
SharedFunction fn = create_function_for_data_inputs(bnode, ctx.indexed_tree, ctx.data_graph);
ParticleFunction particle_fn(fn);
- return ACTION_change_direction(particle_fn, build_action(ctx, {node_outputs.get(0), bnode}));
+ auto post_action = build_action(ctx, {node_outputs.get(0), bnode});
+
+ return std::unique_ptr<ChangeDirectionAction>(
+ new ChangeDirectionAction(particle_fn, std::move(post_action)));
}
static std::unique_ptr<Action> BUILD_ACTION_explode(BuildContext &ctx, bNode *bnode)
More information about the Bf-blender-cvs
mailing list