Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-12-22 17:47:46 +0300
committerHans Goudey <h.goudey@me.com>2021-12-22 17:47:46 +0300
commitfdc4a1a590d8befb1ff9ab1de3f02d82aa46d539 (patch)
tree32f92586f0de79d5f7762999b18fa03f036f9648 /source/blender/blenkernel/BKE_node.h
parentd6224db8f17f7035d8240bb5b9d28ce709cd3cb4 (diff)
Nodes: Refactor to remove node and socket "new" pointers
These pointers point to the new nodes when duplicating, and their even used to point to "original" nodes for "localized" trees. They're just a bad design decision that make code confusing and buggy. Instead, node copy functions now optionally add to a map of old to new socket pointers. The case where the compositor abused these pointers as "original" pointers are handled by looking up the string node names. Differential Revision: https://developer.blender.org/D13518
Diffstat (limited to 'source/blender/blenkernel/BKE_node.h')
-rw-r--r--source/blender/blenkernel/BKE_node.h41
1 files changed, 18 insertions, 23 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 500d8e2e0ac..1e0a75bfc57 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -34,6 +34,7 @@
#include "RNA_types.h"
#ifdef __cplusplus
+# include "BLI_map.hh"
# include "BLI_string_ref.hh"
#endif
@@ -518,8 +519,6 @@ void ntreeSetOutput(struct bNodeTree *ntree);
void ntreeFreeCache(struct bNodeTree *ntree);
-bool ntreeNodeExists(const struct bNodeTree *ntree, const struct bNode *testnode);
-bool ntreeOutputExists(const struct bNode *node, const struct bNodeSocket *testsock);
void ntreeNodeFlagSet(const bNodeTree *ntree, const int flag, const bool enable);
/**
* Returns localized tree for execution in threads.
@@ -697,31 +696,27 @@ void nodeRemoveNode(struct Main *bmain,
struct bNode *node,
bool do_id_user);
+#ifdef __cplusplus
+
+namespace blender::bke {
+
/**
- * \param ntree: is the target tree.
- *
- * \note keep socket list order identical, for copying links.
+ * \note keeps socket list order identical, for copying links.
* \note `unique_name` needs to be true. It's only disabled for speed when doing GPUnodetrees.
*/
-struct bNode *BKE_node_copy_ex(struct bNodeTree *ntree,
- const struct bNode *node_src,
- const int flag,
- const bool unique_name);
+bNode *node_copy_with_mapping(bNodeTree *dst_tree,
+ const bNode &node_src,
+ int flag,
+ bool unique_name,
+ Map<const bNodeSocket *, bNodeSocket *> &new_socket_map);
-/**
- * Same as #BKE_node_copy_ex but stores pointers to a new node and its sockets in the source node.
- *
- * NOTE: DANGER ZONE!
- *
- * TODO(sergey): Maybe it's better to make BKE_node_copy_ex() return a mapping from old node and
- * sockets to new one.
- */
-struct bNode *BKE_node_copy_store_new_pointers(struct bNodeTree *ntree,
- struct bNode *node_src,
- const int flag);
-struct bNodeTree *ntreeCopyTree_ex_new_pointers(const struct bNodeTree *ntree,
- struct Main *bmain,
- const bool do_id_user);
+bNode *node_copy(bNodeTree *dst_tree, const bNode &src_node, int flag, bool unique_name);
+
+} // namespace blender::bke
+
+#endif
+
+bNode *BKE_node_copy(bNodeTree *dst_tree, const bNode *src_node, int flag, bool unique_name);
/**
* Also used via RNA API, so we check for proper input output direction.