[Bf-blender-cvs] [034956978e5] functions: more boilerplate code removal
Jacques Lucke
noreply at git.blender.org
Mon Jul 15 18:12:45 CEST 2019
Commit: 034956978e5940a72627ce93812e04ffeda2b00f
Author: Jacques Lucke
Date: Mon Jul 15 16:18:59 2019 +0200
Branches: functions
https://developer.blender.org/rB034956978e5940a72627ce93812e04ffeda2b00f
more boilerplate code removal
===================================================================
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 d5e8b249359..8735455b253 100644
--- a/source/blender/simulations/bparticles/actions.cpp
+++ b/source/blender/simulations/bparticles/actions.cpp
@@ -4,11 +4,9 @@
namespace BParticles {
-class NoneAction : public Action {
- void execute(ActionInterface &UNUSED(interface)) override
- {
- }
-};
+void NoneAction::execute(ActionInterface &UNUSED(interface))
+{
+}
void ChangeDirectionAction::execute(ActionInterface &interface)
{
@@ -41,12 +39,10 @@ void ChangeDirectionAction::execute(ActionInterface &interface)
m_post_action->execute(interface);
}
-class KillAction : public Action {
- void execute(ActionInterface &interface) override
- {
- interface.kill(interface.particles().pindices());
- }
-};
+void KillAction::execute(ActionInterface &interface)
+{
+ interface.kill(interface.particles().pindices());
+}
static float random_number()
{
@@ -168,18 +164,6 @@ class ConditionAction : public Action {
}
};
-std::unique_ptr<Action> ACTION_none()
-{
- Action *action = new NoneAction();
- return std::unique_ptr<Action>(action);
-}
-
-std::unique_ptr<Action> ACTION_kill()
-{
- Action *action = new KillAction();
- return std::unique_ptr<Action>(action);
-}
-
std::unique_ptr<Action> ACTION_explode(StringRef new_particle_name,
ParticleFunction &compute_inputs,
std::unique_ptr<Action> post_action)
diff --git a/source/blender/simulations/bparticles/actions.hpp b/source/blender/simulations/bparticles/actions.hpp
index 5ed43cbf9d5..70f12131660 100644
--- a/source/blender/simulations/bparticles/actions.hpp
+++ b/source/blender/simulations/bparticles/actions.hpp
@@ -4,6 +4,14 @@
namespace BParticles {
+class NoneAction : public Action {
+ void execute(ActionInterface &UNUSED(interface)) override;
+};
+
+class KillAction : public Action {
+ void execute(ActionInterface &interface) override;
+};
+
class ChangeDirectionAction : public Action {
private:
ParticleFunction m_compute_inputs;
@@ -18,8 +26,6 @@ class ChangeDirectionAction : public Action {
void execute(ActionInterface &interface) override;
};
-std::unique_ptr<Action> ACTION_none();
-std::unique_ptr<Action> ACTION_kill();
std::unique_ptr<Action> ACTION_explode(StringRef new_particle_name,
ParticleFunction &compute_inputs,
std::unique_ptr<Action> post_action);
diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp
index a09fad5c8fc..bf1fb29fbda 100644
--- a/source/blender/simulations/bparticles/inserters.cpp
+++ b/source/blender/simulations/bparticles/inserters.cpp
@@ -110,7 +110,7 @@ using ActionFromNodeCallback =
static std::unique_ptr<Action> BUILD_ACTION_kill(BuildContext &UNUSED(ctx), bNode *UNUSED(bnode))
{
- return ACTION_kill();
+ return std::unique_ptr<Action>(new KillAction());
}
static std::unique_ptr<Action> BUILD_ACTION_change_direction(BuildContext &ctx, bNode *bnode)
@@ -177,7 +177,7 @@ static std::unique_ptr<Action> build_action(BuildContext &ctx, SocketWithNode st
if (start.socket->in_out == SOCK_OUT) {
auto linked = ctx.indexed_tree.linked(start.socket);
if (linked.size() == 0) {
- return ACTION_none();
+ return std::unique_ptr<Action>(new NoneAction());
}
else if (linked.size() == 1) {
return build_action(ctx, linked[0]);
More information about the Bf-blender-cvs
mailing list