diff options
author | Jacques Lucke <jacques@blender.org> | 2021-03-04 20:01:49 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-03-04 20:01:49 +0300 |
commit | 2fb26211dbd37dfa45576a68b14eb6a479b9bafa (patch) | |
tree | 85cf018b6ecfeda82d85c8ffad634fda873c8fcd | |
parent | 238b05ce304ccde556f1bf778c78e8cef8ad521a (diff) |
rename new type to derived node tree
-rw-r--r-- | source/blender/modifiers/intern/MOD_nodes.cc | 94 | ||||
-rw-r--r-- | source/blender/nodes/NOD_XXX_node_tree.hh | 221 | ||||
-rw-r--r-- | source/blender/nodes/NOD_geometry_exec.hh | 4 | ||||
-rw-r--r-- | source/blender/nodes/NOD_node_tree_multi_function.hh | 74 | ||||
-rw-r--r-- | source/blender/nodes/function/nodes/node_fn_random_float.cc | 4 | ||||
-rw-r--r-- | source/blender/nodes/intern/node_tree_multi_function.cc | 44 | ||||
-rw-r--r-- | source/blender/nodes/intern/xxx_node_tree.cc | 81 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_math.cc | 6 |
8 files changed, 259 insertions, 269 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index df1c1032d89..5dc6f0cd187 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -93,7 +93,7 @@ using blender::fn::GMutablePointer; using blender::fn::GValueMap; using blender::nodes::GeoNodeExecParams; using namespace blender::fn::multi_function_types; -using namespace blender::nodes::xxx_node_tree_types; +using namespace blender::nodes::derived_node_tree_types; static void initData(ModifierData *md) { @@ -256,8 +256,8 @@ static bool isDisabled(const struct Scene *UNUSED(scene), class GeometryNodesEvaluator { private: blender::LinearAllocator<> allocator_; - Map<std::pair<XXXInputSocket, XXXOutputSocket>, GMutablePointer> value_by_input_; - Vector<XXXInputSocket> group_outputs_; + Map<std::pair<DInputSocket, DOutputSocket>, GMutablePointer> value_by_input_; + Vector<DInputSocket> group_outputs_; blender::nodes::MultiFunctionByNode &mf_by_node_; const blender::nodes::DataTypeConversions &conversions_; const PersistentDataHandleMap &handle_map_; @@ -266,8 +266,8 @@ class GeometryNodesEvaluator { Depsgraph *depsgraph_; public: - GeometryNodesEvaluator(const Map<XXXOutputSocket, GMutablePointer> &group_input_data, - Vector<XXXInputSocket> group_outputs, + GeometryNodesEvaluator(const Map<DOutputSocket, GMutablePointer> &group_input_data, + Vector<DInputSocket> group_outputs, blender::nodes::MultiFunctionByNode &mf_by_node, const PersistentDataHandleMap &handle_map, const Object *self_object, @@ -289,7 +289,7 @@ class GeometryNodesEvaluator { Vector<GMutablePointer> execute() { Vector<GMutablePointer> results; - for (const XXXInputSocket &group_output : group_outputs_) { + for (const DInputSocket &group_output : group_outputs_) { Vector<GMutablePointer> result = this->get_input_values(group_output); results.append(result[0]); } @@ -300,16 +300,15 @@ class GeometryNodesEvaluator { } private: - Vector<GMutablePointer> get_input_values(const XXXInputSocket socket_to_compute) + Vector<GMutablePointer> get_input_values(const DInputSocket socket_to_compute) { - Vector<XXXSocket> from_sockets; - socket_to_compute.foreach_origin_socket( - [&](XXXSocket socket) { from_sockets.append(socket); }); + Vector<DSocket> from_sockets; + socket_to_compute.foreach_origin_socket([&](DSocket socket) { from_sockets.append(socket); }); /* Multi-input sockets contain a vector of inputs. */ if (socket_to_compute->is_multi_input_socket()) { Vector<GMutablePointer> values; - for (const XXXSocket from_socket : from_sockets) { + for (const DSocket from_socket : from_sockets) { GMutablePointer value = get_input_from_incoming_link(socket_to_compute, from_socket); values.append(value); } @@ -322,18 +321,18 @@ class GeometryNodesEvaluator { return {get_unlinked_input_value(socket_to_compute, type)}; } - const XXXSocket from_socket = from_sockets[0]; + const DSocket from_socket = from_sockets[0]; GMutablePointer value = this->get_input_from_incoming_link(socket_to_compute, from_socket); return {value}; } - GMutablePointer get_input_from_incoming_link(const XXXInputSocket socket_to_compute, - const XXXSocket from_socket) + GMutablePointer get_input_from_incoming_link(const DInputSocket socket_to_compute, + const DSocket from_socket) { if (from_socket->is_output()) { - const XXXOutputSocket from_output_socket{from_socket}; - const std::pair<XXXInputSocket, XXXOutputSocket> key = std::make_pair(socket_to_compute, - from_output_socket); + const DOutputSocket from_output_socket{from_socket}; + const std::pair<DInputSocket, DOutputSocket> key = std::make_pair(socket_to_compute, + from_output_socket); std::optional<GMutablePointer> value = value_by_input_.pop_try(key); if (value.has_value()) { /* This input has been computed before, return it directly. */ @@ -347,13 +346,13 @@ class GeometryNodesEvaluator { /* Get value from an unlinked input socket. */ const CPPType &type = *blender::nodes::socket_cpp_type_get(*socket_to_compute->typeinfo()); - const XXXInputSocket from_input_socket{from_socket}; + const DInputSocket from_input_socket{from_socket}; return {get_unlinked_input_value(from_input_socket, type)}; } - void compute_output_and_forward(const XXXOutputSocket socket_to_compute) + void compute_output_and_forward(const DOutputSocket socket_to_compute) { - const XXXNode node{socket_to_compute.context(), &socket_to_compute->node()}; + const DNode node{socket_to_compute.context(), &socket_to_compute->node()}; if (!socket_to_compute->is_available()) { /* If the output is not available, use a default value. */ @@ -394,7 +393,7 @@ class GeometryNodesEvaluator { } } - void execute_node(const XXXNode node, GeoNodeExecParams params) + void execute_node(const DNode node, GeoNodeExecParams params) { const bNode &bnode = params.node(); @@ -417,7 +416,7 @@ class GeometryNodesEvaluator { this->execute_unknown_node(node, params); } - void store_ui_hints(const XXXNode node, GeoNodeExecParams params) const + void store_ui_hints(const DNode node, GeoNodeExecParams params) const { for (const InputSocketRef *socket_ref : node->inputs()) { if (!socket_ref->is_available()) { @@ -445,7 +444,7 @@ class GeometryNodesEvaluator { } } - void execute_multi_function_node(const XXXNode node, + void execute_multi_function_node(const DNode node, GeoNodeExecParams params, const MultiFunction &fn) { @@ -483,7 +482,7 @@ class GeometryNodesEvaluator { } } - void execute_unknown_node(const XXXNode node, GeoNodeExecParams params) + void execute_unknown_node(const DNode node, GeoNodeExecParams params) { for (const OutputSocketRef *socket : node->outputs()) { if (socket->is_available()) { @@ -493,19 +492,18 @@ class GeometryNodesEvaluator { } } - void forward_to_inputs(const XXXOutputSocket from_socket, GMutablePointer value_to_forward) + void forward_to_inputs(const DOutputSocket from_socket, GMutablePointer value_to_forward) { /* For all sockets that are linked with the from_socket push the value to their node. */ - Vector<XXXInputSocket> to_sockets_all; + Vector<DInputSocket> to_sockets_all; from_socket.foreach_target_socket( - [&](XXXInputSocket to_socket) { to_sockets_all.append(to_socket); }); + [&](DInputSocket to_socket) { to_sockets_all.append(to_socket); }); const CPPType &from_type = *value_to_forward.type(); - Vector<XXXInputSocket> to_sockets_same_type; - for (const XXXInputSocket &to_socket : to_sockets_all) { + Vector<DInputSocket> to_sockets_same_type; + for (const DInputSocket &to_socket : to_sockets_all) { const CPPType &to_type = *blender::nodes::socket_cpp_type_get(*to_socket->typeinfo()); - const std::pair<XXXInputSocket, XXXOutputSocket> key = std::make_pair(to_socket, - from_socket); + const std::pair<DInputSocket, DOutputSocket> key = std::make_pair(to_socket, from_socket); if (from_type == to_type) { to_sockets_same_type.append(to_socket); } @@ -527,23 +525,21 @@ class GeometryNodesEvaluator { } else if (to_sockets_same_type.size() == 1) { /* This value is only used on one input socket, no need to copy it. */ - const XXXInputSocket to_socket = to_sockets_same_type[0]; - const std::pair<XXXInputSocket, XXXOutputSocket> key = std::make_pair(to_socket, - from_socket); + const DInputSocket to_socket = to_sockets_same_type[0]; + const std::pair<DInputSocket, DOutputSocket> key = std::make_pair(to_socket, from_socket); add_value_to_input_socket(key, value_to_forward); } else { /* Multiple inputs use the value, make a copy for every input except for one. */ - const XXXInputSocket first_to_socket = to_sockets_same_type[0]; - Span<XXXInputSocket> other_to_sockets = to_sockets_same_type.as_span().drop_front(1); + const DInputSocket first_to_socket = to_sockets_same_type[0]; + Span<DInputSocket> other_to_sockets = to_sockets_same_type.as_span().drop_front(1); const CPPType &type = *value_to_forward.type(); - const std::pair<XXXInputSocket, XXXOutputSocket> first_key = std::make_pair(first_to_socket, - from_socket); - add_value_to_input_socket(first_key, value_to_forward); - for (const XXXInputSocket &to_socket : other_to_sockets) { - const std::pair<XXXInputSocket, XXXOutputSocket> key = std::make_pair(to_socket, + const std::pair<DInputSocket, DOutputSocket> first_key = std::make_pair(first_to_socket, from_socket); + add_value_to_input_socket(first_key, value_to_forward); + for (const DInputSocket &to_socket : other_to_sockets) { + const std::pair<DInputSocket, DOutputSocket> key = std::make_pair(to_socket, from_socket); void *buffer = allocator_.allocate(type.size(), type.alignment()); type.copy_to_uninitialized(value_to_forward.get(), buffer); add_value_to_input_socket(key, GMutablePointer{type, buffer}); @@ -551,13 +547,13 @@ class GeometryNodesEvaluator { } } - void add_value_to_input_socket(const std::pair<XXXInputSocket, XXXOutputSocket> key, + void add_value_to_input_socket(const std::pair<DInputSocket, DOutputSocket> key, GMutablePointer value) { value_by_input_.add_new(key, value); } - GMutablePointer get_unlinked_input_value(const XXXInputSocket &socket, + GMutablePointer get_unlinked_input_value(const DInputSocket &socket, const CPPType &required_type) { bNodeSocket *bsocket = socket->bsocket(); @@ -994,7 +990,7 @@ static void initialize_group_input(NodesModifierData &nmd, } static void fill_data_handle_map(const NodesModifierSettings &settings, - const XXXNodeTree &tree, + const DerivedNodeTree &tree, PersistentDataHandleMap &handle_map) { Set<ID *> used_ids; @@ -1026,7 +1022,7 @@ static void reset_tree_ui_storage(Span<const blender::nodes::NodeTreeRef *> tree * Currently, this uses a fairly basic and inefficient algorithm that might compute things more * often than necessary. It's going to be replaced soon. */ -static GeometrySet compute_geometry(const XXXNodeTree &tree, +static GeometrySet compute_geometry(const DerivedNodeTree &tree, Span<const OutputSocketRef *> group_input_sockets, const InputSocketRef &socket_to_compute, GeometrySet input_geometry_set, @@ -1040,9 +1036,9 @@ static GeometrySet compute_geometry(const XXXNodeTree &tree, PersistentDataHandleMap handle_map; fill_data_handle_map(nmd->settings, tree, handle_map); - Map<XXXOutputSocket, GMutablePointer> group_inputs; + Map<DOutputSocket, GMutablePointer> group_inputs; - const XXXTreeContext *root_context = &tree.root_context(); + const DTreeContext *root_context = &tree.root_context(); if (group_input_sockets.size() > 0) { Span<const OutputSocketRef *> remaining_input_sockets = group_input_sockets; @@ -1065,7 +1061,7 @@ static GeometrySet compute_geometry(const XXXNodeTree &tree, } } - Vector<XXXInputSocket> group_outputs; + Vector<DInputSocket> group_outputs; group_outputs.append({root_context, &socket_to_compute}); GeometryNodesEvaluator evaluator{group_inputs, @@ -1142,7 +1138,7 @@ static void modifyGeometry(ModifierData *md, check_property_socket_sync(ctx->object, md); NodeTreeRefMap tree_refs; - XXXNodeTree tree{*nmd->node_group, tree_refs}; + DerivedNodeTree tree{*nmd->node_group, tree_refs}; if (tree.has_link_cycles()) { BKE_modifier_set_error(ctx->object, md, "Node group has cycles"); diff --git a/source/blender/nodes/NOD_XXX_node_tree.hh b/source/blender/nodes/NOD_XXX_node_tree.hh index cb453f1d13c..4f55e8c140f 100644 --- a/source/blender/nodes/NOD_XXX_node_tree.hh +++ b/source/blender/nodes/NOD_XXX_node_tree.hh @@ -23,331 +23,328 @@ namespace blender::nodes { -class XXXTreeContext; -class XXXNodeTree; +class DTreeContext; +class DerivedNodeTree; -struct XXXNode; -struct XXXSocket; -struct XXXInputSocket; -struct XXXOutputSocket; +struct DNode; +struct DSocket; +struct DInputSocket; +struct DOutputSocket; -class XXXTreeContext { +class DTreeContext { private: - XXXTreeContext *parent_context_; + DTreeContext *parent_context_; const NodeRef *parent_node_; const NodeTreeRef *tree_; - Map<const NodeRef *, XXXTreeContext *> children_; + Map<const NodeRef *, DTreeContext *> children_; - friend XXXNodeTree; + friend DerivedNodeTree; public: const NodeTreeRef &tree() const; - const XXXTreeContext *parent_context() const; + const DTreeContext *parent_context() const; const NodeRef *parent_node() const; - const XXXTreeContext *child_context(const NodeRef &node) const; + const DTreeContext *child_context(const NodeRef &node) const; bool is_root() const; }; -class XXXNode { +class DNode { private: - const XXXTreeContext *context_ = nullptr; + const DTreeContext *context_ = nullptr; const NodeRef *node_ref_ = nullptr; public: - XXXNode() = default; - XXXNode(const XXXTreeContext *context, const NodeRef *node); + DNode() = default; + DNode(const DTreeContext *context, const NodeRef *node); - const XXXTreeContext *context() const; + const DTreeContext *context() const; const NodeRef *node_ref() const; const NodeRef *operator->() const; - friend bool operator==(const XXXNode &a, const XXXNode &b); - friend bool operator!=(const XXXNode &a, const XXXNode &b); + friend bool operator==(const DNode &a, const DNode &b); + friend bool operator!=(const DNode &a, const DNode &b); operator bool() const; uint64_t hash() const; }; -class XXXSocket { +class DSocket { protected: - const XXXTreeContext *context_ = nullptr; + const DTreeContext *context_ = nullptr; const SocketRef *socket_ref_ = nullptr; public: - XXXSocket() = default; - XXXSocket(const XXXTreeContext *context, const SocketRef *socket); - XXXSocket(const XXXInputSocket &input_socket); - XXXSocket(const XXXOutputSocket &output_socket); + DSocket() = default; + DSocket(const DTreeContext *context, const SocketRef *socket); + DSocket(const DInputSocket &input_socket); + DSocket(const DOutputSocket &output_socket); - const XXXTreeContext *context() const; + const DTreeContext *context() const; const SocketRef *socket_ref() const; const SocketRef *operator->() const; - friend bool operator==(const XXXSocket &a, const XXXSocket &b); - friend bool operator!=(const XXXSocket &a, const XXXSocket &b); + friend bool operator==(const DSocket &a, const DSocket &b); + friend bool operator!=(const DSocket &a, const DSocket &b); operator bool() const; uint64_t hash() const; }; -class XXXInputSocket : public XXXSocket { +class DInputSocket : public DSocket { public: - XXXInputSocket() = default; - XXXInputSocket(const XXXTreeContext *context, const InputSocketRef *socket); - explicit XXXInputSocket(const XXXSocket &base_socket); + DInputSocket() = default; + DInputSocket(const DTreeContext *context, const InputSocketRef *socket); + explicit DInputSocket(const DSocket &base_socket); const InputSocketRef *socket_ref() const; const InputSocketRef *operator->() const; - XXXOutputSocket get_corresponding_group_node_output() const; - XXXOutputSocket get_corresponding_group_input_socket() const; + DOutputSocket get_corresponding_group_node_output() const; + DOutputSocket get_corresponding_group_input_socket() const; - void foreach_origin_socket(FunctionRef<void(XXXSocket)> callback) const; + void foreach_origin_socket(FunctionRef<void(DSocket)> callback) const; }; -class XXXOutputSocket : public XXXSocket { +class DOutputSocket : public DSocket { public: - XXXOutputSocket() = default; - XXXOutputSocket(const XXXTreeContext *context, const OutputSocketRef *socket); - explicit XXXOutputSocket(const XXXSocket &base_socket); + DOutputSocket() = default; + DOutputSocket(const DTreeContext *context, const OutputSocketRef *socket); + explicit DOutputSocket(const DSocket &base_socket); const OutputSocketRef *socket_ref() const; const OutputSocketRef *operator->() const; - XXXInputSocket get_corresponding_group_node_input() const; - XXXInputSocket get_corresponding_group_output_socket() const; + DInputSocket get_corresponding_group_node_input() const; + DInputSocket get_corresponding_group_output_socket() const; - void foreach_target_socket(FunctionRef<void(XXXInputSocket)> callback) const; + void foreach_target_socket(FunctionRef<void(DInputSocket)> callback) const; }; -class XXXNodeTree { +class DerivedNodeTree { private: LinearAllocator<> allocator_; - XXXTreeContext *root_context_; + DTreeContext *root_context_; VectorSet<const NodeTreeRef *> used_node_tree_refs_; public: - XXXNodeTree(bNodeTree &btree, NodeTreeRefMap &node_tree_refs); - ~XXXNodeTree(); + DerivedNodeTree(bNodeTree &btree, NodeTreeRefMap &node_tree_refs); + ~DerivedNodeTree(); - const XXXTreeContext &root_context() const; + const DTreeContext &root_context() const; Span<const NodeTreeRef *> used_node_tree_refs() const; bool has_link_cycles() const; - void foreach_node(FunctionRef<void(XXXNode)> callback) const; + void foreach_node(FunctionRef<void(DNode)> callback) const; private: - XXXTreeContext &construct_context_recursively(XXXTreeContext *parent_context, - const NodeRef *parent_node, - bNodeTree &btree, - NodeTreeRefMap &node_tree_refs); - void destruct_context_recursively(XXXTreeContext *context); - - void foreach_node_in_context_recursive(const XXXTreeContext &context, - FunctionRef<void(XXXNode)> callback) const; + DTreeContext &construct_context_recursively(DTreeContext *parent_context, + const NodeRef *parent_node, + bNodeTree &btree, + NodeTreeRefMap &node_tree_refs); + void destruct_context_recursively(DTreeContext *context); + + void foreach_node_in_context_recursive(const DTreeContext &context, + FunctionRef<void(DNode)> callback) const; }; -namespace xxx_node_tree_types { +namespace derived_node_tree_types { using namespace node_tree_ref_types; -using nodes::XXXInputSocket; -using nodes::XXXNode; -using nodes::XXXNodeTree; -using nodes::XXXOutputSocket; -using nodes::XXXSocket; -using nodes::XXXTreeContext; -} // namespace xxx_node_tree_types +using nodes::DerivedNodeTree; +using nodes::DInputSocket; +using nodes::DNode; +using nodes::DOutputSocket; +using nodes::DSocket; +using nodes::DTreeContext; +} // namespace derived_node_tree_types /* -------------------------------------------------------------------- - * XXXTreeContext inline methods. + * DTreeContext inline methods. */ -inline const NodeTreeRef &XXXTreeContext::tree() const +inline const NodeTreeRef &DTreeContext::tree() const { return *tree_; } -inline const XXXTreeContext *XXXTreeContext::parent_context() const +inline const DTreeContext *DTreeContext::parent_context() const { return parent_context_; } -inline const NodeRef *XXXTreeContext::parent_node() const +inline const NodeRef *DTreeContext::parent_node() const { return parent_node_; } -inline const XXXTreeContext *XXXTreeContext::child_context(const NodeRef &node) const +inline const DTreeContext *DTreeContext::child_context(const NodeRef &node) const { return children_.lookup_default(&node, nullptr); } -inline bool XXXTreeContext::is_root() const +inline bool DTreeContext::is_root() const { return parent_context_ == nullptr; } /* -------------------------------------------------------------------- - * XXXNode inline methods. + * DNode inline methods. */ -inline XXXNode::XXXNode(const XXXTreeContext *context, const NodeRef *node_ref) +inline DNode::DNode(const DTreeContext *context, const NodeRef *node_ref) : context_(context), node_ref_(node_ref) { BLI_assert(node_ref == nullptr || &node_ref->tree() == &context->tree()); } -inline const XXXTreeContext *XXXNode::context() const +inline const DTreeContext *DNode::context() const { return context_; } -inline const NodeRef *XXXNode::node_ref() const +inline const NodeRef *DNode::node_ref() const { return node_ref_; } -inline bool operator==(const XXXNode &a, const XXXNode &b) +inline bool operator==(const DNode &a, const DNode &b) { return a.context_ == b.context_ && a.node_ref_ == b.node_ref_; } -inline bool operator!=(const XXXNode &a, const XXXNode &b) +inline bool operator!=(const DNode &a, const DNode &b) { return !(a == b); } -inline XXXNode::operator bool() const +inline DNode::operator bool() const { return node_ref_ != nullptr; } -inline const NodeRef *XXXNode::operator->() const +inline const NodeRef *DNode::operator->() const { return node_ref_; } -inline uint64_t XXXNode::hash() const +inline uint64_t DNode::hash() const { - return DefaultHash<const XXXTreeContext *>{}(context_) ^ - DefaultHash<const NodeRef *>{}(node_ref_); + return DefaultHash<const DTreeContext *>{}(context_) ^ DefaultHash<const NodeRef *>{}(node_ref_); } /* -------------------------------------------------------------------- - * XXXSocket inline methods. + * DSocket inline methods. */ -inline XXXSocket::XXXSocket(const XXXTreeContext *context, const SocketRef *socket_ref) +inline DSocket::DSocket(const DTreeContext *context, const SocketRef *socket_ref) : context_(context), socket_ref_(socket_ref) { BLI_assert(socket_ref == nullptr || &socket_ref->tree() == &context->tree()); } -inline XXXSocket::XXXSocket(const XXXInputSocket &input_socket) - : XXXSocket(input_socket.context_, input_socket.socket_ref_) +inline DSocket::DSocket(const DInputSocket &input_socket) + : DSocket(input_socket.context_, input_socket.socket_ref_) { } -inline XXXSocket::XXXSocket(const XXXOutputSocket &output_socket) - : XXXSocket(output_socket.context_, output_socket.socket_ref_) +inline DSocket::DSocket(const DOutputSocket &output_socket) + : DSocket(output_socket.context_, output_socket.socket_ref_) { } -inline const XXXTreeContext *XXXSocket::context() const +inline const DTreeContext *DSocket::context() const { return context_; } -inline const SocketRef *XXXSocket::socket_ref() const +inline const SocketRef *DSocket::socket_ref() const { return socket_ref_; } -inline bool operator==(const XXXSocket &a, const XXXSocket &b) +inline bool operator==(const DSocket &a, const DSocket &b) { return a.context_ == b.context_ && a.socket_ref_ == b.socket_ref_; } -inline bool operator!=(const XXXSocket &a, const XXXSocket &b) +inline bool operator!=(const DSocket &a, const DSocket &b) { return !(a == b); } -inline XXXSocket::operator bool() const +inline DSocket::operator bool() const { return socket_ref_ != nullptr; } -inline const SocketRef *XXXSocket::operator->() const +inline const SocketRef *DSocket::operator->() const { return socket_ref_; } -inline uint64_t XXXSocket::hash() const +inline uint64_t DSocket::hash() const { - return DefaultHash<const XXXTreeContext *>{}(context_) ^ + return DefaultHash<const DTreeContext *>{}(context_) ^ DefaultHash<const SocketRef *>{}(socket_ref_); } /* -------------------------------------------------------------------- - * XXXInputSocket inline methods. + * DInputSocket inline methods. */ -inline XXXInputSocket::XXXInputSocket(const XXXTreeContext *context, - const InputSocketRef *socket_ref) - : XXXSocket(context, socket_ref) +inline DInputSocket::DInputSocket(const DTreeContext *context, const InputSocketRef *socket_ref) + : DSocket(context, socket_ref) { } -inline XXXInputSocket::XXXInputSocket(const XXXSocket &base_socket) : XXXSocket(base_socket) +inline DInputSocket::DInputSocket(const DSocket &base_socket) : DSocket(base_socket) { BLI_assert(base_socket->is_input()); } -inline const InputSocketRef *XXXInputSocket::socket_ref() const +inline const InputSocketRef *DInputSocket::socket_ref() const { return (const InputSocketRef *)socket_ref_; } -inline const InputSocketRef *XXXInputSocket::operator->() const +inline const InputSocketRef *DInputSocket::operator->() const { return (const InputSocketRef *)socket_ref_; } /* -------------------------------------------------------------------- - * XXXOutputSocket inline methods. + * DOutputSocket inline methods. */ -inline XXXOutputSocket::XXXOutputSocket(const XXXTreeContext *context, - const OutputSocketRef *socket_ref) - : XXXSocket(context, socket_ref) +inline DOutputSocket::DOutputSocket(const DTreeContext *context, const OutputSocketRef *socket_ref) + : DSocket(context, socket_ref) { } -inline XXXOutputSocket::XXXOutputSocket(const XXXSocket &base_socket) : XXXSocket(base_socket) +inline DOutputSocket::DOutputSocket(const DSocket &base_socket) : DSocket(base_socket) { BLI_assert(base_socket->is_output()); } -inline const OutputSocketRef *XXXOutputSocket::socket_ref() const +inline const OutputSocketRef *DOutputSocket::socket_ref() const { return (const OutputSocketRef *)socket_ref_; } -inline const OutputSocketRef *XXXOutputSocket::operator->() const +inline const OutputSocketRef *DOutputSocket::operator->() const { return (const OutputSocketRef *)socket_ref_; } /* -------------------------------------------------------------------- - * XXXNodeTree inline methods. + * DerivedNodeTree inline methods. */ -inline const XXXTreeContext &XXXNodeTree::root_context() const +inline const DTreeContext &DerivedNodeTree::root_context() const { return *root_context_; } -inline Span<const NodeTreeRef *> XXXNodeTree::used_node_tree_refs() const +inline Span<const NodeTreeRef *> DerivedNodeTree::used_node_tree_refs() const { return used_node_tree_refs_; } diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh index 49c63f5a731..5567622d07d 100644 --- a/source/blender/nodes/NOD_geometry_exec.hh +++ b/source/blender/nodes/NOD_geometry_exec.hh @@ -59,7 +59,7 @@ using fn::GValueMap; class GeoNodeExecParams { private: - const XXXNode node_; + const DNode node_; GValueMap<StringRef> &input_values_; GValueMap<StringRef> &output_values_; const PersistentDataHandleMap &handle_map_; @@ -68,7 +68,7 @@ class GeoNodeExecParams { Depsgraph *depsgraph_; public: - GeoNodeExecParams(const XXXNode node, + GeoNodeExecParams(const DNode node, GValueMap<StringRef> &input_values, GValueMap<StringRef> &output_values, const PersistentDataHandleMap &handle_map, diff --git a/source/blender/nodes/NOD_node_tree_multi_function.hh b/source/blender/nodes/NOD_node_tree_multi_function.hh index e4923215109..bb28422250d 100644 --- a/source/blender/nodes/NOD_node_tree_multi_function.hh +++ b/source/blender/nodes/NOD_node_tree_multi_function.hh @@ -46,17 +46,17 @@ class MFNetworkTreeMap { * Input sockets in a node tree can have multiple corresponding sockets in the generated * MFNetwork. This is because nodes are allowed to expand into multiple multi-function nodes. */ - const XXXNodeTree &tree_; + const DerivedNodeTree &tree_; fn::MFNetwork &network_; - MultiValueMap<XXXSocket, fn::MFSocket *> sockets_by_xxx_socket_; + MultiValueMap<DSocket, fn::MFSocket *> sockets_by_dsocket_; public: - MFNetworkTreeMap(const XXXNodeTree &tree, fn::MFNetwork &network) + MFNetworkTreeMap(const DerivedNodeTree &tree, fn::MFNetwork &network) : tree_(tree), network_(network) { } - const XXXNodeTree &tree() const + const DerivedNodeTree &tree() const { return tree_; } @@ -71,46 +71,46 @@ class MFNetworkTreeMap { return network_; } - void add(const XXXSocket &dsocket, fn::MFSocket &socket) + void add(const DSocket &dsocket, fn::MFSocket &socket) { BLI_assert(dsocket->is_input() == socket.is_input()); - BLI_assert(dsocket->is_input() || sockets_by_xxx_socket_.lookup(dsocket).is_empty()); - sockets_by_xxx_socket_.add(dsocket, &socket); + BLI_assert(dsocket->is_input() || sockets_by_dsocket_.lookup(dsocket).is_empty()); + sockets_by_dsocket_.add(dsocket, &socket); } - void add(const XXXInputSocket &dsocket, fn::MFInputSocket &socket) + void add(const DInputSocket &dsocket, fn::MFInputSocket &socket) { - sockets_by_xxx_socket_.add(dsocket, &socket); + sockets_by_dsocket_.add(dsocket, &socket); } - void add(const XXXOutputSocket &dsocket, fn::MFOutputSocket &socket) + void add(const DOutputSocket &dsocket, fn::MFOutputSocket &socket) { /* There can be at most one matching output socket. */ - BLI_assert(sockets_by_xxx_socket_.lookup(dsocket).is_empty()); - sockets_by_xxx_socket_.add(dsocket, &socket); + BLI_assert(sockets_by_dsocket_.lookup(dsocket).is_empty()); + sockets_by_dsocket_.add(dsocket, &socket); } - void add(const XXXTreeContext &context, + void add(const DTreeContext &context, Span<const InputSocketRef *> dsockets, Span<fn::MFInputSocket *> sockets) { assert_same_size(dsockets, sockets); for (int i : dsockets.index_range()) { - this->add(XXXInputSocket(&context, dsockets[i]), *sockets[i]); + this->add(DInputSocket(&context, dsockets[i]), *sockets[i]); } } - void add(const XXXTreeContext &context, + void add(const DTreeContext &context, Span<const OutputSocketRef *> dsockets, Span<fn::MFOutputSocket *> sockets) { assert_same_size(dsockets, sockets); for (int i : dsockets.index_range()) { - this->add(XXXOutputSocket(&context, dsockets[i]), *sockets[i]); + this->add(DOutputSocket(&context, dsockets[i]), *sockets[i]); } } - void add_try_match(const XXXNode &dnode, fn::MFNode &node) + void add_try_match(const DNode &dnode, fn::MFNode &node) { this->add_try_match(*dnode.context(), dnode->inputs().cast<const SocketRef *>(), @@ -120,7 +120,7 @@ class MFNetworkTreeMap { node.outputs().cast<fn::MFSocket *>()); } - void add_try_match(const XXXTreeContext &context, + void add_try_match(const DTreeContext &context, Span<const InputSocketRef *> dsockets, Span<fn::MFInputSocket *> sockets) { @@ -128,7 +128,7 @@ class MFNetworkTreeMap { context, dsockets.cast<const SocketRef *>(), sockets.cast<fn::MFSocket *>()); } - void add_try_match(const XXXTreeContext &context, + void add_try_match(const DTreeContext &context, Span<const OutputSocketRef *> dsockets, Span<fn::MFOutputSocket *> sockets) { @@ -136,7 +136,7 @@ class MFNetworkTreeMap { context, dsockets.cast<const SocketRef *>(), sockets.cast<fn::MFSocket *>()); } - void add_try_match(const XXXTreeContext &context, + void add_try_match(const DTreeContext &context, Span<const SocketRef *> dsockets, Span<fn::MFSocket *> sockets) { @@ -149,22 +149,22 @@ class MFNetworkTreeMap { continue; } fn::MFSocket *socket = sockets[used_sockets]; - this->add(XXXSocket(&context, dsocket), *socket); + this->add(DSocket(&context, dsocket), *socket); used_sockets++; } } - fn::MFOutputSocket &lookup(const XXXOutputSocket &dsocket) + fn::MFOutputSocket &lookup(const DOutputSocket &dsocket) { - return sockets_by_xxx_socket_.lookup(dsocket)[0]->as_output(); + return sockets_by_dsocket_.lookup(dsocket)[0]->as_output(); } - Span<fn::MFInputSocket *> lookup(const XXXInputSocket &dsocket) + Span<fn::MFInputSocket *> lookup(const DInputSocket &dsocket) { - return sockets_by_xxx_socket_.lookup(dsocket).cast<fn::MFInputSocket *>(); + return sockets_by_dsocket_.lookup(dsocket).cast<fn::MFInputSocket *>(); } - fn::MFInputSocket &lookup_dummy(const XXXInputSocket &dsocket) + fn::MFInputSocket &lookup_dummy(const DInputSocket &dsocket) { Span<fn::MFInputSocket *> sockets = this->lookup(dsocket); BLI_assert(sockets.size() == 1); @@ -173,16 +173,16 @@ class MFNetworkTreeMap { return socket; } - fn::MFOutputSocket &lookup_dummy(const XXXOutputSocket &dsocket) + fn::MFOutputSocket &lookup_dummy(const DOutputSocket &dsocket) { fn::MFOutputSocket &socket = this->lookup(dsocket); BLI_assert(socket.node().is_dummy()); return socket; } - bool is_mapped(const XXXSocket &dsocket) const + bool is_mapped(const DSocket &dsocket) const { - return !sockets_by_xxx_socket_.lookup(dsocket).is_empty(); + return !sockets_by_dsocket_.lookup(dsocket).is_empty(); } }; @@ -193,7 +193,7 @@ struct CommonMFNetworkBuilderData { ResourceCollector &resources; fn::MFNetwork &network; MFNetworkTreeMap &network_map; - const XXXNodeTree &tree; + const DerivedNodeTree &tree; }; class MFNetworkBuilderBase { @@ -253,7 +253,7 @@ class SocketMFNetworkBuilder : public MFNetworkBuilderBase { fn::MFOutputSocket *built_socket_ = nullptr; public: - SocketMFNetworkBuilder(CommonMFNetworkBuilderData &common, const XXXSocket &dsocket) + SocketMFNetworkBuilder(CommonMFNetworkBuilderData &common, const DSocket &dsocket) : MFNetworkBuilderBase(common), bsocket_(dsocket->bsocket()) { } @@ -322,10 +322,10 @@ class SocketMFNetworkBuilder : public MFNetworkBuilderBase { */ class NodeMFNetworkBuilder : public MFNetworkBuilderBase { private: - XXXNode node_; + DNode node_; public: - NodeMFNetworkBuilder(CommonMFNetworkBuilderData &common, XXXNode node) + NodeMFNetworkBuilder(CommonMFNetworkBuilderData &common, DNode node) : MFNetworkBuilderBase(common), node_(node) { } @@ -374,18 +374,18 @@ class NodeMFNetworkBuilder : public MFNetworkBuilderBase { /** * Returns the node that is currently being built. */ - const XXXNode &dnode() const + const DNode &dnode() const { return node_; } }; MFNetworkTreeMap insert_node_tree_into_mf_network(fn::MFNetwork &network, - const XXXNodeTree &tree, + const DerivedNodeTree &tree, ResourceCollector &resources); -using MultiFunctionByNode = Map<XXXNode, const fn::MultiFunction *>; -MultiFunctionByNode get_multi_function_per_node(const XXXNodeTree &tree, +using MultiFunctionByNode = Map<DNode, const fn::MultiFunction *>; +MultiFunctionByNode get_multi_function_per_node(const DerivedNodeTree &tree, ResourceCollector &resources); class DataTypeConversions { diff --git a/source/blender/nodes/function/nodes/node_fn_random_float.cc b/source/blender/nodes/function/nodes/node_fn_random_float.cc index 6c467b70cf3..1eddee9f8e1 100644 --- a/source/blender/nodes/function/nodes/node_fn_random_float.cc +++ b/source/blender/nodes/function/nodes/node_fn_random_float.cc @@ -67,10 +67,10 @@ static void fn_node_random_float_expand_in_mf_network( blender::nodes::NodeMFNetworkBuilder &builder) { uint32_t function_seed = 1746872341u; - blender::nodes::XXXNode node = builder.dnode(); + blender::nodes::DNode node = builder.dnode(); const blender::DefaultHash<blender::StringRefNull> hasher; function_seed = 33 * function_seed + hasher(node->name()); - for (const blender::nodes::XXXTreeContext *context = node.context(); context != nullptr; + for (const blender::nodes::DTreeContext *context = node.context(); context != nullptr; context = context->parent_context()) { function_seed = 33 * function_seed + hasher(context->parent_node()->name()); } diff --git a/source/blender/nodes/intern/node_tree_multi_function.cc b/source/blender/nodes/intern/node_tree_multi_function.cc index f6f620b5018..8491862c4b6 100644 --- a/source/blender/nodes/intern/node_tree_multi_function.cc +++ b/source/blender/nodes/intern/node_tree_multi_function.cc @@ -51,7 +51,7 @@ const fn::MultiFunction &NodeMFNetworkBuilder::get_default_fn(StringRef name) return fn; } -static void insert_dummy_node(CommonMFNetworkBuilderData &common, const XXXNode &dnode) +static void insert_dummy_node(CommonMFNetworkBuilderData &common, const DNode &dnode) { constexpr int stack_capacity = 10; @@ -92,7 +92,7 @@ static void insert_dummy_node(CommonMFNetworkBuilderData &common, const XXXNode common.network_map.add(*dnode.context(), output_dsockets, dummy_node.outputs()); } -static bool has_data_sockets(const XXXNode &dnode) +static bool has_data_sockets(const DNode &dnode) { for (const InputSocketRef *socket : dnode->inputs()) { if (socket_is_mf_data_socket(*socket->bsocket()->typeinfo)) { @@ -108,9 +108,9 @@ static bool has_data_sockets(const XXXNode &dnode) } static void foreach_node_to_insert(CommonMFNetworkBuilderData &common, - FunctionRef<void(XXXNode)> callback) + FunctionRef<void(DNode)> callback) { - common.tree.foreach_node([&](const XXXNode dnode) { + common.tree.foreach_node([&](const DNode dnode) { if (dnode->is_group_node()) { return; } @@ -130,7 +130,7 @@ static void foreach_node_to_insert(CommonMFNetworkBuilderData &common, */ static void insert_nodes(CommonMFNetworkBuilderData &common) { - foreach_node_to_insert(common, [&](const XXXNode dnode) { + foreach_node_to_insert(common, [&](const DNode dnode) { const bNodeType *node_type = dnode->typeinfo(); if (node_type->expand_in_mf_network != nullptr) { NodeMFNetworkBuilder builder{common, dnode}; @@ -256,7 +256,7 @@ static fn::MFOutputSocket &insert_default_value_for_type(CommonMFNetworkBuilderD } static fn::MFOutputSocket *insert_unlinked_input(CommonMFNetworkBuilderData &common, - const XXXInputSocket &dsocket) + const DInputSocket &dsocket) { bNodeSocket *bsocket = dsocket->bsocket(); bNodeSocketType *socktype = bsocket->typeinfo; @@ -272,9 +272,9 @@ static fn::MFOutputSocket *insert_unlinked_input(CommonMFNetworkBuilderData &com static void insert_links_and_unlinked_inputs(CommonMFNetworkBuilderData &common) { - foreach_node_to_insert(common, [&](const XXXNode dnode) { + foreach_node_to_insert(common, [&](const DNode dnode) { for (const InputSocketRef *socket_ref : dnode->inputs()) { - const XXXInputSocket to_dsocket{dnode.context(), socket_ref}; + const DInputSocket to_dsocket{dnode.context(), socket_ref}; if (!to_dsocket->is_available()) { continue; } @@ -286,8 +286,8 @@ static void insert_links_and_unlinked_inputs(CommonMFNetworkBuilderData &common) BLI_assert(to_sockets.size() >= 1); const fn::MFDataType to_type = to_sockets[0]->data_type(); - Vector<XXXSocket> from_dsockets; - to_dsocket.foreach_origin_socket([&](XXXSocket socket) { from_dsockets.append(socket); }); + Vector<DSocket> from_dsockets; + to_dsocket.foreach_origin_socket([&](DSocket socket) { from_dsockets.append(socket); }); if (from_dsockets.size() > 1) { fn::MFOutputSocket &from_socket = insert_default_value_for_type(common, to_type); for (fn::MFInputSocket *to_socket : to_sockets) { @@ -304,14 +304,14 @@ static void insert_links_and_unlinked_inputs(CommonMFNetworkBuilderData &common) continue; } if (from_dsockets[0]->is_input()) { - XXXInputSocket from_dsocket{from_dsockets[0]}; + DInputSocket from_dsocket{from_dsockets[0]}; fn::MFOutputSocket *built_socket = insert_unlinked_input(common, from_dsocket); for (fn::MFInputSocket *to_socket : to_sockets) { common.network.add_link(*built_socket, *to_socket); } continue; } - XXXOutputSocket from_dsocket{from_dsockets[0]}; + DOutputSocket from_dsocket{from_dsockets[0]}; fn::MFOutputSocket *from_socket = &common.network_map.lookup(from_dsocket); const fn::MFDataType from_type = from_socket->data_type(); @@ -343,7 +343,7 @@ static void insert_links_and_unlinked_inputs(CommonMFNetworkBuilderData &common) * processing. */ MFNetworkTreeMap insert_node_tree_into_mf_network(fn::MFNetwork &network, - const XXXNodeTree &tree, + const DerivedNodeTree &tree, ResourceCollector &resources) { MFNetworkTreeMap network_map{tree, network}; @@ -371,7 +371,7 @@ enum class NodeExpandType { * function node, the corresponding function is returned as well. */ static NodeExpandType get_node_expand_type(MFNetworkTreeMap &network_map, - const XXXNode &dnode, + const DNode &dnode, const fn::MultiFunction **r_single_function) { const fn::MFFunctionNode *single_function_node = nullptr; @@ -396,15 +396,14 @@ static NodeExpandType get_node_expand_type(MFNetworkTreeMap &network_map, for (const InputSocketRef *dsocket : dnode->inputs()) { if (dsocket->is_available()) { for (fn::MFInputSocket *mf_input : - network_map.lookup(XXXInputSocket(dnode.context(), dsocket))) { + network_map.lookup(DInputSocket(dnode.context(), dsocket))) { check_mf_node(mf_input->node()); } } } for (const OutputSocketRef *dsocket : dnode->outputs()) { if (dsocket->is_available()) { - fn::MFOutputSocket &mf_output = network_map.lookup( - XXXOutputSocket(dnode.context(), dsocket)); + fn::MFOutputSocket &mf_output = network_map.lookup(DOutputSocket(dnode.context(), dsocket)); check_mf_node(mf_output.node()); } } @@ -420,7 +419,7 @@ static NodeExpandType get_node_expand_type(MFNetworkTreeMap &network_map, } static const fn::MultiFunction &create_function_for_node_that_expands_into_multiple( - const XXXNode &dnode, + const DNode &dnode, fn::MFNetwork &network, MFNetworkTreeMap &network_map, ResourceCollector &resources) @@ -431,7 +430,7 @@ static const fn::MultiFunction &create_function_for_node_that_expands_into_multi MFDataType data_type = *socket_mf_type_get(*dsocket->typeinfo()); fn::MFOutputSocket &fn_input = network.add_input(data_type.to_string(), data_type); for (fn::MFInputSocket *mf_input : - network_map.lookup(XXXInputSocket(dnode.context(), dsocket))) { + network_map.lookup(DInputSocket(dnode.context(), dsocket))) { network.add_link(fn_input, *mf_input); dummy_fn_inputs.append(&fn_input); } @@ -440,8 +439,7 @@ static const fn::MultiFunction &create_function_for_node_that_expands_into_multi Vector<const fn::MFInputSocket *> dummy_fn_outputs; for (const OutputSocketRef *dsocket : dnode->outputs()) { if (dsocket->is_available()) { - fn::MFOutputSocket &mf_output = network_map.lookup( - XXXOutputSocket(dnode.context(), dsocket)); + fn::MFOutputSocket &mf_output = network_map.lookup(DOutputSocket(dnode.context(), dsocket)); MFDataType data_type = mf_output.data_type(); fn::MFInputSocket &fn_output = network.add_output(data_type.to_string(), data_type); network.add_link(mf_output, fn_output); @@ -458,7 +456,7 @@ static const fn::MultiFunction &create_function_for_node_that_expands_into_multi * Returns a single multi-function for every node that supports it. This makes it easier to reuse * the multi-function implementation of nodes in different contexts. */ -MultiFunctionByNode get_multi_function_per_node(const XXXNodeTree &tree, +MultiFunctionByNode get_multi_function_per_node(const DerivedNodeTree &tree, ResourceCollector &resources) { /* Build a network that nodes can insert themselves into. However, the individual nodes are not @@ -469,7 +467,7 @@ MultiFunctionByNode get_multi_function_per_node(const XXXNodeTree &tree, CommonMFNetworkBuilderData common{resources, network, network_map, tree}; - tree.foreach_node([&](XXXNode dnode) { + tree.foreach_node([&](DNode dnode) { const bNodeType *node_type = dnode->typeinfo(); if (node_type->expand_in_mf_network == nullptr) { /* This node does not have a multi-function implementation. */ diff --git a/source/blender/nodes/intern/xxx_node_tree.cc b/source/blender/nodes/intern/xxx_node_tree.cc index d1214ac860d..cc6940fcb6e 100644 --- a/source/blender/nodes/intern/xxx_node_tree.cc +++ b/source/blender/nodes/intern/xxx_node_tree.cc @@ -18,17 +18,17 @@ namespace blender::nodes { -XXXNodeTree::XXXNodeTree(bNodeTree &btree, NodeTreeRefMap &node_tree_refs) +DerivedNodeTree::DerivedNodeTree(bNodeTree &btree, NodeTreeRefMap &node_tree_refs) { root_context_ = &this->construct_context_recursively(nullptr, nullptr, btree, node_tree_refs); } -XXXTreeContext &XXXNodeTree::construct_context_recursively(XXXTreeContext *parent_context, - const NodeRef *parent_node, - bNodeTree &btree, - NodeTreeRefMap &node_tree_refs) +DTreeContext &DerivedNodeTree::construct_context_recursively(DTreeContext *parent_context, + const NodeRef *parent_node, + bNodeTree &btree, + NodeTreeRefMap &node_tree_refs) { - XXXTreeContext &context = *allocator_.construct<XXXTreeContext>(); + DTreeContext &context = *allocator_.construct<DTreeContext>(); context.parent_context_ = parent_context; context.parent_node_ = parent_node; context.tree_ = &get_tree_ref_from_map(node_tree_refs, btree); @@ -39,7 +39,7 @@ XXXTreeContext &XXXNodeTree::construct_context_recursively(XXXTreeContext *paren bNode *bnode = node->bnode(); bNodeTree *child_btree = reinterpret_cast<bNodeTree *>(bnode->id); if (child_btree != nullptr) { - XXXTreeContext &child = this->construct_context_recursively( + DTreeContext &child = this->construct_context_recursively( &context, node, *child_btree, node_tree_refs); context.children_.add_new(node, &child); } @@ -49,21 +49,21 @@ XXXTreeContext &XXXNodeTree::construct_context_recursively(XXXTreeContext *paren return context; } -XXXNodeTree::~XXXNodeTree() +DerivedNodeTree::~DerivedNodeTree() { /* Has to be destructed manually, because the context info is allocated in a linear allocator. */ this->destruct_context_recursively(root_context_); } -void XXXNodeTree::destruct_context_recursively(XXXTreeContext *context) +void DerivedNodeTree::destruct_context_recursively(DTreeContext *context) { - for (XXXTreeContext *child : context->children_.values()) { + for (DTreeContext *child : context->children_.values()) { this->destruct_context_recursively(child); } - context->~XXXTreeContext(); + context->~DTreeContext(); } -bool XXXNodeTree::has_link_cycles() const +bool DerivedNodeTree::has_link_cycles() const { for (const NodeTreeRef *tree_ref : used_node_tree_refs_) { if (tree_ref->has_link_cycles()) { @@ -73,29 +73,29 @@ bool XXXNodeTree::has_link_cycles() const return false; } -void XXXNodeTree::foreach_node(FunctionRef<void(XXXNode)> callback) const +void DerivedNodeTree::foreach_node(FunctionRef<void(DNode)> callback) const { this->foreach_node_in_context_recursive(*root_context_, callback); } -void XXXNodeTree::foreach_node_in_context_recursive(const XXXTreeContext &context, - FunctionRef<void(XXXNode)> callback) const +void DerivedNodeTree::foreach_node_in_context_recursive(const DTreeContext &context, + FunctionRef<void(DNode)> callback) const { for (const NodeRef *node_ref : context.tree_->nodes()) { - callback(XXXNode(&context, node_ref)); + callback(DNode(&context, node_ref)); } - for (const XXXTreeContext *child_context : context.children_.values()) { + for (const DTreeContext *child_context : context.children_.values()) { this->foreach_node_in_context_recursive(*child_context, callback); } } -XXXOutputSocket XXXInputSocket::get_corresponding_group_node_output() const +DOutputSocket DInputSocket::get_corresponding_group_node_output() const { BLI_assert(*this); BLI_assert(socket_ref_->node().is_group_output_node()); BLI_assert(socket_ref_->index() < socket_ref_->node().inputs().size() - 1); - const XXXTreeContext *parent_context = context_->parent_context(); + const DTreeContext *parent_context = context_->parent_context(); const NodeRef *parent_node = context_->parent_node(); BLI_assert(parent_context != nullptr); BLI_assert(parent_node != nullptr); @@ -104,12 +104,12 @@ XXXOutputSocket XXXInputSocket::get_corresponding_group_node_output() const return {parent_context, &parent_node->output(socket_index)}; } -XXXOutputSocket XXXInputSocket::get_corresponding_group_input_socket() const +DOutputSocket DInputSocket::get_corresponding_group_input_socket() const { BLI_assert(*this); BLI_assert(socket_ref_->node().is_group_node()); - const XXXTreeContext *child_context = context_->child_context(socket_ref_->node()); + const DTreeContext *child_context = context_->child_context(socket_ref_->node()); BLI_assert(child_context != nullptr); const NodeTreeRef &child_tree = child_context->tree(); @@ -120,13 +120,13 @@ XXXOutputSocket XXXInputSocket::get_corresponding_group_input_socket() const return {child_context, &group_input_nodes[0]->output(socket_index)}; } -XXXInputSocket XXXOutputSocket::get_corresponding_group_node_input() const +DInputSocket DOutputSocket::get_corresponding_group_node_input() const { BLI_assert(*this); BLI_assert(socket_ref_->node().is_group_input_node()); BLI_assert(socket_ref_->index() < socket_ref_->node().outputs().size() - 1); - const XXXTreeContext *parent_context = context_->parent_context(); + const DTreeContext *parent_context = context_->parent_context(); const NodeRef *parent_node = context_->parent_node(); BLI_assert(parent_context != nullptr); BLI_assert(parent_node != nullptr); @@ -135,12 +135,12 @@ XXXInputSocket XXXOutputSocket::get_corresponding_group_node_input() const return {parent_context, &parent_node->input(socket_index)}; } -XXXInputSocket XXXOutputSocket::get_corresponding_group_output_socket() const +DInputSocket DOutputSocket::get_corresponding_group_output_socket() const { BLI_assert(*this); BLI_assert(socket_ref_->node().is_group_node()); - const XXXTreeContext *child_context = context_->child_context(socket_ref_->node()); + const DTreeContext *child_context = context_->child_context(socket_ref_->node()); BLI_assert(child_context != nullptr); const NodeTreeRef &child_tree = child_context->tree(); @@ -151,28 +151,27 @@ XXXInputSocket XXXOutputSocket::get_corresponding_group_output_socket() const return {child_context, &group_output_nodes[0]->input(socket_index)}; } -void XXXInputSocket::foreach_origin_socket(FunctionRef<void(XXXSocket)> callback) const +void DInputSocket::foreach_origin_socket(FunctionRef<void(DSocket)> callback) const { BLI_assert(*this); for (const OutputSocketRef *linked_socket : socket_ref_->as_input().linked_sockets()) { const NodeRef &linked_node = linked_socket->node(); - XXXOutputSocket linked_xxx_socket{context_, linked_socket}; + DOutputSocket linked_dsocket{context_, linked_socket}; if (linked_node.is_muted()) { for (const InternalLinkRef *internal_link : linked_node.internal_links()) { if (&internal_link->to() == linked_socket) { - XXXInputSocket input_of_muted_node{context_, &internal_link->from()}; + DInputSocket input_of_muted_node{context_, &internal_link->from()}; input_of_muted_node.foreach_origin_socket(callback); } } } else if (linked_node.is_group_input_node()) { if (context_->is_root()) { - callback(linked_xxx_socket); + callback(linked_dsocket); } else { - XXXInputSocket socket_in_parent_group = - linked_xxx_socket.get_corresponding_group_node_input(); + DInputSocket socket_in_parent_group = linked_dsocket.get_corresponding_group_node_input(); if (socket_in_parent_group->is_linked()) { socket_in_parent_group.foreach_origin_socket(callback); } @@ -182,7 +181,7 @@ void XXXInputSocket::foreach_origin_socket(FunctionRef<void(XXXSocket)> callback } } else if (linked_node.is_group_node()) { - XXXInputSocket socket_in_group = linked_xxx_socket.get_corresponding_group_output_socket(); + DInputSocket socket_in_group = linked_dsocket.get_corresponding_group_output_socket(); if (socket_in_group->is_linked()) { socket_in_group.foreach_origin_socket(callback); } @@ -191,41 +190,41 @@ void XXXInputSocket::foreach_origin_socket(FunctionRef<void(XXXSocket)> callback } } else { - callback(linked_xxx_socket); + callback(linked_dsocket); } } } -void XXXOutputSocket::foreach_target_socket(FunctionRef<void(XXXInputSocket)> callback) const +void DOutputSocket::foreach_target_socket(FunctionRef<void(DInputSocket)> callback) const { for (const InputSocketRef *linked_socket : socket_ref_->as_output().linked_sockets()) { const NodeRef &linked_node = linked_socket->node(); - XXXInputSocket linked_xxx_socket{context_, linked_socket}; + DInputSocket linked_dsocket{context_, linked_socket}; if (linked_node.is_muted()) { for (const InternalLinkRef *internal_link : linked_node.internal_links()) { if (&internal_link->from() == linked_socket) { - XXXOutputSocket output_of_muted_node{context_, &internal_link->to()}; + DOutputSocket output_of_muted_node{context_, &internal_link->to()}; output_of_muted_node.foreach_target_socket(callback); } } } else if (linked_node.is_group_output_node()) { if (context_->is_root()) { - callback(linked_xxx_socket); + callback(linked_dsocket); } else { - XXXOutputSocket socket_in_parent_group = - linked_xxx_socket.get_corresponding_group_node_output(); + DOutputSocket socket_in_parent_group = + linked_dsocket.get_corresponding_group_node_output(); socket_in_parent_group.foreach_target_socket(callback); } } else if (linked_node.is_group_node()) { - XXXOutputSocket socket_in_group = linked_xxx_socket.get_corresponding_group_input_socket(); + DOutputSocket socket_in_group = linked_dsocket.get_corresponding_group_input_socket(); socket_in_group.foreach_target_socket(callback); } else { - callback(linked_xxx_socket); + callback(linked_dsocket); } } } diff --git a/source/blender/nodes/shader/nodes/node_shader_math.cc b/source/blender/nodes/shader/nodes/node_shader_math.cc index 5cfbb3745bc..7a846031456 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.cc +++ b/source/blender/nodes/shader/nodes/node_shader_math.cc @@ -112,7 +112,7 @@ static void sh_node_math_expand_in_mf_network(blender::nodes::NodeMFNetworkBuild { const blender::fn::MultiFunction &base_function = get_base_multi_function(builder); - const blender::nodes::XXXNode &dnode = builder.dnode(); + const blender::nodes::DNode &dnode = builder.dnode(); blender::fn::MFNetwork &network = builder.network(); blender::fn::MFFunctionNode &base_node = network.add_function(base_function); @@ -126,11 +126,11 @@ static void sh_node_math_expand_in_mf_network(blender::nodes::NodeMFNetworkBuild }}; blender::fn::MFFunctionNode &clamp_node = network.add_function(clamp_fn); network.add_link(base_node.output(0), clamp_node.input(0)); - builder.network_map().add(blender::nodes::XXXOutputSocket(dnode.context(), &dnode->output(0)), + builder.network_map().add(blender::nodes::DOutputSocket(dnode.context(), &dnode->output(0)), clamp_node.output(0)); } else { - builder.network_map().add(blender::nodes::XXXOutputSocket(dnode.context(), &dnode->output(0)), + builder.network_map().add(blender::nodes::DOutputSocket(dnode.context(), &dnode->output(0)), base_node.output(0)); } } |