[Bf-blender-cvs] [9a4d1255337] functions: use virtual node tree for parsing particle system node trees
Jacques Lucke
noreply at git.blender.org
Mon Jul 22 18:13:12 CEST 2019
Commit: 9a4d12553371bdf248c785879cc415d7378d3f91
Author: Jacques Lucke
Date: Mon Jul 22 16:35:49 2019 +0200
Branches: functions
https://developer.blender.org/rB9a4d12553371bdf248c785879cc415d7378d3f91
use virtual node tree for parsing particle system node trees
===================================================================
M source/blender/blenkernel/BKE_node_tree.hpp
M source/blender/simulations/bparticles/c_wrapper.cpp
M source/blender/simulations/bparticles/inserters.cpp
M source/blender/simulations/bparticles/inserters.hpp
M source/blender/simulations/bparticles/node_frontend.cpp
M source/blender/simulations/bparticles/node_frontend.hpp
===================================================================
diff --git a/source/blender/blenkernel/BKE_node_tree.hpp b/source/blender/blenkernel/BKE_node_tree.hpp
index c4d0abd6ede..ad81bd5fb2c 100644
--- a/source/blender/blenkernel/BKE_node_tree.hpp
+++ b/source/blender/blenkernel/BKE_node_tree.hpp
@@ -220,6 +220,13 @@ class VirtualNode {
{
return &m_btree->id;
}
+
+ PointerRNA get_rna()
+ {
+ PointerRNA rna;
+ RNA_pointer_create(&m_btree->id, &RNA_Node, m_bnode, &rna);
+ return rna;
+ }
};
class VirtualSocket {
diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index c4a0e09db84..0efa1753980 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -79,9 +79,12 @@ void BParticles_simulate_modifier(BParticlesModifierData *bpmd,
WorldState &world_state = *unwrap(world_state_c);
bNodeTree *btree = (bNodeTree *)DEG_get_original_id((ID *)bpmd->bparticles_tree);
- IndexedNodeTree indexed_tree(btree);
- auto step_description = step_description_from_node_tree(indexed_tree, world_state, time_step);
+ VirtualNodeTree vtree;
+ vtree.add_all_of_tree(btree);
+ vtree.freeze_and_index();
+
+ auto step_description = step_description_from_node_tree(vtree, world_state, time_step);
ParticlesState &particles_state = *unwrap(particles_state_c);
simulate_step(particles_state, *step_description);
diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp
index 75baaaa8943..f425ac8ffde 100644
--- a/source/blender/simulations/bparticles/inserters.cpp
+++ b/source/blender/simulations/bparticles/inserters.cpp
@@ -18,442 +18,432 @@
namespace BParticles {
-// using FN::SharedFunction;
-
-// static bool is_particle_data_input(bNode *bnode)
-// {
-// return STREQ(bnode->idname, "bp_ParticleInfoNode") ||
-// STREQ(bnode->idname, "bp_MeshCollisionEventNode");
-// }
-
-// static SmallVector<FN::DFGraphSocket> insert_inputs(FN::FunctionBuilder &fn_builder,
-// VirtualNodeTree &vtree,
-// BTreeDataGraph &data_graph,
-// ArrayRef<bNodeSocket *> output_sockets)
-// {
-// SmallSet<bNodeSocket *> to_be_checked = output_sockets;
-// SmallSet<bNodeSocket *> found_inputs;
-// SmallVector<FN::DFGraphSocket> inputs;
-
-// while (to_be_checked.size() > 0) {
-// bNodeSocket *bsocket = to_be_checked.pop();
-// if (bsocket->in_out == SOCK_IN) {
-// auto linked = vtree.linked(bsocket);
-// BLI_assert(linked.size() <= 1);
-// if (linked.size() == 1) {
-// SocketWithNode origin = linked[0];
-// if (is_particle_data_input(origin.node) && !found_inputs.contains(origin.socket)) {
-// FN::DFGraphSocket socket = data_graph.lookup_socket(origin.socket);
-// FN::SharedType &type = data_graph.graph()->type_of_socket(socket);
-// std::string name_prefix;
-// if (STREQ(origin.node->idname, "bp_ParticleInfoNode")) {
-// name_prefix = "Attribute: ";
-// }
-// else if (STREQ(origin.node->idname, "bp_MeshCollisionEventNode")) {
-// name_prefix = "Event: ";
-// }
-// fn_builder.add_input(name_prefix + origin.socket->name, type);
-// found_inputs.add(origin.socket);
-// inputs.append(socket);
-// }
-// else {
-// to_be_checked.add(origin.socket);
-// }
-// }
-// }
-// else {
-// bNode *bnode = vtree.node_of_socket(bsocket);
-// for (bNodeSocket *input : bSocketList(bnode->inputs)) {
-// to_be_checked.add(input);
-// }
-// }
-// }
-// return inputs;
-// }
-
-// static SharedFunction create_function(VirtualNodeTree &vtree,
-// BTreeDataGraph &data_graph,
-// ArrayRef<bNodeSocket *> output_bsockets,
-// StringRef name)
-// {
-// FN::FunctionBuilder fn_builder;
-// auto inputs = insert_inputs(fn_builder, vtree, data_graph, output_bsockets);
-
-// SmallVector<FN::DFGraphSocket> outputs;
-// for (bNodeSocket *bsocket : output_bsockets) {
-// FN::DFGraphSocket socket = data_graph.lookup_socket(bsocket);
-// fn_builder.add_output(bsocket->name, data_graph.graph()->type_of_socket(socket));
-// outputs.append(socket);
-// }
-
-// FN::FunctionGraph function_graph(data_graph.graph(), inputs, outputs);
-// SharedFunction fn = fn_builder.build(name);
-// FN::fgraph_add_DependenciesBody(fn, function_graph);
-// FN::fgraph_add_TupleCallBody(fn, function_graph);
-// return fn;
-// }
-
-// static SharedFunction create_function_for_data_inputs(bNode *bnode,
-// VirtualNodeTree &vtree,
-// BTreeDataGraph &data_graph)
-// {
-// SmallVector<bNodeSocket *> bsockets_to_compute;
-// for (bNodeSocket *bsocket : bSocketList(bnode->inputs)) {
-// if (data_graph.uses_socket(bsocket)) {
-// bsockets_to_compute.append(bsocket);
-// }
-// }
-// return create_function(vtree, data_graph, bsockets_to_compute, bnode->name);
-// }
-
-// static std::unique_ptr<Action> build_action(BuildContext &ctx, SocketWithNode start);
-// using ActionFromNodeCallback =
-// std::function<std::unique_ptr<Action>(BuildContext &ctx, bNode *bnode)>;
-
-// static std::unique_ptr<Action> BUILD_ACTION_kill(BuildContext &UNUSED(ctx), bNode
-// *UNUSED(bnode))
-// {
-// return std::unique_ptr<Action>(new KillAction());
-// }
-
-// static std::unique_ptr<Action> BUILD_ACTION_change_direction(BuildContext &ctx, bNode *bnode)
-// {
-// bSocketList node_inputs(bnode->inputs);
-// bSocketList node_outputs(bnode->outputs);
-
-// SharedFunction fn = create_function_for_data_inputs(bnode, ctx.vtree, ctx.data_graph);
-// ParticleFunction particle_fn(fn);
-// 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)
-// {
-// bSocketList node_inputs(bnode->inputs);
-// bSocketList node_outputs(bnode->outputs);
-
-// SharedFunction fn = create_function_for_data_inputs(bnode, ctx.vtree, ctx.data_graph);
-// ParticleFunction particle_fn(fn);
-
-// PointerRNA rna = ctx.vtree.get_rna(bnode);
-// char name[65];
-// RNA_string_get(&rna, "particle_type_name", name);
-
-// auto post_action = build_action(ctx, {node_outputs.get(0), bnode});
-
-// if (ctx.step_builder.has_type(name)) {
-// return std::unique_ptr<Action>(new ExplodeAction(name, particle_fn,
-// std::move(post_action)));
-// }
-// else {
-// return post_action;
-// }
-// }
-
-// static std::unique_ptr<Action> BUILD_ACTION_condition(BuildContext &ctx, bNode *bnode)
-// {
-// bSocketList node_inputs(bnode->inputs);
-// bSocketList node_outputs(bnode->outputs);
-
-// SharedFunction fn = create_function_for_data_inputs(bnode, ctx.vtree, ctx.data_graph);
-// ParticleFunction particle_fn(fn);
-
-// auto true_action = build_action(ctx, {node_outputs.get(0), bnode});
-// auto false_action = build_action(ctx, {node_outputs.get(1), bnode});
-
-// return std::unique_ptr<Action>(
-// new ConditionAction(particle_fn, std::move(true_action), std::move(false_action)));
-// }
-
-// BLI_LAZY_INIT_STATIC(StringMap<ActionFromNodeCallback>, get_action_builders)
-// {
-// StringMap<ActionFromNodeCallback> map;
-// map.add_new("bp_KillParticleNode", BUILD_ACTION_kill);
-// map.add_new("bp_ChangeParticleDirectionNode", BUILD_ACTION_change_direction);
-// map.add_new("bp_ExplodeParticleNode", BUILD_ACTION_explode);
-// map.add_new("bp_ParticleConditionNode", BUILD_ACTION_condition);
-// return map;
-// }
-
-// static std::unique_ptr<Action> build_action(BuildContext &ctx, SocketWithNode start)
-// {
-// if (start.socket->in_out == SOCK_OUT) {
-// auto linked = ctx.vtree.linked(start.socket);
-// if (linked.size() == 0) {
-// return std::unique_ptr<Action>(new NoneAction());
-// }
-// else if (linked.size() == 1) {
-// return build_action(ctx, linked[0]);
-// }
-// else {
-// return nullptr;
-// }
-// }
-
-// BLI_assert(start.socket->in_out == SOCK_IN);
-// bNode *bnode = start.node;
-
-// auto builders = get_action_builders();
-// return builders.lookup(bnode->idname)(ctx, bnode);
-// }
-
-// static std::unique_ptr<Force> BUILD_FORCE_gravity(BuildContext &ctx, bNode *bnode)
-// {
-// SharedFunction fn = create_function_for_data_inputs(bnode, ctx.vtree, ctx.data_graph);
-// return std::unique_ptr<Force>(new GravityForce(fn));
-// }
-
-// static std::unique_ptr<Force> BUILD_FORCE_turbulence(BuildContext &ctx, bNode *bnode)
-// {
-// SharedFunction fn = create_function_for_data_inputs(bnode, ctx.vtree, ctx.data_graph);
-// return std::unique_ptr<Force>(new TurbulenceForce(fn));
-// }
-
-// static std::unique_ptr<Event> BUILD_EVENT_mesh_collision(BuildContext &ctx, bNode *bnode)
-// {
-// PointerRNA rna = ctx.vtree.get_rna(bnode);
-// Object *object = (Object *)RNA_pointer_get(&rna, "object").id.data;
-// if (object == nullptr || object->type != OB_MESH) {
-// return {};
-// }
-
-// auto action = build_action(ctx, {bSocketList(bnode->outputs).get(0), bnode});
-// return std::unique_ptr<Event>(new MeshCollisionEvent(bnode->name, object, std::move(action)));
-// }
-
-// static std::unique_ptr<Event> BUILD_EVENT_age_reached(BuildContext &ctx, bNode *bnode)
-// {
-// SharedFunction fn = create_function_for_data_inputs(bnode, ctx.vtree, ctx.data_graph);
-// auto action = build_action(ctx, {bSocketList(bnode->outputs).get(0), bnode});
-// return std::unique_ptr<Event>(new AgeReachedEvent(bnode->name, fn, std::move(action)));
-// }
-
-// static std::unique_ptr<Event> BUILD_EVENT_close
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list