Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/node.cc
| Show First 20 Lines • Show All 1,308 Lines • ▼ Show 20 Lines | |||||
| void nodeUnregisterType(bNodeType *nt) | void nodeUnregisterType(bNodeType *nt) | ||||
| { | { | ||||
| BLI_ghash_remove(nodetypes_hash, nt->idname, nullptr, node_free_type); | BLI_ghash_remove(nodetypes_hash, nt->idname, nullptr, node_free_type); | ||||
| } | } | ||||
| bool nodeTypeUndefined(bNode *node) | bool nodeTypeUndefined(bNode *node) | ||||
| { | { | ||||
| return (node->typeinfo == &NodeTypeUndefined) || | return (node->typeinfo == &NodeTypeUndefined) || | ||||
| (node->type == NODE_GROUP && node->id && ID_IS_LINKED(node->id) && | ((node->type == NODE_GROUP || node->type == NODE_CUSTOM_GROUP) && node->id && | ||||
| (node->id->tag & LIB_TAG_MISSING)); | ID_IS_LINKED(node->id) && (node->id->tag & LIB_TAG_MISSING)); | ||||
| } | } | ||||
| GHashIterator *nodeTypeGetIterator(void) | GHashIterator *nodeTypeGetIterator(void) | ||||
| { | { | ||||
| return BLI_ghashIterator_new(nodetypes_hash); | return BLI_ghashIterator_new(nodetypes_hash); | ||||
| } | } | ||||
| bNodeSocketType *nodeSocketTypeFind(const char *idname) | bNodeSocketType *nodeSocketTypeFind(const char *idname) | ||||
| ▲ Show 20 Lines • Show All 675 Lines • ▼ Show 20 Lines | |||||
| bNode *nodeAddStaticNode(const struct bContext *C, bNodeTree *ntree, int type) | bNode *nodeAddStaticNode(const struct bContext *C, bNodeTree *ntree, int type) | ||||
| { | { | ||||
| const char *idname = nullptr; | const char *idname = nullptr; | ||||
| NODE_TYPES_BEGIN (ntype) { | NODE_TYPES_BEGIN (ntype) { | ||||
| /* do an extra poll here, because some int types are used | /* do an extra poll here, because some int types are used | ||||
| * 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))) { | const char *disabled_hint; | ||||
| if (ntype->type == type && (!ntype->poll || ntype->poll(ntype, ntree, &disabled_hint))) { | |||||
| idname = ntype->idname; | idname = ntype->idname; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| NODE_TYPES_END; | NODE_TYPES_END; | ||||
| if (!idname) { | if (!idname) { | ||||
| CLOG_ERROR(&LOG, "static node type %d undefined", type); | CLOG_ERROR(&LOG, "static node type %d undefined", type); | ||||
| return nullptr; | return nullptr; | ||||
| ▲ Show 20 Lines • Show All 1,072 Lines • ▼ Show 20 Lines | if (node->type == NODE_GROUP_OUTPUT) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* here we could recursively set which nodes have to be done, | /* here we could recursively set which nodes have to be done, | ||||
| * might be different for editor or for "real" use... */ | * might be different for editor or for "real" use... */ | ||||
| } | } | ||||
| /** Get address of potential nodetree pointer of given ID. | /** | ||||
| * Get address of potential node-tree pointer of given ID. | |||||
| * | * | ||||
| * \warning Using this function directly is potentially dangerous, if you don't know or are not | * \warning Using this function directly is potentially dangerous, if you don't know or are not | ||||
| * sure, please use `ntreeFromID()` instead. */ | * sure, please use `ntreeFromID()` instead. | ||||
| */ | |||||
| bNodeTree **BKE_ntree_ptr_from_id(ID *id) | bNodeTree **BKE_ntree_ptr_from_id(ID *id) | ||||
| { | { | ||||
| switch (GS(id->name)) { | switch (GS(id->name)) { | ||||
| case ID_MA: | case ID_MA: | ||||
| return &((Material *)id)->nodetree; | return &((Material *)id)->nodetree; | ||||
| case ID_LA: | case ID_LA: | ||||
| return &((Light *)id)->nodetree; | return &((Light *)id)->nodetree; | ||||
| case ID_WO: | case ID_WO: | ||||
| ▲ Show 20 Lines • Show All 1,289 Lines • ▼ Show 20 Lines | static void node_type_base_defaults(bNodeType *ntype) | ||||
| /* default size values */ | /* default size values */ | ||||
| node_type_size_preset(ntype, NODE_SIZE_DEFAULT); | node_type_size_preset(ntype, NODE_SIZE_DEFAULT); | ||||
| ntype->height = 100; | ntype->height = 100; | ||||
| ntype->minheight = 30; | ntype->minheight = 30; | ||||
| ntype->maxheight = FLT_MAX; | ntype->maxheight = FLT_MAX; | ||||
| } | } | ||||
| /* allow this node for any tree type */ | /* allow this node for any tree type */ | ||||
| static bool node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *UNUSED(ntree)) | static bool node_poll_default(bNodeType *UNUSED(ntype), | ||||
| bNodeTree *UNUSED(ntree), | |||||
| const char **UNUSED(disabled_hint)) | |||||
| { | { | ||||
| return true; | return true; | ||||
| } | } | ||||
| /* use the basic poll function */ | /* use the basic poll function */ | ||||
| static bool node_poll_instance_default(bNode *node, bNodeTree *ntree) | static bool node_poll_instance_default(bNode *node, bNodeTree *ntree, const char **disabled_hint) | ||||
| { | { | ||||
| return node->typeinfo->poll(node->typeinfo, ntree); | return node->typeinfo->poll(node->typeinfo, ntree, disabled_hint); | ||||
| } | } | ||||
| /* NOLINTNEXTLINE: readability-function-size */ | /* NOLINTNEXTLINE: readability-function-size */ | ||||
| void node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag) | void node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag) | ||||
| { | { | ||||
| /* Use static type info header to map static int type to identifier string and RNA struct type. | /* Use static type info header to map static int type to identifier string and RNA struct type. | ||||
| * Associate the RNA struct type with the bNodeType. | * Associate the RNA struct type with the bNodeType. | ||||
| * Dynamically registered nodes will create an RNA type at runtime | * Dynamically registered nodes will create an RNA type at runtime | ||||
| ▲ Show 20 Lines • Show All 202 Lines • ▼ Show 20 Lines | |||||
| void node_type_internal_links(bNodeType *ntype, | void node_type_internal_links(bNodeType *ntype, | ||||
| void (*update_internal_links)(bNodeTree *, bNode *)) | void (*update_internal_links)(bNodeTree *, bNode *)) | ||||
| { | { | ||||
| ntype->update_internal_links = update_internal_links; | ntype->update_internal_links = update_internal_links; | ||||
| } | } | ||||
| /* callbacks for undefined types */ | /* callbacks for undefined types */ | ||||
| static bool node_undefined_poll(bNodeType *UNUSED(ntype), bNodeTree *UNUSED(nodetree)) | static bool node_undefined_poll(bNodeType *UNUSED(ntype), | ||||
| bNodeTree *UNUSED(nodetree), | |||||
| const char **UNUSED(r_disabled_hint)) | |||||
| { | { | ||||
| /* this type can not be added deliberately, it's just a placeholder */ | /* this type can not be added deliberately, it's just a placeholder */ | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* register fallback types used for undefined tree, nodes, sockets */ | /* register fallback types used for undefined tree, nodes, sockets */ | ||||
| static void register_undefined_types() | static void register_undefined_types() | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 312 Lines • ▼ Show 20 Lines | static void registerGeometryNodes() | ||||
| register_node_type_geo_point_rotate(); | register_node_type_geo_point_rotate(); | ||||
| register_node_type_geo_point_scale(); | register_node_type_geo_point_scale(); | ||||
| register_node_type_geo_point_separate(); | register_node_type_geo_point_separate(); | ||||
| register_node_type_geo_point_translate(); | register_node_type_geo_point_translate(); | ||||
| register_node_type_geo_points_to_volume(); | register_node_type_geo_points_to_volume(); | ||||
| register_node_type_geo_sample_texture(); | register_node_type_geo_sample_texture(); | ||||
| register_node_type_geo_subdivide(); | register_node_type_geo_subdivide(); | ||||
| register_node_type_geo_subdivision_surface(); | register_node_type_geo_subdivision_surface(); | ||||
| register_node_type_geo_switch(); | |||||
| register_node_type_geo_transform(); | register_node_type_geo_transform(); | ||||
| register_node_type_geo_triangulate(); | register_node_type_geo_triangulate(); | ||||
| register_node_type_geo_volume_to_mesh(); | register_node_type_geo_volume_to_mesh(); | ||||
| } | } | ||||
| static void registerFunctionNodes() | static void registerFunctionNodes() | ||||
| { | { | ||||
| register_node_type_fn_boolean_math(); | register_node_type_fn_boolean_math(); | ||||
| ▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines | |||||