[Bf-blender-cvs] [3a64bed4e45] temp-derived-node-tree-refactor: more constructors
Jacques Lucke
noreply at git.blender.org
Wed Mar 3 09:57:03 CET 2021
Commit: 3a64bed4e4517f07022d4aa850717b39fafe5914
Author: Jacques Lucke
Date: Wed Mar 3 09:13:37 2021 +0100
Branches: temp-derived-node-tree-refactor
https://developer.blender.org/rB3a64bed4e4517f07022d4aa850717b39fafe5914
more constructors
===================================================================
M source/blender/nodes/NOD_XXX_node_tree.hh
M source/blender/nodes/intern/xxx_node_tree.cc
===================================================================
diff --git a/source/blender/nodes/NOD_XXX_node_tree.hh b/source/blender/nodes/NOD_XXX_node_tree.hh
index 18462c7bf8e..6587ff3113a 100644
--- a/source/blender/nodes/NOD_XXX_node_tree.hh
+++ b/source/blender/nodes/NOD_XXX_node_tree.hh
@@ -60,6 +60,9 @@ struct XXXNode {
XXXNodeTreeContext context;
const NodeRef *node = nullptr;
+ XXXNode() = default;
+ XXXNode(XXXNodeTreeContext context, const NodeRef *node);
+
friend bool operator==(const XXXNode &a, const XXXNode &b);
friend bool operator!=(const XXXNode &a, const XXXNode &b);
@@ -72,6 +75,9 @@ struct XXXSocket {
XXXNodeTreeContext context;
const SocketRef *socket;
+ XXXSocket() = default;
+ XXXSocket(XXXNodeTreeContext context, const SocketRef *socket);
+
XXXSocket(const XXXInputSocket &input_socket);
XXXSocket(const XXXOutputSocket &output_socket);
@@ -87,6 +93,8 @@ struct XXXInputSocket {
XXXNodeTreeContext context;
const InputSocketRef *socket = nullptr;
+ XXXInputSocket() = default;
+ XXXInputSocket(XXXNodeTreeContext context, const InputSocketRef *socket);
explicit XXXInputSocket(const XXXSocket &base_socket);
friend bool operator==(const XXXInputSocket &a, const XXXInputSocket &b);
@@ -95,12 +103,16 @@ struct XXXInputSocket {
operator bool() const;
uint64_t hash() const;
+
+ XXXOutputSocket try_get_single_origin() const;
};
struct XXXOutputSocket {
XXXNodeTreeContext context;
const OutputSocketRef *socket = nullptr;
+ XXXOutputSocket() = default;
+ XXXOutputSocket(XXXNodeTreeContext context, const OutputSocketRef *socket);
explicit XXXOutputSocket(const XXXSocket &base_socket);
friend bool operator==(const XXXOutputSocket &a, const XXXOutputSocket &b);
@@ -166,6 +178,11 @@ inline const XXXNodeTreeContextInfo &XXXNodeTreeContext::info() const
* XXXNode inline methods.
*/
+inline XXXNode::XXXNode(XXXNodeTreeContext context, const NodeRef *node)
+ : context(context), node(node)
+{
+}
+
inline bool operator==(const XXXNode &a, const XXXNode &b)
{
return a.context == b.context && a.node == b.node;
@@ -190,6 +207,11 @@ inline uint64_t XXXNode::hash() const
* XXXSocket inline methods.
*/
+inline XXXSocket::XXXSocket(XXXNodeTreeContext context, const SocketRef *socket)
+ : context(context), socket(socket)
+{
+}
+
inline XXXSocket::XXXSocket(const XXXInputSocket &input_socket)
: context(input_socket.context), socket(input_socket.socket)
{
@@ -224,6 +246,11 @@ inline uint64_t XXXSocket::hash() const
* XXXInputSocket inline methods.
*/
+inline XXXInputSocket::XXXInputSocket(XXXNodeTreeContext context, const InputSocketRef *socket)
+ : context(context), socket(socket)
+{
+}
+
inline XXXInputSocket::XXXInputSocket(const XXXSocket &base_socket)
: context(base_socket.context), socket(&base_socket.socket->as_input())
{
@@ -254,6 +281,11 @@ inline uint64_t XXXInputSocket::hash() const
* XXXOutputSocket inline methods.
*/
+inline XXXOutputSocket::XXXOutputSocket(XXXNodeTreeContext context, const OutputSocketRef *socket)
+ : context(context), socket(socket)
+{
+}
+
inline XXXOutputSocket::XXXOutputSocket(const XXXSocket &base_socket)
: context(base_socket.context), socket(&base_socket.socket->as_output())
{
diff --git a/source/blender/nodes/intern/xxx_node_tree.cc b/source/blender/nodes/intern/xxx_node_tree.cc
index c966024077b..13c513ec07d 100644
--- a/source/blender/nodes/intern/xxx_node_tree.cc
+++ b/source/blender/nodes/intern/xxx_node_tree.cc
@@ -59,4 +59,14 @@ void XXXNodeTree::destruct_context_info_recursively(XXXNodeTreeContextInfo *cont
context_info->~XXXNodeTreeContextInfo();
}
+XXXOutputSocket XXXInputSocket::try_get_single_origin() const
+{
+ Span<const OutputSocketRef *> origins = socket->linked_sockets();
+ if (origins.size() != 1) {
+ return {};
+ }
+ const OutputSocketRef *origin = origins[0];
+ return {context, origin};
+}
+
} // namespace blender::nodes
More information about the Bf-blender-cvs
mailing list