Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/node.cc
| Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | |||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_vector_set.hh" | #include "BLI_vector_set.hh" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "BKE_anim_data.h" | #include "BKE_anim_data.h" | ||||
| #include "BKE_animsys.h" | #include "BKE_animsys.h" | ||||
| #include "BKE_bpath.h" | #include "BKE_bpath.h" | ||||
| #include "BKE_colortools.h" | #include "BKE_colortools.h" | ||||
| #include "BKE_context.h" | |||||
| #include "BKE_cryptomatte.h" | #include "BKE_cryptomatte.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_icons.h" | #include "BKE_icons.h" | ||||
| #include "BKE_idprop.h" | #include "BKE_idprop.h" | ||||
| #include "BKE_idtype.h" | #include "BKE_idtype.h" | ||||
| #include "BKE_lib_id.h" | #include "BKE_lib_id.h" | ||||
| #include "BKE_lib_query.h" | #include "BKE_lib_query.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| ▲ Show 20 Lines • Show All 2,087 Lines • ▼ Show 20 Lines | bNode *nodeAddNode(const struct bContext *C, bNodeTree *ntree, const char *idname) | ||||
| bNode *node = MEM_cnew<bNode>("new node"); | bNode *node = MEM_cnew<bNode>("new node"); | ||||
| BLI_addtail(&ntree->nodes, node); | BLI_addtail(&ntree->nodes, node); | ||||
| BLI_strncpy(node->idname, idname, sizeof(node->idname)); | BLI_strncpy(node->idname, idname, sizeof(node->idname)); | ||||
| node_set_typeinfo(C, ntree, node, nodeTypeFind(idname)); | node_set_typeinfo(C, ntree, node, nodeTypeFind(idname)); | ||||
| BKE_ntree_update_tag_node_new(ntree, node); | BKE_ntree_update_tag_node_new(ntree, node); | ||||
| if (node->type == GEO_NODE_INPUT_SCENE_TIME) { | |||||
| DEG_relations_tag_update(CTX_data_main(C)); | |||||
| } | |||||
| return node; | return node; | ||||
| } | } | ||||
| 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) { | ||||
| ▲ Show 20 Lines • Show All 715 Lines • ▼ Show 20 Lines | void BKE_node_preview_clear_tree(bNodeTree *ntree) | ||||
| bNodeInstanceHashIterator iter; | bNodeInstanceHashIterator iter; | ||||
| NODE_INSTANCE_HASH_ITER (iter, ntree->previews) { | NODE_INSTANCE_HASH_ITER (iter, ntree->previews) { | ||||
| bNodePreview *preview = (bNodePreview *)BKE_node_instance_hash_iterator_get_value(&iter); | bNodePreview *preview = (bNodePreview *)BKE_node_instance_hash_iterator_get_value(&iter); | ||||
| BKE_node_preview_clear(preview); | BKE_node_preview_clear(preview); | ||||
| } | } | ||||
| } | } | ||||
| static void node_preview_sync(bNodePreview *to, bNodePreview *from) | |||||
| { | |||||
| /* sizes should have been initialized by BKE_node_preview_init_tree */ | |||||
| BLI_assert(to->xsize == from->xsize && to->ysize == from->ysize); | |||||
| /* copy over contents of previews */ | |||||
| if (to->rect && from->rect) { | |||||
| int xsize = to->xsize; | |||||
| int ysize = to->ysize; | |||||
| memcpy(to->rect, from->rect, xsize * ysize * sizeof(char[4])); | |||||
| } | |||||
| } | |||||
| void BKE_node_preview_sync_tree(bNodeTree *to_ntree, bNodeTree *from_ntree) | |||||
| { | |||||
| bNodeInstanceHash *from_previews = from_ntree->previews; | |||||
| bNodeInstanceHash *to_previews = to_ntree->previews; | |||||
| if (!from_previews || !to_previews) { | |||||
| return; | |||||
| } | |||||
| bNodeInstanceHashIterator iter; | |||||
| NODE_INSTANCE_HASH_ITER (iter, from_previews) { | |||||
| bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter); | |||||
| bNodePreview *from = (bNodePreview *)BKE_node_instance_hash_iterator_get_value(&iter); | |||||
| bNodePreview *to = (bNodePreview *)BKE_node_instance_hash_lookup(to_previews, key); | |||||
| if (from && to) { | |||||
| node_preview_sync(to, from); | |||||
| } | |||||
| } | |||||
| } | |||||
| void BKE_node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, bool remove_old) | void BKE_node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, bool remove_old) | ||||
| { | { | ||||
| if (remove_old || !to_ntree->previews) { | if (remove_old || !to_ntree->previews) { | ||||
| /* free old previews */ | /* free old previews */ | ||||
| if (to_ntree->previews) { | if (to_ntree->previews) { | ||||
| BKE_node_instance_hash_free(to_ntree->previews, (bNodeInstanceValueFP)BKE_node_preview_free); | BKE_node_instance_hash_free(to_ntree->previews, (bNodeInstanceValueFP)BKE_node_preview_free); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 392 Lines • ▼ Show 20 Lines | bNodeTree *ntreeLocalize(bNodeTree *ntree) | ||||
| if (ntree->typeinfo->localize) { | if (ntree->typeinfo->localize) { | ||||
| ntree->typeinfo->localize(ltree, ntree); | ntree->typeinfo->localize(ltree, ntree); | ||||
| } | } | ||||
| return ltree; | return ltree; | ||||
| } | } | ||||
| void ntreeLocalSync(bNodeTree *localtree, bNodeTree *ntree) | |||||
| { | |||||
| if (localtree && ntree) { | |||||
| if (ntree->typeinfo->local_sync) { | |||||
| ntree->typeinfo->local_sync(localtree, ntree); | |||||
| } | |||||
| } | |||||
| } | |||||
| void ntreeLocalMerge(Main *bmain, bNodeTree *localtree, bNodeTree *ntree) | void ntreeLocalMerge(Main *bmain, bNodeTree *localtree, bNodeTree *ntree) | ||||
| { | { | ||||
| if (ntree && localtree) { | if (ntree && localtree) { | ||||
| if (ntree->typeinfo->local_merge) { | if (ntree->typeinfo->local_merge) { | ||||
| ntree->typeinfo->local_merge(bmain, localtree, ntree); | ntree->typeinfo->local_merge(bmain, localtree, ntree); | ||||
| } | } | ||||
| ntreeFreeTree(localtree); | ntreeFreeTree(localtree); | ||||
| ▲ Show 20 Lines • Show All 1,029 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* use the basic poll function */ | /* use the basic poll function */ | ||||
| static bool node_poll_instance_default(bNode *node, bNodeTree *ntree, const char **disabled_hint) | static bool node_poll_instance_default(bNode *node, bNodeTree *ntree, const char **disabled_hint) | ||||
| { | { | ||||
| return node->typeinfo->poll(node->typeinfo, ntree, disabled_hint); | return node->typeinfo->poll(node->typeinfo, ntree, disabled_hint); | ||||
| } | } | ||||
| /* NOLINTNEXTLINE: readability-function-size */ | void node_type_base(bNodeType *ntype, int type, const char *name, short nclass) | ||||
| 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 | ||||
| * and call RNA_struct_blender_type_set, so this only needs to be done for old RNA types | * and call RNA_struct_blender_type_set, so this only needs to be done for old RNA types | ||||
| * created in makesrna, which can not be associated to a bNodeType immediately, | * created in makesrna, which can not be associated to a bNodeType immediately, | ||||
| * since bNodeTypes are registered afterward ... | * since bNodeTypes are registered afterward ... | ||||
| */ | */ | ||||
| Show All 10 Lines | #include "NOD_static_types.h" | ||||
| } | } | ||||
| /* make sure we have a valid type (everything registered) */ | /* make sure we have a valid type (everything registered) */ | ||||
| BLI_assert(ntype->idname[0] != '\0'); | BLI_assert(ntype->idname[0] != '\0'); | ||||
| ntype->type = type; | ntype->type = type; | ||||
| BLI_strncpy(ntype->ui_name, name, sizeof(ntype->ui_name)); | BLI_strncpy(ntype->ui_name, name, sizeof(ntype->ui_name)); | ||||
| ntype->nclass = nclass; | ntype->nclass = nclass; | ||||
| ntype->flag = flag; | |||||
| node_type_base_defaults(ntype); | node_type_base_defaults(ntype); | ||||
| ntype->poll = node_poll_default; | ntype->poll = node_poll_default; | ||||
| ntype->poll_instance = node_poll_instance_default; | ntype->poll_instance = node_poll_instance_default; | ||||
| } | } | ||||
| void node_type_base_custom( | void node_type_base_custom(bNodeType *ntype, const char *idname, const char *name, short nclass) | ||||
| bNodeType *ntype, const char *idname, const char *name, short nclass, short flag) | |||||
| { | { | ||||
| BLI_strncpy(ntype->idname, idname, sizeof(ntype->idname)); | BLI_strncpy(ntype->idname, idname, sizeof(ntype->idname)); | ||||
| ntype->type = NODE_CUSTOM; | ntype->type = NODE_CUSTOM; | ||||
| BLI_strncpy(ntype->ui_name, name, sizeof(ntype->ui_name)); | BLI_strncpy(ntype->ui_name, name, sizeof(ntype->ui_name)); | ||||
| ntype->nclass = nclass; | ntype->nclass = nclass; | ||||
| ntype->flag = flag; | |||||
| node_type_base_defaults(ntype); | node_type_base_defaults(ntype); | ||||
| } | } | ||||
| struct SocketTemplateIdentifierCallbackData { | struct SocketTemplateIdentifierCallbackData { | ||||
| bNodeSocketTemplate *list; | bNodeSocketTemplate *list; | ||||
| bNodeSocketTemplate *ntemp; | bNodeSocketTemplate *ntemp; | ||||
| }; | }; | ||||
| ▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | static void register_undefined_types() | ||||
| * they are just used as placeholders in case the actual types are not registered. | * they are just used as placeholders in case the actual types are not registered. | ||||
| */ | */ | ||||
| NodeTreeTypeUndefined.type = NTREE_UNDEFINED; | NodeTreeTypeUndefined.type = NTREE_UNDEFINED; | ||||
| strcpy(NodeTreeTypeUndefined.idname, "NodeTreeUndefined"); | strcpy(NodeTreeTypeUndefined.idname, "NodeTreeUndefined"); | ||||
| strcpy(NodeTreeTypeUndefined.ui_name, N_("Undefined")); | strcpy(NodeTreeTypeUndefined.ui_name, N_("Undefined")); | ||||
| strcpy(NodeTreeTypeUndefined.ui_description, N_("Undefined Node Tree Type")); | strcpy(NodeTreeTypeUndefined.ui_description, N_("Undefined Node Tree Type")); | ||||
| node_type_base_custom(&NodeTypeUndefined, "NodeUndefined", "Undefined", 0, 0); | node_type_base_custom(&NodeTypeUndefined, "NodeUndefined", "Undefined", 0); | ||||
| NodeTypeUndefined.poll = node_undefined_poll; | NodeTypeUndefined.poll = node_undefined_poll; | ||||
| BLI_strncpy(NodeSocketTypeUndefined.idname, | BLI_strncpy(NodeSocketTypeUndefined.idname, | ||||
| "NodeSocketUndefined", | "NodeSocketUndefined", | ||||
| sizeof(NodeSocketTypeUndefined.idname)); | sizeof(NodeSocketTypeUndefined.idname)); | ||||
| /* extra type info for standard socket types */ | /* extra type info for standard socket types */ | ||||
| NodeSocketTypeUndefined.type = SOCK_CUSTOM; | NodeSocketTypeUndefined.type = SOCK_CUSTOM; | ||||
| NodeSocketTypeUndefined.subtype = PROP_NONE; | NodeSocketTypeUndefined.subtype = PROP_NONE; | ||||
| ▲ Show 20 Lines • Show All 277 Lines • ▼ Show 20 Lines | static void registerGeometryNodes() | ||||
| register_node_type_geo_legacy_mesh_to_curve(); | register_node_type_geo_legacy_mesh_to_curve(); | ||||
| register_node_type_geo_legacy_points_to_volume(); | register_node_type_geo_legacy_points_to_volume(); | ||||
| register_node_type_geo_legacy_raycast(); | register_node_type_geo_legacy_raycast(); | ||||
| register_node_type_geo_legacy_select_by_handle_type(); | register_node_type_geo_legacy_select_by_handle_type(); | ||||
| register_node_type_geo_legacy_select_by_material(); | register_node_type_geo_legacy_select_by_material(); | ||||
| register_node_type_geo_legacy_subdivision_surface(); | register_node_type_geo_legacy_subdivision_surface(); | ||||
| register_node_type_geo_legacy_volume_to_mesh(); | register_node_type_geo_legacy_volume_to_mesh(); | ||||
| register_node_type_geo_accumulate_field(); | |||||
| register_node_type_geo_align_rotation_to_vector(); | register_node_type_geo_align_rotation_to_vector(); | ||||
| register_node_type_geo_attribute_capture(); | register_node_type_geo_attribute_capture(); | ||||
| register_node_type_geo_attribute_clamp(); | register_node_type_geo_attribute_clamp(); | ||||
| register_node_type_geo_attribute_color_ramp(); | register_node_type_geo_attribute_color_ramp(); | ||||
| register_node_type_geo_attribute_combine_xyz(); | register_node_type_geo_attribute_combine_xyz(); | ||||
| register_node_type_geo_attribute_compare(); | register_node_type_geo_attribute_compare(); | ||||
| register_node_type_geo_attribute_convert(); | register_node_type_geo_attribute_convert(); | ||||
| register_node_type_geo_attribute_curve_map(); | register_node_type_geo_attribute_curve_map(); | ||||
| Show All 40 Lines | static void registerGeometryNodes() | ||||
| register_node_type_geo_geometry_to_instance(); | register_node_type_geo_geometry_to_instance(); | ||||
| register_node_type_geo_image_texture(); | register_node_type_geo_image_texture(); | ||||
| register_node_type_geo_input_curve_handles(); | register_node_type_geo_input_curve_handles(); | ||||
| register_node_type_geo_input_curve_tilt(); | register_node_type_geo_input_curve_tilt(); | ||||
| register_node_type_geo_input_id(); | register_node_type_geo_input_id(); | ||||
| register_node_type_geo_input_index(); | register_node_type_geo_input_index(); | ||||
| register_node_type_geo_input_material_index(); | register_node_type_geo_input_material_index(); | ||||
| register_node_type_geo_input_material(); | register_node_type_geo_input_material(); | ||||
| register_node_type_geo_input_mesh_edge_angle(); | |||||
| register_node_type_geo_input_mesh_edge_neighbors(); | register_node_type_geo_input_mesh_edge_neighbors(); | ||||
| register_node_type_geo_input_mesh_edge_vertices(); | register_node_type_geo_input_mesh_edge_vertices(); | ||||
| register_node_type_geo_input_mesh_face_area(); | register_node_type_geo_input_mesh_face_area(); | ||||
| register_node_type_geo_input_mesh_face_neighbors(); | register_node_type_geo_input_mesh_face_neighbors(); | ||||
| register_node_type_geo_input_mesh_island(); | register_node_type_geo_input_mesh_island(); | ||||
| register_node_type_geo_input_mesh_vertex_neighbors(); | register_node_type_geo_input_mesh_vertex_neighbors(); | ||||
| register_node_type_geo_input_normal(); | register_node_type_geo_input_normal(); | ||||
| register_node_type_geo_input_position(); | register_node_type_geo_input_position(); | ||||
| ▲ Show 20 Lines • Show All 237 Lines • Show Last 20 Lines | |||||