Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/node.c
| Show All 23 Lines | |||||
| * | * | ||||
| * ***** END GPL LICENSE BLOCK ***** | * ***** END GPL LICENSE BLOCK ***** | ||||
| */ | */ | ||||
| /** \file blender/blenkernel/intern/node.c | /** \file blender/blenkernel/intern/node.c | ||||
| * \ingroup bke | * \ingroup bke | ||||
| */ | */ | ||||
| #include "CLG_log.h" | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <stddef.h> | #include <stddef.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include <limits.h> | #include <limits.h> | ||||
| #include "DNA_action_types.h" | #include "DNA_action_types.h" | ||||
| Show All 38 Lines | |||||
| #define NODE_DEFAULT_MAX_WIDTH 700 | #define NODE_DEFAULT_MAX_WIDTH 700 | ||||
| /* Fallback types for undefined tree, nodes, sockets */ | /* Fallback types for undefined tree, nodes, sockets */ | ||||
| bNodeTreeType NodeTreeTypeUndefined; | bNodeTreeType NodeTreeTypeUndefined; | ||||
| bNodeType NodeTypeUndefined; | bNodeType NodeTypeUndefined; | ||||
| bNodeSocketType NodeSocketTypeUndefined; | bNodeSocketType NodeSocketTypeUndefined; | ||||
| static CLG_LogRef LOG = {"bke.node"}; | |||||
| static void node_add_sockets_from_type(bNodeTree *ntree, bNode *node, bNodeType *ntype) | static void node_add_sockets_from_type(bNodeTree *ntree, bNode *node, bNodeType *ntype) | ||||
| { | { | ||||
| bNodeSocketTemplate *sockdef; | bNodeSocketTemplate *sockdef; | ||||
| /* bNodeSocket *sock; */ /* UNUSED */ | /* bNodeSocket *sock; */ /* UNUSED */ | ||||
| if (ntype->inputs) { | if (ntype->inputs) { | ||||
| sockdef = ntype->inputs; | sockdef = ntype->inputs; | ||||
| ▲ Show 20 Lines • Show All 426 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| void nodeModifySocketType(bNodeTree *ntree, bNode *UNUSED(node), bNodeSocket *sock, | void nodeModifySocketType(bNodeTree *ntree, bNode *UNUSED(node), bNodeSocket *sock, | ||||
| int type, int subtype) | int type, int subtype) | ||||
| { | { | ||||
| const char *idname = nodeStaticSocketType(type, subtype); | const char *idname = nodeStaticSocketType(type, subtype); | ||||
| if (!idname) { | if (!idname) { | ||||
| printf("Error: static node socket type %d undefined\n", type); | CLOG_ERROR(&LOG, "static node socket type %d undefined", type); | ||||
| return; | return; | ||||
| } | } | ||||
| if (sock->default_value) { | if (sock->default_value) { | ||||
| MEM_freeN(sock->default_value); | MEM_freeN(sock->default_value); | ||||
| sock->default_value = NULL; | sock->default_value = NULL; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | |||||
| bNodeSocket *nodeAddStaticSocket(bNodeTree *ntree, bNode *node, int in_out, int type, int subtype, | bNodeSocket *nodeAddStaticSocket(bNodeTree *ntree, bNode *node, int in_out, int type, int subtype, | ||||
| const char *identifier, const char *name) | const char *identifier, const char *name) | ||||
| { | { | ||||
| const char *idname = nodeStaticSocketType(type, subtype); | const char *idname = nodeStaticSocketType(type, subtype); | ||||
| bNodeSocket *sock; | bNodeSocket *sock; | ||||
| if (!idname) { | if (!idname) { | ||||
| printf("Error: static node socket type %d undefined\n", type); | CLOG_ERROR(&LOG, "static node socket type %d undefined", type); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| sock = nodeAddSocket(ntree, node, in_out, idname, identifier, name); | sock = nodeAddSocket(ntree, node, in_out, idname, identifier, name); | ||||
| sock->type = type; | sock->type = type; | ||||
| return sock; | return sock; | ||||
| } | } | ||||
| bNodeSocket *nodeInsertStaticSocket(bNodeTree *ntree, bNode *node, int in_out, int type, int subtype, | bNodeSocket *nodeInsertStaticSocket(bNodeTree *ntree, bNode *node, int in_out, int type, int subtype, | ||||
| bNodeSocket *next_sock, const char *identifier, const char *name) | bNodeSocket *next_sock, const char *identifier, const char *name) | ||||
| { | { | ||||
| const char *idname = nodeStaticSocketType(type, subtype); | const char *idname = nodeStaticSocketType(type, subtype); | ||||
| bNodeSocket *sock; | bNodeSocket *sock; | ||||
| if (!idname) { | if (!idname) { | ||||
| printf("Error: static node socket type %d undefined\n", type); | CLOG_ERROR(&LOG, "static node socket type %d undefined", type); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| sock = nodeInsertSocket(ntree, node, in_out, idname, next_sock, identifier, name); | sock = nodeInsertSocket(ntree, node, in_out, idname, next_sock, identifier, name); | ||||
| sock->type = type; | sock->type = type; | ||||
| return sock; | return sock; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | NODE_TYPES_BEGIN(ntype) { | ||||
| * for multiple node types, this helps find the desired type | * for multiple node types, this helps find the desired type | ||||
| */ | */ | ||||
| if (ntype->type == type && (!ntype->poll || ntype->poll(ntype, ntree))) { | if (ntype->type == type && (!ntype->poll || ntype->poll(ntype, ntree))) { | ||||
| idname = ntype->idname; | idname = ntype->idname; | ||||
| break; | break; | ||||
| } | } | ||||
| } NODE_TYPES_END; | } NODE_TYPES_END; | ||||
| if (!idname) { | if (!idname) { | ||||
| printf("Error: static node type %d undefined\n", type); | CLOG_ERROR(&LOG, "static node type %d undefined", type); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| return nodeAddNode(C, ntree, idname); | return nodeAddNode(C, ntree, idname); | ||||
| } | } | ||||
| static void node_socket_copy(bNodeSocket *sock_dst, bNodeSocket *sock_src, const int flag) | static void node_socket_copy(bNodeSocket *sock_dst, bNodeSocket *sock_src, const int flag) | ||||
| { | { | ||||
| sock_src->new_sock = sock_dst; | sock_src->new_sock = sock_dst; | ||||
| ▲ Show 20 Lines • Show All 2,841 Lines • Show Last 20 Lines | |||||