From 2a5c0c34914cc89efb8816edba2cf62a6299a6c1 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 1 Apr 2021 13:10:22 +0200 Subject: Geometry Nodes: add socket value logging capability The node tree evaluator now calls a callback for every used socket with its corresponding value(s). Right now the callback does nothing. However, we can use it to collect attribute name hints, socket values for debugging or data that will be displayed in the spreadsheet. The main difficulty here was to also call the callback for sockets in nodes that are not directly executed (such as group nodes, muted nodes and reroutes). No functional changes are expected. --- source/blender/nodes/NOD_derived_node_tree.hh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'source/blender/nodes/NOD_derived_node_tree.hh') diff --git a/source/blender/nodes/NOD_derived_node_tree.hh b/source/blender/nodes/NOD_derived_node_tree.hh index c29de611e18..e294bef2ea8 100644 --- a/source/blender/nodes/NOD_derived_node_tree.hh +++ b/source/blender/nodes/NOD_derived_node_tree.hh @@ -59,6 +59,7 @@ class DTreeContext { const NodeTreeRef *tree_; /* All the children contexts of this context. */ Map children_; + DerivedNodeTree *derived_tree_; friend DerivedNodeTree; @@ -67,6 +68,7 @@ class DTreeContext { const DTreeContext *parent_context() const; const NodeRef *parent_node() const; const DTreeContext *child_context(const NodeRef &node) const; + const DerivedNodeTree &derived_tree() const; bool is_root() const; }; @@ -117,6 +119,8 @@ class DSocket { operator bool() const; uint64_t hash() const; + + DNode node() const; }; /* A (nullable) reference to an input socket and the context it is in. */ @@ -132,7 +136,7 @@ class DInputSocket : public DSocket { DOutputSocket get_corresponding_group_node_output() const; Vector get_corresponding_group_input_sockets() const; - void foreach_origin_socket(FunctionRef callback) const; + void foreach_origin_socket(FunctionRef origin_fn) const; }; /* A (nullable) reference to an output socket and the context it is in. */ @@ -148,7 +152,8 @@ class DOutputSocket : public DSocket { DInputSocket get_corresponding_group_node_input() const; DInputSocket get_active_corresponding_group_output_socket() const; - void foreach_target_socket(FunctionRef callback) const; + void foreach_target_socket(FunctionRef target_fn, + FunctionRef skipped_fn) const; }; class DerivedNodeTree { @@ -214,6 +219,11 @@ inline const DTreeContext *DTreeContext::child_context(const NodeRef &node) cons return children_.lookup_default(&node, nullptr); } +inline const DerivedNodeTree &DTreeContext::derived_tree() const +{ + return *derived_tree_; +} + inline bool DTreeContext::is_root() const { return parent_context_ == nullptr; @@ -319,6 +329,12 @@ inline uint64_t DSocket::hash() const return get_default_hash_2(context_, socket_ref_); } +inline DNode DSocket::node() const +{ + BLI_assert(socket_ref_ != nullptr); + return {context_, &socket_ref_->node()}; +} + /* -------------------------------------------------------------------- * DInputSocket inline methods. */ -- cgit v1.2.3