[Bf-blender-cvs] [e49edb2ef19] functions: actually read socket value
Jacques Lucke
noreply at git.blender.org
Mon Feb 11 18:30:30 CET 2019
Commit: e49edb2ef197f6815df87c7b716134f0ead6fbf7
Author: Jacques Lucke
Date: Mon Feb 11 17:13:31 2019 +0100
Branches: functions
https://developer.blender.org/rBe49edb2ef197f6815df87c7b716134f0ead6fbf7
actually read socket value
===================================================================
M source/blender/functions/function_nodes/function_nodes.cpp
M source/blender/functions/function_nodes/function_nodes.hpp
M source/blender/modifiers/intern/MOD_functiondeform.c
===================================================================
diff --git a/source/blender/functions/function_nodes/function_nodes.cpp b/source/blender/functions/function_nodes/function_nodes.cpp
index 50916eeceab..eb2dd2f6763 100644
--- a/source/blender/functions/function_nodes/function_nodes.cpp
+++ b/source/blender/functions/function_nodes/function_nodes.cpp
@@ -5,10 +5,13 @@
#include "BKE_node.h"
#include "BKE_idprop.h"
+#include "RNA_access.h"
+
namespace FN::FunctionNodes {
using SocketMap = SmallMap<bNodeSocket *, Socket>;
typedef void (*InsertInGraphFunction)(
+ const FunctionNodeTree &tree,
SharedDataFlowGraph &graph,
SocketMap &map,
bNode *bnode);
@@ -23,6 +26,7 @@ namespace FN::FunctionNodes {
};
static void insert_add_floats_node(
+ const FunctionNodeTree &UNUSED(tree),
SharedDataFlowGraph &graph,
SocketMap &socket_map,
bNode *bnode)
@@ -60,6 +64,7 @@ namespace FN::FunctionNodes {
};
static void insert_combine_vector_node(
+ const FunctionNodeTree &UNUSED(tree),
SharedDataFlowGraph &graph,
SocketMap &socket_map,
bNode *bnode)
@@ -86,18 +91,19 @@ namespace FN::FunctionNodes {
class FloatSocketInput : public FN::TupleCallBody {
private:
+ bNodeTree *m_btree;
bNodeSocket *m_bsocket;
public:
- FloatSocketInput(bNodeSocket *bsocket)
- : m_bsocket(bsocket) {}
+ FloatSocketInput(bNodeTree *btree, bNodeSocket *bsocket)
+ : m_btree(btree), m_bsocket(bsocket) {}
virtual void call(const Tuple &UNUSED(fn_in), Tuple &fn_out) const
{
- // PointerRNA ptr;
- // RNA_pointer_create(m_btree, &RNA_NodeSocket, m_bsocket, &ptr);
- // float value = RNA_float_get(&ptr, "value");
- fn_out.set<float>(0, 0.0f);
+ PointerRNA ptr;
+ RNA_pointer_create(&m_btree->id, &RNA_NodeSocket, m_bsocket, &ptr);
+ float value = RNA_float_get(&ptr, "value");
+ fn_out.set<float>(0, value);
}
};
@@ -130,6 +136,7 @@ namespace FN::FunctionNodes {
}
static const Node *get_input_node_for_socket(
+ const FunctionNodeTree &tree,
SharedDataFlowGraph &graph,
bNodeSocket *bsocket)
{
@@ -138,7 +145,7 @@ namespace FN::FunctionNodes {
if (type == Types::get_float_type()) {
auto fn = SharedFunction::New("Float Input", Signature(
{}, {OutputParameter("Value", Types::get_float_type())}));
- fn->add_body(new FloatSocketInput(bsocket));
+ fn->add_body(new FloatSocketInput(tree.orig_tree(), bsocket));
return graph->insert(fn);
}
else if (type == Types::get_fvec3_type()) {
@@ -154,11 +161,12 @@ namespace FN::FunctionNodes {
}
static void insert_input_socket_node(
+ const FunctionNodeTree &tree,
SharedDataFlowGraph &graph,
Socket socket,
bNodeSocket *bsocket)
{
- const Node *node = get_input_node_for_socket(graph, bsocket);
+ const Node *node = get_input_node_for_socket(tree, graph, bsocket);
graph->link(node->output(0), socket);
}
@@ -172,6 +180,7 @@ namespace FN::FunctionNodes {
}
static void insert_output_node(
+ const FunctionNodeTree &UNUSED(tree),
SharedDataFlowGraph &graph,
SocketMap &socket_map,
bNode *bnode)
@@ -202,12 +211,13 @@ namespace FN::FunctionNodes {
}
static void insert_input_node(
+ const FunctionNodeTree &tree,
SharedDataFlowGraph &graph,
SocketMap &socket_map,
bNode *bnode)
{
for (bNodeSocket *bsocket : bSocketList(&bnode->outputs)) {
- const Node *node = get_input_node_for_socket(graph, bsocket);
+ const Node *node = get_input_node_for_socket(tree, graph, bsocket);
socket_map.add(bsocket, node->output(0));
}
}
@@ -240,7 +250,7 @@ namespace FN::FunctionNodes {
for (bNode *bnode : this->nodes()) {
auto insert = inserters.lookup(bnode->idname);
- insert(graph, socket_map, bnode);
+ insert(*this, graph, socket_map, bnode);
if (is_input_node(bnode)) {
for (bNodeSocket *bsocket : bSocketList(&bnode->outputs)) {
@@ -266,7 +276,7 @@ namespace FN::FunctionNodes {
for (bNodeSocket *bsocket : bSocketList(&bnode->inputs)) {
Socket socket = socket_map.lookup(bsocket);
if (!socket.is_linked()) {
- insert_input_socket_node(graph, socket, bsocket);
+ insert_input_socket_node(*this, graph, socket, bsocket);
}
}
}
diff --git a/source/blender/functions/function_nodes/function_nodes.hpp b/source/blender/functions/function_nodes/function_nodes.hpp
index e671b072330..e78530ae4f2 100644
--- a/source/blender/functions/function_nodes/function_nodes.hpp
+++ b/source/blender/functions/function_nodes/function_nodes.hpp
@@ -16,6 +16,11 @@ namespace FN::FunctionNodes {
FunctionNodeTree(bNodeTree *tree)
: m_tree(tree) {}
+ bNodeTree *orig_tree() const
+ {
+ return m_tree;
+ }
+
bNodeList nodes() const
{
return bNodeList(&m_tree->nodes);
diff --git a/source/blender/modifiers/intern/MOD_functiondeform.c b/source/blender/modifiers/intern/MOD_functiondeform.c
index 400b7d1d15e..fee920e3d5c 100644
--- a/source/blender/modifiers/intern/MOD_functiondeform.c
+++ b/source/blender/modifiers/intern/MOD_functiondeform.c
@@ -51,12 +51,17 @@
#include "FN_functions.h"
+bNodeTree *get_node_tree()
+{
+ return (bNodeTree *)G.main->nodetree.first;
+}
+
static void do_deformation(
FunctionDeformModifierData *fdmd,
float (*vertexCos)[3],
int numVerts)
{
- FnFunction fn = FN_testing((bNodeTree *)G.main->nodetree.first);
+ FnFunction fn = FN_testing(get_node_tree());
// FnFunction fn = FN_get_generated_function();
FnCallable fn_call = FN_function_get_callable(fn);
BLI_assert(fn_call);
@@ -112,6 +117,11 @@ static bool dependsOnTime(ModifierData *UNUSED(md))
return true;
}
+static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
+{
+ FunctionDeformModifierData *bmd = (FunctionDeformModifierData *)md;
+}
+
ModifierTypeInfo modifierType_FunctionDeform = {
/* name */ "Function Deform",
@@ -137,7 +147,7 @@ ModifierTypeInfo modifierType_FunctionDeform = {
/* requiredDataMask */ NULL,
/* freeData */ NULL,
/* isDisabled */ NULL,
- /* updateDepsgraph */ NULL,
+ /* updateDepsgraph */ updateDepsgraph,
/* dependsOnTime */ dependsOnTime,
/* dependsOnNormals */ NULL,
/* foreachObjectLink */ NULL,
More information about the Bf-blender-cvs
mailing list