Commit: a0cff9838a3d857e6e8018f7bbca474664f2fcb4 Author: Jacques Lucke Date: Tue Jul 2 15:05:38 2019 +0200 Branches: functions https://developer.blender.org/rBa0cff9838a3d857e6e8018f7bbca474664f2fcb4
utility to get nodes with idname =================================================================== M source/blender/blenkernel/BKE_node_tree.hpp M source/blender/blenkernel/intern/node_tree.cpp M source/blender/simulations/bparticles/c_wrapper.cpp M tests/gtests/functions/CMakeLists.txt =================================================================== diff --git a/source/blender/blenkernel/BKE_node_tree.hpp b/source/blender/blenkernel/BKE_node_tree.hpp index 2542b70e25b..68c4c1ac864 100644 --- a/source/blender/blenkernel/BKE_node_tree.hpp +++ b/source/blender/blenkernel/BKE_node_tree.hpp @@ -2,6 +2,7 @@ #include "DNA_node_types.h" +#include "BLI_string_ref.hpp" #include "BLI_array_ref.hpp" #include "BLI_small_map.hpp" #include "BLI_small_vector.hpp" @@ -13,10 +14,11 @@ using BLI::ArrayRef; using BLI::ListBaseWrapper; using BLI::SmallMap; using BLI::SmallVector; +using BLI::StringRef; -using bNodeList = ListBaseWrapper<struct bNode, true>; -using bLinkList = ListBaseWrapper<struct bNodeLink, true>; -using bSocketList = ListBaseWrapper<struct bNodeSocket, true>; +using bNodeList = ListBaseWrapper<struct bNode *, true>; +using bLinkList = ListBaseWrapper<struct bNodeLink *, true>; +using bSocketList = ListBaseWrapper<struct bNodeSocket *, true>; class BNodeTreeLookup { public: @@ -33,10 +35,13 @@ class BNodeTreeLookup { return m_data_links; } + SmallVector<bNode *> nodes_with_idname(StringRef idname); + private: bool is_reroute(bNode *bnode); bNodeSocket *try_find_data_origin(bNodeSocket *bsocket); + SmallVector<bNode *> m_nodes; SmallMap<bNodeSocket *, bNode *> m_node_by_socket; SmallMap<bNodeSocket *, bNodeSocket *> m_direct_origin; SmallVector<DataLink> m_data_links; diff --git a/source/blender/blenkernel/intern/node_tree.cpp b/source/blender/blenkernel/intern/node_tree.cpp index 8eb7dbe8681..5469f3d5c89 100644 --- a/source/blender/blenkernel/intern/node_tree.cpp +++ b/source/blender/blenkernel/intern/node_tree.cpp @@ -2,9 +2,9 @@ namespace BKE { -BNodeTreeLookup::BNodeTreeLookup(bNodeTree *btree) +BNodeTreeLookup::BNodeTreeLookup(bNodeTree *btree) : m_nodes(btree->nodes, true) { - for (bNode *bnode : bNodeList(&btree->nodes)) { + for (bNode *bnode : m_nodes) { for (bNodeSocket *bsocket : bSocketList(&bnode->inputs)) { m_node_by_socket.add(bsocket, bnode); } @@ -54,4 +54,15 @@ bool BNodeTreeLookup::is_reroute(bNode *bnode) return STREQ(bnode->idname, "NodeReroute"); } +SmallVector<bNode *> BNodeTreeLookup::nodes_with_idname(StringRef idname) +{ + SmallVector<bNode *> result; + for (bNode *bnode : m_nodes) { + if (bnode->idname == idname) { + result.append(bnode); + } + } + return result; +} + } // namespace BKE diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp index 0ff9c7f5412..10ae8414f56 100644 --- a/source/blender/simulations/bparticles/c_wrapper.cpp +++ b/source/blender/simulations/bparticles/c_wrapper.cpp @@ -14,6 +14,7 @@ #include "BKE_bvhutils.h" #include "BKE_mesh.h" #include "BKE_customdata.h" +#include "BKE_node_tree.hpp" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -33,6 +34,7 @@ using namespace BParticles; +using BKE::BNodeTreeLookup; using BLI::ArrayRef; using BLI::float3; using BLI::SmallVector; @@ -218,6 +220,11 @@ class ModifierStepDescription : public StepDescription { } }; +// ModifierStepDescription *step_description_from_node_tree(bNodeTree *btree) +// { +// BNodeTreeLookup btree_lookup(btree); +// } + void BParticles_simulate_modifier(NodeParticlesModifierData *npmd, Depsgraph *UNUSED(depsgraph), BParticlesState state_c) diff --git a/tests/gtests/functions/CMakeLists.txt b/tests/gtests/functions/CMakeLists.txt index a41144d7937..9467433f147 100644 --- a/tests/gtests/functions/CMakeLists.txt +++ b/tests/gtests/functions/CMakeLists.txt @@ -23,6 +23,7 @@ set(INC .. ../../../source/blender/blenlib ../../../source/blender/functions + ../../../source/blender/makesdna ../../../intern/guardedalloc ${LLVM_INCLUDE_DIRS} ) _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs