[Bf-blender-cvs] [be0ed93f99e] functions: use indexed node tree in more places
Jacques Lucke
noreply at git.blender.org
Thu Jul 4 16:46:02 CEST 2019
Commit: be0ed93f99e133edc721744acd2ba5bd3a7b5f2d
Author: Jacques Lucke
Date: Thu Jul 4 13:44:33 2019 +0200
Branches: functions
https://developer.blender.org/rBbe0ed93f99e133edc721744acd2ba5bd3a7b5f2d
use indexed node tree in more places
===================================================================
M source/blender/blenkernel/BKE_node_tree.hpp
M source/blender/functions/frontends/data_flow_nodes/builder.cpp
M source/blender/functions/frontends/data_flow_nodes/builder.hpp
M source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
===================================================================
diff --git a/source/blender/blenkernel/BKE_node_tree.hpp b/source/blender/blenkernel/BKE_node_tree.hpp
index f6f8373f37b..961582d6b82 100644
--- a/source/blender/blenkernel/BKE_node_tree.hpp
+++ b/source/blender/blenkernel/BKE_node_tree.hpp
@@ -42,7 +42,8 @@ struct SingleOriginLink {
* - Which node corresponds to a socket?
* - Which other sockets are connected to a socket (with and without reroutes)?
*
- * This data structure does some preprocessing to make these queries more efficient.
+ * This data structure does some preprocessing to make these queries more efficient. It is only
+ * valid as long as the underlying node tree is not modified.
*/
class IndexedNodeTree {
public:
diff --git a/source/blender/functions/frontends/data_flow_nodes/builder.cpp b/source/blender/functions/frontends/data_flow_nodes/builder.cpp
index feefdb763f7..1f912e91cce 100644
--- a/source/blender/functions/frontends/data_flow_nodes/builder.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/builder.cpp
@@ -98,14 +98,14 @@ DFGB_Node *BTreeGraphBuilder::insert_matching_function(SharedFunction &fn, bNode
DFGB_Node *BTreeGraphBuilder::insert_function(SharedFunction &fn, bNode *bnode)
{
BLI_assert(bnode != nullptr);
- NodeSource *source = m_graph.new_source_info<NodeSource>(m_btree, bnode);
+ NodeSource *source = m_graph.new_source_info<NodeSource>(m_indexed_btree.btree(), bnode);
return m_graph.insert_function(fn, source);
}
DFGB_Node *BTreeGraphBuilder::insert_function(SharedFunction &fn, bNodeLink *blink)
{
BLI_assert(blink != nullptr);
- LinkSource *source = m_graph.new_source_info<LinkSource>(m_btree, blink);
+ LinkSource *source = m_graph.new_source_info<LinkSource>(m_indexed_btree.btree(), blink);
return m_graph.insert_function(fn, source);
}
@@ -186,7 +186,7 @@ bool BTreeGraphBuilder::check_if_sockets_are_mapped(struct bNode *bnode,
if (this->is_data_socket(bsocket)) {
if (!m_socket_map.contains(bsocket)) {
std::cout << "Data DFGB_Socket not mapped: " << std::endl;
- std::cout << " Tree: " << m_btree->id.name << std::endl;
+ std::cout << " Tree: " << m_indexed_btree.btree_id()->name << std::endl;
std::cout << " DFGB_Node: " << bnode->name << std::endl;
if (bsocket->in_out == SOCK_IN) {
std::cout << " Input";
@@ -211,12 +211,12 @@ bool BTreeGraphBuilder::verify_data_sockets_mapped(struct bNode *bnode) const
struct bNodeTree *BTreeGraphBuilder::btree() const
{
- return m_btree;
+ return m_indexed_btree.btree();
}
struct ID *BTreeGraphBuilder::btree_id() const
{
- return &m_btree->id;
+ return m_indexed_btree.btree_id();
}
bool BTreeGraphBuilder::is_data_socket(bNodeSocket *bsocket) const
diff --git a/source/blender/functions/frontends/data_flow_nodes/builder.hpp b/source/blender/functions/frontends/data_flow_nodes/builder.hpp
index 561d0c379b9..dd3f48a89fe 100644
--- a/source/blender/functions/frontends/data_flow_nodes/builder.hpp
+++ b/source/blender/functions/frontends/data_flow_nodes/builder.hpp
@@ -12,18 +12,19 @@ namespace DataFlowNodes {
using BKE::bLinkList;
using BKE::bNodeList;
using BKE::bSocketList;
+using BKE::IndexedNodeTree;
class BTreeGraphBuilder {
private:
DataFlowGraphBuilder &m_graph;
- struct bNodeTree *m_btree;
+ IndexedNodeTree &m_indexed_btree;
SmallMap<struct bNodeSocket *, DFGB_Socket> &m_socket_map;
public:
- BTreeGraphBuilder(struct bNodeTree *btree,
+ BTreeGraphBuilder(IndexedNodeTree &indexed_btree,
DataFlowGraphBuilder &graph,
SmallMap<struct bNodeSocket *, DFGB_Socket> &socket_map)
- : m_graph(graph), m_btree(btree), m_socket_map(socket_map)
+ : m_graph(graph), m_indexed_btree(indexed_btree), m_socket_map(socket_map)
{
}
diff --git a/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp b/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
index 6e68e7d1111..8b38190f337 100644
--- a/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
@@ -197,10 +197,12 @@ static FunctionGraph finalize_function_graph(DataFlowGraphBuilder &builder,
Optional<FunctionGraph> generate_function_graph(bNodeTree *btree)
{
+ IndexedNodeTree indexed_btree(btree);
+
DataFlowGraphBuilder graph_builder;
SmallMap<struct bNodeSocket *, DFGB_Socket> socket_map;
- BTreeGraphBuilder builder(btree, graph_builder, socket_map);
+ BTreeGraphBuilder builder(indexed_btree, graph_builder, socket_map);
GraphInserters &inserters = get_standard_inserters();
if (!insert_functions_for_bnodes(builder, inserters)) {
More information about the Bf-blender-cvs
mailing list