From 5910dbdbf7dc7999597a680f81c261fa7bbcf011 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 17 Jul 2020 11:36:59 +0200 Subject: Nodes: move some code from blenkernel directory to nodes This also introduces the `blender::nodes` namespace. Eventually, we want to move most/all of the node implementation files into this namespace. The reason for this file-move is that the code fits much better into the `nodes` directory than in the `blenkernel` directory. --- source/blender/blenkernel/intern/simulation.cc | 44 +++++++++++++++----------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'source/blender/blenkernel/intern/simulation.cc') diff --git a/source/blender/blenkernel/intern/simulation.cc b/source/blender/blenkernel/intern/simulation.cc index 831de084500..f38001bf69f 100644 --- a/source/blender/blenkernel/intern/simulation.cc +++ b/source/blender/blenkernel/intern/simulation.cc @@ -45,10 +45,10 @@ #include "BKE_lib_remap.h" #include "BKE_main.h" #include "BKE_node.h" -#include "BKE_node_tree_multi_function.hh" #include "BKE_pointcache.h" #include "BKE_simulation.h" +#include "NOD_node_tree_multi_function.hh" #include "NOD_simulation.h" #include "BLT_translation.h" @@ -216,16 +216,19 @@ static void copy_states_to_cow(Simulation *simulation_orig, Simulation *simulati } static Map deduplicate_attribute_nodes( - fn::MFNetwork &network, MFNetworkTreeMap &network_map, const DerivedNodeTree &tree) + fn::MFNetwork &network, + nodes::MFNetworkTreeMap &network_map, + const nodes::DerivedNodeTree &tree) { - Span attribute_dnodes = tree.nodes_by_type("SimulationNodeParticleAttribute"); + Span attribute_dnodes = tree.nodes_by_type( + "SimulationNodeParticleAttribute"); uint amount = attribute_dnodes.size(); if (amount == 0) { return {}; } Vector name_sockets; - for (const DNode *dnode : attribute_dnodes) { + for (const nodes::DNode *dnode : attribute_dnodes) { fn::MFInputSocket &name_socket = network_map.lookup_dummy(dnode->input(0)); name_sockets.append(&name_socket); } @@ -309,10 +312,10 @@ class CustomDataAttributesRef { } }; -static std::string dnode_to_path(const DNode &dnode) +static std::string dnode_to_path(const nodes::DNode &dnode) { std::string path; - for (const DParentNode *parent = dnode.parent(); parent; parent = parent->parent()) { + for (const nodes::DParentNode *parent = dnode.parent(); parent; parent = parent->parent()) { path = parent->node_ref().name() + "/" + path; } path = path + dnode.name(); @@ -373,10 +376,10 @@ static void add_missing_particle_states(Simulation *simulation, Span state_names; - for (const DNode *dnode : tree.nodes_by_type("SimulationNodeParticleSimulation")) { + for (const nodes::DNode *dnode : tree.nodes_by_type("SimulationNodeParticleSimulation")) { state_names.add(dnode_to_path(*dnode)); } @@ -385,10 +388,11 @@ static void reinitialize_empty_simulation_states(Simulation *simulation, add_missing_particle_states(simulation, state_names); } -static void update_simulation_state_list(Simulation *simulation, const DerivedNodeTree &tree) +static void update_simulation_state_list(Simulation *simulation, + const nodes::DerivedNodeTree &tree) { VectorSet state_names; - for (const DNode *dnode : tree.nodes_by_type("SimulationNodeParticleSimulation")) { + for (const nodes::DNode *dnode : tree.nodes_by_type("SimulationNodeParticleSimulation")) { state_names.add(dnode_to_path(*dnode)); } @@ -672,14 +676,15 @@ class ParticleFunctionForce : public ParticleForce { }; static Vector create_forces_for_particle_simulation( - const DNode &simulation_node, - MFNetworkTreeMap &network_map, + const nodes::DNode &simulation_node, + nodes::MFNetworkTreeMap &network_map, ResourceCollector &resources, const Map &attribute_inputs) { Vector forces; - for (const DOutputSocket *origin_socket : simulation_node.input(2, "Forces").linked_sockets()) { - const DNode &origin_node = origin_socket->node(); + for (const nodes::DOutputSocket *origin_socket : + simulation_node.input(2, "Forces").linked_sockets()) { + const nodes::DNode &origin_node = origin_socket->node(); if (origin_node.idname() != "SimulationNodeForce") { continue; } @@ -701,12 +706,13 @@ static Vector create_forces_for_particle_simulation( } static Map> collect_forces( - MFNetworkTreeMap &network_map, + nodes::MFNetworkTreeMap &network_map, ResourceCollector &resources, const Map &attribute_inputs) { Map> forces_by_simulation; - for (const DNode *dnode : network_map.tree().nodes_by_type("SimulationNodeParticleSimulation")) { + for (const nodes::DNode *dnode : + network_map.tree().nodes_by_type("SimulationNodeParticleSimulation")) { std::string name = dnode_to_path(*dnode); Vector forces = create_forces_for_particle_simulation( *dnode, network_map, resources, attribute_inputs); @@ -729,12 +735,12 @@ static void simulation_data_update(Depsgraph *depsgraph, Scene *scene, Simulatio Simulation *simulation_orig = (Simulation *)DEG_get_original_id(&simulation_cow->id); - NodeTreeRefMap tree_refs; + nodes::NodeTreeRefMap tree_refs; /* TODO: Use simulation_cow, but need to add depsgraph relations before that. */ - const DerivedNodeTree tree{simulation_orig->nodetree, tree_refs}; + const nodes::DerivedNodeTree tree{simulation_orig->nodetree, tree_refs}; fn::MFNetwork network; ResourceCollector resources; - MFNetworkTreeMap network_map = insert_node_tree_into_mf_network(network, tree, resources); + nodes::MFNetworkTreeMap network_map = insert_node_tree_into_mf_network(network, tree, resources); Map attribute_inputs = deduplicate_attribute_nodes( network, network_map, tree); fn::mf_network_optimization::constant_folding(network, resources); -- cgit v1.2.3