diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_node.h | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.cc | 20 |
2 files changed, 28 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 379d4332473..5e0526ab262 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -113,6 +113,7 @@ namespace blender { namespace nodes { class NodeMultiFunctionBuilder; class GeoNodeExecParams; +class NodeDeclarationBuilder; } // namespace nodes namespace fn { class CPPType; @@ -122,6 +123,7 @@ class MFDataType; using NodeMultiFunctionBuildFunction = void (*)(blender::nodes::NodeMultiFunctionBuilder &builder); using NodeGeometryExecFunction = void (*)(blender::nodes::GeoNodeExecParams params); +using NodeDeclareFunction = void (*)(blender::nodes::NodeDeclarationBuilder &builder); using SocketGetCPPTypeFunction = const blender::fn::CPPType *(*)(); using SocketGetCPPValueFunction = void (*)(const struct bNodeSocket &socket, void *r_value); using SocketGetGeometryNodesCPPTypeFunction = const blender::fn::CPPType *(*)(); @@ -131,6 +133,7 @@ using SocketGetGeometryNodesCPPValueFunction = void (*)(const struct bNodeSocket #else typedef void *NodeMultiFunctionBuildFunction; typedef void *NodeGeometryExecFunction; +typedef void *NodeDeclareFunction; typedef void *SocketGetCPPTypeFunction; typedef void *SocketGetGeometryNodesCPPTypeFunction; typedef void *SocketGetGeometryNodesCPPValueFunction; @@ -334,6 +337,9 @@ typedef struct bNodeType { NodeGeometryExecFunction geometry_node_execute; bool geometry_node_execute_supports_laziness; + /* Declares which sockets the node has. */ + NodeDeclareFunction declare; + /* RNA integration */ ExtensionRNA rna_ext; } bNodeType; @@ -615,6 +621,10 @@ struct bNodeSocket *nodeInsertStaticSocket(struct bNodeTree *ntree, const char *identifier, const char *name); void nodeRemoveSocket(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *sock); +void nodeRemoveSocketEx(struct bNodeTree *ntree, + struct bNode *node, + struct bNodeSocket *sock, + bool do_id_user); void nodeRemoveAllSockets(struct bNodeTree *ntree, struct bNode *node); void nodeModifySocketType(struct bNodeTree *ntree, struct bNode *node, diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index fb43d1fc87f..48d747e2bf3 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -79,6 +79,7 @@ #include "NOD_composite.h" #include "NOD_function.h" #include "NOD_geometry.h" +#include "NOD_node_declaration.hh" #include "NOD_shader.h" #include "NOD_socket.h" #include "NOD_texture.h" @@ -887,7 +888,7 @@ void ntreeBlendReadLib(struct BlendLibReader *reader, struct bNodeTree *ntree) * to match the static layout. */ if (!BLO_read_lib_is_undo(reader)) { LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { - node_verify_socket_templates(ntree, node); + node_verify_sockets(ntree, node, false); } } } @@ -1011,6 +1012,13 @@ IDTypeInfo IDType_ID_NT = { static void node_add_sockets_from_type(bNodeTree *ntree, bNode *node, bNodeType *ntype) { + if (ntype->declare != nullptr) { + blender::nodes::NodeDeclaration node_decl; + blender::nodes::NodeDeclarationBuilder builder{node_decl}; + ntype->declare(builder); + node_decl.build(*ntree, *node); + return; + } bNodeSocketTemplate *sockdef; /* bNodeSocket *sock; */ /* UNUSED */ @@ -1916,6 +1924,14 @@ static void node_socket_free(bNodeTree *UNUSED(ntree), void nodeRemoveSocket(bNodeTree *ntree, bNode *node, bNodeSocket *sock) { + nodeRemoveSocketEx(ntree, node, sock, true); +} + +void nodeRemoveSocketEx(struct bNodeTree *ntree, + struct bNode *node, + struct bNodeSocket *sock, + bool do_id_user) +{ LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) { if (link->fromsock == sock || link->tosock == sock) { nodeRemLink(ntree, link); @@ -1926,7 +1942,7 @@ void nodeRemoveSocket(bNodeTree *ntree, bNode *node, bNodeSocket *sock) BLI_remlink(&node->inputs, sock); BLI_remlink(&node->outputs, sock); - node_socket_free(ntree, sock, node, true); + node_socket_free(ntree, sock, node, do_id_user); MEM_freeN(sock); node->update |= NODE_UPDATE; |