[Bf-blender-cvs] [c92dd7bed6e] functions: create particle function more centrally for offset handlers
Jacques Lucke
noreply at git.blender.org
Thu Jul 25 15:10:29 CEST 2019
Commit: c92dd7bed6e0deeeef17a70cff38cc832706f22c
Author: Jacques Lucke
Date: Thu Jul 25 09:54:46 2019 +0200
Branches: functions
https://developer.blender.org/rBc92dd7bed6e0deeeef17a70cff38cc832706f22c
create particle function more centrally for offset handlers
===================================================================
M source/blender/simulations/bparticles/inserters.cpp
M source/blender/simulations/bparticles/inserters.hpp
M source/blender/simulations/bparticles/node_frontend.cpp
===================================================================
diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp
index ad6f22ecac8..4e53f85ccd7 100644
--- a/source/blender/simulations/bparticles/inserters.cpp
+++ b/source/blender/simulations/bparticles/inserters.cpp
@@ -89,7 +89,7 @@ static ValueOrError<SharedFunction> create_function__action_inputs(VirtualNode *
return fn;
}
-static ValueOrError<SharedFunction> create_function__offset_handler_inputs(
+ValueOrError<SharedFunction> create_function__offset_handler_inputs(
VirtualNode *offset_handler_vnode, VTreeDataGraph &data_graph)
{
return create_function__action_inputs(offset_handler_vnode, data_graph);
@@ -460,22 +460,16 @@ static std::unique_ptr<Emitter> BUILD_EMITTER_initial_grid(BuildContext &ctx,
body.get_output<float>(fn_out, 4, "Size")));
}
-static std::unique_ptr<OffsetHandler> BUILD_OFFSET_HANDLER_trails(BuildContext &ctx,
- VirtualNode *vnode)
+static std::unique_ptr<OffsetHandler> BUILD_OFFSET_HANDLER_trails(
+ BuildContext &ctx, VirtualNode *vnode, ParticleFunction compute_inputs_fn)
{
PointerRNA rna = vnode->rna();
char name[65];
RNA_string_get(&rna, "particle_type_name", name);
- auto fn_or_error = create_function__offset_handler_inputs(vnode, ctx.data_graph);
- if (fn_or_error.is_error()) {
- return {};
- }
-
- SharedFunction fn = fn_or_error.extract_value();
-
if (ctx.type_name_exists(name)) {
- return std::unique_ptr<OffsetHandler>(new CreateTrailHandler(name, ParticleFunction(fn)));
+ return std::unique_ptr<OffsetHandler>(
+ new CreateTrailHandler(name, std::move(compute_inputs_fn)));
}
else {
return {};
diff --git a/source/blender/simulations/bparticles/inserters.hpp b/source/blender/simulations/bparticles/inserters.hpp
index 68284f81c14..a4c9d696337 100644
--- a/source/blender/simulations/bparticles/inserters.hpp
+++ b/source/blender/simulations/bparticles/inserters.hpp
@@ -5,10 +5,12 @@
#include "BKE_node_tree.hpp"
#include "FN_data_flow_nodes.hpp"
#include "BLI_string_map.hpp"
+#include "BLI_value_or_error.hpp"
#include "world_state.hpp"
#include "step_description.hpp"
#include "forces.hpp"
+#include "particle_function.hpp"
namespace BParticles {
@@ -20,6 +22,7 @@ using BKE::VirtualNode;
using BKE::VirtualNodeTree;
using BKE::VirtualSocket;
using BLI::StringMap;
+using BLI::ValueOrError;
using FN::DataFlowNodes::VTreeDataGraph;
struct BuildContext {
@@ -33,6 +36,9 @@ struct BuildContext {
}
};
+ValueOrError<SharedFunction> create_function__offset_handler_inputs(
+ VirtualNode *offset_handler_vnode, VTreeDataGraph &data_graph);
+
using ForceFromNodeCallback =
std::function<std::unique_ptr<Force>(BuildContext &ctx, VirtualNode *vnode)>;
@@ -42,8 +48,8 @@ using EventFromNodeCallback =
using EmitterFromNodeCallback = std::function<std::unique_ptr<Emitter>(
BuildContext &ctx, VirtualNode *vnode, StringRef particle_type_name)>;
-using OffsetHandlerFromNodeCallback =
- std::function<std::unique_ptr<OffsetHandler>(BuildContext &ctx, VirtualNode *vnode)>;
+using OffsetHandlerFromNodeCallback = std::function<std::unique_ptr<OffsetHandler>(
+ BuildContext &ctx, VirtualNode *vnode, ParticleFunction compute_inputs_fn)>;
StringMap<ForceFromNodeCallback> &get_force_builders();
StringMap<EventFromNodeCallback> &get_event_builders();
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp
index 5ff33b561a6..70c16ea8c0f 100644
--- a/source/blender/simulations/bparticles/node_frontend.cpp
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -83,7 +83,14 @@ std::unique_ptr<StepDescription> step_description_from_node_tree(VirtualNodeTree
for (VirtualNode *vnode : vtree.nodes_with_idname(item.key)) {
for (VirtualSocket *linked : vnode->output(0)->links()) {
if (is_particle_type_node(linked->vnode())) {
- auto listener = item.value(ctx, vnode);
+ auto fn_or_error = create_function__offset_handler_inputs(vnode, data_graph);
+ if (fn_or_error.is_error()) {
+ continue;
+ }
+
+ ParticleFunction fn(fn_or_error.extract_value());
+
+ auto listener = item.value(ctx, vnode, std::move(fn));
if (listener) {
offset_handlers.add(linked->vnode()->name(), listener.release());
}
More information about the Bf-blender-cvs
mailing list