[Bf-blender-cvs] [a90dca0ff5d] functions: also keep track of link sources
Jacques Lucke
noreply at git.blender.org
Tue Mar 26 11:22:29 CET 2019
Commit: a90dca0ff5da3d6bcf999e4bccd2092447bd8040
Author: Jacques Lucke
Date: Tue Mar 26 11:20:33 2019 +0100
Branches: functions
https://developer.blender.org/rBa90dca0ff5da3d6bcf999e4bccd2092447bd8040
also keep track of link sources
===================================================================
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/inserters.cpp
M source/blender/functions/frontends/data_flow_nodes/inserters.hpp
===================================================================
diff --git a/source/blender/functions/frontends/data_flow_nodes/builder.cpp b/source/blender/functions/frontends/data_flow_nodes/builder.cpp
index 8220dc8f698..a2e9e073756 100644
--- a/source/blender/functions/frontends/data_flow_nodes/builder.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/builder.cpp
@@ -6,6 +6,8 @@
#include "RNA_access.h"
+#include <sstream>
+
namespace FN { namespace DataFlowNodes {
class NodeSource : public SourceInfo {
@@ -19,21 +21,50 @@ namespace FN { namespace DataFlowNodes {
std::string to_string() const override
{
- return m_btree->id.name + std::string(" : ") + m_bnode->name;
+ std::stringstream ss;
+ ss << "NodeTree \"" << m_btree->id.name + 2 << "\"";
+ ss << " - Node \"" << m_bnode->name << "\"";
+ return ss.str();
}
};
- Node *Builder::insert_function(SharedFunction &function)
+ class LinkSource : public SourceInfo {
+ private:
+ bNodeTree *m_btree;
+ bNodeLink *m_blink;
+
+ public:
+ LinkSource(bNodeTree *btree, bNodeLink *blink)
+ : m_btree(btree), m_blink(blink) {}
+
+ std::string to_string() const override
+ {
+ std::stringstream ss;
+ ss << "NodeTree \"" << m_btree->id.name + 2 << "\"";
+ ss << " - Link";
+ return ss.str();
+ }
+ };
+
+ Node *Builder::insert_function(SharedFunction &fn)
{
- return m_graph->insert(function);
+ return m_graph->insert(fn);
}
- Node *Builder::insert_function(SharedFunction &function, bNodeTree *btree, bNode *bnode)
+ Node *Builder::insert_function(SharedFunction &fn, bNodeTree *btree, bNode *bnode)
{
BLI_assert(btree != nullptr);
BLI_assert(bnode != nullptr);
NodeSource *source = m_graph->new_source_info<NodeSource>(btree, bnode);
- return m_graph->insert(function, source);
+ return m_graph->insert(fn, source);
+ }
+
+ Node *Builder::insert_function(SharedFunction &fn, bNodeTree *btree, bNodeLink *blink)
+ {
+ BLI_assert(btree != nullptr);
+ BLI_assert(blink != nullptr);
+ LinkSource *source = m_graph->new_source_info<LinkSource>(btree, blink);
+ return m_graph->insert(fn, source);
}
void Builder::insert_link(Socket a, Socket b)
diff --git a/source/blender/functions/frontends/data_flow_nodes/builder.hpp b/source/blender/functions/frontends/data_flow_nodes/builder.hpp
index 89690bc9e06..255cb3268e5 100644
--- a/source/blender/functions/frontends/data_flow_nodes/builder.hpp
+++ b/source/blender/functions/frontends/data_flow_nodes/builder.hpp
@@ -27,8 +27,9 @@ namespace FN { namespace DataFlowNodes {
SocketMap &socket_map)
: m_graph(graph), m_socket_map(socket_map) {}
- Node *insert_function(SharedFunction &function);
- Node *insert_function(SharedFunction &function, struct bNodeTree *btree, struct bNode *bnode);
+ Node *insert_function(SharedFunction &fn);
+ Node *insert_function(SharedFunction &fn, struct bNodeTree *btree, struct bNode *bnode);
+ Node *insert_function(SharedFunction &fn, struct bNodeTree *btree, struct bNodeLink *blink);
void insert_link(Socket a, Socket b);
void map_socket(Socket socket, struct bNodeSocket *bsocket);
diff --git a/source/blender/functions/frontends/data_flow_nodes/inserters.cpp b/source/blender/functions/frontends/data_flow_nodes/inserters.cpp
index 56b8ed81130..dc8243767c0 100644
--- a/source/blender/functions/frontends/data_flow_nodes/inserters.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/inserters.cpp
@@ -66,12 +66,13 @@ namespace FN { namespace DataFlowNodes {
{
auto inserter = [getter](
Builder &builder,
- const BuilderContext &UNUSED(ctx),
+ const BuilderContext &ctx,
+ bNodeLink *blink,
Socket from,
Socket to)
{
auto fn = getter();
- Node *node = builder.insert_function(fn);
+ Node *node = builder.insert_function(fn, ctx.btree(), blink);
builder.insert_link(from, node->input(0));
builder.insert_link(node->output(0), to);
};
@@ -174,7 +175,7 @@ namespace FN { namespace DataFlowNodes {
auto key = std::pair<std::string, std::string>(from_type, to_type);
if (m_conversion_inserters.contains(key)) {
auto inserter = m_conversion_inserters.lookup(key);
- inserter(builder, ctx, from_socket, to_socket);
+ inserter(builder, ctx, blink, from_socket, to_socket);
return true;
}
diff --git a/source/blender/functions/frontends/data_flow_nodes/inserters.hpp b/source/blender/functions/frontends/data_flow_nodes/inserters.hpp
index d87f9efd1bd..9625bede1d9 100644
--- a/source/blender/functions/frontends/data_flow_nodes/inserters.hpp
+++ b/source/blender/functions/frontends/data_flow_nodes/inserters.hpp
@@ -23,6 +23,7 @@ namespace FN { namespace DataFlowNodes {
typedef std::function<void (
Builder &builder,
const BuilderContext &ctx,
+ bNodeLink *blink,
Socket from,
Socket to)> ConversionInserter;
More information about the Bf-blender-cvs
mailing list