diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 8eecdc6e39c..fc7bcede398 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -406,13 +406,6 @@ typedef struct bNodeType { #define NODE_CLASS_ATTRIBUTE 42 #define NODE_CLASS_LAYOUT 100 -typedef enum eNodeSizePreset { - NODE_SIZE_DEFAULT, - NODE_SIZE_SMALL, - NODE_SIZE_MIDDLE, - NODE_SIZE_LARGE, -} eNodeSizePreset; - struct bNodeTreeExec; typedef void (*bNodeClassCallback)(void *calldata, int nclass, const char *name); @@ -496,26 +489,10 @@ void ntreeSetTypes(const struct bContext *C, struct bNodeTree *ntree); struct bNodeTree *ntreeAddTree(struct Main *bmain, const char *name, const char *idname); -struct bNodeTree *ntreeAddTreeEmbedded(struct Main *bmain, - struct ID *owner_id, - const char *name, - const char *idname); - -/* Copy/free functions, need to manage ID users. */ - -/** - * Free (or release) any data used by this node-tree. - * Does not free the node-tree itself and does no ID user counting. - */ -void ntreeFreeTree(struct bNodeTree *ntree); /** * Free tree which is embedded into another data-block. */ void ntreeFreeEmbeddedTree(struct bNodeTree *ntree); -struct bNodeTree *ntreeCopyTree_ex(const struct bNodeTree *ntree, - struct Main *bmain, - bool do_id_user); -struct bNodeTree *ntreeCopyTree(struct Main *bmain, const struct bNodeTree *ntree); /** * Get address of potential node-tree pointer of given ID. @@ -524,14 +501,13 @@ struct bNodeTree *ntreeCopyTree(struct Main *bmain, const struct bNodeTree *ntre * sure, please use `ntreeFromID()` instead. */ struct bNodeTree **BKE_ntree_ptr_from_id(struct ID *id); + /** * Returns the private NodeTree object of the data-block, if it has one. */ struct bNodeTree *ntreeFromID(struct ID *id); -void ntreeFreeLocalNode(struct bNodeTree *ntree, struct bNode *node); void ntreeFreeLocalTree(struct bNodeTree *ntree); -struct bNode *ntreeFindType(struct bNodeTree *ntree, int type); /** * Check recursively if a node tree contains another. @@ -539,7 +515,6 @@ struct bNode *ntreeFindType(struct bNodeTree *ntree, int type); bool ntreeContainsTree(const struct bNodeTree *tree_to_search_in, const struct bNodeTree *tree_to_search_for); -void ntreeUpdateAllNew(struct Main *main); void ntreeUpdateAllUsers(struct Main *main, struct ID *id); /** @@ -549,30 +524,15 @@ void ntreeUpdateAllUsers(struct Main *main, struct ID *id); */ void ntreeSetOutput(struct bNodeTree *ntree); -void ntreeNodeFlagSet(const bNodeTree *ntree, int flag, bool enable); /** * Returns localized tree for execution in threads. */ struct bNodeTree *ntreeLocalize(struct bNodeTree *ntree); -/** - * Merge local tree results back, and free local tree. - * - * We have to assume the editor already changed completely. - */ -void ntreeLocalMerge(struct Main *bmain, struct bNodeTree *localtree, struct bNodeTree *ntree); /** * This is only direct data, tree itself should have been written. */ void ntreeBlendWrite(struct BlendWriter *writer, struct bNodeTree *ntree); -/** - * \note `ntree` itself has been read! - */ -void ntreeBlendReadData(struct BlendDataReader *reader, - struct ID *owner_id, - struct bNodeTree *ntree); -void ntreeBlendReadLib(struct BlendLibReader *reader, struct bNodeTree *ntree); -void ntreeBlendReadExpand(struct BlendExpander *expander, struct bNodeTree *ntree); /** \} */ @@ -580,31 +540,12 @@ void ntreeBlendReadExpand(struct BlendExpander *expander, struct bNodeTree *ntre /** \name Node Tree Interface * \{ */ -struct bNodeSocket *ntreeFindSocketInterface(struct bNodeTree *ntree, - eNodeSocketInOut in_out, - const char *identifier); +void ntreeRemoveSocketInterface(bNodeTree *ntree, bNodeSocket *sock); + struct bNodeSocket *ntreeAddSocketInterface(struct bNodeTree *ntree, eNodeSocketInOut in_out, const char *idname, const char *name); -struct bNodeSocket *ntreeInsertSocketInterface(struct bNodeTree *ntree, - eNodeSocketInOut in_out, - const char *idname, - struct bNodeSocket *next_sock, - const char *name); -struct bNodeSocket *ntreeAddSocketInterfaceFromSocket(struct bNodeTree *ntree, - const struct bNode *from_node, - const struct bNodeSocket *from_sock); -struct bNodeSocket *ntreeAddSocketInterfaceFromSocketWithName(struct bNodeTree *ntree, - const struct bNode *from_node, - const struct bNodeSocket *from_sock, - const char *idname, - const char *name); -struct bNodeSocket *ntreeInsertSocketInterfaceFromSocket(struct bNodeTree *ntree, - struct bNodeSocket *next_sock, - const struct bNode *from_node, - const struct bNodeSocket *from_sock); -void ntreeRemoveSocketInterface(struct bNodeTree *ntree, struct bNodeSocket *sock); /** \} */ @@ -615,7 +556,6 @@ void ntreeRemoveSocketInterface(struct bNodeTree *ntree, struct bNodeSocket *soc struct bNodeType *nodeTypeFind(const char *idname); void nodeRegisterType(struct bNodeType *ntype); void nodeUnregisterType(struct bNodeType *ntype); -bool nodeTypeUndefined(const struct bNode *node); struct GHashIterator *nodeTypeGetIterator(void); /* Helper macros for iterating over node types. */ @@ -639,11 +579,9 @@ bool nodeSocketIsRegistered(const struct bNodeSocket *sock); struct GHashIterator *nodeSocketTypeGetIterator(void); const char *nodeSocketTypeLabel(const bNodeSocketType *stype); -bool nodeIsStaticSocketType(const struct bNodeSocketType *stype); const char *nodeStaticSocketType(int type, int subtype); const char *nodeStaticSocketInterfaceType(int type, int subtype); const char *nodeStaticSocketLabel(int type, int subtype); -const char *nodeSocketSubTypeLabel(int subtype); /* Helper macros for iterating over node types. */ #define NODE_SOCKET_TYPES_BEGIN(stype) \ @@ -678,24 +616,13 @@ struct bNodeSocket *nodeAddStaticSocket(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, - struct bNodeSocket *sock, - const char *idname); + void nodeModifySocketTypeStatic( struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *sock, int type, int subtype); struct bNode *nodeAddNode(const struct bContext *C, struct bNodeTree *ntree, const char *idname); struct bNode *nodeAddStaticNode(const struct bContext *C, struct bNodeTree *ntree, int type); -/** - * \note Goes over entire tree. - */ -void nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node); + /** * Find the first available, non-duplicate name for a given node. */ @@ -706,13 +633,6 @@ void nodeUniqueName(struct bNodeTree *ntree, struct bNode *node); */ void nodeUniqueID(struct bNodeTree *ntree, struct bNode *node); -/** - * Rebuild the `node_by_id` runtime vector set. Call after removing a node if not handled - * separately. This is important instead of just using `nodes_by_id.remove()` since it maintains - * the node order. - */ -void nodeRebuildIDVector(struct bNodeTree *node_tree); - /** * Delete node, associated animation data and ID user count. */ @@ -725,47 +645,6 @@ void nodeDimensionsGet(const struct bNode *node, float *r_width, float *r_height void nodeTagUpdateID(struct bNode *node); void nodeInternalLinks(struct bNode *node, struct bNodeLink **r_links, int *r_len); -#ifdef __cplusplus - -namespace blender::bke { - -/** - * \note keeps socket list order identical, for copying links. - * \param use_unique: If true, make sure the node's identifier and name are unique in the new - * tree. Must be *true* if the \a dst_tree had nodes that weren't in the source node's tree. - * Must be *false* when simply copying a node tree, so that identifiers don't change. - */ -bNode *node_copy_with_mapping(bNodeTree *dst_tree, - const bNode &node_src, - int flag, - bool use_unique, - Map &new_socket_map); - -bNode *node_copy(bNodeTree *dst_tree, const bNode &src_node, int flag, bool use_unique); - -/** - * Move socket default from \a src (input socket) to locations specified by \a dst (output socket). - * Result value moved in specific location. (potentially multiple group nodes socket values, if \a - * dst is a group input node). - * \note Conceptually, the effect should be such that the evaluation of - * this graph again returns the value in src. - */ -void node_socket_move_default_value(Main &bmain, - bNodeTree &tree, - bNodeSocket &src, - bNodeSocket &dst); - -/** - * Free the node itself. - * - * \note ID user reference-counting and changing the `nodes_by_id` vector are up to the caller. - */ -void node_free_node(bNodeTree *tree, bNode *node); - -} // namespace blender::bke - -#endif - /** * Also used via RNA API, so we check for proper input output direction. */ @@ -776,25 +655,19 @@ struct bNodeLink *nodeAddLink(struct bNodeTree *ntree, struct bNodeSocket *tosock); void nodeRemLink(struct bNodeTree *ntree, struct bNodeLink *link); void nodeRemSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock); -/** - * Set the mute status of a single link. - */ -void nodeLinkSetMute(struct bNodeTree *ntree, struct bNodeLink *link, const bool muted); -bool nodeLinkIsHidden(const struct bNodeLink *link); -bool nodeLinkIsSelected(const struct bNodeLink *link); -void nodeInternalRelink(struct bNodeTree *ntree, struct bNode *node); -void nodeToView(const struct bNode *node, float x, float y, float *rx, float *ry); -void nodeFromView(const struct bNode *node, float x, float y, float *rx, float *ry); +bool nodeLinkIsHidden(const struct bNodeLink *link); + void nodeAttachNode(struct bNodeTree *ntree, struct bNode *node, struct bNode *parent); void nodeDetachNode(struct bNodeTree *ntree, struct bNode *node); -void nodePositionRelative(struct bNode *from_node, - const struct bNode *to_node, - const struct bNodeSocket *from_sock, - const struct bNodeSocket *to_sock); -void nodePositionPropagate(struct bNode *node); - +/** + * Same as above but expects that the socket definitely is in the node tree. + */ +void nodeFindNode(struct bNodeTree *ntree, + struct bNodeSocket *sock, + struct bNode **r_node, + int *r_sockindex); /** * Finds a node based on its name. */ @@ -806,65 +679,9 @@ bool nodeFindNodeTry(struct bNodeTree *ntree, struct bNodeSocket *sock, struct bNode **r_node, int *r_sockindex); -/** - * Same as above but expects that the socket definitely is in the node tree. - */ -void nodeFindNode(struct bNodeTree *ntree, - struct bNodeSocket *sock, - struct bNode **r_node, - int *r_sockindex); -/** - * \note Recursive. - */ -struct bNode *nodeFindRootParent(bNode *node); bool nodeIsParentAndChild(const bNode *parent, const bNode *child); -/** - * Iterate over a chain of nodes, starting with \a node_start, executing - * \a callback for each node (which can return false to end iterator). - * - * \param reversed: for backwards iteration - * \note Recursive - */ -void nodeChainIter(const bNodeTree *ntree, - const bNode *node_start, - bool (*callback)(bNode *, bNode *, void *, const bool), - void *userdata, - bool reversed); -/** - * Iterate over a chain of nodes, starting with \a node_start, executing - * \a callback for each node (which can return false to end iterator). - * - * Faster than nodeChainIter. Iter only once per node. - * Can be called recursively (using another nodeChainIterBackwards) by - * setting the recursion_lvl accordingly. - * - * \note Needs updated socket links (ntreeUpdateTree). - * \note Recursive - */ -void nodeChainIterBackwards(const bNodeTree *ntree, - const bNode *node_start, - bool (*callback)(bNode *, bNode *, void *), - void *userdata, - int recursion_lvl); -/** - * Iterate over all parents of \a node, executing \a callback for each parent - * (which can return false to end iterator) - * - * \note Recursive - */ -void nodeParentsIter(bNode *node, bool (*callback)(bNode *, void *), void *userdata); - -/** - * A dangling reroute node is a reroute node that does *not* have a "data source", i.e. no - * non-reroute node is connected to its input. - */ -bool nodeIsDanglingReroute(const struct bNodeTree *ntree, const struct bNode *node); - -struct bNodeLink *nodeFindLink(struct bNodeTree *ntree, - const struct bNodeSocket *from, - const struct bNodeSocket *to); int nodeCountSocketLinks(const struct bNodeTree *ntree, const struct bNodeSocket *sock); void nodeSetSelected(struct bNode *node, bool select); @@ -878,37 +695,9 @@ void nodeClearActive(struct bNodeTree *ntree); * Two active flags, ID nodes have special flag for buttons display. */ struct bNode *nodeGetActiveTexture(struct bNodeTree *ntree); -struct bNode *nodeGetActivePaintCanvas(struct bNodeTree *ntree); - -/** - * \brief Does the given node supports the sub active flag. - * - * \param sub_active: The active flag to check. #NODE_ACTIVE_TEXTURE / #NODE_ACTIVE_PAINT_CANVAS. - */ -bool nodeSupportsActiveFlag(const struct bNode *node, int sub_active); - -void nodeSetSocketAvailability(struct bNodeTree *ntree, - struct bNodeSocket *sock, - bool is_available); int nodeSocketLinkLimit(const struct bNodeSocket *sock); -/** - * If the node implements a `declare` function, this function makes sure that `node->declaration` - * is up to date. It is expected that the sockets of the node are up to date already. - */ -bool nodeDeclarationEnsure(struct bNodeTree *ntree, struct bNode *node); -/** - * Just update `node->declaration` if necessary. This can also be called on nodes that may not be - * up to date (e.g. because the need versioning or are dynamic). - */ -bool nodeDeclarationEnsureOnOutdatedNode(struct bNodeTree *ntree, struct bNode *node); -/** - * Update `socket->declaration` for all sockets in the node. This assumes that the node declaration - * and sockets are up to date already. - */ -void nodeSocketDeclarationsUpdate(struct bNode *node); - /** * Node Instance Hash. */ @@ -947,89 +736,22 @@ bool BKE_node_instance_hash_tag_key(bNodeInstanceHash *hash, bNodeInstanceKey ke void BKE_node_instance_hash_remove_untagged(bNodeInstanceHash *hash, bNodeInstanceValueFP valfreefp); -typedef GHashIterator bNodeInstanceHashIterator; - -BLI_INLINE bNodeInstanceHashIterator *BKE_node_instance_hash_iterator_new(bNodeInstanceHash *hash) -{ - return BLI_ghashIterator_new(hash->ghash); -} -BLI_INLINE void BKE_node_instance_hash_iterator_init(bNodeInstanceHashIterator *iter, - bNodeInstanceHash *hash) -{ - BLI_ghashIterator_init(iter, hash->ghash); -} -BLI_INLINE void BKE_node_instance_hash_iterator_free(bNodeInstanceHashIterator *iter) -{ - BLI_ghashIterator_free(iter); -} -BLI_INLINE bNodeInstanceKey -BKE_node_instance_hash_iterator_get_key(bNodeInstanceHashIterator *iter) -{ - return *(bNodeInstanceKey *)BLI_ghashIterator_getKey(iter); -} -BLI_INLINE void *BKE_node_instance_hash_iterator_get_value(bNodeInstanceHashIterator *iter) -{ - return BLI_ghashIterator_getValue(iter); -} -BLI_INLINE void BKE_node_instance_hash_iterator_step(bNodeInstanceHashIterator *iter) -{ - BLI_ghashIterator_step(iter); -} -BLI_INLINE bool BKE_node_instance_hash_iterator_done(bNodeInstanceHashIterator *iter) -{ - return BLI_ghashIterator_done(iter); -} - -#define NODE_INSTANCE_HASH_ITER(iter_, hash_) \ - for (BKE_node_instance_hash_iterator_init(&iter_, hash_); \ - BKE_node_instance_hash_iterator_done(&iter_) == false; \ - BKE_node_instance_hash_iterator_step(&iter_)) - -/* Node Previews */ - -bool BKE_node_preview_used(const struct bNode *node); -bNodePreview *BKE_node_preview_verify( - struct bNodeInstanceHash *previews, bNodeInstanceKey key, int xsize, int ysize, bool create); -bNodePreview *BKE_node_preview_copy(struct bNodePreview *preview); -void BKE_node_preview_free(struct bNodePreview *preview); -void BKE_node_preview_init_tree(struct bNodeTree *ntree, int xsize, int ysize); -void BKE_node_preview_remove_unused(struct bNodeTree *ntree); -void BKE_node_preview_clear(struct bNodePreview *preview); void BKE_node_preview_clear_tree(struct bNodeTree *ntree); - -void BKE_node_preview_merge_tree(struct bNodeTree *to_ntree, - struct bNodeTree *from_ntree, - bool remove_old); - /** \} */ /* -------------------------------------------------------------------- */ /** \name Node Type Access * \{ */ -void nodeLabel(const struct bNodeTree *ntree, const struct bNode *node, char *label, int maxlen); -/** - * Get node socket label if it is set. - */ -const char *nodeSocketLabel(const struct bNodeSocket *sock); - bool nodeGroupPoll(const struct bNodeTree *nodetree, const struct bNodeTree *grouptree, const char **r_disabled_hint); -/** - * Initialize a new node type struct with default values and callbacks. - */ -void node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass); void node_type_base_custom(struct bNodeType *ntype, const char *idname, const char *name, short nclass); -void node_type_socket_templates(struct bNodeType *ntype, - struct bNodeSocketTemplate *inputs, - struct bNodeSocketTemplate *outputs); -void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwidth); -void node_type_size_preset(struct bNodeType *ntype, eNodeSizePreset size); + /** * \warning Nodes defining a storage type _must_ allocate this for new nodes. * Otherwise nodes will reload as undefined (#46619). @@ -1043,12 +765,6 @@ void node_type_storage(struct bNodeType *ntype, /** \} */ -/* -------------------------------------------------------------------- */ -/** \name Node Generic Functions - * \{ */ - -bool BKE_node_is_connected_to_output(const struct bNodeTree *ntree, const struct bNode *node); - /* ************** COMMON NODES *************** */ #define NODE_UNDEFINED -2 /* node type is not registered */ @@ -1620,32 +1336,6 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, i void BKE_node_system_init(void); void BKE_node_system_exit(void); -extern bNodeTreeType NodeTreeTypeUndefined; -extern struct bNodeType NodeTypeUndefined; -extern struct bNodeSocketType NodeSocketTypeUndefined; - #ifdef __cplusplus } #endif - -#ifdef __cplusplus - -namespace blender::bke { - -bNodeSocket *node_find_enabled_socket(bNode &node, eNodeSocketInOut in_out, StringRef name); -bNodeSocket *node_find_enabled_input_socket(bNode &node, StringRef name); -bNodeSocket *node_find_enabled_output_socket(bNode &node, StringRef name); - -} // namespace blender::bke - -#endif - -#define NODE_STORAGE_FUNCS(StorageT) \ - [[maybe_unused]] static StorageT &node_storage(bNode &node) \ - { \ - return *static_cast(node.storage); \ - } \ - [[maybe_unused]] static const StorageT &node_storage(const bNode &node) \ - { \ - return *static_cast(node.storage); \ - } diff --git a/source/blender/blenkernel/BKE_node.hh b/source/blender/blenkernel/BKE_node.hh new file mode 100644 index 00000000000..411d83d003c --- /dev/null +++ b/source/blender/blenkernel/BKE_node.hh @@ -0,0 +1,372 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2005 Blender Foundation */ + +#pragma once + +/** \file + * \ingroup bke + */ + +#include "BLI_compiler_compat.h" +#include "BLI_ghash.h" + +#include "DNA_listBase.h" + +#include "BKE_node.h" + +/* for FOREACH_NODETREE_BEGIN */ +#include "DNA_node_types.h" + +#include "RNA_types.h" + +#include "BLI_map.hh" +#include "BLI_string_ref.hh" + +namespace blender::bke { + +bNodeTree *ntreeAddTreeEmbedded(Main *bmain, ID *owner_id, const char *name, const char *idname); + +/* Copy/free functions, need to manage ID users. */ + +/** + * Free (or release) any data used by this node-tree. + * Does not free the node-tree itself and does no ID user counting. + */ +void ntreeFreeTree(bNodeTree *ntree); + +bNodeTree *ntreeCopyTree_ex(const bNodeTree *ntree, Main *bmain, bool do_id_user); +bNodeTree *ntreeCopyTree(Main *bmain, const bNodeTree *ntree); + +void ntreeFreeLocalNode(bNodeTree *ntree, bNode *node); + +bNode *ntreeFindType(bNodeTree *ntree, int type); + +void ntreeUpdateAllNew(Main *main); + +void ntreeNodeFlagSet(const bNodeTree *ntree, int flag, bool enable); + +/** + * Merge local tree results back, and free local tree. + * + * We have to assume the editor already changed completely. + */ +void ntreeLocalMerge(Main *bmain, bNodeTree *localtree, bNodeTree *ntree); + +/** + * \note `ntree` itself has been read! + */ +void ntreeBlendReadData(BlendDataReader *reader, ID *owner_id, bNodeTree *ntree); +void ntreeBlendReadLib(BlendLibReader *reader, bNodeTree *ntree); + +void ntreeBlendReadExpand(BlendExpander *expander, bNodeTree *ntree); + +/* -------------------------------------------------------------------- */ +/** \name Node Tree Interface + * \{ */ + +bNodeSocket *ntreeFindSocketInterface(bNodeTree *ntree, + eNodeSocketInOut in_out, + const char *identifier); + +bNodeSocket *ntreeInsertSocketInterface(bNodeTree *ntree, + eNodeSocketInOut in_out, + const char *idname, + bNodeSocket *next_sock, + const char *name); + +bNodeSocket *ntreeAddSocketInterfaceFromSocket(bNodeTree *ntree, + const bNode *from_node, + const bNodeSocket *from_sock); + +bNodeSocket *ntreeAddSocketInterfaceFromSocketWithName(bNodeTree *ntree, + const bNode *from_node, + const bNodeSocket *from_sock, + const char *idname, + const char *name); + +bNodeSocket *ntreeInsertSocketInterfaceFromSocket(bNodeTree *ntree, + bNodeSocket *next_sock, + const bNode *from_node, + const bNodeSocket *from_sock); + +/** \} */ + +bool node_type_is_undefined(const bNode *node); + +bool nodeIsStaticSocketType(const bNodeSocketType *stype); + +const char *nodeSocketSubTypeLabel(int subtype); + +void nodeRemoveSocketEx(bNodeTree *ntree, bNode *node, bNodeSocket *sock, bool do_id_user); + +void nodeRemoveAllSockets(bNodeTree *ntree, bNode *node); + +void nodeModifySocketType(bNodeTree *ntree, bNode *node, bNodeSocket *sock, const char *idname); + +/** + * \note Goes over entire tree. + */ +void nodeUnlinkNode(bNodeTree *ntree, bNode *node); + +/** + * Rebuild the `node_by_id` runtime vector set. Call after removing a node if not handled + * separately. This is important instead of just using `nodes_by_id.remove()` since it maintains + * the node order. + */ +void nodeRebuildIDVector(bNodeTree *node_tree); + +/** + * \note keeps socket list order identical, for copying links. + * \param use_unique: If true, make sure the node's identifier and name are unique in the new + * tree. Must be *true* if the \a dst_tree had nodes that weren't in the source node's tree. + * Must be *false* when simply copying a node tree, so that identifiers don't change. + */ +bNode *node_copy_with_mapping(bNodeTree *dst_tree, + const bNode &node_src, + int flag, + bool use_unique, + Map &new_socket_map); + +bNode *node_copy(bNodeTree *dst_tree, const bNode &src_node, int flag, bool use_unique); + +/** + * Move socket default from \a src (input socket) to locations specified by \a dst (output socket). + * Result value moved in specific location. (potentially multiple group nodes socket values, if \a + * dst is a group input node). + * \note Conceptually, the effect should be such that the evaluation of + * this graph again returns the value in src. + */ +void node_socket_move_default_value(Main &bmain, + bNodeTree &tree, + bNodeSocket &src, + bNodeSocket &dst); + +/** + * Free the node itself. + * + * \note ID user reference-counting and changing the `nodes_by_id` vector are up to the caller. + */ +void node_free_node(bNodeTree *tree, bNode *node); + +/** + * Set the mute status of a single link. + */ +void nodeLinkSetMute(bNodeTree *ntree, bNodeLink *link, const bool muted); + +bool nodeLinkIsSelected(const bNodeLink *link); + +void nodeInternalRelink(bNodeTree *ntree, bNode *node); + +void nodeToView(const bNode *node, float x, float y, float *rx, float *ry); + +void nodeFromView(const bNode *node, float x, float y, float *rx, float *ry); + +void nodePositionRelative(bNode *from_node, + const bNode *to_node, + const bNodeSocket *from_sock, + const bNodeSocket *to_sock); + +void nodePositionPropagate(bNode *node); + +/** + * \note Recursive. + */ +bNode *nodeFindRootParent(bNode *node); + +/** + * Iterate over a chain of nodes, starting with \a node_start, executing + * \a callback for each node (which can return false to end iterator). + * + * \param reversed: for backwards iteration + * \note Recursive + */ +void nodeChainIter(const bNodeTree *ntree, + const bNode *node_start, + bool (*callback)(bNode *, bNode *, void *, const bool), + void *userdata, + bool reversed); + +/** + * Iterate over a chain of nodes, starting with \a node_start, executing + * \a callback for each node (which can return false to end iterator). + * + * Faster than nodeChainIter. Iter only once per node. + * Can be called recursively (using another nodeChainIterBackwards) by + * setting the recursion_lvl accordingly. + * + * \note Needs updated socket links (ntreeUpdateTree). + * \note Recursive + */ +void nodeChainIterBackwards(const bNodeTree *ntree, + const bNode *node_start, + bool (*callback)(bNode *, bNode *, void *), + void *userdata, + int recursion_lvl); + +/** + * Iterate over all parents of \a node, executing \a callback for each parent + * (which can return false to end iterator) + * + * \note Recursive + */ +void nodeParentsIter(bNode *node, bool (*callback)(bNode *, void *), void *userdata); + +/** + * A dangling reroute node is a reroute node that does *not* have a "data source", i.e. no + * non-reroute node is connected to its input. + */ +bool nodeIsDanglingReroute(const struct bNodeTree *ntree, const struct bNode *node); + +struct bNodeLink *nodeFindLink(struct bNodeTree *ntree, + const struct bNodeSocket *from, + const struct bNodeSocket *to); + +struct bNode *nodeGetActivePaintCanvas(struct bNodeTree *ntree); + +/** + * \brief Does the given node supports the sub active flag. + * + * \param sub_active: The active flag to check. #NODE_ACTIVE_TEXTURE / #NODE_ACTIVE_PAINT_CANVAS. + */ +bool nodeSupportsActiveFlag(const struct bNode *node, int sub_active); + +void nodeSetSocketAvailability(struct bNodeTree *ntree, + struct bNodeSocket *sock, + bool is_available); + +/** + * If the node implements a `declare` function, this function makes sure that `node->declaration` + * is up to date. It is expected that the sockets of the node are up to date already. + */ +bool nodeDeclarationEnsure(struct bNodeTree *ntree, struct bNode *node); + +/** + * Just update `node->declaration` if necessary. This can also be called on nodes that may not be + * up to date (e.g. because the need versioning or are dynamic). + */ +bool nodeDeclarationEnsureOnOutdatedNode(struct bNodeTree *ntree, struct bNode *node); + +/** + * Update `socket->declaration` for all sockets in the node. This assumes that the node declaration + * and sockets are up to date already. + */ +void nodeSocketDeclarationsUpdate(struct bNode *node); + +typedef GHashIterator bNodeInstanceHashIterator; + +BLI_INLINE bNodeInstanceHashIterator *node_instance_hash_iterator_new(bNodeInstanceHash *hash) +{ + return BLI_ghashIterator_new(hash->ghash); +} + +BLI_INLINE void node_instance_hash_iterator_init(bNodeInstanceHashIterator *iter, + bNodeInstanceHash *hash) +{ + BLI_ghashIterator_init(iter, hash->ghash); +} + +BLI_INLINE void node_instance_hash_iterator_free(bNodeInstanceHashIterator *iter) +{ + BLI_ghashIterator_free(iter); +} + +BLI_INLINE bNodeInstanceKey node_instance_hash_iterator_get_key(bNodeInstanceHashIterator *iter) +{ + return *(bNodeInstanceKey *)BLI_ghashIterator_getKey(iter); +} + +BLI_INLINE void *node_instance_hash_iterator_get_value(bNodeInstanceHashIterator *iter) +{ + return BLI_ghashIterator_getValue(iter); +} + +BLI_INLINE void node_instance_hash_iterator_step(bNodeInstanceHashIterator *iter) +{ + BLI_ghashIterator_step(iter); +} + +BLI_INLINE bool node_instance_hash_iterator_done(bNodeInstanceHashIterator *iter) +{ + return BLI_ghashIterator_done(iter); +} + +#define NODE_INSTANCE_HASH_ITER(iter_, hash_) \ + for (blender::bke::node_instance_hash_iterator_init(&iter_, hash_); \ + blender::bke::node_instance_hash_iterator_done(&iter_) == false; \ + blender::bke::node_instance_hash_iterator_step(&iter_)) + +/* Node Previews */ +bool node_preview_used(const bNode *node); + +bNodePreview *node_preview_verify( + bNodeInstanceHash *previews, bNodeInstanceKey key, int xsize, int ysize, bool create); + +bNodePreview *node_preview_copy(bNodePreview *preview); + +void node_preview_free(bNodePreview *preview); + +void node_preview_init_tree(bNodeTree *ntree, int xsize, int ysize); + +void node_preview_remove_unused(bNodeTree *ntree); + +void node_preview_clear(bNodePreview *preview); + +void node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, bool remove_old); + +/* -------------------------------------------------------------------- */ +/** \name Node Type Access + * \{ */ +void nodeLabel(const bNodeTree *ntree, const bNode *node, char *label, int maxlen); + +/** + * Get node socket label if it is set. + */ +const char *nodeSocketLabel(const bNodeSocket *sock); + +/** + * Initialize a new node type struct with default values and callbacks. + */ +void node_type_base(bNodeType *ntype, int type, const char *name, short nclass); + +void node_type_socket_templates(bNodeType *ntype, + bNodeSocketTemplate *inputs, + bNodeSocketTemplate *outputs); + +void node_type_size(bNodeType *ntype, int width, int minwidth, int maxwidth); + +enum class eNodeSizePreset : int8_t { + DEFAULT, + SMALL, + MIDDLE, + LARGE, +}; + +void node_type_size_preset(bNodeType *ntype, eNodeSizePreset size); + +/* -------------------------------------------------------------------- */ +/** \name Node Generic Functions + * \{ */ + +bool node_is_connected_to_output(const struct bNodeTree *ntree, const struct bNode *node); + +bNodeSocket *node_find_enabled_socket(bNode &node, eNodeSocketInOut in_out, StringRef name); + +bNodeSocket *node_find_enabled_input_socket(bNode &node, StringRef name); + +bNodeSocket *node_find_enabled_output_socket(bNode &node, StringRef name); + +extern bNodeTreeType NodeTreeTypeUndefined; +extern bNodeType NodeTypeUndefined; +extern bNodeSocketType NodeSocketTypeUndefined; + +} // namespace blender::bke + +#define NODE_STORAGE_FUNCS(StorageT) \ + [[maybe_unused]] static StorageT &node_storage(bNode &node) \ + { \ + return *static_cast(node.storage); \ + } \ + [[maybe_unused]] static const StorageT &node_storage(const bNode &node) \ + { \ + return *static_cast(node.storage); \ + } diff --git a/source/blender/blenkernel/BKE_node_runtime.hh b/source/blender/blenkernel/BKE_node_runtime.hh index 3c0a77d5e24..afebe5c63ec 100644 --- a/source/blender/blenkernel/BKE_node_runtime.hh +++ b/source/blender/blenkernel/BKE_node_runtime.hh @@ -15,7 +15,7 @@ #include "DNA_node_types.h" -#include "BKE_node.h" +#include "BKE_node.hh" struct bNode; struct bNodeSocket; diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index b419871c8ed..61f09f84a51 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -70,7 +70,7 @@ #include "BKE_image_format.h" #include "BKE_lib_id.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" #include "BKE_packedFile.h" diff --git a/source/blender/blenkernel/intern/layer.cc b/source/blender/blenkernel/intern/layer.cc index b14b97a1c30..54ac1b39011 100644 --- a/source/blender/blenkernel/intern/layer.cc +++ b/source/blender/blenkernel/intern/layer.cc @@ -26,7 +26,7 @@ #include "BKE_layer.h" #include "BKE_lib_id.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_object.h" #include "DNA_ID.h" diff --git a/source/blender/blenkernel/intern/lib_override.cc b/source/blender/blenkernel/intern/lib_override.cc index 7a609d895c9..ff8e578c71e 100644 --- a/source/blender/blenkernel/intern/lib_override.cc +++ b/source/blender/blenkernel/intern/lib_override.cc @@ -38,7 +38,7 @@ #include "BKE_lib_remap.h" #include "BKE_main.h" #include "BKE_main_namemap.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_report.h" #include "BKE_scene.h" diff --git a/source/blender/blenkernel/intern/lib_remap_test.cc b/source/blender/blenkernel/intern/lib_remap_test.cc index 43644eccb90..521fb2f79af 100644 --- a/source/blender/blenkernel/intern/lib_remap_test.cc +++ b/source/blender/blenkernel/intern/lib_remap_test.cc @@ -21,7 +21,7 @@ #include "BKE_lib_remap.h" #include "BKE_main.h" #include "BKE_mesh.hh" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_object.h" #include "BKE_scene.h" diff --git a/source/blender/blenkernel/intern/linestyle.cc b/source/blender/blenkernel/intern/linestyle.cc index e1840a9af63..b34fd9585a0 100644 --- a/source/blender/blenkernel/intern/linestyle.cc +++ b/source/blender/blenkernel/intern/linestyle.cc @@ -33,7 +33,7 @@ #include "BKE_lib_query.h" #include "BKE_linestyle.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_tree_update.h" #include "BKE_texture.h" @@ -2038,7 +2038,8 @@ void BKE_linestyle_default_shader(const bContext *C, FreestyleLineStyle *linesty BLI_assert(linestyle->nodetree == nullptr); - ntree = ntreeAddTreeEmbedded(nullptr, &linestyle->id, "stroke_shader", "ShaderNodeTree"); + ntree = blender::bke::ntreeAddTreeEmbedded( + nullptr, &linestyle->id, "stroke_shader", "ShaderNodeTree"); uv_along_stroke = nodeAddStaticNode(C, ntree, SH_NODE_UVALONGSTROKE); uv_along_stroke->locx = 0.0f; diff --git a/source/blender/blenkernel/intern/material.cc b/source/blender/blenkernel/intern/material.cc index 7b907deabdb..d9fa415c16b 100644 --- a/source/blender/blenkernel/intern/material.cc +++ b/source/blender/blenkernel/intern/material.cc @@ -57,7 +57,7 @@ #include "BKE_main.h" #include "BKE_material.h" #include "BKE_mesh.hh" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_object.h" #include "BKE_scene.h" @@ -1560,7 +1560,7 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma, const struct Ob ma->texpaintslot = static_cast( MEM_callocN(sizeof(TexPaintSlot) * count, "texpaint_slots")); - bNode *active_node = nodeGetActivePaintCanvas(ma->nodetree); + bNode *active_node = blender::bke::nodeGetActivePaintCanvas(ma->nodetree); fill_texpaint_slots_recursive(ma->nodetree, active_node, ob, ma, count, slot_filter); @@ -1932,7 +1932,7 @@ void BKE_material_copybuf_copy(Main *bmain, Material *ma) matcopybuf = blender::dna::shallow_copy(*ma); if (ma->nodetree != nullptr) { - matcopybuf.nodetree = ntreeCopyTree_ex(ma->nodetree, bmain, false); + matcopybuf.nodetree = blender::bke::ntreeCopyTree_ex(ma->nodetree, bmain, false); } matcopybuf.preview = nullptr; @@ -1962,7 +1962,7 @@ void BKE_material_copybuf_paste(Main *bmain, Material *ma) (ma->id) = id; if (matcopybuf.nodetree != nullptr) { - ma->nodetree = ntreeCopyTree_ex(matcopybuf.nodetree, bmain, false); + ma->nodetree = blender::bke::ntreeCopyTree_ex(matcopybuf.nodetree, bmain, false); } } @@ -2001,7 +2001,7 @@ static void material_default_surface_init(Material *ma) { strcpy(ma->id.name, "MADefault Surface"); - bNodeTree *ntree = ntreeAddTreeEmbedded( + bNodeTree *ntree = blender::bke::ntreeAddTreeEmbedded( nullptr, &ma->id, "Shader Nodetree", ntreeType_Shader->idname); ma->use_nodes = true; @@ -2029,7 +2029,7 @@ static void material_default_volume_init(Material *ma) { strcpy(ma->id.name, "MADefault Volume"); - bNodeTree *ntree = ntreeAddTreeEmbedded( + bNodeTree *ntree = blender::bke::ntreeAddTreeEmbedded( nullptr, &ma->id, "Shader Nodetree", ntreeType_Shader->idname); ma->use_nodes = true; @@ -2054,7 +2054,7 @@ static void material_default_holdout_init(Material *ma) { strcpy(ma->id.name, "MADefault Holdout"); - bNodeTree *ntree = ntreeAddTreeEmbedded( + bNodeTree *ntree = blender::bke::ntreeAddTreeEmbedded( nullptr, &ma->id, "Shader Nodetree", ntreeType_Shader->idname); ma->use_nodes = true; diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 384018a1e86..1dc5f004eab 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -63,7 +63,7 @@ #include "BKE_lib_id.h" #include "BKE_lib_query.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" #include "BKE_node_tree_zones.hh" @@ -112,321 +112,21 @@ using blender::nodes::OutputFieldDependency; using blender::nodes::OutputSocketFieldType; using blender::nodes::SocketDeclaration; -/* Fallback types for undefined tree, nodes, sockets */ +static CLG_LogRef LOG = {"bke.node"}; + +namespace blender::bke { + +/* Fallback types for undefined tree, nodes, sockets. */ bNodeTreeType NodeTreeTypeUndefined; bNodeType NodeTypeUndefined; bNodeSocketType NodeSocketTypeUndefined; -static CLG_LogRef LOG = {"bke.node"}; +} // namespace blender::bke -static void ntree_set_typeinfo(bNodeTree *ntree, bNodeTreeType *typeinfo); -static void node_socket_copy(bNodeSocket *sock_dst, const bNodeSocket *sock_src, const int flag); -static void free_localized_node_groups(bNodeTree *ntree); static void node_socket_interface_free(bNodeTree * /*ntree*/, bNodeSocket *sock, const bool do_id_user); -static void ntree_init_data(ID *id) -{ - bNodeTree *ntree = reinterpret_cast(id); - ntree->runtime = MEM_new(__func__); - ntree_set_typeinfo(ntree, nullptr); -} - -static void ntree_copy_data(Main * /*bmain*/, ID *id_dst, const ID *id_src, const int flag) -{ - bNodeTree *ntree_dst = reinterpret_cast(id_dst); - const bNodeTree *ntree_src = reinterpret_cast(id_src); - - /* We never handle user-count here for own data. */ - const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT; - - ntree_dst->runtime = MEM_new(__func__); - bNodeTreeRuntime &dst_runtime = *ntree_dst->runtime; - - Map socket_map; - - dst_runtime.nodes_by_id.reserve(ntree_src->all_nodes().size()); - BLI_listbase_clear(&ntree_dst->nodes); - int i; - LISTBASE_FOREACH_INDEX (const bNode *, src_node, &ntree_src->nodes, i) { - /* Don't find a unique name for every node, since they should have valid names already. */ - bNode *new_node = blender::bke::node_copy_with_mapping( - ntree_dst, *src_node, flag_subdata, false, socket_map); - dst_runtime.nodes_by_id.add_new(new_node); - new_node->runtime->index_in_tree = i; - } - - /* copy links */ - BLI_listbase_clear(&ntree_dst->links); - LISTBASE_FOREACH (const bNodeLink *, src_link, &ntree_src->links) { - bNodeLink *dst_link = static_cast(MEM_dupallocN(src_link)); - dst_link->fromnode = dst_runtime.nodes_by_id.lookup_key_as(src_link->fromnode->identifier); - dst_link->fromsock = socket_map.lookup(src_link->fromsock); - dst_link->tonode = dst_runtime.nodes_by_id.lookup_key_as(src_link->tonode->identifier); - dst_link->tosock = socket_map.lookup(src_link->tosock); - BLI_assert(dst_link->tosock); - dst_link->tosock->link = dst_link; - BLI_addtail(&ntree_dst->links, dst_link); - } - - /* update node->parent pointers */ - for (bNode *node : ntree_dst->all_nodes()) { - if (node->parent) { - node->parent = dst_runtime.nodes_by_id.lookup_key_as(node->parent->identifier); - } - } - - for (bNode *node : ntree_dst->all_nodes()) { - nodeDeclarationEnsure(ntree_dst, node); - } - - /* copy interface sockets */ - BLI_listbase_clear(&ntree_dst->inputs); - LISTBASE_FOREACH (const bNodeSocket *, src_socket, &ntree_src->inputs) { - bNodeSocket *dst_socket = static_cast(MEM_dupallocN(src_socket)); - node_socket_copy(dst_socket, src_socket, flag_subdata); - BLI_addtail(&ntree_dst->inputs, dst_socket); - } - BLI_listbase_clear(&ntree_dst->outputs); - LISTBASE_FOREACH (const bNodeSocket *, src_socket, &ntree_src->outputs) { - bNodeSocket *dst_socket = static_cast(MEM_dupallocN(src_socket)); - node_socket_copy(dst_socket, src_socket, flag_subdata); - BLI_addtail(&ntree_dst->outputs, dst_socket); - } - - /* copy preview hash */ - if (ntree_src->previews && (flag & LIB_ID_COPY_NO_PREVIEW) == 0) { - bNodeInstanceHashIterator iter; - - ntree_dst->previews = BKE_node_instance_hash_new("node previews"); - - NODE_INSTANCE_HASH_ITER (iter, ntree_src->previews) { - bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter); - bNodePreview *preview = static_cast( - BKE_node_instance_hash_iterator_get_value(&iter)); - BKE_node_instance_hash_insert(ntree_dst->previews, key, BKE_node_preview_copy(preview)); - } - } - else { - ntree_dst->previews = nullptr; - } - - if (ntree_src->runtime->field_inferencing_interface) { - dst_runtime.field_inferencing_interface = std::make_unique( - *ntree_src->runtime->field_inferencing_interface); - } - if (ntree_src->runtime->anonymous_attribute_relations) { - dst_runtime.anonymous_attribute_relations = - std::make_unique( - *ntree_src->runtime->anonymous_attribute_relations); - } - - if (flag & LIB_ID_COPY_NO_PREVIEW) { - ntree_dst->preview = nullptr; - } - else { - BKE_previewimg_id_copy(&ntree_dst->id, &ntree_src->id); - } -} - -static void ntree_free_data(ID *id) -{ - bNodeTree *ntree = reinterpret_cast(id); - - /* XXX hack! node trees should not store execution graphs at all. - * This should be removed when old tree types no longer require it. - * Currently the execution data for texture nodes remains in the tree - * after execution, until the node tree is updated or freed. */ - if (ntree->runtime->execdata) { - switch (ntree->type) { - case NTREE_SHADER: - ntreeShaderEndExecTree(ntree->runtime->execdata); - break; - case NTREE_TEXTURE: - ntreeTexEndExecTree(ntree->runtime->execdata); - ntree->runtime->execdata = nullptr; - break; - } - } - - /* XXX not nice, but needed to free localized node groups properly */ - free_localized_node_groups(ntree); - - BLI_freelistN(&ntree->links); - - LISTBASE_FOREACH_MUTABLE (bNode *, node, &ntree->nodes) { - blender::bke::node_free_node(ntree, node); - } - - /* free interface sockets */ - LISTBASE_FOREACH_MUTABLE (bNodeSocket *, sock, &ntree->inputs) { - node_socket_interface_free(ntree, sock, false); - MEM_freeN(sock); - } - LISTBASE_FOREACH_MUTABLE (bNodeSocket *, sock, &ntree->outputs) { - node_socket_interface_free(ntree, sock, false); - MEM_freeN(sock); - } - - /* free preview hash */ - if (ntree->previews) { - BKE_node_instance_hash_free(ntree->previews, (bNodeInstanceValueFP)BKE_node_preview_free); - } - - if (ntree->id.tag & LIB_TAG_LOCALIZED) { - BKE_libblock_free_data(&ntree->id, true); - } - - BKE_previewimg_free(&ntree->preview); - MEM_delete(ntree->runtime); -} - -static void library_foreach_node_socket(LibraryForeachIDData *data, bNodeSocket *sock) -{ - BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL( - data, - IDP_foreach_property( - sock->prop, IDP_TYPE_FILTER_ID, BKE_lib_query_idpropertiesForeachIDLink_callback, data)); - - switch (eNodeSocketDatatype(sock->type)) { - case SOCK_OBJECT: { - bNodeSocketValueObject &default_value = *sock->default_value_typed(); - BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, default_value.value, IDWALK_CB_USER); - break; - } - case SOCK_IMAGE: { - bNodeSocketValueImage &default_value = *sock->default_value_typed(); - BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, default_value.value, IDWALK_CB_USER); - break; - } - case SOCK_COLLECTION: { - bNodeSocketValueCollection &default_value = - *sock->default_value_typed(); - BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, default_value.value, IDWALK_CB_USER); - break; - } - case SOCK_TEXTURE: { - bNodeSocketValueTexture &default_value = - *sock->default_value_typed(); - BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, default_value.value, IDWALK_CB_USER); - break; - } - case SOCK_MATERIAL: { - bNodeSocketValueMaterial &default_value = - *sock->default_value_typed(); - BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, default_value.value, IDWALK_CB_USER); - break; - } - case SOCK_FLOAT: - case SOCK_VECTOR: - case SOCK_RGBA: - case SOCK_BOOLEAN: - case SOCK_INT: - case SOCK_STRING: - case __SOCK_MESH: - case SOCK_CUSTOM: - case SOCK_SHADER: - case SOCK_GEOMETRY: - break; - } -} - -static void node_foreach_id(ID *id, LibraryForeachIDData *data) -{ - bNodeTree *ntree = reinterpret_cast(id); - - BKE_LIB_FOREACHID_PROCESS_ID(data, ntree->owner_id, IDWALK_CB_LOOPBACK); - - BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, ntree->gpd, IDWALK_CB_USER); - - for (bNode *node : ntree->all_nodes()) { - BKE_LIB_FOREACHID_PROCESS_ID(data, node->id, IDWALK_CB_USER); - - BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL( - data, - IDP_foreach_property(node->prop, - IDP_TYPE_FILTER_ID, - BKE_lib_query_idpropertiesForeachIDLink_callback, - data)); - LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { - BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data, library_foreach_node_socket(data, sock)); - } - LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) { - BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data, library_foreach_node_socket(data, sock)); - } - } - - LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->inputs) { - BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data, library_foreach_node_socket(data, sock)); - } - LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->outputs) { - BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data, library_foreach_node_socket(data, sock)); - } -} - -static void node_foreach_cache(ID *id, - IDTypeForeachCacheFunctionCallback function_callback, - void *user_data) -{ - bNodeTree *nodetree = reinterpret_cast(id); - IDCacheKey key = {0}; - key.id_session_uuid = id->session_uuid; - key.offset_in_ID = offsetof(bNodeTree, previews); - - /* TODO: see also `direct_link_nodetree()` in readfile.c. */ -#if 0 - function_callback(id, &key, static_cast(&nodetree->previews), 0, user_data); -#endif - - if (nodetree->type == NTREE_COMPOSIT) { - for (bNode *node : nodetree->all_nodes()) { - if (node->type == CMP_NODE_MOVIEDISTORTION) { - key.offset_in_ID = size_t(BLI_ghashutil_strhash_p(node->name)); - function_callback(id, &key, static_cast(&node->storage), 0, user_data); - } - } - } -} - -static void node_foreach_path(ID *id, BPathForeachPathData *bpath_data) -{ - bNodeTree *ntree = reinterpret_cast(id); - - switch (ntree->type) { - case NTREE_SHADER: { - for (bNode *node : ntree->all_nodes()) { - if (node->type == SH_NODE_SCRIPT) { - NodeShaderScript *nss = static_cast(node->storage); - BKE_bpath_foreach_path_fixed_process(bpath_data, nss->filepath); - } - else if (node->type == SH_NODE_TEX_IES) { - NodeShaderTexIES *ies = static_cast(node->storage); - BKE_bpath_foreach_path_fixed_process(bpath_data, ies->filepath); - } - } - break; - } - default: - break; - } -} - -static ID **node_owner_pointer_get(ID *id) -{ - if ((id->flag & LIB_EMBEDDED_DATA) == 0) { - return nullptr; - } - /* TODO: Sort this NO_MAIN or not for embedded node trees. See #86119. */ - // BLI_assert((id->tag & LIB_TAG_NO_MAIN) == 0); - - bNodeTree *ntree = reinterpret_cast(id); - BLI_assert(ntree->owner_id != nullptr); - BLI_assert(ntreeFromID(ntree->owner_id) == ntree); - - return &ntree->owner_id; -} - static void write_node_socket_default_value(BlendWriter *writer, bNodeSocket *sock) { if (sock->default_value == nullptr) { @@ -592,7 +292,7 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree) } BLO_write_struct_by_name(writer, node->typeinfo->storagename, storage); } - else if (node->typeinfo != &NodeTypeUndefined) { + else if (node->typeinfo != &blender::bke::NodeTypeUndefined) { BLO_write_struct_by_name(writer, node->typeinfo->storagename, node->storage); } } @@ -639,474 +339,6 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree) BKE_previewimg_blend_write(writer, ntree->preview); } -static void ntree_blend_write(BlendWriter *writer, ID *id, const void *id_address) -{ - bNodeTree *ntree = reinterpret_cast(id); - - /* Clean up, important in undo case to reduce false detection of changed datablocks. */ - ntree->typeinfo = nullptr; - ntree->runtime->execdata = nullptr; - - BLO_write_id_struct(writer, bNodeTree, id_address, &ntree->id); - - ntreeBlendWrite(writer, ntree); -} - -static void direct_link_node_socket(BlendDataReader *reader, bNodeSocket *sock) -{ - BLO_read_data_address(reader, &sock->prop); - IDP_BlendDataRead(reader, &sock->prop); - - BLO_read_data_address(reader, &sock->link); - sock->typeinfo = nullptr; - BLO_read_data_address(reader, &sock->storage); - BLO_read_data_address(reader, &sock->default_value); - BLO_read_data_address(reader, &sock->default_attribute_name); - sock->runtime = MEM_new(__func__); -} - -void ntreeBlendReadData(BlendDataReader *reader, ID *owner_id, bNodeTree *ntree) -{ - /* Special case for this pointer, do not rely on regular `lib_link` process here. Avoids needs - * for do_versioning, and ensures coherence of data in any case. - * - * NOTE: Old versions are very often 'broken' here, just fix it silently in these cases. - */ - if (BLO_read_fileversion_get(reader) > 300) { - BLI_assert((ntree->id.flag & LIB_EMBEDDED_DATA) != 0 || owner_id == nullptr); - } - BLI_assert(owner_id == nullptr || owner_id->lib == ntree->id.lib); - if (owner_id != nullptr && (ntree->id.flag & LIB_EMBEDDED_DATA) == 0) { - /* This is unfortunate, but currently a lot of existing files (including startup ones) have - * missing `LIB_EMBEDDED_DATA` flag. - * - * NOTE: Using do_version is not a solution here, since this code will be called before any - * do_version takes place. Keeping it here also ensures future (or unknown existing) similar - * bugs won't go easily unnoticed. */ - if (BLO_read_fileversion_get(reader) > 300) { - CLOG_WARN(&LOG, - "Fixing root node tree '%s' owned by '%s' missing EMBEDDED tag, please consider " - "re-saving your (startup) file", - ntree->id.name, - owner_id->name); - } - ntree->id.flag |= LIB_EMBEDDED_DATA; - } - ntree->owner_id = owner_id; - - /* NOTE: writing and reading goes in sync, for speed. */ - ntree->typeinfo = nullptr; - - ntree->runtime = MEM_new(__func__); - BKE_ntree_update_tag_missing_runtime_data(ntree); - - BLO_read_data_address(reader, &ntree->adt); - BKE_animdata_blend_read_data(reader, ntree->adt); - - BLO_read_list(reader, &ntree->nodes); - int i; - LISTBASE_FOREACH_INDEX (bNode *, node, &ntree->nodes, i) { - node->runtime = MEM_new(__func__); - node->typeinfo = nullptr; - node->runtime->index_in_tree = i; - - /* Create the `nodes_by_id` cache eagerly so it can be expected to be valid. Because - * we create it here we also have to check for zero identifiers from previous versions. */ - if (node->identifier == 0 || ntree->runtime->nodes_by_id.contains_as(node->identifier)) { - nodeUniqueID(ntree, node); - } - else { - ntree->runtime->nodes_by_id.add_new(node); - } - - BLO_read_list(reader, &node->inputs); - BLO_read_list(reader, &node->outputs); - - BLO_read_data_address(reader, &node->prop); - IDP_BlendDataRead(reader, &node->prop); - - if (node->type == CMP_NODE_MOVIEDISTORTION) { - /* Do nothing, this is runtime cache and hence handled by generic code using - * `IDTypeInfo.foreach_cache` callback. */ - } - else { - BLO_read_data_address(reader, &node->storage); - } - - if (node->storage) { - switch (node->type) { - case SH_NODE_CURVE_VEC: - case SH_NODE_CURVE_RGB: - case SH_NODE_CURVE_FLOAT: - case CMP_NODE_TIME: - case CMP_NODE_CURVE_VEC: - case CMP_NODE_CURVE_RGB: - case CMP_NODE_HUECORRECT: - case TEX_NODE_CURVE_RGB: - case TEX_NODE_CURVE_TIME: { - BKE_curvemapping_blend_read(reader, static_cast(node->storage)); - break; - } - case SH_NODE_SCRIPT: { - NodeShaderScript *nss = static_cast(node->storage); - BLO_read_data_address(reader, &nss->bytecode); - break; - } - case SH_NODE_TEX_POINTDENSITY: { - NodeShaderTexPointDensity *npd = static_cast(node->storage); - npd->pd = blender::dna::shallow_zero_initialize(); - break; - } - case SH_NODE_TEX_IMAGE: { - NodeTexImage *tex = static_cast(node->storage); - tex->iuser.scene = nullptr; - break; - } - case SH_NODE_TEX_ENVIRONMENT: { - NodeTexEnvironment *tex = static_cast(node->storage); - tex->iuser.scene = nullptr; - break; - } - case CMP_NODE_IMAGE: - case CMP_NODE_R_LAYERS: - case CMP_NODE_VIEWER: - case CMP_NODE_SPLITVIEWER: { - ImageUser *iuser = static_cast(node->storage); - iuser->scene = nullptr; - break; - } - case CMP_NODE_CRYPTOMATTE_LEGACY: - case CMP_NODE_CRYPTOMATTE: { - NodeCryptomatte *nc = static_cast(node->storage); - BLO_read_data_address(reader, &nc->matte_id); - BLO_read_list(reader, &nc->entries); - BLI_listbase_clear(&nc->runtime.layers); - break; - } - case TEX_NODE_IMAGE: { - ImageUser *iuser = static_cast(node->storage); - iuser->scene = nullptr; - break; - } - case CMP_NODE_OUTPUT_FILE: { - NodeImageMultiFile *nimf = static_cast(node->storage); - BKE_image_format_blend_read_data(reader, &nimf->format); - break; - } - case FN_NODE_INPUT_STRING: { - NodeInputString *storage = static_cast(node->storage); - BLO_read_data_address(reader, &storage->string); - break; - } - case GEO_NODE_SIMULATION_OUTPUT: { - NodeGeometrySimulationOutput &storage = *static_cast( - node->storage); - BLO_read_data_address(reader, &storage.items); - for (const NodeSimulationItem &item : Span(storage.items, storage.items_num)) { - BLO_read_data_address(reader, &item.name); - } - break; - } - - default: - break; - } - } - } - BLO_read_list(reader, &ntree->links); - BLI_assert(ntree->all_nodes().size() == BLI_listbase_count(&ntree->nodes)); - - /* and we connect the rest */ - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { - BLO_read_data_address(reader, &node->parent); - - LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { - direct_link_node_socket(reader, sock); - } - LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) { - direct_link_node_socket(reader, sock); - } - - /* Socket storage. */ - if (node->type == CMP_NODE_OUTPUT_FILE) { - LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { - NodeImageMultiFileSocket *sockdata = static_cast( - sock->storage); - BKE_image_format_blend_read_data(reader, &sockdata->format); - } - } - } - - /* interface socket lists */ - BLO_read_list(reader, &ntree->inputs); - BLO_read_list(reader, &ntree->outputs); - LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->inputs) { - direct_link_node_socket(reader, sock); - } - LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->outputs) { - direct_link_node_socket(reader, sock); - } - - LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { - BLO_read_data_address(reader, &link->fromnode); - BLO_read_data_address(reader, &link->tonode); - BLO_read_data_address(reader, &link->fromsock); - BLO_read_data_address(reader, &link->tosock); - } - - /* TODO: should be dealt by new generic cache handling of IDs... */ - ntree->previews = nullptr; - - BLO_read_data_address(reader, &ntree->preview); - BKE_previewimg_blend_read(reader, ntree->preview); - - /* type verification is in lib-link */ -} - -static void ntree_blend_read_data(BlendDataReader *reader, ID *id) -{ - bNodeTree *ntree = reinterpret_cast(id); - ntreeBlendReadData(reader, nullptr, ntree); -} - -static void lib_link_node_socket(BlendLibReader *reader, Library *lib, bNodeSocket *sock) -{ - IDP_BlendReadLib(reader, lib, sock->prop); - - /* This can happen for all socket types when a file is saved in an older version of Blender than - * it was originally created in (#86298). Some socket types still require a default value. The - * default value of those sockets will be created in `ntreeSetTypes`. */ - if (sock->default_value == nullptr) { - return; - } - - switch (eNodeSocketDatatype(sock->type)) { - case SOCK_OBJECT: { - BLO_read_id_address( - reader, lib, &sock->default_value_typed()->value); - break; - } - case SOCK_IMAGE: { - BLO_read_id_address(reader, lib, &sock->default_value_typed()->value); - break; - } - case SOCK_COLLECTION: { - BLO_read_id_address( - reader, lib, &sock->default_value_typed()->value); - break; - } - case SOCK_TEXTURE: { - BLO_read_id_address( - reader, lib, &sock->default_value_typed()->value); - break; - } - case SOCK_MATERIAL: { - BLO_read_id_address( - reader, lib, &sock->default_value_typed()->value); - break; - } - case SOCK_FLOAT: - case SOCK_VECTOR: - case SOCK_RGBA: - case SOCK_BOOLEAN: - case SOCK_INT: - case SOCK_STRING: - case __SOCK_MESH: - case SOCK_CUSTOM: - case SOCK_SHADER: - case SOCK_GEOMETRY: - break; - } -} - -static void lib_link_node_sockets(BlendLibReader *reader, Library *lib, ListBase *sockets) -{ - LISTBASE_FOREACH (bNodeSocket *, sock, sockets) { - lib_link_node_socket(reader, lib, sock); - } -} - -void ntreeBlendReadLib(BlendLibReader *reader, bNodeTree *ntree) -{ - Library *lib = ntree->id.lib; - - BLO_read_id_address(reader, lib, &ntree->gpd); - - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { - /* Link ID Properties -- and copy this comment EXACTLY for easy finding - * of library blocks that implement this. */ - IDP_BlendReadLib(reader, lib, node->prop); - - BLO_read_id_address(reader, lib, &node->id); - - lib_link_node_sockets(reader, lib, &node->inputs); - lib_link_node_sockets(reader, lib, &node->outputs); - } - - lib_link_node_sockets(reader, lib, &ntree->inputs); - lib_link_node_sockets(reader, lib, &ntree->outputs); - - /* Set `node->typeinfo` pointers. This is done in lib linking, after the - * first versioning that can change types still without functions that - * update the `typeinfo` pointers. Versioning after lib linking needs - * these top be valid. */ - ntreeSetTypes(nullptr, ntree); - - /* For nodes with static socket layout, add/remove sockets as needed - * to match the static layout. */ - if (!BLO_read_lib_is_undo(reader)) { - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { - /* Don't update node groups here because they may depend on other node groups which are not - * fully versioned yet and don't have `typeinfo` pointers set. */ - if (!node->is_group()) { - node_verify_sockets(ntree, node, false); - } - } - } -} - -static void ntree_blend_read_lib(BlendLibReader *reader, ID *id) -{ - bNodeTree *ntree = reinterpret_cast(id); - ntreeBlendReadLib(reader, ntree); -} - -static void expand_node_socket(BlendExpander *expander, bNodeSocket *sock) -{ - IDP_BlendReadExpand(expander, sock->prop); - - if (sock->default_value == nullptr) { - return; - } - - switch (eNodeSocketDatatype(sock->type)) { - case SOCK_OBJECT: { - BLO_expand(expander, sock->default_value_typed()->value); - break; - } - case SOCK_IMAGE: { - BLO_expand(expander, sock->default_value_typed()->value); - break; - } - case SOCK_COLLECTION: { - BLO_expand(expander, sock->default_value_typed()->value); - break; - } - case SOCK_TEXTURE: { - BLO_expand(expander, sock->default_value_typed()->value); - break; - } - case SOCK_MATERIAL: { - BLO_expand(expander, sock->default_value_typed()->value); - break; - } - case SOCK_FLOAT: - case SOCK_VECTOR: - case SOCK_RGBA: - case SOCK_BOOLEAN: - case SOCK_INT: - case SOCK_STRING: - case __SOCK_MESH: - case SOCK_CUSTOM: - case SOCK_SHADER: - case SOCK_GEOMETRY: - break; - } -} - -static void expand_node_sockets(BlendExpander *expander, ListBase *sockets) -{ - LISTBASE_FOREACH (bNodeSocket *, sock, sockets) { - expand_node_socket(expander, sock); - } -} - -void ntreeBlendReadExpand(BlendExpander *expander, bNodeTree *ntree) -{ - if (ntree->gpd) { - BLO_expand(expander, ntree->gpd); - } - - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { - if (node->id && !(node->type == CMP_NODE_R_LAYERS) && - !(node->type == CMP_NODE_CRYPTOMATTE && node->custom1 == CMP_CRYPTOMATTE_SRC_RENDER)) - { - BLO_expand(expander, node->id); - } - - IDP_BlendReadExpand(expander, node->prop); - - expand_node_sockets(expander, &node->inputs); - expand_node_sockets(expander, &node->outputs); - } - - expand_node_sockets(expander, &ntree->inputs); - expand_node_sockets(expander, &ntree->outputs); -} - -static void ntree_blend_read_expand(BlendExpander *expander, ID *id) -{ - bNodeTree *ntree = reinterpret_cast(id); - ntreeBlendReadExpand(expander, ntree); -} - -namespace blender::bke { - -static void node_tree_asset_pre_save(void *asset_ptr, AssetMetaData *asset_data) -{ - bNodeTree &node_tree = *static_cast(asset_ptr); - - BKE_asset_metadata_idprop_ensure(asset_data, idprop::create("type", node_tree.type).release()); - auto inputs = idprop::create_group("inputs"); - auto outputs = idprop::create_group("outputs"); - LISTBASE_FOREACH (const bNodeSocket *, socket, &node_tree.inputs) { - auto property = idprop::create(socket->name, socket->typeinfo->idname); - IDP_AddToGroup(inputs.get(), property.release()); - } - LISTBASE_FOREACH (const bNodeSocket *, socket, &node_tree.outputs) { - auto property = idprop::create(socket->name, socket->typeinfo->idname); - IDP_AddToGroup(outputs.get(), property.release()); - } - BKE_asset_metadata_idprop_ensure(asset_data, inputs.release()); - BKE_asset_metadata_idprop_ensure(asset_data, outputs.release()); -} - -} // namespace blender::bke - -static AssetTypeInfo AssetType_NT = { - /*pre_save_fn*/ blender::bke::node_tree_asset_pre_save, -}; - -IDTypeInfo IDType_ID_NT = { - /*id_code*/ ID_NT, - /*id_filter*/ FILTER_ID_NT, - /*main_listbase_index*/ INDEX_ID_NT, - /*struct_size*/ sizeof(bNodeTree), - /*name*/ "NodeTree", - /*name_plural*/ "node_groups", - /*translation_context*/ BLT_I18NCONTEXT_ID_NODETREE, - /*flags*/ IDTYPE_FLAGS_APPEND_IS_REUSABLE, - /*asset_type_info*/ &AssetType_NT, - - /*init_data*/ ntree_init_data, - /*copy_data*/ ntree_copy_data, - /*free_data*/ ntree_free_data, - /*make_local*/ nullptr, - /*foreach_id*/ node_foreach_id, - /*foreach_cache*/ node_foreach_cache, - /*foreach_path*/ node_foreach_path, - /*owner_pointer_get*/ node_owner_pointer_get, - - /*blend_write*/ ntree_blend_write, - /*blend_read_data*/ ntree_blend_read_data, - /*blend_read_lib*/ ntree_blend_read_lib, - /*blend_read_expand*/ ntree_blend_read_expand, - - /*blend_read_undo_preserve*/ nullptr, - - /*lib_override_apply_post*/ nullptr, -}; - static void node_add_sockets_from_type(bNodeTree *ntree, bNode *node, bNodeType *ntype) { if (ntype->declare || ntype->declare_dynamic) { @@ -1139,7 +371,7 @@ static void node_init(const bContext *C, bNodeTree *ntree, bNode *node) { BLI_assert(ntree != nullptr); bNodeType *ntype = node->typeinfo; - if (ntype == &NodeTypeUndefined) { + if (ntype == &blender::bke::NodeTypeUndefined) { return; } @@ -1205,7 +437,7 @@ static void ntree_set_typeinfo(bNodeTree *ntree, bNodeTreeType *typeinfo) ntree->typeinfo = typeinfo; } else { - ntree->typeinfo = &NodeTreeTypeUndefined; + ntree->typeinfo = &blender::bke::NodeTreeTypeUndefined; } /* Deprecated integer type. */ @@ -1235,7 +467,7 @@ static void node_set_typeinfo(const bContext *C, node_init(C, ntree, node); } else { - node->typeinfo = &NodeTypeUndefined; + node->typeinfo = &blender::bke::NodeTypeUndefined; } } @@ -1258,7 +490,7 @@ static void node_socket_set_typeinfo(bNodeTree *ntree, } } else { - sock->typeinfo = &NodeSocketTypeUndefined; + sock->typeinfo = &blender::bke::NodeSocketTypeUndefined; } BKE_ntree_update_tag_socket_type(ntree, sock); } @@ -1379,7 +611,7 @@ void ntreeTypeFreeLink(const bNodeTreeType *nt) bool ntreeIsRegistered(const bNodeTree *ntree) { - return (ntree->typeinfo != &NodeTreeTypeUndefined); + return (ntree->typeinfo != &blender::bke::NodeTreeTypeUndefined); } GHashIterator *ntreeTypeGetIterator() @@ -1441,28 +673,6 @@ void nodeUnregisterType(bNodeType *nt) BLI_ghash_remove(nodetypes_hash, nt->idname, nullptr, node_free_type); } -bool nodeTypeUndefined(const bNode *node) -{ - if (node->typeinfo == &NodeTypeUndefined) { - return true; - } - - if (node->is_group()) { - const ID *group_tree = node->id; - if (group_tree == nullptr) { - return false; - } - if (!ID_IS_LINKED(group_tree)) { - return false; - } - if ((group_tree->tag & LIB_TAG_MISSING) == 0) { - return false; - } - return true; - } - return false; -} - GHashIterator *nodeTypeGetIterator() { return BLI_ghashIterator_new(nodetypes_hash); @@ -1508,7 +718,7 @@ void nodeUnregisterSocketType(bNodeSocketType *st) bool nodeSocketIsRegistered(const bNodeSocket *sock) { - return (sock->typeinfo != &NodeSocketTypeUndefined); + return (sock->typeinfo != &blender::bke::NodeSocketTypeUndefined); } GHashIterator *nodeSocketTypeGetIterator() @@ -1525,15 +735,6 @@ const char *nodeSocketTypeLabel(const bNodeSocketType *stype) return stype->label; } -const char *nodeSocketSubTypeLabel(int subtype) -{ - const char *name; - if (RNA_enum_name(rna_enum_property_subtype_items, subtype, &name)) { - return name; - } - return ""; -} - bNodeSocket *nodeFindSocket(const bNode *node, const eNodeSocketInOut in_out, const char *identifier) @@ -1547,33 +748,6 @@ bNodeSocket *nodeFindSocket(const bNode *node, return nullptr; } -namespace blender::bke { - -bNodeSocket *node_find_enabled_socket(bNode &node, - const eNodeSocketInOut in_out, - const StringRef name) -{ - ListBase *sockets = (in_out == SOCK_IN) ? &node.inputs : &node.outputs; - LISTBASE_FOREACH (bNodeSocket *, socket, sockets) { - if (socket->is_available() && socket->name == name) { - return socket; - } - } - return nullptr; -} - -bNodeSocket *node_find_enabled_input_socket(bNode &node, const StringRef name) -{ - return node_find_enabled_socket(node, SOCK_IN, name); -} - -bNodeSocket *node_find_enabled_output_socket(bNode &node, const StringRef name) -{ - return node_find_enabled_socket(node, SOCK_OUT, name); -} - -} // namespace blender::bke - static bool unique_identifier_check(void *arg, const char *identifier) { const ListBase *lb = static_cast(arg); @@ -1717,66 +891,6 @@ static bool socket_id_user_decrement(bNodeSocket *sock) return false; } -void nodeModifySocketType(bNodeTree *ntree, - bNode * /*node*/, - bNodeSocket *sock, - const char *idname) -{ - bNodeSocketType *socktype = nodeSocketTypeFind(idname); - - if (!socktype) { - CLOG_ERROR(&LOG, "node socket type %s undefined", idname); - return; - } - - if (sock->default_value) { - if (sock->type != socktype->type) { - /* Only reallocate the default value if the type changed so that UI data like min and max - * isn't removed. This assumes that the default value is stored in the same format for all - * socket types with the same #eNodeSocketDatatype. */ - socket_id_user_decrement(sock); - MEM_freeN(sock->default_value); - sock->default_value = nullptr; - } - else { - /* Update the socket subtype when the storage isn't freed and recreated. */ - switch (eNodeSocketDatatype(sock->type)) { - case SOCK_FLOAT: { - sock->default_value_typed()->subtype = socktype->subtype; - break; - } - case SOCK_VECTOR: { - sock->default_value_typed()->subtype = socktype->subtype; - break; - } - case SOCK_INT: { - sock->default_value_typed()->subtype = socktype->subtype; - break; - } - case SOCK_STRING: { - sock->default_value_typed()->subtype = socktype->subtype; - break; - } - case SOCK_RGBA: - case SOCK_SHADER: - case SOCK_BOOLEAN: - case SOCK_CUSTOM: - case __SOCK_MESH: - case SOCK_OBJECT: - case SOCK_IMAGE: - case SOCK_GEOMETRY: - case SOCK_COLLECTION: - case SOCK_TEXTURE: - case SOCK_MATERIAL: - break; - } - } - } - - STRNCPY(sock->idname, idname); - node_socket_set_typeinfo(ntree, sock, socktype); -} - void nodeModifySocketTypeStatic( bNodeTree *ntree, bNode *node, bNodeSocket *sock, const int type, const int subtype) { @@ -1787,7 +901,7 @@ void nodeModifySocketTypeStatic( return; } - nodeModifySocketType(ntree, node, sock, idname); + blender::bke::nodeModifySocketType(ntree, node, sock, idname); } bNodeSocket *nodeAddSocket(bNodeTree *ntree, @@ -1812,15 +926,6 @@ bNodeSocket *nodeAddSocket(bNodeTree *ntree, return sock; } -bool nodeIsStaticSocketType(const bNodeSocketType *stype) -{ - /* - * Cannot rely on type==SOCK_CUSTOM here, because type is 0 by default - * and can be changed on custom sockets. - */ - return RNA_struct_is_a(stype->ext_socket.srna, &RNA_NodeSocketStandard); -} - const char *nodeStaticSocketType(const int type, const int subtype) { switch (eNodeSocketDatatype(type)) { @@ -2034,80 +1139,9 @@ bNodeSocket *nodeAddStaticSocket(bNodeTree *ntree, return sock; } -static void node_socket_free(bNodeSocket *sock, const bool do_id_user) -{ - if (sock->prop) { - IDP_FreePropertyContent_ex(sock->prop, do_id_user); - MEM_freeN(sock->prop); - } - - if (sock->default_value) { - if (do_id_user) { - socket_id_user_decrement(sock); - } - MEM_freeN(sock->default_value); - } - if (sock->default_attribute_name) { - MEM_freeN(sock->default_attribute_name); - } - MEM_delete(sock->runtime); -} - void nodeRemoveSocket(bNodeTree *ntree, bNode *node, bNodeSocket *sock) { - nodeRemoveSocketEx(ntree, node, sock, true); -} - -void nodeRemoveSocketEx(bNodeTree *ntree, bNode *node, bNodeSocket *sock, const bool do_id_user) -{ - LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) { - if (link->fromsock == sock || link->tosock == sock) { - nodeRemLink(ntree, link); - } - } - - for (const int64_t i : node->runtime->internal_links.index_range()) { - const bNodeLink &link = node->runtime->internal_links[i]; - if (link.fromsock == sock || link.tosock == sock) { - node->runtime->internal_links.remove_and_reorder(i); - BKE_ntree_update_tag_node_internal_link(ntree, node); - break; - } - } - - /* this is fast, this way we don't need an in_out argument */ - BLI_remlink(&node->inputs, sock); - BLI_remlink(&node->outputs, sock); - - node_socket_free(sock, do_id_user); - MEM_freeN(sock); - - BKE_ntree_update_tag_socket_removed(ntree); -} - -void nodeRemoveAllSockets(bNodeTree *ntree, bNode *node) -{ - LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) { - if (link->fromnode == node || link->tonode == node) { - nodeRemLink(ntree, link); - } - } - - node->runtime->internal_links.clear(); - - LISTBASE_FOREACH_MUTABLE (bNodeSocket *, sock, &node->inputs) { - node_socket_free(sock, true); - MEM_freeN(sock); - } - BLI_listbase_clear(&node->inputs); - - LISTBASE_FOREACH_MUTABLE (bNodeSocket *, sock, &node->outputs) { - node_socket_free(sock, true); - MEM_freeN(sock); - } - BLI_listbase_clear(&node->outputs); - - BKE_ntree_update_tag_socket_removed(ntree); + blender::bke::nodeRemoveSocketEx(ntree, node, sock, true); } bNode *nodeFindNodebyName(bNodeTree *ntree, const char *name) @@ -2115,23 +1149,6 @@ bNode *nodeFindNodebyName(bNodeTree *ntree, const char *name) return reinterpret_cast(BLI_findstring(&ntree->nodes, name, offsetof(bNode, name))); } -void nodeFindNode(bNodeTree *ntree, bNodeSocket *sock, bNode **r_node, int *r_sockindex) -{ - *r_node = nullptr; - if (ntree->runtime->topology_cache_mutex.is_cached()) { - bNode *node = &sock->owner_node(); - *r_node = node; - if (r_sockindex) { - const ListBase *sockets = (sock->in_out == SOCK_IN) ? &node->inputs : &node->outputs; - *r_sockindex = BLI_findindex(sockets, sock); - } - return; - } - const bool success = nodeFindNodeTry(ntree, sock, r_node, r_sockindex); - BLI_assert(success); - UNUSED_VARS_NDEBUG(success); -} - bool nodeFindNodeTry(bNodeTree *ntree, bNodeSocket *sock, bNode **r_node, int *r_sockindex) { for (bNode *node : ntree->all_nodes()) { @@ -2152,18 +1169,6 @@ bool nodeFindNodeTry(bNodeTree *ntree, bNodeSocket *sock, bNode **r_node, int *r return false; } -bNode *nodeFindRootParent(bNode *node) -{ - bNode *parent_iter = node; - while (parent_iter->parent != nullptr) { - parent_iter = parent_iter->parent; - } - if (parent_iter->type != NODE_FRAME) { - return nullptr; - } - return parent_iter; -} - bool nodeIsParentAndChild(const bNode *parent, const bNode *child) { for (const bNode *child_iter = child; child_iter; child_iter = child_iter->parent) { @@ -2174,129 +1179,6 @@ bool nodeIsParentAndChild(const bNode *parent, const bNode *child) return false; } -void nodeChainIter(const bNodeTree *ntree, - const bNode *node_start, - bool (*callback)(bNode *, bNode *, void *, const bool), - void *userdata, - const bool reversed) -{ - LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { - if ((link->flag & NODE_LINK_VALID) == 0) { - /* Skip links marked as cyclic. */ - continue; - } - /* Is the link part of the chain meaning node_start == fromnode - * (or tonode for reversed case)? */ - if (!reversed) { - if (link->fromnode != node_start) { - continue; - } - } - else { - if (link->tonode != node_start) { - continue; - } - } - - if (!callback(link->fromnode, link->tonode, userdata, reversed)) { - return; - } - nodeChainIter(ntree, reversed ? link->fromnode : link->tonode, callback, userdata, reversed); - } -} - -static void iter_backwards_ex(const bNodeTree *ntree, - const bNode *node_start, - bool (*callback)(bNode *, bNode *, void *), - void *userdata, - const char recursion_mask) -{ - LISTBASE_FOREACH (bNodeSocket *, sock, &node_start->inputs) { - bNodeLink *link = sock->link; - if (link == nullptr) { - continue; - } - if ((link->flag & NODE_LINK_VALID) == 0) { - /* Skip links marked as cyclic. */ - continue; - } - if (link->fromnode->runtime->iter_flag & recursion_mask) { - continue; - } - - link->fromnode->runtime->iter_flag |= recursion_mask; - - if (!callback(link->fromnode, link->tonode, userdata)) { - return; - } - iter_backwards_ex(ntree, link->fromnode, callback, userdata, recursion_mask); - } -} - -void nodeChainIterBackwards(const bNodeTree *ntree, - const bNode *node_start, - bool (*callback)(bNode *, bNode *, void *), - void *userdata, - const int recursion_lvl) -{ - if (!node_start) { - return; - } - - /* Limited by iter_flag type. */ - BLI_assert(recursion_lvl < 8); - const char recursion_mask = (1 << recursion_lvl); - - /* Reset flag. */ - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { - node->runtime->iter_flag &= ~recursion_mask; - } - - iter_backwards_ex(ntree, node_start, callback, userdata, recursion_mask); -} - -void nodeParentsIter(bNode *node, bool (*callback)(bNode *, void *), void *userdata) -{ - if (node->parent) { - if (!callback(node->parent, userdata)) { - return; - } - nodeParentsIter(node->parent, callback, userdata); - } -} - -bool nodeIsDanglingReroute(const bNodeTree *ntree, const bNode *node) -{ - ntree->ensure_topology_cache(); - BLI_assert(blender::bke::node_tree_runtime::topology_cache_is_available(*ntree)); - BLI_assert(!ntree->has_available_link_cycle()); - - const bNode *iter_node = node; - if (!iter_node->is_reroute()) { - return false; - } - - while (true) { - const blender::Span links = - iter_node->input_socket(0).directly_linked_links(); - BLI_assert(links.size() <= 1); - if (links.is_empty()) { - return true; - } - const bNodeLink &link = *links[0]; - if (!link.is_available()) { - return false; - } - if (link.is_muted()) { - return false; - } - iter_node = link.fromnode; - if (!iter_node->is_reroute()) { - return false; - } - } -} - void nodeUniqueName(bNodeTree *ntree, bNode *node) { BLI_uniquename( @@ -2366,6 +1248,1429 @@ bNode *nodeAddStaticNode(const bContext *C, bNodeTree *ntree, const int type) return nodeAddNode(C, ntree, idname); } +static int node_count_links(const bNodeTree *ntree, const bNodeSocket *socket) +{ + int count = 0; + LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { + if (ELEM(socket, link->fromsock, link->tosock)) { + count++; + } + } + return count; +} + +bNodeLink *nodeAddLink( + bNodeTree *ntree, bNode *fromnode, bNodeSocket *fromsock, bNode *tonode, bNodeSocket *tosock) +{ + BLI_assert(fromnode); + BLI_assert(tonode); + BLI_assert(ntree->all_nodes().contains(fromnode)); + BLI_assert(ntree->all_nodes().contains(tonode)); + + bNodeLink *link = nullptr; + if (eNodeSocketInOut(fromsock->in_out) == SOCK_OUT && + eNodeSocketInOut(tosock->in_out) == SOCK_IN) { + link = MEM_cnew("link"); + if (ntree) { + BLI_addtail(&ntree->links, link); + } + link->fromnode = fromnode; + link->fromsock = fromsock; + link->tonode = tonode; + link->tosock = tosock; + } + else if (eNodeSocketInOut(fromsock->in_out) == SOCK_IN && + eNodeSocketInOut(tosock->in_out) == SOCK_OUT) + { + /* OK but flip */ + link = MEM_cnew("link"); + if (ntree) { + BLI_addtail(&ntree->links, link); + } + link->fromnode = tonode; + link->fromsock = tosock; + link->tonode = fromnode; + link->tosock = fromsock; + } + + if (ntree) { + BKE_ntree_update_tag_link_added(ntree, link); + } + + if (link != nullptr && link->tosock->is_multi_input()) { + link->multi_input_socket_index = node_count_links(ntree, link->tosock) - 1; + } + + return link; +} + +void nodeRemLink(bNodeTree *ntree, bNodeLink *link) +{ + /* Can be called for links outside a node tree (e.g. clipboard). */ + if (ntree) { + BLI_remlink(&ntree->links, link); + } + + if (link->tosock) { + link->tosock->link = nullptr; + } + MEM_freeN(link); + + if (ntree) { + BKE_ntree_update_tag_link_removed(ntree); + } +} + +void nodeRemSocketLinks(bNodeTree *ntree, bNodeSocket *sock) +{ + LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) { + if (link->fromsock == sock || link->tosock == sock) { + nodeRemLink(ntree, link); + } + } +} + +bool nodeLinkIsHidden(const bNodeLink *link) +{ + return !(link->fromsock->is_visible() && link->tosock->is_visible()); +} + +/* Adjust the indices of links connected to the given multi input socket after deleting the link at + * `deleted_index`. This function also works if the link has not yet been deleted. */ +static void adjust_multi_input_indices_after_removed_link(bNodeTree *ntree, + const bNodeSocket *sock, + const int deleted_index) +{ + LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { + /* We only need to adjust those with a greater index, because the others will have the same + * index. */ + if (link->tosock != sock || link->multi_input_socket_index <= deleted_index) { + continue; + } + link->multi_input_socket_index -= 1; + } +} + +void nodeAttachNode(bNodeTree *ntree, bNode *node, bNode *parent) +{ + BLI_assert(parent->type == NODE_FRAME); + BLI_assert(!nodeIsParentAndChild(parent, node)); + + float locx, locy; + blender::bke::nodeToView(node, 0.0f, 0.0f, &locx, &locy); + + node->parent = parent; + BKE_ntree_update_tag_parent_change(ntree, node); + /* transform to parent space */ + blender::bke::nodeFromView(parent, locx, locy, &node->locx, &node->locy); +} + +void nodeDetachNode(bNodeTree *ntree, bNode *node) +{ + if (node->parent) { + BLI_assert(node->parent->type == NODE_FRAME); + + /* transform to view space */ + float locx, locy; + blender::bke::nodeToView(node, 0.0f, 0.0f, &locx, &locy); + node->locx = locx; + node->locy = locy; + node->parent = nullptr; + BKE_ntree_update_tag_parent_change(ntree, node); + } +} + +static bNodeTree *ntreeAddTree_do( + Main *bmain, ID *owner_id, const bool is_embedded, const char *name, const char *idname) +{ + /* trees are created as local trees for compositor, material or texture nodes, + * node groups and other tree types are created as library data. + */ + int flag = 0; + if (is_embedded || bmain == nullptr) { + flag |= LIB_ID_CREATE_NO_MAIN; + } + bNodeTree *ntree = reinterpret_cast(BKE_libblock_alloc(bmain, ID_NT, name, flag)); + BKE_libblock_init_empty(&ntree->id); + if (is_embedded) { + BLI_assert(owner_id != nullptr); + ntree->id.flag |= LIB_EMBEDDED_DATA; + ntree->owner_id = owner_id; + bNodeTree **ntree_owner_ptr = BKE_ntree_ptr_from_id(owner_id); + BLI_assert(ntree_owner_ptr != nullptr); + *ntree_owner_ptr = ntree; + } + else { + BLI_assert(owner_id == nullptr); + } + + STRNCPY(ntree->idname, idname); + ntree_set_typeinfo(ntree, ntreeTypeFind(idname)); + + return ntree; +} + +bNodeTree *ntreeAddTree(Main *bmain, const char *name, const char *idname) +{ + return ntreeAddTree_do(bmain, nullptr, false, name, idname); +} + +/* *************** Node Preview *********** */ + +/* XXX this should be removed eventually ... + * Currently BKE functions are modeled closely on previous code, + * using blender::bke::node_preview_init_tree to set up previews for a whole node tree in advance. + * This should be left more to the individual node tree implementations. */ + +static void node_preview_init_tree_recursive(bNodeInstanceHash *previews, + bNodeTree *ntree, + bNodeInstanceKey parent_key, + const int xsize, + const int ysize) +{ + for (bNode *node : ntree->all_nodes()) { + bNodeInstanceKey key = BKE_node_instance_key(parent_key, ntree, node); + + if (blender::bke::node_preview_used(node)) { + node->runtime->preview_xsize = xsize; + node->runtime->preview_ysize = ysize; + + blender::bke::node_preview_verify(previews, key, xsize, ysize, false); + } + + bNodeTree *group = reinterpret_cast(node->id); + if (node->is_group() && group != nullptr) { + node_preview_init_tree_recursive(previews, group, key, xsize, ysize); + } + } +} + +static void node_preview_tag_used_recursive(bNodeInstanceHash *previews, + bNodeTree *ntree, + bNodeInstanceKey parent_key) +{ + for (bNode *node : ntree->all_nodes()) { + bNodeInstanceKey key = BKE_node_instance_key(parent_key, ntree, node); + + if (blender::bke::node_preview_used(node)) { + BKE_node_instance_hash_tag_key(previews, key); + } + + bNodeTree *group = reinterpret_cast(node->id); + if (node->is_group() && group != nullptr) { + node_preview_tag_used_recursive(previews, group, key); + } + } +} + +void BKE_node_preview_clear_tree(bNodeTree *ntree) +{ + if (!ntree || !ntree->previews) { + return; + } + + blender::bke::bNodeInstanceHashIterator iter; + NODE_INSTANCE_HASH_ITER (iter, ntree->previews) { + bNodePreview *preview = static_cast( + blender::bke::node_instance_hash_iterator_get_value(&iter)); + blender::bke::node_preview_clear(preview); + } +} + +static void node_unlink_attached(bNodeTree *ntree, const bNode *parent) +{ + for (bNode *node : ntree->all_nodes()) { + if (node->parent == parent) { + nodeDetachNode(ntree, node); + } + } +} + +void nodeRemoveNode(Main *bmain, bNodeTree *ntree, bNode *node, const bool do_id_user) +{ + BLI_assert(ntree != nullptr); + /* This function is not for localized node trees, we do not want + * do to ID user reference-counting and removal of animdation data then. */ + BLI_assert((ntree->id.tag & LIB_TAG_LOCALIZED) == 0); + + bool node_has_id = false; + + if (do_id_user) { + /* Free callback for NodeCustomGroup. */ + if (node->typeinfo->freefunc_api) { + PointerRNA ptr; + RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); + + node->typeinfo->freefunc_api(&ptr); + } + + /* Do user counting. */ + if (node->id) { + id_us_min(node->id); + node_has_id = true; + } + + LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { + node_has_id |= socket_id_user_decrement(sock); + } + LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) { + node_has_id |= socket_id_user_decrement(sock); + } + } + + /* Remove animation data. */ + char propname_esc[MAX_IDPROP_NAME * 2]; + char prefix[MAX_IDPROP_NAME * 2]; + + BLI_str_escape(propname_esc, node->name, sizeof(propname_esc)); + SNPRINTF(prefix, "nodes[\"%s\"]", propname_esc); + + if (BKE_animdata_fix_paths_remove(&ntree->id, prefix)) { + if (bmain != nullptr) { + DEG_relations_tag_update(bmain); + } + } + + /* Also update relations for the scene time node, which causes a dependency + * on time that users expect to be removed when the node is removed. */ + if (node_has_id || + ELEM(node->type, GEO_NODE_INPUT_SCENE_TIME, GEO_NODE_SELF_OBJECT, GEO_NODE_SIMULATION_INPUT)) + { + if (bmain != nullptr) { + DEG_relations_tag_update(bmain); + } + } + + blender::bke::nodeUnlinkNode(ntree, node); + node_unlink_attached(ntree, node); + + /* Free node itself. */ + blender::bke::node_free_node(ntree, node); + blender::bke::nodeRebuildIDVector(ntree); +} + +static void node_socket_interface_free(bNodeTree * /*ntree*/, + bNodeSocket *sock, + const bool do_id_user) +{ + if (sock->prop) { + IDP_FreeProperty_ex(sock->prop, do_id_user); + } + + if (sock->default_value) { + if (do_id_user) { + socket_id_user_decrement(sock); + } + MEM_freeN(sock->default_value); + } + if (sock->default_attribute_name) { + MEM_freeN(sock->default_attribute_name); + } + MEM_delete(sock->runtime); +} + +void ntreeFreeEmbeddedTree(bNodeTree *ntree) +{ + blender::bke::ntreeFreeTree(ntree); + BKE_libblock_free_data(&ntree->id, true); + BKE_libblock_free_data_py(&ntree->id); +} + +void ntreeFreeLocalTree(bNodeTree *ntree) +{ + if (ntree->id.tag & LIB_TAG_LOCALIZED) { + blender::bke::ntreeFreeTree(ntree); + } + else { + blender::bke::ntreeFreeTree(ntree); + BKE_libblock_free_data(&ntree->id, true); + } +} + +void ntreeSetOutput(bNodeTree *ntree) +{ + const bool is_compositor = ntree->type == NTREE_COMPOSIT; + /* find the active outputs, might become tree type dependent handler */ + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) { + /* we need a check for which output node should be tagged like this, below an exception */ + if (ELEM(node->type, CMP_NODE_OUTPUT_FILE, GEO_NODE_VIEWER)) { + continue; + } + const bool node_is_output = ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER); + + int output = 0; + /* there is more types having output class, each one is checked */ + + LISTBASE_FOREACH (bNode *, tnode, &ntree->nodes) { + if (tnode->typeinfo->nclass != NODE_CLASS_OUTPUT) { + continue; + } + + /* same type, exception for viewer */ + const bool tnode_is_output = ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER); + const bool compositor_case = is_compositor && tnode_is_output && node_is_output; + if (tnode->type == node->type || compositor_case) { + if (tnode->flag & NODE_DO_OUTPUT) { + output++; + if (output > 1) { + tnode->flag &= ~NODE_DO_OUTPUT; + } + } + } + } + + if (output == 0) { + node->flag |= NODE_DO_OUTPUT; + } + } + + /* group node outputs use this flag too */ + if (node->type == NODE_GROUP_OUTPUT) { + int output = 0; + LISTBASE_FOREACH (bNode *, tnode, &ntree->nodes) { + if (tnode->type != NODE_GROUP_OUTPUT) { + continue; + } + if (tnode->flag & NODE_DO_OUTPUT) { + output++; + if (output > 1) { + tnode->flag &= ~NODE_DO_OUTPUT; + } + } + } + if (output == 0) { + node->flag |= NODE_DO_OUTPUT; + } + } + } + + /* here we could recursively set which nodes have to be done, + * might be different for editor or for "real" use... */ +} + +bNodeTree **BKE_ntree_ptr_from_id(ID *id) +{ + switch (GS(id->name)) { + case ID_MA: + return &reinterpret_cast(id)->nodetree; + case ID_LA: + return &reinterpret_cast(id)->nodetree; + case ID_WO: + return &reinterpret_cast(id)->nodetree; + case ID_TE: + return &reinterpret_cast(id)->nodetree; + case ID_SCE: + return &reinterpret_cast(id)->nodetree; + case ID_LS: + return &reinterpret_cast(id)->nodetree; + case ID_SIM: + return &reinterpret_cast(id)->nodetree; + default: + return nullptr; + } +} + +bNodeTree *ntreeFromID(ID *id) +{ + bNodeTree **nodetree = BKE_ntree_ptr_from_id(id); + return (nodetree != nullptr) ? *nodetree : nullptr; +} + +bNodeTree *ntreeLocalize(bNodeTree *ntree) +{ + if (ntree == nullptr) { + return nullptr; + } + + /* Make full copy outside of Main database. + * NOTE: previews are not copied here. */ + bNodeTree *ltree = reinterpret_cast(BKE_id_copy_ex( + nullptr, &ntree->id, nullptr, (LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA))); + + ltree->id.tag |= LIB_TAG_LOCALIZED; + + LISTBASE_FOREACH (bNode *, node, <ree->nodes) { + bNodeTree *group = reinterpret_cast(node->id); + if (node->is_group() && group != nullptr) { + node->id = reinterpret_cast(ntreeLocalize(group)); + } + } + + /* Ensures only a single output node is enabled. */ + ntreeSetOutput(ntree); + + bNode *node_src = reinterpret_cast(ntree->nodes.first); + bNode *node_local = reinterpret_cast(ltree->nodes.first); + while (node_src != nullptr) { + node_local->runtime->original = node_src; + node_src = node_src->next; + node_local = node_local->next; + } + + if (ntree->typeinfo->localize) { + ntree->typeinfo->localize(ltree, ntree); + } + + return ltree; +} + +/* ************ NODE TREE INTERFACE *************** */ + +void ntreeRemoveSocketInterface(bNodeTree *ntree, bNodeSocket *sock) +{ + /* this is fast, this way we don't need an in_out argument */ + BLI_remlink(&ntree->inputs, sock); + BLI_remlink(&ntree->outputs, sock); + + node_socket_interface_free(ntree, sock, true); + MEM_freeN(sock); + + BKE_ntree_update_tag_interface(ntree); +} + +static bNodeSocket *make_socket_interface(bNodeTree *ntree, + const eNodeSocketInOut in_out, + const char *idname, + const char *name) +{ + bNodeSocketType *stype = nodeSocketTypeFind(idname); + if (stype == nullptr) { + return nullptr; + } + + bNodeSocket *sock = MEM_cnew("socket template"); + sock->runtime = MEM_new(__func__); + STRNCPY(sock->idname, stype->idname); + sock->in_out = int(in_out); + sock->type = int(SOCK_CUSTOM); /* int type undefined by default */ + node_socket_set_typeinfo(ntree, sock, stype); + + /* assign new unique index */ + const int own_index = ntree->cur_index++; + /* use the own_index as socket identifier */ + if (in_out == SOCK_IN) { + SNPRINTF(sock->identifier, "Input_%d", own_index); + } + else { + SNPRINTF(sock->identifier, "Output_%d", own_index); + } + + sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF); + + STRNCPY(sock->name, name); + sock->storage = nullptr; + sock->flag |= SOCK_COLLAPSED; + + return sock; +} + +bNodeSocket *ntreeAddSocketInterface(bNodeTree *ntree, + const eNodeSocketInOut in_out, + const char *idname, + const char *name) +{ + bNodeSocket *iosock = make_socket_interface(ntree, in_out, idname, name); + if (in_out == SOCK_IN) { + BLI_addtail(&ntree->inputs, iosock); + } + else if (in_out == SOCK_OUT) { + BLI_addtail(&ntree->outputs, iosock); + } + BKE_ntree_update_tag_interface(ntree); + return iosock; +} + +/* ************ find stuff *************** */ + +static bool ntree_contains_tree_exec(const bNodeTree *tree_to_search_in, + const bNodeTree *tree_to_search_for, + Set &already_passed) +{ + if (tree_to_search_in == tree_to_search_for) { + return true; + } + + tree_to_search_in->ensure_topology_cache(); + for (const bNode *node_group : tree_to_search_in->group_nodes()) { + const bNodeTree *sub_tree_search_in = reinterpret_cast(node_group->id); + if (!sub_tree_search_in) { + continue; + } + if (!already_passed.add(sub_tree_search_in)) { + continue; + } + if (ntree_contains_tree_exec(sub_tree_search_in, tree_to_search_for, already_passed)) { + return true; + } + } + + return false; +} + +bool ntreeContainsTree(const bNodeTree *tree_to_search_in, const bNodeTree *tree_to_search_for) +{ + if (tree_to_search_in == tree_to_search_for) { + return true; + } + + Set already_passed; + return ntree_contains_tree_exec(tree_to_search_in, tree_to_search_for, already_passed); +} + +int nodeCountSocketLinks(const bNodeTree *ntree, const bNodeSocket *sock) +{ + int tot = 0; + LISTBASE_FOREACH (const bNodeLink *, link, &ntree->links) { + if (link->fromsock == sock || link->tosock == sock) { + tot++; + } + } + return tot; +} + +bNode *nodeGetActive(bNodeTree *ntree) +{ + if (ntree == nullptr) { + return nullptr; + } + + for (bNode *node : ntree->all_nodes()) { + if (node->flag & NODE_ACTIVE) { + return node; + } + } + return nullptr; +} + +void nodeSetSelected(bNode *node, const bool select) +{ + if (select) { + node->flag |= NODE_SELECT; + return; + } + node->flag &= ~NODE_SELECT; + /* deselect sockets too */ + LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { + sock->flag &= ~NODE_SELECT; + } + LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) { + sock->flag &= ~NODE_SELECT; + } +} + +void nodeClearActive(bNodeTree *ntree) +{ + if (ntree == nullptr) { + return; + } + + for (bNode *node : ntree->all_nodes()) { + node->flag &= ~NODE_ACTIVE; + } +} + +void nodeSetActive(bNodeTree *ntree, bNode *node) +{ + const bool is_paint_canvas = blender::bke::nodeSupportsActiveFlag(node, + NODE_ACTIVE_PAINT_CANVAS); + const bool is_texture_class = blender::bke::nodeSupportsActiveFlag(node, NODE_ACTIVE_TEXTURE); + int flags_to_set = NODE_ACTIVE; + SET_FLAG_FROM_TEST(flags_to_set, is_paint_canvas, NODE_ACTIVE_PAINT_CANVAS); + SET_FLAG_FROM_TEST(flags_to_set, is_texture_class, NODE_ACTIVE_TEXTURE); + + /* Make sure only one node is active per node tree. */ + for (bNode *tnode : ntree->all_nodes()) { + tnode->flag &= ~flags_to_set; + } + node->flag |= flags_to_set; +} + +int nodeSocketLinkLimit(const bNodeSocket *sock) +{ + if (sock->is_multi_input()) { + return 4095; + } + if (sock->typeinfo == nullptr) { + return sock->limit; + } + const bNodeSocketType &stype = *sock->typeinfo; + if (!stype.use_link_limits_of_type) { + return sock->limit; + } + return eNodeSocketInOut(sock->in_out) == SOCK_IN ? stype.input_link_limit : + stype.output_link_limit; +} + +void nodeDimensionsGet(const bNode *node, float *r_width, float *r_height) +{ + *r_width = node->runtime->totr.xmax - node->runtime->totr.xmin; + *r_height = node->runtime->totr.ymax - node->runtime->totr.ymin; +} + +void nodeTagUpdateID(bNode *node) +{ + node->runtime->update |= NODE_UPDATE_ID; +} + +void nodeInternalLinks(bNode *node, bNodeLink **r_links, int *r_len) +{ + *r_links = node->runtime->internal_links.data(); + *r_len = node->runtime->internal_links.size(); +} + +/* Node Instance Hash */ + +const bNodeInstanceKey NODE_INSTANCE_KEY_BASE = {5381}; +const bNodeInstanceKey NODE_INSTANCE_KEY_NONE = {0}; + +/* Generate a hash key from ntree and node names + * Uses the djb2 algorithm with xor by Bernstein: + * http://www.cse.yorku.ca/~oz/hash.html + */ +static bNodeInstanceKey node_hash_int_str(bNodeInstanceKey hash, const char *str) +{ + char c; + + while ((c = *str++)) { + hash.value = ((hash.value << 5) + hash.value) ^ c; /* (hash * 33) ^ c */ + } + + /* separator '\0' character, to avoid ambiguity from concatenated strings */ + hash.value = (hash.value << 5) + hash.value; /* hash * 33 */ + + return hash; +} + +bNodeInstanceKey BKE_node_instance_key(bNodeInstanceKey parent_key, + const bNodeTree *ntree, + const bNode *node) +{ + bNodeInstanceKey key = node_hash_int_str(parent_key, ntree->id.name + 2); + + if (node) { + key = node_hash_int_str(key, node->name); + } + + return key; +} + +static uint node_instance_hash_key(const void *key) +{ + return static_cast(key)->value; +} + +static bool node_instance_hash_key_cmp(const void *a, const void *b) +{ + uint value_a = static_cast(a)->value; + uint value_b = static_cast(b)->value; + + return (value_a != value_b); +} + +bNodeInstanceHash *BKE_node_instance_hash_new(const char *info) +{ + bNodeInstanceHash *hash = static_cast( + MEM_mallocN(sizeof(bNodeInstanceHash), info)); + hash->ghash = BLI_ghash_new( + node_instance_hash_key, node_instance_hash_key_cmp, "node instance hash ghash"); + return hash; +} + +void BKE_node_instance_hash_free(bNodeInstanceHash *hash, bNodeInstanceValueFP valfreefp) +{ + BLI_ghash_free(hash->ghash, nullptr, reinterpret_cast(valfreefp)); + MEM_freeN(hash); +} + +void BKE_node_instance_hash_insert(bNodeInstanceHash *hash, bNodeInstanceKey key, void *value) +{ + bNodeInstanceHashEntry *entry = static_cast(value); + entry->key = key; + entry->tag = 0; + BLI_ghash_insert(hash->ghash, &entry->key, value); +} + +void *BKE_node_instance_hash_lookup(bNodeInstanceHash *hash, bNodeInstanceKey key) +{ + return BLI_ghash_lookup(hash->ghash, &key); +} + +int BKE_node_instance_hash_remove(bNodeInstanceHash *hash, + bNodeInstanceKey key, + bNodeInstanceValueFP valfreefp) +{ + return BLI_ghash_remove(hash->ghash, &key, nullptr, reinterpret_cast(valfreefp)); +} + +void BKE_node_instance_hash_clear(bNodeInstanceHash *hash, bNodeInstanceValueFP valfreefp) +{ + BLI_ghash_clear(hash->ghash, nullptr, reinterpret_cast(valfreefp)); +} + +void *BKE_node_instance_hash_pop(bNodeInstanceHash *hash, bNodeInstanceKey key) +{ + return BLI_ghash_popkey(hash->ghash, &key, nullptr); +} + +int BKE_node_instance_hash_haskey(bNodeInstanceHash *hash, bNodeInstanceKey key) +{ + return BLI_ghash_haskey(hash->ghash, &key); +} + +int BKE_node_instance_hash_size(bNodeInstanceHash *hash) +{ + return BLI_ghash_len(hash->ghash); +} + +void BKE_node_instance_hash_clear_tags(bNodeInstanceHash *hash) +{ + blender::bke::bNodeInstanceHashIterator iter; + + NODE_INSTANCE_HASH_ITER (iter, hash) { + bNodeInstanceHashEntry *value = static_cast( + blender::bke::node_instance_hash_iterator_get_value(&iter)); + + value->tag = 0; + } +} + +void BKE_node_instance_hash_tag(bNodeInstanceHash * /*hash*/, void *value) +{ + bNodeInstanceHashEntry *entry = static_cast(value); + entry->tag = 1; +} + +bool BKE_node_instance_hash_tag_key(bNodeInstanceHash *hash, bNodeInstanceKey key) +{ + bNodeInstanceHashEntry *entry = static_cast( + BKE_node_instance_hash_lookup(hash, key)); + + if (entry) { + entry->tag = 1; + return true; + } + + return false; +} + +void BKE_node_instance_hash_remove_untagged(bNodeInstanceHash *hash, + bNodeInstanceValueFP valfreefp) +{ + /* NOTE: Hash must not be mutated during iterating! + * Store tagged entries in a separate list and remove items afterward. + */ + bNodeInstanceKey *untagged = static_cast( + MEM_mallocN(sizeof(bNodeInstanceKey) * BKE_node_instance_hash_size(hash), + "temporary node instance key list")); + blender::bke::bNodeInstanceHashIterator iter; + int num_untagged = 0; + NODE_INSTANCE_HASH_ITER (iter, hash) { + bNodeInstanceHashEntry *value = static_cast( + blender::bke::node_instance_hash_iterator_get_value(&iter)); + + if (!value->tag) { + untagged[num_untagged++] = blender::bke::node_instance_hash_iterator_get_key(&iter); + } + } + + for (int i = 0; i < num_untagged; i++) { + BKE_node_instance_hash_remove(hash, untagged[i], valfreefp); + } + + MEM_freeN(untagged); +} + +void ntreeUpdateAllUsers(Main *main, ID *id) +{ + if (id == nullptr) { + return; + } + + bool need_update = false; + + /* Update all users of ngroup, to add/remove sockets as needed. */ + FOREACH_NODETREE_BEGIN (main, ntree, owner_id) { + for (bNode *node : ntree->all_nodes()) { + if (node->id == id) { + BKE_ntree_update_tag_node_property(ntree, node); + need_update = true; + } + } + } + FOREACH_NODETREE_END; + if (need_update) { + BKE_ntree_update_main(main, nullptr); + } +} + +/* ************* node type access ********** */ + +static void node_type_base_defaults(bNodeType *ntype) +{ + /* default size values */ + blender::bke::node_type_size_preset(ntype, blender::bke::eNodeSizePreset::DEFAULT); + ntype->height = 100; + ntype->minheight = 30; + ntype->maxheight = FLT_MAX; +} + +/* allow this node for any tree type */ +static bool node_poll_default(const bNodeType * /*ntype*/, + const bNodeTree * /*ntree*/, + const char ** /*disabled_hint*/) +{ + return true; +} + +void node_type_base_custom(bNodeType *ntype, + const char *idname, + const char *name, + const short nclass) +{ + STRNCPY(ntype->idname, idname); + ntype->type = NODE_CUSTOM; + STRNCPY(ntype->ui_name, name); + ntype->nclass = nclass; + + node_type_base_defaults(ntype); +} + +struct SocketTemplateIdentifierCallbackData { + bNodeSocketTemplate *list; + bNodeSocketTemplate *ntemp; +}; + +static bool unique_socket_template_identifier_check(void *arg, const char *name) +{ + const SocketTemplateIdentifierCallbackData *data = + static_cast(arg); + + for (bNodeSocketTemplate *ntemp = data->list; ntemp->type >= 0; ntemp++) { + if (ntemp != data->ntemp) { + if (STREQ(ntemp->identifier, name)) { + return true; + } + } + } + + return false; +} + +static void unique_socket_template_identifier(bNodeSocketTemplate *list, + bNodeSocketTemplate *ntemp, + const char defname[], + const char delim) +{ + SocketTemplateIdentifierCallbackData data; + data.list = list; + data.ntemp = ntemp; + + BLI_uniquename_cb(unique_socket_template_identifier_check, + &data, + defname, + delim, + ntemp->identifier, + sizeof(ntemp->identifier)); +} + +void node_type_storage(bNodeType *ntype, + const char *storagename, + void (*freefunc)(bNode *node), + void (*copyfunc)(bNodeTree *dest_ntree, + bNode *dest_node, + const bNode *src_node)) +{ + if (storagename) { + STRNCPY(ntype->storagename, storagename); + } + else { + ntype->storagename[0] = '\0'; + } + ntype->copyfunc = copyfunc; + ntype->freefunc = freefunc; +} + +void BKE_node_system_init() +{ + nodetreetypes_hash = BLI_ghash_str_new("nodetreetypes_hash gh"); + nodetypes_hash = BLI_ghash_str_new("nodetypes_hash gh"); + nodesockettypes_hash = BLI_ghash_str_new("nodesockettypes_hash gh"); + + register_nodes(); +} + +void BKE_node_system_exit() +{ + if (nodetypes_hash) { + NODE_TYPES_BEGIN (nt) { + if (nt->rna_ext.free) { + nt->rna_ext.free(nt->rna_ext.data); + } + } + NODE_TYPES_END; + + BLI_ghash_free(nodetypes_hash, nullptr, node_free_type); + nodetypes_hash = nullptr; + } + + if (nodesockettypes_hash) { + NODE_SOCKET_TYPES_BEGIN (st) { + if (st->ext_socket.free) { + st->ext_socket.free(st->ext_socket.data); + } + if (st->ext_interface.free) { + st->ext_interface.free(st->ext_interface.data); + } + } + NODE_SOCKET_TYPES_END; + + BLI_ghash_free(nodesockettypes_hash, nullptr, node_free_socket_type); + nodesockettypes_hash = nullptr; + } + + if (nodetreetypes_hash) { + NODE_TREE_TYPES_BEGIN (nt) { + if (nt->rna_ext.free) { + nt->rna_ext.free(nt->rna_ext.data); + } + } + NODE_TREE_TYPES_END; + + BLI_ghash_free(nodetreetypes_hash, nullptr, ntree_free_type); + nodetreetypes_hash = nullptr; + } +} + +/* -------------------------------------------------------------------- */ +/* NodeTree Iterator Helpers (FOREACH_NODETREE_BEGIN) */ + +void BKE_node_tree_iter_init(NodeTreeIterStore *ntreeiter, Main *bmain) +{ + ntreeiter->ngroup = (bNodeTree *)bmain->nodetrees.first; + ntreeiter->scene = (Scene *)bmain->scenes.first; + ntreeiter->mat = (Material *)bmain->materials.first; + ntreeiter->tex = (Tex *)bmain->textures.first; + ntreeiter->light = (Light *)bmain->lights.first; + ntreeiter->world = (World *)bmain->worlds.first; + ntreeiter->linestyle = (FreestyleLineStyle *)bmain->linestyles.first; + ntreeiter->simulation = (Simulation *)bmain->simulations.first; +} +bool BKE_node_tree_iter_step(NodeTreeIterStore *ntreeiter, bNodeTree **r_nodetree, ID **r_id) +{ + if (ntreeiter->ngroup) { + bNodeTree &node_tree = *reinterpret_cast(ntreeiter->ngroup); + *r_nodetree = &node_tree; + *r_id = &node_tree.id; + ntreeiter->ngroup = reinterpret_cast(node_tree.id.next); + } + else if (ntreeiter->scene) { + *r_nodetree = reinterpret_cast(ntreeiter->scene->nodetree); + *r_id = &ntreeiter->scene->id; + ntreeiter->scene = reinterpret_cast(ntreeiter->scene->id.next); + } + else if (ntreeiter->mat) { + *r_nodetree = reinterpret_cast(ntreeiter->mat->nodetree); + *r_id = &ntreeiter->mat->id; + ntreeiter->mat = reinterpret_cast(ntreeiter->mat->id.next); + } + else if (ntreeiter->tex) { + *r_nodetree = reinterpret_cast(ntreeiter->tex->nodetree); + *r_id = &ntreeiter->tex->id; + ntreeiter->tex = reinterpret_cast(ntreeiter->tex->id.next); + } + else if (ntreeiter->light) { + *r_nodetree = reinterpret_cast(ntreeiter->light->nodetree); + *r_id = &ntreeiter->light->id; + ntreeiter->light = reinterpret_cast(ntreeiter->light->id.next); + } + else if (ntreeiter->world) { + *r_nodetree = reinterpret_cast(ntreeiter->world->nodetree); + *r_id = &ntreeiter->world->id; + ntreeiter->world = reinterpret_cast(ntreeiter->world->id.next); + } + else if (ntreeiter->linestyle) { + *r_nodetree = reinterpret_cast(ntreeiter->linestyle->nodetree); + *r_id = &ntreeiter->linestyle->id; + ntreeiter->linestyle = reinterpret_cast(ntreeiter->linestyle->id.next); + } + else if (ntreeiter->simulation) { + *r_nodetree = reinterpret_cast(ntreeiter->simulation->nodetree); + *r_id = &ntreeiter->simulation->id; + ntreeiter->simulation = reinterpret_cast(ntreeiter->simulation->id.next); + } + else { + return false; + } + + return true; +} + +void BKE_nodetree_remove_layer_n(bNodeTree *ntree, Scene *scene, const int layer_index) +{ + BLI_assert(layer_index != -1); + BLI_assert(scene != nullptr); + for (bNode *node : ntree->all_nodes()) { + if (node->type == CMP_NODE_R_LAYERS && node->id == &scene->id) { + if (node->custom1 == layer_index) { + node->custom1 = 0; + } + else if (node->custom1 > layer_index) { + node->custom1--; + } + } + } +} + +void nodeFindNode(bNodeTree *ntree, bNodeSocket *sock, bNode **r_node, int *r_sockindex) +{ + *r_node = nullptr; + if (ntree->runtime->topology_cache_mutex.is_cached()) { + bNode *node = &sock->owner_node(); + *r_node = node; + if (r_sockindex) { + const ListBase *sockets = (sock->in_out == SOCK_IN) ? &node->inputs : &node->outputs; + *r_sockindex = BLI_findindex(sockets, sock); + } + return; + } + const bool success = nodeFindNodeTry(ntree, sock, r_node, r_sockindex); + BLI_assert(success); + UNUSED_VARS_NDEBUG(success); +} + +namespace blender::bke { + +static void ntree_blend_write(BlendWriter *writer, ID *id, const void *id_address) +{ + bNodeTree *ntree = reinterpret_cast(id); + + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + ntree->typeinfo = nullptr; + ntree->runtime->execdata = nullptr; + + BLO_write_id_struct(writer, bNodeTree, id_address, &ntree->id); + + ntreeBlendWrite(writer, ntree); +} + +static void ntree_blend_read_data(BlendDataReader *reader, ID *id) +{ + bNodeTree *ntree = reinterpret_cast(id); + ntreeBlendReadData(reader, nullptr, ntree); +} + +static void ntree_blend_read_lib(BlendLibReader *reader, ID *id) +{ + bNodeTree *ntree = reinterpret_cast(id); + ntreeBlendReadLib(reader, ntree); +} + +static void ntree_blend_read_expand(BlendExpander *expander, ID *id) +{ + bNodeTree *ntree = reinterpret_cast(id); + ntreeBlendReadExpand(expander, ntree); +} + +/* *************** Node Preview *********** */ + +/* XXX this should be removed eventually ... + * Currently BKE functions are modeled closely on previous code, + * using node_preview_init_tree to set up previews for a whole node tree in advance. + * This should be left more to the individual node tree implementations. */ + +bool node_preview_used(const bNode *node) +{ + /* XXX check for closed nodes? */ + return (node->typeinfo->flag & NODE_PREVIEW) != 0; +} + +bNodePreview *node_preview_verify(bNodeInstanceHash *previews, + bNodeInstanceKey key, + const int xsize, + const int ysize, + const bool create) +{ + bNodePreview *preview = static_cast( + BKE_node_instance_hash_lookup(previews, key)); + if (!preview) { + if (create) { + preview = MEM_cnew("node preview"); + BKE_node_instance_hash_insert(previews, key, preview); + } + else { + return nullptr; + } + } + + /* node previews can get added with variable size this way */ + if (xsize == 0 || ysize == 0) { + return preview; + } + + /* sanity checks & initialize */ + if (preview->rect) { + if (preview->xsize != xsize || preview->ysize != ysize) { + MEM_freeN(preview->rect); + preview->rect = nullptr; + } + } + + if (preview->rect == nullptr) { + preview->rect = reinterpret_cast( + MEM_callocN(4 * xsize + xsize * ysize * sizeof(char[4]), "node preview rect")); + preview->xsize = xsize; + preview->ysize = ysize; + } + /* no clear, makes nicer previews */ + + return preview; +} + +bNodePreview *node_preview_copy(bNodePreview *preview) +{ + bNodePreview *new_preview = static_cast(MEM_dupallocN(preview)); + if (preview->rect) { + new_preview->rect = static_cast(MEM_dupallocN(preview->rect)); + } + return new_preview; +} + +static void node_tree_asset_pre_save(void *asset_ptr, AssetMetaData *asset_data) +{ + bNodeTree &node_tree = *static_cast(asset_ptr); + + BKE_asset_metadata_idprop_ensure(asset_data, idprop::create("type", node_tree.type).release()); + auto inputs = idprop::create_group("inputs"); + auto outputs = idprop::create_group("outputs"); + LISTBASE_FOREACH (const bNodeSocket *, socket, &node_tree.inputs) { + auto property = idprop::create(socket->name, socket->typeinfo->idname); + IDP_AddToGroup(inputs.get(), property.release()); + } + LISTBASE_FOREACH (const bNodeSocket *, socket, &node_tree.outputs) { + auto property = idprop::create(socket->name, socket->typeinfo->idname); + IDP_AddToGroup(outputs.get(), property.release()); + } + BKE_asset_metadata_idprop_ensure(asset_data, inputs.release()); + BKE_asset_metadata_idprop_ensure(asset_data, outputs.release()); +} + +static void node_foreach_path(ID *id, BPathForeachPathData *bpath_data) +{ + bNodeTree *ntree = reinterpret_cast(id); + + switch (ntree->type) { + case NTREE_SHADER: { + for (bNode *node : ntree->all_nodes()) { + if (node->type == SH_NODE_SCRIPT) { + NodeShaderScript *nss = static_cast(node->storage); + BKE_bpath_foreach_path_fixed_process(bpath_data, nss->filepath); + } + else if (node->type == SH_NODE_TEX_IES) { + NodeShaderTexIES *ies = static_cast(node->storage); + BKE_bpath_foreach_path_fixed_process(bpath_data, ies->filepath); + } + } + break; + } + default: + break; + } +} + +static ID **node_owner_pointer_get(ID *id) +{ + if ((id->flag & LIB_EMBEDDED_DATA) == 0) { + return nullptr; + } + /* TODO: Sort this NO_MAIN or not for embedded node trees. See #86119. */ + // BLI_assert((id->tag & LIB_TAG_NO_MAIN) == 0); + + bNodeTree *ntree = reinterpret_cast(id); + BLI_assert(ntree->owner_id != nullptr); + BLI_assert(ntreeFromID(ntree->owner_id) == ntree); + + return &ntree->owner_id; +} + +static void node_foreach_cache(ID *id, + IDTypeForeachCacheFunctionCallback function_callback, + void *user_data) +{ + bNodeTree *nodetree = reinterpret_cast(id); + IDCacheKey key = {0}; + key.id_session_uuid = id->session_uuid; + key.offset_in_ID = offsetof(bNodeTree, previews); + + /* TODO: see also `direct_link_nodetree()` in readfile.c. */ +#if 0 + function_callback(id, &key, static_cast(&nodetree->previews), 0, user_data); +#endif + + if (nodetree->type == NTREE_COMPOSIT) { + for (bNode *node : nodetree->all_nodes()) { + if (node->type == CMP_NODE_MOVIEDISTORTION) { + key.offset_in_ID = size_t(BLI_ghashutil_strhash_p(node->name)); + function_callback(id, &key, static_cast(&node->storage), 0, user_data); + } + } + } +} + +static void library_foreach_node_socket(LibraryForeachIDData *data, bNodeSocket *sock) +{ + BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL( + data, + IDP_foreach_property( + sock->prop, IDP_TYPE_FILTER_ID, BKE_lib_query_idpropertiesForeachIDLink_callback, data)); + + switch (eNodeSocketDatatype(sock->type)) { + case SOCK_OBJECT: { + bNodeSocketValueObject &default_value = *sock->default_value_typed(); + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, default_value.value, IDWALK_CB_USER); + break; + } + case SOCK_IMAGE: { + bNodeSocketValueImage &default_value = *sock->default_value_typed(); + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, default_value.value, IDWALK_CB_USER); + break; + } + case SOCK_COLLECTION: { + bNodeSocketValueCollection &default_value = + *sock->default_value_typed(); + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, default_value.value, IDWALK_CB_USER); + break; + } + case SOCK_TEXTURE: { + bNodeSocketValueTexture &default_value = + *sock->default_value_typed(); + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, default_value.value, IDWALK_CB_USER); + break; + } + case SOCK_MATERIAL: { + bNodeSocketValueMaterial &default_value = + *sock->default_value_typed(); + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, default_value.value, IDWALK_CB_USER); + break; + } + case SOCK_FLOAT: + case SOCK_VECTOR: + case SOCK_RGBA: + case SOCK_BOOLEAN: + case SOCK_INT: + case SOCK_STRING: + case __SOCK_MESH: + case SOCK_CUSTOM: + case SOCK_SHADER: + case SOCK_GEOMETRY: + break; + } +} + +static void node_foreach_id(ID *id, LibraryForeachIDData *data) +{ + bNodeTree *ntree = reinterpret_cast(id); + + BKE_LIB_FOREACHID_PROCESS_ID(data, ntree->owner_id, IDWALK_CB_LOOPBACK); + + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, ntree->gpd, IDWALK_CB_USER); + + for (bNode *node : ntree->all_nodes()) { + BKE_LIB_FOREACHID_PROCESS_ID(data, node->id, IDWALK_CB_USER); + + BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL( + data, + IDP_foreach_property(node->prop, + IDP_TYPE_FILTER_ID, + BKE_lib_query_idpropertiesForeachIDLink_callback, + data)); + LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { + BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data, library_foreach_node_socket(data, sock)); + } + LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) { + BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data, library_foreach_node_socket(data, sock)); + } + } + + LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->inputs) { + BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data, library_foreach_node_socket(data, sock)); + } + LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->outputs) { + BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data, library_foreach_node_socket(data, sock)); + } +} + +static void free_localized_node_groups(bNodeTree *ntree) +{ + /* Only localized node trees store a copy for each node group tree. + * Each node group tree in a localized node tree can be freed, + * since it is a localized copy itself (no risk of accessing free'd + * data in main, see #37939). */ + if (!(ntree->id.tag & LIB_TAG_LOCALIZED)) { + return; + } + + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + bNodeTree *ngroup = reinterpret_cast(node->id); + if (node->is_group() && ngroup != nullptr) { + ntreeFreeTree(ngroup); + MEM_freeN(ngroup); + } + } +} + +static void ntree_free_data(ID *id) +{ + bNodeTree *ntree = reinterpret_cast(id); + + /* XXX hack! node trees should not store execution graphs at all. + * This should be removed when old tree types no longer require it. + * Currently the execution data for texture nodes remains in the tree + * after execution, until the node tree is updated or freed. */ + if (ntree->runtime->execdata) { + switch (ntree->type) { + case NTREE_SHADER: + ntreeShaderEndExecTree(ntree->runtime->execdata); + break; + case NTREE_TEXTURE: + ntreeTexEndExecTree(ntree->runtime->execdata); + ntree->runtime->execdata = nullptr; + break; + } + } + + /* XXX not nice, but needed to free localized node groups properly */ + free_localized_node_groups(ntree); + + BLI_freelistN(&ntree->links); + + LISTBASE_FOREACH_MUTABLE (bNode *, node, &ntree->nodes) { + node_free_node(ntree, node); + } + + /* free interface sockets */ + LISTBASE_FOREACH_MUTABLE (bNodeSocket *, sock, &ntree->inputs) { + node_socket_interface_free(ntree, sock, false); + MEM_freeN(sock); + } + LISTBASE_FOREACH_MUTABLE (bNodeSocket *, sock, &ntree->outputs) { + node_socket_interface_free(ntree, sock, false); + MEM_freeN(sock); + } + + /* free preview hash */ + if (ntree->previews) { + BKE_node_instance_hash_free(ntree->previews, (bNodeInstanceValueFP)node_preview_free); + } + + if (ntree->id.tag & LIB_TAG_LOCALIZED) { + BKE_libblock_free_data(&ntree->id, true); + } + + BKE_previewimg_free(&ntree->preview); + MEM_delete(ntree->runtime); +} + static void node_socket_copy(bNodeSocket *sock_dst, const bNodeSocket *sock_src, const int flag) { sock_dst->runtime = MEM_new(__func__); @@ -2387,7 +2692,132 @@ static void node_socket_copy(bNodeSocket *sock_dst, const bNodeSocket *sock_src, sock_dst->stack_index = 0; } -namespace blender::bke { +static void ntree_copy_data(Main * /*bmain*/, ID *id_dst, const ID *id_src, const int flag) +{ + bNodeTree *ntree_dst = reinterpret_cast(id_dst); + const bNodeTree *ntree_src = reinterpret_cast(id_src); + + /* We never handle user-count here for own data. */ + const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT; + + ntree_dst->runtime = MEM_new(__func__); + bNodeTreeRuntime &dst_runtime = *ntree_dst->runtime; + + Map socket_map; + + dst_runtime.nodes_by_id.reserve(ntree_src->all_nodes().size()); + BLI_listbase_clear(&ntree_dst->nodes); + int i; + LISTBASE_FOREACH_INDEX (const bNode *, src_node, &ntree_src->nodes, i) { + /* Don't find a unique name for every node, since they should have valid names already. */ + bNode *new_node = node_copy_with_mapping( + ntree_dst, *src_node, flag_subdata, false, socket_map); + dst_runtime.nodes_by_id.add_new(new_node); + new_node->runtime->index_in_tree = i; + } + + /* copy links */ + BLI_listbase_clear(&ntree_dst->links); + LISTBASE_FOREACH (const bNodeLink *, src_link, &ntree_src->links) { + bNodeLink *dst_link = static_cast(MEM_dupallocN(src_link)); + dst_link->fromnode = dst_runtime.nodes_by_id.lookup_key_as(src_link->fromnode->identifier); + dst_link->fromsock = socket_map.lookup(src_link->fromsock); + dst_link->tonode = dst_runtime.nodes_by_id.lookup_key_as(src_link->tonode->identifier); + dst_link->tosock = socket_map.lookup(src_link->tosock); + BLI_assert(dst_link->tosock); + dst_link->tosock->link = dst_link; + BLI_addtail(&ntree_dst->links, dst_link); + } + + /* update node->parent pointers */ + for (bNode *node : ntree_dst->all_nodes()) { + if (node->parent) { + node->parent = dst_runtime.nodes_by_id.lookup_key_as(node->parent->identifier); + } + } + + for (bNode *node : ntree_dst->all_nodes()) { + nodeDeclarationEnsure(ntree_dst, node); + } + + /* copy interface sockets */ + BLI_listbase_clear(&ntree_dst->inputs); + LISTBASE_FOREACH (const bNodeSocket *, src_socket, &ntree_src->inputs) { + bNodeSocket *dst_socket = static_cast(MEM_dupallocN(src_socket)); + node_socket_copy(dst_socket, src_socket, flag_subdata); + BLI_addtail(&ntree_dst->inputs, dst_socket); + } + BLI_listbase_clear(&ntree_dst->outputs); + LISTBASE_FOREACH (const bNodeSocket *, src_socket, &ntree_src->outputs) { + bNodeSocket *dst_socket = static_cast(MEM_dupallocN(src_socket)); + node_socket_copy(dst_socket, src_socket, flag_subdata); + BLI_addtail(&ntree_dst->outputs, dst_socket); + } + + /* copy preview hash */ + if (ntree_src->previews && (flag & LIB_ID_COPY_NO_PREVIEW) == 0) { + bNodeInstanceHashIterator iter; + + ntree_dst->previews = BKE_node_instance_hash_new("node previews"); + + NODE_INSTANCE_HASH_ITER (iter, ntree_src->previews) { + bNodeInstanceKey key = node_instance_hash_iterator_get_key(&iter); + bNodePreview *preview = static_cast( + node_instance_hash_iterator_get_value(&iter)); + BKE_node_instance_hash_insert(ntree_dst->previews, key, node_preview_copy(preview)); + } + } + else { + ntree_dst->previews = nullptr; + } + + if (ntree_src->runtime->field_inferencing_interface) { + dst_runtime.field_inferencing_interface = std::make_unique( + *ntree_src->runtime->field_inferencing_interface); + } + if (ntree_src->runtime->anonymous_attribute_relations) { + dst_runtime.anonymous_attribute_relations = + std::make_unique( + *ntree_src->runtime->anonymous_attribute_relations); + } + + if (flag & LIB_ID_COPY_NO_PREVIEW) { + ntree_dst->preview = nullptr; + } + else { + BKE_previewimg_id_copy(&ntree_dst->id, &ntree_src->id); + } +} + +static void ntree_init_data(ID *id) +{ + bNodeTree *ntree = reinterpret_cast(id); + ntree->runtime = MEM_new(__func__); + ntree_set_typeinfo(ntree, nullptr); +} + +bNodeSocket *node_find_enabled_socket(bNode &node, + const eNodeSocketInOut in_out, + const StringRef name) +{ + ListBase *sockets = (in_out == SOCK_IN) ? &node.inputs : &node.outputs; + LISTBASE_FOREACH (bNodeSocket *, socket, sockets) { + if (socket->is_available() && socket->name == name) { + return socket; + } + } + return nullptr; +} + +bNodeSocket *node_find_enabled_input_socket(bNode &node, const StringRef name) +{ + return node_find_enabled_socket(node, SOCK_IN, name); +} + +bNodeSocket *node_find_enabled_output_socket(bNode &node, const StringRef name) +{ + return node_find_enabled_socket(node, SOCK_OUT, name); +} bNode *node_copy_with_mapping(bNodeTree *dst_tree, const bNode &node_src, @@ -2581,81 +3011,809 @@ bNode *node_copy(bNodeTree *dst_tree, const bNode &src_node, const int flag, con return node_copy_with_mapping(dst_tree, src_node, flag, use_unique, socket_map); } -} // namespace blender::bke - -static int node_count_links(const bNodeTree *ntree, const bNodeSocket *socket) +static void node_socket_free(bNodeSocket *sock, const bool do_id_user) { - int count = 0; + if (sock->prop) { + IDP_FreePropertyContent_ex(sock->prop, do_id_user); + MEM_freeN(sock->prop); + } + + if (sock->default_value) { + if (do_id_user) { + socket_id_user_decrement(sock); + } + MEM_freeN(sock->default_value); + } + if (sock->default_attribute_name) { + MEM_freeN(sock->default_attribute_name); + } + MEM_delete(sock->runtime); +} + +void node_free_node(bNodeTree *ntree, bNode *node) +{ + /* since it is called while free database, node->id is undefined */ + + /* can be called for nodes outside a node tree (e.g. clipboard) */ + if (ntree) { + BLI_remlink(&ntree->nodes, node); + /* Rebuild nodes #VectorSet which must have the same order as the list. */ + nodeRebuildIDVector(ntree); + + /* texture node has bad habit of keeping exec data around */ + if (ntree->type == NTREE_TEXTURE && ntree->runtime->execdata) { + ntreeTexEndExecTree(ntree->runtime->execdata); + ntree->runtime->execdata = nullptr; + } + } + + if (node->typeinfo->freefunc) { + node->typeinfo->freefunc(node); + } + + LISTBASE_FOREACH_MUTABLE (bNodeSocket *, sock, &node->inputs) { + /* Remember, no ID user refcount management here! */ + node_socket_free(sock, false); + MEM_freeN(sock); + } + LISTBASE_FOREACH_MUTABLE (bNodeSocket *, sock, &node->outputs) { + /* Remember, no ID user refcount management here! */ + node_socket_free(sock, false); + MEM_freeN(sock); + } + + if (node->prop) { + /* Remember, no ID user refcount management here! */ + IDP_FreePropertyContent_ex(node->prop, false); + MEM_freeN(node->prop); + } + + if (node->typeinfo->declare_dynamic) { + delete node->runtime->declaration; + } + + MEM_delete(node->runtime); + MEM_freeN(node); + + if (ntree) { + BKE_ntree_update_tag_node_removed(ntree); + } +} + +bNodeTree *ntreeAddTreeEmbedded(Main * /*bmain*/, + ID *owner_id, + const char *name, + const char *idname) +{ + return ntreeAddTree_do(nullptr, owner_id, true, name, idname); +} + +void ntreeFreeTree(bNodeTree *ntree) +{ + ntree_free_data(&ntree->id); + BKE_animdata_free(&ntree->id, false); +} + +bNodeTree *ntreeCopyTree_ex(const bNodeTree *ntree, Main *bmain, const bool do_id_user) +{ + const int flag = do_id_user ? 0 : LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_MAIN; + + bNodeTree *ntree_copy = reinterpret_cast( + BKE_id_copy_ex(bmain, reinterpret_cast(ntree), nullptr, flag)); + return ntree_copy; +} + +bNodeTree *ntreeCopyTree(Main *bmain, const bNodeTree *ntree) +{ + return ntreeCopyTree_ex(ntree, bmain, true); +} + +void ntreeFreeLocalNode(bNodeTree *ntree, bNode *node) +{ + /* For removing nodes while editing localized node trees. */ + BLI_assert((ntree->id.tag & LIB_TAG_LOCALIZED) != 0); + + /* These two lines assume the caller might want to free a single node and maintain + * a valid state in the node tree. */ + nodeUnlinkNode(ntree, node); + node_unlink_attached(ntree, node); + + node_free_node(ntree, node); + nodeRebuildIDVector(ntree); +} + +/* ************ find stuff *************** */ + +bNode *ntreeFindType(bNodeTree *ntree, const int type) +{ + if (ntree) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + if (node->type == type) { + return node; + } + } + } + return nullptr; +} + +void ntreeUpdateAllNew(Main *main) +{ + /* Update all new node trees on file read or append, to add/remove sockets + * in groups nodes if the group changed, and handle any update flags that + * might have been set in file reading or versioning. */ + FOREACH_NODETREE_BEGIN (main, ntree, owner_id) { + if (owner_id->tag & LIB_TAG_NEW) { + BKE_ntree_update_tag_all(ntree); + } + } + FOREACH_NODETREE_END; + BKE_ntree_update_main(main, nullptr); +} + +void ntreeNodeFlagSet(const bNodeTree *ntree, const int flag, const bool enable) +{ + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + if (enable) { + node->flag |= flag; + } + else { + node->flag &= ~flag; + } + } +} + +void ntreeLocalMerge(Main *bmain, bNodeTree *localtree, bNodeTree *ntree) +{ + if (ntree && localtree) { + if (ntree->typeinfo->local_merge) { + ntree->typeinfo->local_merge(bmain, localtree, ntree); + } + + ntreeFreeTree(localtree); + MEM_freeN(localtree); + } +} + +static void direct_link_node_socket(BlendDataReader *reader, bNodeSocket *sock) +{ + BLO_read_data_address(reader, &sock->prop); + IDP_BlendDataRead(reader, &sock->prop); + + BLO_read_data_address(reader, &sock->link); + sock->typeinfo = nullptr; + BLO_read_data_address(reader, &sock->storage); + BLO_read_data_address(reader, &sock->default_value); + BLO_read_data_address(reader, &sock->default_attribute_name); + sock->runtime = MEM_new(__func__); +} + +void ntreeBlendReadData(BlendDataReader *reader, ID *owner_id, bNodeTree *ntree) +{ + /* Special case for this pointer, do not rely on regular `lib_link` process here. Avoids needs + * for do_versioning, and ensures coherence of data in any case. + * + * NOTE: Old versions are very often 'broken' here, just fix it silently in these cases. + */ + if (BLO_read_fileversion_get(reader) > 300) { + BLI_assert((ntree->id.flag & LIB_EMBEDDED_DATA) != 0 || owner_id == nullptr); + } + BLI_assert(owner_id == nullptr || owner_id->lib == ntree->id.lib); + if (owner_id != nullptr && (ntree->id.flag & LIB_EMBEDDED_DATA) == 0) { + /* This is unfortunate, but currently a lot of existing files (including startup ones) have + * missing `LIB_EMBEDDED_DATA` flag. + * + * NOTE: Using do_version is not a solution here, since this code will be called before any + * do_version takes place. Keeping it here also ensures future (or unknown existing) similar + * bugs won't go easily unnoticed. */ + if (BLO_read_fileversion_get(reader) > 300) { + CLOG_WARN(&LOG, + "Fixing root node tree '%s' owned by '%s' missing EMBEDDED tag, please consider " + "re-saving your (startup) file", + ntree->id.name, + owner_id->name); + } + ntree->id.flag |= LIB_EMBEDDED_DATA; + } + ntree->owner_id = owner_id; + + /* NOTE: writing and reading goes in sync, for speed. */ + ntree->typeinfo = nullptr; + + ntree->runtime = MEM_new(__func__); + BKE_ntree_update_tag_missing_runtime_data(ntree); + + BLO_read_data_address(reader, &ntree->adt); + BKE_animdata_blend_read_data(reader, ntree->adt); + + BLO_read_list(reader, &ntree->nodes); + int i; + LISTBASE_FOREACH_INDEX (bNode *, node, &ntree->nodes, i) { + node->runtime = MEM_new(__func__); + node->typeinfo = nullptr; + node->runtime->index_in_tree = i; + + /* Create the `nodes_by_id` cache eagerly so it can be expected to be valid. Because + * we create it here we also have to check for zero identifiers from previous versions. */ + if (node->identifier == 0 || ntree->runtime->nodes_by_id.contains_as(node->identifier)) { + nodeUniqueID(ntree, node); + } + else { + ntree->runtime->nodes_by_id.add_new(node); + } + + BLO_read_list(reader, &node->inputs); + BLO_read_list(reader, &node->outputs); + + BLO_read_data_address(reader, &node->prop); + IDP_BlendDataRead(reader, &node->prop); + + if (node->type == CMP_NODE_MOVIEDISTORTION) { + /* Do nothing, this is runtime cache and hence handled by generic code using + * `IDTypeInfo.foreach_cache` callback. */ + } + else { + BLO_read_data_address(reader, &node->storage); + } + + if (node->storage) { + switch (node->type) { + case SH_NODE_CURVE_VEC: + case SH_NODE_CURVE_RGB: + case SH_NODE_CURVE_FLOAT: + case CMP_NODE_TIME: + case CMP_NODE_CURVE_VEC: + case CMP_NODE_CURVE_RGB: + case CMP_NODE_HUECORRECT: + case TEX_NODE_CURVE_RGB: + case TEX_NODE_CURVE_TIME: { + BKE_curvemapping_blend_read(reader, static_cast(node->storage)); + break; + } + case SH_NODE_SCRIPT: { + NodeShaderScript *nss = static_cast(node->storage); + BLO_read_data_address(reader, &nss->bytecode); + break; + } + case SH_NODE_TEX_POINTDENSITY: { + NodeShaderTexPointDensity *npd = static_cast(node->storage); + npd->pd = blender::dna::shallow_zero_initialize(); + break; + } + case SH_NODE_TEX_IMAGE: { + NodeTexImage *tex = static_cast(node->storage); + tex->iuser.scene = nullptr; + break; + } + case SH_NODE_TEX_ENVIRONMENT: { + NodeTexEnvironment *tex = static_cast(node->storage); + tex->iuser.scene = nullptr; + break; + } + case CMP_NODE_IMAGE: + case CMP_NODE_R_LAYERS: + case CMP_NODE_VIEWER: + case CMP_NODE_SPLITVIEWER: { + ImageUser *iuser = static_cast(node->storage); + iuser->scene = nullptr; + break; + } + case CMP_NODE_CRYPTOMATTE_LEGACY: + case CMP_NODE_CRYPTOMATTE: { + NodeCryptomatte *nc = static_cast(node->storage); + BLO_read_data_address(reader, &nc->matte_id); + BLO_read_list(reader, &nc->entries); + BLI_listbase_clear(&nc->runtime.layers); + break; + } + case TEX_NODE_IMAGE: { + ImageUser *iuser = static_cast(node->storage); + iuser->scene = nullptr; + break; + } + case CMP_NODE_OUTPUT_FILE: { + NodeImageMultiFile *nimf = static_cast(node->storage); + BKE_image_format_blend_read_data(reader, &nimf->format); + break; + } + case FN_NODE_INPUT_STRING: { + NodeInputString *storage = static_cast(node->storage); + BLO_read_data_address(reader, &storage->string); + break; + } + case GEO_NODE_SIMULATION_OUTPUT: { + NodeGeometrySimulationOutput &storage = *static_cast( + node->storage); + BLO_read_data_address(reader, &storage.items); + for (const NodeSimulationItem &item : Span(storage.items, storage.items_num)) { + BLO_read_data_address(reader, &item.name); + } + break; + } + + default: + break; + } + } + } + BLO_read_list(reader, &ntree->links); + BLI_assert(ntree->all_nodes().size() == BLI_listbase_count(&ntree->nodes)); + + /* and we connect the rest */ + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + BLO_read_data_address(reader, &node->parent); + + LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { + direct_link_node_socket(reader, sock); + } + LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) { + direct_link_node_socket(reader, sock); + } + + /* Socket storage. */ + if (node->type == CMP_NODE_OUTPUT_FILE) { + LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { + NodeImageMultiFileSocket *sockdata = static_cast( + sock->storage); + BKE_image_format_blend_read_data(reader, &sockdata->format); + } + } + } + + /* interface socket lists */ + BLO_read_list(reader, &ntree->inputs); + BLO_read_list(reader, &ntree->outputs); + LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->inputs) { + direct_link_node_socket(reader, sock); + } + LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->outputs) { + direct_link_node_socket(reader, sock); + } + LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { - if (ELEM(socket, link->fromsock, link->tosock)) { - count++; - } + BLO_read_data_address(reader, &link->fromnode); + BLO_read_data_address(reader, &link->tonode); + BLO_read_data_address(reader, &link->fromsock); + BLO_read_data_address(reader, &link->tosock); } - return count; + + /* TODO: should be dealt by new generic cache handling of IDs... */ + ntree->previews = nullptr; + + BLO_read_data_address(reader, &ntree->preview); + BKE_previewimg_blend_read(reader, ntree->preview); + + /* type verification is in lib-link */ } -bNodeLink *nodeAddLink( - bNodeTree *ntree, bNode *fromnode, bNodeSocket *fromsock, bNode *tonode, bNodeSocket *tosock) +static void lib_link_node_socket(BlendLibReader *reader, Library *lib, bNodeSocket *sock) { - BLI_assert(fromnode); - BLI_assert(tonode); - BLI_assert(ntree->all_nodes().contains(fromnode)); - BLI_assert(ntree->all_nodes().contains(tonode)); + IDP_BlendReadLib(reader, lib, sock->prop); - bNodeLink *link = nullptr; - if (eNodeSocketInOut(fromsock->in_out) == SOCK_OUT && - eNodeSocketInOut(tosock->in_out) == SOCK_IN) { - link = MEM_cnew("link"); - if (ntree) { - BLI_addtail(&ntree->links, link); + /* This can happen for all socket types when a file is saved in an older version of Blender than + * it was originally created in (#86298). Some socket types still require a default value. The + * default value of those sockets will be created in `ntreeSetTypes`. */ + if (sock->default_value == nullptr) { + return; + } + + switch (eNodeSocketDatatype(sock->type)) { + case SOCK_OBJECT: { + BLO_read_id_address( + reader, lib, &sock->default_value_typed()->value); + break; } - link->fromnode = fromnode; - link->fromsock = fromsock; - link->tonode = tonode; - link->tosock = tosock; - } - else if (eNodeSocketInOut(fromsock->in_out) == SOCK_IN && - eNodeSocketInOut(tosock->in_out) == SOCK_OUT) - { - /* OK but flip */ - link = MEM_cnew("link"); - if (ntree) { - BLI_addtail(&ntree->links, link); + case SOCK_IMAGE: { + BLO_read_id_address(reader, lib, &sock->default_value_typed()->value); + break; } - link->fromnode = tonode; - link->fromsock = tosock; - link->tonode = fromnode; - link->tosock = fromsock; + case SOCK_COLLECTION: { + BLO_read_id_address( + reader, lib, &sock->default_value_typed()->value); + break; + } + case SOCK_TEXTURE: { + BLO_read_id_address( + reader, lib, &sock->default_value_typed()->value); + break; + } + case SOCK_MATERIAL: { + BLO_read_id_address( + reader, lib, &sock->default_value_typed()->value); + break; + } + case SOCK_FLOAT: + case SOCK_VECTOR: + case SOCK_RGBA: + case SOCK_BOOLEAN: + case SOCK_INT: + case SOCK_STRING: + case __SOCK_MESH: + case SOCK_CUSTOM: + case SOCK_SHADER: + case SOCK_GEOMETRY: + break; } - - if (ntree) { - BKE_ntree_update_tag_link_added(ntree, link); - } - - if (link != nullptr && link->tosock->is_multi_input()) { - link->multi_input_socket_index = node_count_links(ntree, link->tosock) - 1; - } - - return link; } -void nodeRemLink(bNodeTree *ntree, bNodeLink *link) +static void lib_link_node_sockets(BlendLibReader *reader, Library *lib, ListBase *sockets) { - /* Can be called for links outside a node tree (e.g. clipboard). */ - if (ntree) { - BLI_remlink(&ntree->links, link); + LISTBASE_FOREACH (bNodeSocket *, sock, sockets) { + lib_link_node_socket(reader, lib, sock); + } +} + +void ntreeBlendReadLib(BlendLibReader *reader, bNodeTree *ntree) +{ + Library *lib = ntree->id.lib; + + BLO_read_id_address(reader, lib, &ntree->gpd); + + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + /* Link ID Properties -- and copy this comment EXACTLY for easy finding + * of library blocks that implement this. */ + IDP_BlendReadLib(reader, lib, node->prop); + + BLO_read_id_address(reader, lib, &node->id); + + lib_link_node_sockets(reader, lib, &node->inputs); + lib_link_node_sockets(reader, lib, &node->outputs); } - if (link->tosock) { - link->tosock->link = nullptr; - } - MEM_freeN(link); + lib_link_node_sockets(reader, lib, &ntree->inputs); + lib_link_node_sockets(reader, lib, &ntree->outputs); - if (ntree) { - BKE_ntree_update_tag_link_removed(ntree); + /* Set `node->typeinfo` pointers. This is done in lib linking, after the + * first versioning that can change types still without functions that + * update the `typeinfo` pointers. Versioning after lib linking needs + * these top be valid. */ + ntreeSetTypes(nullptr, ntree); + + /* For nodes with static socket layout, add/remove sockets as needed + * to match the static layout. */ + if (!BLO_read_lib_is_undo(reader)) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + /* Don't update node groups here because they may depend on other node groups which are not + * fully versioned yet and don't have `typeinfo` pointers set. */ + if (!node->is_group()) { + node_verify_sockets(ntree, node, false); + } + } } } +static void expand_node_socket(BlendExpander *expander, bNodeSocket *sock) +{ + IDP_BlendReadExpand(expander, sock->prop); + + if (sock->default_value == nullptr) { + return; + } + + switch (eNodeSocketDatatype(sock->type)) { + case SOCK_OBJECT: { + BLO_expand(expander, sock->default_value_typed()->value); + break; + } + case SOCK_IMAGE: { + BLO_expand(expander, sock->default_value_typed()->value); + break; + } + case SOCK_COLLECTION: { + BLO_expand(expander, sock->default_value_typed()->value); + break; + } + case SOCK_TEXTURE: { + BLO_expand(expander, sock->default_value_typed()->value); + break; + } + case SOCK_MATERIAL: { + BLO_expand(expander, sock->default_value_typed()->value); + break; + } + case SOCK_FLOAT: + case SOCK_VECTOR: + case SOCK_RGBA: + case SOCK_BOOLEAN: + case SOCK_INT: + case SOCK_STRING: + case __SOCK_MESH: + case SOCK_CUSTOM: + case SOCK_SHADER: + case SOCK_GEOMETRY: + break; + } +} + +static void expand_node_sockets(BlendExpander *expander, ListBase *sockets) +{ + LISTBASE_FOREACH (bNodeSocket *, sock, sockets) { + expand_node_socket(expander, sock); + } +} + +void ntreeBlendReadExpand(BlendExpander *expander, bNodeTree *ntree) +{ + if (ntree->gpd) { + BLO_expand(expander, ntree->gpd); + } + + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + if (node->id && !(node->type == CMP_NODE_R_LAYERS) && + !(node->type == CMP_NODE_CRYPTOMATTE && node->custom1 == CMP_CRYPTOMATTE_SRC_RENDER)) + { + BLO_expand(expander, node->id); + } + + IDP_BlendReadExpand(expander, node->prop); + + expand_node_sockets(expander, &node->inputs); + expand_node_sockets(expander, &node->outputs); + } + + expand_node_sockets(expander, &ntree->inputs); + expand_node_sockets(expander, &ntree->outputs); +} + +void nodeModifySocketType(bNodeTree *ntree, + bNode * /*node*/, + bNodeSocket *sock, + const char *idname) +{ + bNodeSocketType *socktype = nodeSocketTypeFind(idname); + + if (!socktype) { + CLOG_ERROR(&LOG, "node socket type %s undefined", idname); + return; + } + + if (sock->default_value) { + if (sock->type != socktype->type) { + /* Only reallocate the default value if the type changed so that UI data like min and max + * isn't removed. This assumes that the default value is stored in the same format for all + * socket types with the same #eNodeSocketDatatype. */ + socket_id_user_decrement(sock); + MEM_freeN(sock->default_value); + sock->default_value = nullptr; + } + else { + /* Update the socket subtype when the storage isn't freed and recreated. */ + switch (eNodeSocketDatatype(sock->type)) { + case SOCK_FLOAT: { + sock->default_value_typed()->subtype = socktype->subtype; + break; + } + case SOCK_VECTOR: { + sock->default_value_typed()->subtype = socktype->subtype; + break; + } + case SOCK_INT: { + sock->default_value_typed()->subtype = socktype->subtype; + break; + } + case SOCK_STRING: { + sock->default_value_typed()->subtype = socktype->subtype; + break; + } + case SOCK_RGBA: + case SOCK_SHADER: + case SOCK_BOOLEAN: + case SOCK_CUSTOM: + case __SOCK_MESH: + case SOCK_OBJECT: + case SOCK_IMAGE: + case SOCK_GEOMETRY: + case SOCK_COLLECTION: + case SOCK_TEXTURE: + case SOCK_MATERIAL: + break; + } + } + } + + STRNCPY(sock->idname, idname); + node_socket_set_typeinfo(ntree, sock, socktype); +} + +void nodeRebuildIDVector(bNodeTree *node_tree) +{ + /* Rebuild nodes #VectorSet which must have the same order as the list. */ + node_tree->runtime->nodes_by_id.clear(); + int i; + LISTBASE_FOREACH_INDEX (bNode *, node, &node_tree->nodes, i) { + node_tree->runtime->nodes_by_id.add_new(node); + node->runtime->index_in_tree = i; + } +} + +void nodeUnlinkNode(bNodeTree *ntree, bNode *node) +{ + LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) { + ListBase *lb = nullptr; + if (link->fromnode == node) { + lb = &node->outputs; + } + else if (link->tonode == node) { + lb = &node->inputs; + } + + if (lb) { + /* Only bother adjusting if the socket is not on the node we're deleting. */ + if (link->tonode != node && link->tosock->is_multi_input()) { + adjust_multi_input_indices_after_removed_link( + ntree, link->tosock, link->multi_input_socket_index); + } + LISTBASE_FOREACH (const bNodeSocket *, sock, lb) { + if (link->fromsock == sock || link->tosock == sock) { + nodeRemLink(ntree, link); + break; + } + } + } + } +} + +void nodeRemoveAllSockets(bNodeTree *ntree, bNode *node) +{ + LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) { + if (link->fromnode == node || link->tonode == node) { + nodeRemLink(ntree, link); + } + } + + node->runtime->internal_links.clear(); + + LISTBASE_FOREACH_MUTABLE (bNodeSocket *, sock, &node->inputs) { + node_socket_free(sock, true); + MEM_freeN(sock); + } + BLI_listbase_clear(&node->inputs); + + LISTBASE_FOREACH_MUTABLE (bNodeSocket *, sock, &node->outputs) { + node_socket_free(sock, true); + MEM_freeN(sock); + } + BLI_listbase_clear(&node->outputs); + + BKE_ntree_update_tag_socket_removed(ntree); +} + +void nodeRemoveSocketEx(bNodeTree *ntree, bNode *node, bNodeSocket *sock, const bool do_id_user) +{ + LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) { + if (link->fromsock == sock || link->tosock == sock) { + nodeRemLink(ntree, link); + } + } + + for (const int64_t i : node->runtime->internal_links.index_range()) { + const bNodeLink &link = node->runtime->internal_links[i]; + if (link.fromsock == sock || link.tosock == sock) { + node->runtime->internal_links.remove_and_reorder(i); + BKE_ntree_update_tag_node_internal_link(ntree, node); + break; + } + } + + /* this is fast, this way we don't need an in_out argument */ + BLI_remlink(&node->inputs, sock); + BLI_remlink(&node->outputs, sock); + + node_socket_free(sock, do_id_user); + MEM_freeN(sock); + + BKE_ntree_update_tag_socket_removed(ntree); +} + +const char *nodeSocketSubTypeLabel(int subtype) +{ + const char *name; + if (RNA_enum_name(rna_enum_property_subtype_items, subtype, &name)) { + return name; + } + return ""; +} + +bool nodeIsStaticSocketType(const bNodeSocketType *stype) +{ + /* + * Cannot rely on type==SOCK_CUSTOM here, because type is 0 by default + * and can be changed on custom sockets. + */ + return RNA_struct_is_a(stype->ext_socket.srna, &RNA_NodeSocketStandard); +} + +bool node_type_is_undefined(const bNode *node) +{ + if (node->typeinfo == &NodeTypeUndefined) { + return true; + } + + if (node->is_group()) { + const ID *group_tree = node->id; + if (group_tree == nullptr) { + return false; + } + if (!ID_IS_LINKED(group_tree)) { + return false; + } + if ((group_tree->tag & LIB_TAG_MISSING) == 0) { + return false; + } + return true; + } + return false; +} + +bNodeSocket *ntreeInsertSocketInterfaceFromSocket(bNodeTree *ntree, + bNodeSocket *next_sock, + const bNode *from_node, + const bNodeSocket *from_sock) +{ + bNodeSocket *iosock = ntreeInsertSocketInterface( + ntree, eNodeSocketInOut(from_sock->in_out), from_sock->idname, next_sock, from_sock->name); + if (iosock) { + if (iosock->typeinfo->interface_from_socket) { + iosock->typeinfo->interface_from_socket(ntree, iosock, from_node, from_sock); + } + } + return iosock; +} + +bNodeSocket *ntreeAddSocketInterfaceFromSocketWithName(bNodeTree *ntree, + const bNode *from_node, + const bNodeSocket *from_sock, + const char *idname, + const char *name) +{ + bNodeSocket *iosock = ntreeAddSocketInterface( + ntree, eNodeSocketInOut(from_sock->in_out), idname, DATA_(name)); + if (iosock == nullptr) { + return nullptr; + } + if (iosock->typeinfo->interface_from_socket) { + iosock->typeinfo->interface_from_socket(ntree, iosock, from_node, from_sock); + } + return iosock; +} + +bNodeSocket *ntreeAddSocketInterfaceFromSocket(bNodeTree *ntree, + const bNode *from_node, + const bNodeSocket *from_sock) +{ + return ntreeAddSocketInterfaceFromSocketWithName( + ntree, from_node, from_sock, from_sock->idname, from_sock->name); +} + +bNodeSocket *ntreeInsertSocketInterface(bNodeTree *ntree, + const eNodeSocketInOut in_out, + const char *idname, + bNodeSocket *next_sock, + const char *name) +{ + bNodeSocket *iosock = make_socket_interface(ntree, in_out, idname, name); + if (in_out == SOCK_IN) { + BLI_insertlinkbefore(&ntree->inputs, next_sock, iosock); + } + else if (in_out == SOCK_OUT) { + BLI_insertlinkbefore(&ntree->outputs, next_sock, iosock); + } + BKE_ntree_update_tag_interface(ntree); + return iosock; +} + +bNodeSocket *ntreeFindSocketInterface(bNodeTree *ntree, + const eNodeSocketInOut in_out, + const char *identifier) +{ + ListBase *sockets = (in_out == SOCK_IN) ? &ntree->inputs : &ntree->outputs; + LISTBASE_FOREACH (bNodeSocket *, iosock, sockets) { + if (STREQ(iosock->identifier, identifier)) { + return iosock; + } + } + return nullptr; +} + void nodeLinkSetMute(bNodeTree *ntree, bNodeLink *link, const bool muted) { const bool was_muted = link->is_muted(); @@ -2665,41 +3823,11 @@ void nodeLinkSetMute(bNodeTree *ntree, bNodeLink *link, const bool muted) } } -void nodeRemSocketLinks(bNodeTree *ntree, bNodeSocket *sock) -{ - LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) { - if (link->fromsock == sock || link->tosock == sock) { - nodeRemLink(ntree, link); - } - } -} - -bool nodeLinkIsHidden(const bNodeLink *link) -{ - return !(link->fromsock->is_visible() && link->tosock->is_visible()); -} - bool nodeLinkIsSelected(const bNodeLink *link) { return (link->fromnode->flag & NODE_SELECT) || (link->tonode->flag & NODE_SELECT); } -/* Adjust the indices of links connected to the given multi input socket after deleting the link at - * `deleted_index`. This function also works if the link has not yet been deleted. */ -static void adjust_multi_input_indices_after_removed_link(bNodeTree *ntree, - const bNodeSocket *sock, - const int deleted_index) -{ - LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { - /* We only need to adjust those with a greater index, because the others will have the same - * index. */ - if (link->tosock != sock || link->multi_input_socket_index <= deleted_index) { - continue; - } - link->multi_input_socket_index -= 1; - } -} - void nodeInternalRelink(bNodeTree *ntree, bNode *node) { /* store link pointers in output sockets, for efficient lookup */ @@ -2793,35 +3921,6 @@ void nodeFromView(const bNode *node, const float x, const float y, float *rx, fl *ry = -mapping_y + y; } -void nodeAttachNode(bNodeTree *ntree, bNode *node, bNode *parent) -{ - BLI_assert(parent->type == NODE_FRAME); - BLI_assert(!nodeIsParentAndChild(parent, node)); - - float locx, locy; - nodeToView(node, 0.0f, 0.0f, &locx, &locy); - - node->parent = parent; - BKE_ntree_update_tag_parent_change(ntree, node); - /* transform to parent space */ - nodeFromView(parent, locx, locy, &node->locx, &node->locy); -} - -void nodeDetachNode(bNodeTree *ntree, bNode *node) -{ - if (node->parent) { - BLI_assert(node->parent->type == NODE_FRAME); - - /* transform to view space */ - float locx, locy; - nodeToView(node, 0.0f, 0.0f, &locx, &locy); - node->locx = locx; - node->locy = locy; - node->parent = nullptr; - BKE_ntree_update_tag_parent_change(ntree, node); - } -} - void nodePositionRelative(bNode *from_node, const bNode *to_node, const bNodeSocket *from_sock, @@ -2875,839 +3974,139 @@ void nodePositionPropagate(bNode *node) } } -static bNodeTree *ntreeAddTree_do( - Main *bmain, ID *owner_id, const bool is_embedded, const char *name, const char *idname) +bNode *nodeFindRootParent(bNode *node) { - /* trees are created as local trees for compositor, material or texture nodes, - * node groups and other tree types are created as library data. - */ - int flag = 0; - if (is_embedded || bmain == nullptr) { - flag |= LIB_ID_CREATE_NO_MAIN; + bNode *parent_iter = node; + while (parent_iter->parent != nullptr) { + parent_iter = parent_iter->parent; } - bNodeTree *ntree = reinterpret_cast(BKE_libblock_alloc(bmain, ID_NT, name, flag)); - BKE_libblock_init_empty(&ntree->id); - if (is_embedded) { - BLI_assert(owner_id != nullptr); - ntree->id.flag |= LIB_EMBEDDED_DATA; - ntree->owner_id = owner_id; - bNodeTree **ntree_owner_ptr = BKE_ntree_ptr_from_id(owner_id); - BLI_assert(ntree_owner_ptr != nullptr); - *ntree_owner_ptr = ntree; + if (parent_iter->type != NODE_FRAME) { + return nullptr; } - else { - BLI_assert(owner_id == nullptr); - } - - STRNCPY(ntree->idname, idname); - ntree_set_typeinfo(ntree, ntreeTypeFind(idname)); - - return ntree; + return parent_iter; } -bNodeTree *ntreeAddTree(Main *bmain, const char *name, const char *idname) +static void iter_backwards_ex(const bNodeTree *ntree, + const bNode *node_start, + bool (*callback)(bNode *, bNode *, void *), + void *userdata, + const char recursion_mask) { - return ntreeAddTree_do(bmain, nullptr, false, name, idname); -} - -bNodeTree *ntreeAddTreeEmbedded(Main * /*bmain*/, - ID *owner_id, - const char *name, - const char *idname) -{ - return ntreeAddTree_do(nullptr, owner_id, true, name, idname); -} - -bNodeTree *ntreeCopyTree_ex(const bNodeTree *ntree, Main *bmain, const bool do_id_user) -{ - const int flag = do_id_user ? 0 : LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_MAIN; - - bNodeTree *ntree_copy = reinterpret_cast( - BKE_id_copy_ex(bmain, reinterpret_cast(ntree), nullptr, flag)); - return ntree_copy; -} -bNodeTree *ntreeCopyTree(Main *bmain, const bNodeTree *ntree) -{ - return ntreeCopyTree_ex(ntree, bmain, true); -} - -/* *************** Node Preview *********** */ - -/* XXX this should be removed eventually ... - * Currently BKE functions are modeled closely on previous code, - * using BKE_node_preview_init_tree to set up previews for a whole node tree in advance. - * This should be left more to the individual node tree implementations. */ - -bool BKE_node_preview_used(const bNode *node) -{ - /* XXX check for closed nodes? */ - return (node->typeinfo->flag & NODE_PREVIEW) != 0; -} - -bNodePreview *BKE_node_preview_verify(bNodeInstanceHash *previews, - bNodeInstanceKey key, - const int xsize, - const int ysize, - const bool create) -{ - bNodePreview *preview = static_cast( - BKE_node_instance_hash_lookup(previews, key)); - if (!preview) { - if (create) { - preview = MEM_cnew("node preview"); - BKE_node_instance_hash_insert(previews, key, preview); + LISTBASE_FOREACH (bNodeSocket *, sock, &node_start->inputs) { + bNodeLink *link = sock->link; + if (link == nullptr) { + continue; } - else { - return nullptr; + if ((link->flag & NODE_LINK_VALID) == 0) { + /* Skip links marked as cyclic. */ + continue; } - } - - /* node previews can get added with variable size this way */ - if (xsize == 0 || ysize == 0) { - return preview; - } - - /* sanity checks & initialize */ - if (preview->rect) { - if (preview->xsize != xsize || preview->ysize != ysize) { - MEM_freeN(preview->rect); - preview->rect = nullptr; - } - } - - if (preview->rect == nullptr) { - preview->rect = reinterpret_cast( - MEM_callocN(4 * xsize + xsize * ysize * sizeof(char[4]), "node preview rect")); - preview->xsize = xsize; - preview->ysize = ysize; - } - /* no clear, makes nicer previews */ - - return preview; -} - -bNodePreview *BKE_node_preview_copy(bNodePreview *preview) -{ - bNodePreview *new_preview = static_cast(MEM_dupallocN(preview)); - if (preview->rect) { - new_preview->rect = static_cast(MEM_dupallocN(preview->rect)); - } - return new_preview; -} - -void BKE_node_preview_free(bNodePreview *preview) -{ - if (preview->rect) { - MEM_freeN(preview->rect); - } - MEM_freeN(preview); -} - -static void node_preview_init_tree_recursive(bNodeInstanceHash *previews, - bNodeTree *ntree, - bNodeInstanceKey parent_key, - const int xsize, - const int ysize) -{ - for (bNode *node : ntree->all_nodes()) { - bNodeInstanceKey key = BKE_node_instance_key(parent_key, ntree, node); - - if (BKE_node_preview_used(node)) { - node->runtime->preview_xsize = xsize; - node->runtime->preview_ysize = ysize; - - BKE_node_preview_verify(previews, key, xsize, ysize, false); + if (link->fromnode->runtime->iter_flag & recursion_mask) { + continue; } - bNodeTree *group = reinterpret_cast(node->id); - if (node->is_group() && group != nullptr) { - node_preview_init_tree_recursive(previews, group, key, xsize, ysize); + link->fromnode->runtime->iter_flag |= recursion_mask; + + if (!callback(link->fromnode, link->tonode, userdata)) { + return; } + iter_backwards_ex(ntree, link->fromnode, callback, userdata, recursion_mask); } } -void BKE_node_preview_init_tree(bNodeTree *ntree, int xsize, int ysize) +void nodeChainIter(const bNodeTree *ntree, + const bNode *node_start, + bool (*callback)(bNode *, bNode *, void *, const bool), + void *userdata, + const bool reversed) { - if (!ntree) { - return; - } - - if (!ntree->previews) { - ntree->previews = BKE_node_instance_hash_new("node previews"); - } - - node_preview_init_tree_recursive(ntree->previews, ntree, NODE_INSTANCE_KEY_BASE, xsize, ysize); -} - -static void node_preview_tag_used_recursive(bNodeInstanceHash *previews, - bNodeTree *ntree, - bNodeInstanceKey parent_key) -{ - for (bNode *node : ntree->all_nodes()) { - bNodeInstanceKey key = BKE_node_instance_key(parent_key, ntree, node); - - if (BKE_node_preview_used(node)) { - BKE_node_instance_hash_tag_key(previews, key); + LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { + if ((link->flag & NODE_LINK_VALID) == 0) { + /* Skip links marked as cyclic. */ + continue; } - - bNodeTree *group = reinterpret_cast(node->id); - if (node->is_group() && group != nullptr) { - node_preview_tag_used_recursive(previews, group, key); - } - } -} - -void BKE_node_preview_remove_unused(bNodeTree *ntree) -{ - if (!ntree || !ntree->previews) { - return; - } - - /* use the instance hash functions for tagging and removing unused previews */ - BKE_node_instance_hash_clear_tags(ntree->previews); - node_preview_tag_used_recursive(ntree->previews, ntree, NODE_INSTANCE_KEY_BASE); - - BKE_node_instance_hash_remove_untagged( - ntree->previews, reinterpret_cast(BKE_node_preview_free)); -} - -void BKE_node_preview_clear(bNodePreview *preview) -{ - if (preview && preview->rect) { - memset(preview->rect, 0, MEM_allocN_len(preview->rect)); - } -} - -void BKE_node_preview_clear_tree(bNodeTree *ntree) -{ - if (!ntree || !ntree->previews) { - return; - } - - bNodeInstanceHashIterator iter; - NODE_INSTANCE_HASH_ITER (iter, ntree->previews) { - bNodePreview *preview = static_cast( - BKE_node_instance_hash_iterator_get_value(&iter)); - BKE_node_preview_clear(preview); - } -} - -void BKE_node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, bool remove_old) -{ - if (remove_old || !to_ntree->previews) { - /* free old previews */ - if (to_ntree->previews) { - BKE_node_instance_hash_free(to_ntree->previews, - reinterpret_cast(BKE_node_preview_free)); - } - - /* transfer previews */ - to_ntree->previews = from_ntree->previews; - from_ntree->previews = nullptr; - - /* clean up, in case any to_ntree nodes have been removed */ - BKE_node_preview_remove_unused(to_ntree); - } - else { - if (from_ntree->previews) { - bNodeInstanceHashIterator iter; - NODE_INSTANCE_HASH_ITER (iter, from_ntree->previews) { - bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter); - bNodePreview *preview = static_cast( - BKE_node_instance_hash_iterator_get_value(&iter)); - - /* replace existing previews */ - BKE_node_instance_hash_remove( - to_ntree->previews, - key, - reinterpret_cast(BKE_node_preview_free)); - BKE_node_instance_hash_insert(to_ntree->previews, key, preview); - } - - /* NOTE: null free function here, - * because pointers have already been moved over to to_ntree->previews! */ - BKE_node_instance_hash_free(from_ntree->previews, nullptr); - from_ntree->previews = nullptr; - } - } -} - -void nodeUnlinkNode(bNodeTree *ntree, bNode *node) -{ - LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) { - ListBase *lb = nullptr; - if (link->fromnode == node) { - lb = &node->outputs; - } - else if (link->tonode == node) { - lb = &node->inputs; - } - - if (lb) { - /* Only bother adjusting if the socket is not on the node we're deleting. */ - if (link->tonode != node && link->tosock->is_multi_input()) { - adjust_multi_input_indices_after_removed_link( - ntree, link->tosock, link->multi_input_socket_index); - } - LISTBASE_FOREACH (const bNodeSocket *, sock, lb) { - if (link->fromsock == sock || link->tosock == sock) { - nodeRemLink(ntree, link); - break; - } - } - } - } -} - -static void node_unlink_attached(bNodeTree *ntree, const bNode *parent) -{ - for (bNode *node : ntree->all_nodes()) { - if (node->parent == parent) { - nodeDetachNode(ntree, node); - } - } -} - -void nodeRebuildIDVector(bNodeTree *node_tree) -{ - /* Rebuild nodes #VectorSet which must have the same order as the list. */ - node_tree->runtime->nodes_by_id.clear(); - int i; - LISTBASE_FOREACH_INDEX (bNode *, node, &node_tree->nodes, i) { - node_tree->runtime->nodes_by_id.add_new(node); - node->runtime->index_in_tree = i; - } -} - -namespace blender::bke { - -void node_free_node(bNodeTree *ntree, bNode *node) -{ - /* since it is called while free database, node->id is undefined */ - - /* can be called for nodes outside a node tree (e.g. clipboard) */ - if (ntree) { - BLI_remlink(&ntree->nodes, node); - /* Rebuild nodes #VectorSet which must have the same order as the list. */ - nodeRebuildIDVector(ntree); - - /* texture node has bad habit of keeping exec data around */ - if (ntree->type == NTREE_TEXTURE && ntree->runtime->execdata) { - ntreeTexEndExecTree(ntree->runtime->execdata); - ntree->runtime->execdata = nullptr; - } - } - - if (node->typeinfo->freefunc) { - node->typeinfo->freefunc(node); - } - - LISTBASE_FOREACH_MUTABLE (bNodeSocket *, sock, &node->inputs) { - /* Remember, no ID user refcount management here! */ - node_socket_free(sock, false); - MEM_freeN(sock); - } - LISTBASE_FOREACH_MUTABLE (bNodeSocket *, sock, &node->outputs) { - /* Remember, no ID user refcount management here! */ - node_socket_free(sock, false); - MEM_freeN(sock); - } - - if (node->prop) { - /* Remember, no ID user refcount management here! */ - IDP_FreePropertyContent_ex(node->prop, false); - MEM_freeN(node->prop); - } - - if (node->typeinfo->declare_dynamic) { - delete node->runtime->declaration; - } - - MEM_delete(node->runtime); - MEM_freeN(node); - - if (ntree) { - BKE_ntree_update_tag_node_removed(ntree); - } -} - -} // namespace blender::bke - -void ntreeFreeLocalNode(bNodeTree *ntree, bNode *node) -{ - /* For removing nodes while editing localized node trees. */ - BLI_assert((ntree->id.tag & LIB_TAG_LOCALIZED) != 0); - - /* These two lines assume the caller might want to free a single node and maintain - * a valid state in the node tree. */ - nodeUnlinkNode(ntree, node); - node_unlink_attached(ntree, node); - - blender::bke::node_free_node(ntree, node); - nodeRebuildIDVector(ntree); -} - -void nodeRemoveNode(Main *bmain, bNodeTree *ntree, bNode *node, const bool do_id_user) -{ - BLI_assert(ntree != nullptr); - /* This function is not for localized node trees, we do not want - * do to ID user reference-counting and removal of animdation data then. */ - BLI_assert((ntree->id.tag & LIB_TAG_LOCALIZED) == 0); - - bool node_has_id = false; - - if (do_id_user) { - /* Free callback for NodeCustomGroup. */ - if (node->typeinfo->freefunc_api) { - PointerRNA ptr; - RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); - - node->typeinfo->freefunc_api(&ptr); - } - - /* Do user counting. */ - if (node->id) { - id_us_min(node->id); - node_has_id = true; - } - - LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { - node_has_id |= socket_id_user_decrement(sock); - } - LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) { - node_has_id |= socket_id_user_decrement(sock); - } - } - - /* Remove animation data. */ - char propname_esc[MAX_IDPROP_NAME * 2]; - char prefix[MAX_IDPROP_NAME * 2]; - - BLI_str_escape(propname_esc, node->name, sizeof(propname_esc)); - SNPRINTF(prefix, "nodes[\"%s\"]", propname_esc); - - if (BKE_animdata_fix_paths_remove(&ntree->id, prefix)) { - if (bmain != nullptr) { - DEG_relations_tag_update(bmain); - } - } - - /* Also update relations for the scene time node, which causes a dependency - * on time that users expect to be removed when the node is removed. */ - if (node_has_id || - ELEM(node->type, GEO_NODE_INPUT_SCENE_TIME, GEO_NODE_SELF_OBJECT, GEO_NODE_SIMULATION_INPUT)) - { - if (bmain != nullptr) { - DEG_relations_tag_update(bmain); - } - } - - nodeUnlinkNode(ntree, node); - node_unlink_attached(ntree, node); - - /* Free node itself. */ - blender::bke::node_free_node(ntree, node); - nodeRebuildIDVector(ntree); -} - -static void node_socket_interface_free(bNodeTree * /*ntree*/, - bNodeSocket *sock, - const bool do_id_user) -{ - if (sock->prop) { - IDP_FreeProperty_ex(sock->prop, do_id_user); - } - - if (sock->default_value) { - if (do_id_user) { - socket_id_user_decrement(sock); - } - MEM_freeN(sock->default_value); - } - if (sock->default_attribute_name) { - MEM_freeN(sock->default_attribute_name); - } - MEM_delete(sock->runtime); -} - -static void free_localized_node_groups(bNodeTree *ntree) -{ - /* Only localized node trees store a copy for each node group tree. - * Each node group tree in a localized node tree can be freed, - * since it is a localized copy itself (no risk of accessing free'd - * data in main, see #37939). */ - if (!(ntree->id.tag & LIB_TAG_LOCALIZED)) { - return; - } - - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { - bNodeTree *ngroup = reinterpret_cast(node->id); - if (node->is_group() && ngroup != nullptr) { - ntreeFreeTree(ngroup); - MEM_freeN(ngroup); - } - } -} - -void ntreeFreeTree(bNodeTree *ntree) -{ - ntree_free_data(&ntree->id); - BKE_animdata_free(&ntree->id, false); -} - -void ntreeFreeEmbeddedTree(bNodeTree *ntree) -{ - ntreeFreeTree(ntree); - BKE_libblock_free_data(&ntree->id, true); - BKE_libblock_free_data_py(&ntree->id); -} - -void ntreeFreeLocalTree(bNodeTree *ntree) -{ - if (ntree->id.tag & LIB_TAG_LOCALIZED) { - ntreeFreeTree(ntree); - } - else { - ntreeFreeTree(ntree); - BKE_libblock_free_data(&ntree->id, true); - } -} - -void ntreeSetOutput(bNodeTree *ntree) -{ - const bool is_compositor = ntree->type == NTREE_COMPOSIT; - /* find the active outputs, might become tree type dependent handler */ - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { - if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) { - /* we need a check for which output node should be tagged like this, below an exception */ - if (ELEM(node->type, CMP_NODE_OUTPUT_FILE, GEO_NODE_VIEWER)) { + /* Is the link part of the chain meaning node_start == fromnode + * (or tonode for reversed case)? */ + if (!reversed) { + if (link->fromnode != node_start) { continue; } - const bool node_is_output = ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER); - - int output = 0; - /* there is more types having output class, each one is checked */ - - LISTBASE_FOREACH (bNode *, tnode, &ntree->nodes) { - if (tnode->typeinfo->nclass != NODE_CLASS_OUTPUT) { - continue; - } - - /* same type, exception for viewer */ - const bool tnode_is_output = ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER); - const bool compositor_case = is_compositor && tnode_is_output && node_is_output; - if (tnode->type == node->type || compositor_case) { - if (tnode->flag & NODE_DO_OUTPUT) { - output++; - if (output > 1) { - tnode->flag &= ~NODE_DO_OUTPUT; - } - } - } - } - - if (output == 0) { - node->flag |= NODE_DO_OUTPUT; - } - } - - /* group node outputs use this flag too */ - if (node->type == NODE_GROUP_OUTPUT) { - int output = 0; - LISTBASE_FOREACH (bNode *, tnode, &ntree->nodes) { - if (tnode->type != NODE_GROUP_OUTPUT) { - continue; - } - if (tnode->flag & NODE_DO_OUTPUT) { - output++; - if (output > 1) { - tnode->flag &= ~NODE_DO_OUTPUT; - } - } - } - if (output == 0) { - node->flag |= NODE_DO_OUTPUT; - } - } - } - - /* here we could recursively set which nodes have to be done, - * might be different for editor or for "real" use... */ -} - -bNodeTree **BKE_ntree_ptr_from_id(ID *id) -{ - switch (GS(id->name)) { - case ID_MA: - return &reinterpret_cast(id)->nodetree; - case ID_LA: - return &reinterpret_cast(id)->nodetree; - case ID_WO: - return &reinterpret_cast(id)->nodetree; - case ID_TE: - return &reinterpret_cast(id)->nodetree; - case ID_SCE: - return &reinterpret_cast(id)->nodetree; - case ID_LS: - return &reinterpret_cast(id)->nodetree; - case ID_SIM: - return &reinterpret_cast(id)->nodetree; - default: - return nullptr; - } -} - -bNodeTree *ntreeFromID(ID *id) -{ - bNodeTree **nodetree = BKE_ntree_ptr_from_id(id); - return (nodetree != nullptr) ? *nodetree : nullptr; -} - -void ntreeNodeFlagSet(const bNodeTree *ntree, const int flag, const bool enable) -{ - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { - if (enable) { - node->flag |= flag; } else { - node->flag &= ~flag; - } - } -} - -bNodeTree *ntreeLocalize(bNodeTree *ntree) -{ - if (ntree == nullptr) { - return nullptr; - } - - /* Make full copy outside of Main database. - * NOTE: previews are not copied here. */ - bNodeTree *ltree = reinterpret_cast(BKE_id_copy_ex( - nullptr, &ntree->id, nullptr, (LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA))); - - ltree->id.tag |= LIB_TAG_LOCALIZED; - - LISTBASE_FOREACH (bNode *, node, <ree->nodes) { - bNodeTree *group = reinterpret_cast(node->id); - if (node->is_group() && group != nullptr) { - node->id = reinterpret_cast(ntreeLocalize(group)); - } - } - - /* Ensures only a single output node is enabled. */ - ntreeSetOutput(ntree); - - bNode *node_src = reinterpret_cast(ntree->nodes.first); - bNode *node_local = reinterpret_cast(ltree->nodes.first); - while (node_src != nullptr) { - node_local->runtime->original = node_src; - node_src = node_src->next; - node_local = node_local->next; - } - - if (ntree->typeinfo->localize) { - ntree->typeinfo->localize(ltree, ntree); - } - - return ltree; -} - -void ntreeLocalMerge(Main *bmain, bNodeTree *localtree, bNodeTree *ntree) -{ - if (ntree && localtree) { - if (ntree->typeinfo->local_merge) { - ntree->typeinfo->local_merge(bmain, localtree, ntree); - } - - ntreeFreeTree(localtree); - MEM_freeN(localtree); - } -} - -/* ************ NODE TREE INTERFACE *************** */ - -static bNodeSocket *make_socket_interface(bNodeTree *ntree, - const eNodeSocketInOut in_out, - const char *idname, - const char *name) -{ - bNodeSocketType *stype = nodeSocketTypeFind(idname); - if (stype == nullptr) { - return nullptr; - } - - bNodeSocket *sock = MEM_cnew("socket template"); - sock->runtime = MEM_new(__func__); - STRNCPY(sock->idname, stype->idname); - sock->in_out = int(in_out); - sock->type = int(SOCK_CUSTOM); /* int type undefined by default */ - node_socket_set_typeinfo(ntree, sock, stype); - - /* assign new unique index */ - const int own_index = ntree->cur_index++; - /* use the own_index as socket identifier */ - if (in_out == SOCK_IN) { - SNPRINTF(sock->identifier, "Input_%d", own_index); - } - else { - SNPRINTF(sock->identifier, "Output_%d", own_index); - } - - sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF); - - STRNCPY(sock->name, name); - sock->storage = nullptr; - sock->flag |= SOCK_COLLAPSED; - - return sock; -} - -bNodeSocket *ntreeFindSocketInterface(bNodeTree *ntree, - const eNodeSocketInOut in_out, - const char *identifier) -{ - ListBase *sockets = (in_out == SOCK_IN) ? &ntree->inputs : &ntree->outputs; - LISTBASE_FOREACH (bNodeSocket *, iosock, sockets) { - if (STREQ(iosock->identifier, identifier)) { - return iosock; - } - } - return nullptr; -} - -bNodeSocket *ntreeAddSocketInterface(bNodeTree *ntree, - const eNodeSocketInOut in_out, - const char *idname, - const char *name) -{ - bNodeSocket *iosock = make_socket_interface(ntree, in_out, idname, name); - if (in_out == SOCK_IN) { - BLI_addtail(&ntree->inputs, iosock); - } - else if (in_out == SOCK_OUT) { - BLI_addtail(&ntree->outputs, iosock); - } - BKE_ntree_update_tag_interface(ntree); - return iosock; -} - -bNodeSocket *ntreeInsertSocketInterface(bNodeTree *ntree, - const eNodeSocketInOut in_out, - const char *idname, - bNodeSocket *next_sock, - const char *name) -{ - bNodeSocket *iosock = make_socket_interface(ntree, in_out, idname, name); - if (in_out == SOCK_IN) { - BLI_insertlinkbefore(&ntree->inputs, next_sock, iosock); - } - else if (in_out == SOCK_OUT) { - BLI_insertlinkbefore(&ntree->outputs, next_sock, iosock); - } - BKE_ntree_update_tag_interface(ntree); - return iosock; -} - -bNodeSocket *ntreeAddSocketInterfaceFromSocket(bNodeTree *ntree, - const bNode *from_node, - const bNodeSocket *from_sock) -{ - return ntreeAddSocketInterfaceFromSocketWithName( - ntree, from_node, from_sock, from_sock->idname, from_sock->name); -} - -bNodeSocket *ntreeAddSocketInterfaceFromSocketWithName(bNodeTree *ntree, - const bNode *from_node, - const bNodeSocket *from_sock, - const char *idname, - const char *name) -{ - bNodeSocket *iosock = ntreeAddSocketInterface( - ntree, eNodeSocketInOut(from_sock->in_out), idname, DATA_(name)); - if (iosock == nullptr) { - return nullptr; - } - if (iosock->typeinfo->interface_from_socket) { - iosock->typeinfo->interface_from_socket(ntree, iosock, from_node, from_sock); - } - return iosock; -} - -bNodeSocket *ntreeInsertSocketInterfaceFromSocket(bNodeTree *ntree, - bNodeSocket *next_sock, - const bNode *from_node, - const bNodeSocket *from_sock) -{ - bNodeSocket *iosock = ntreeInsertSocketInterface( - ntree, eNodeSocketInOut(from_sock->in_out), from_sock->idname, next_sock, from_sock->name); - if (iosock) { - if (iosock->typeinfo->interface_from_socket) { - iosock->typeinfo->interface_from_socket(ntree, iosock, from_node, from_sock); - } - } - return iosock; -} - -void ntreeRemoveSocketInterface(bNodeTree *ntree, bNodeSocket *sock) -{ - /* this is fast, this way we don't need an in_out argument */ - BLI_remlink(&ntree->inputs, sock); - BLI_remlink(&ntree->outputs, sock); - - node_socket_interface_free(ntree, sock, true); - MEM_freeN(sock); - - BKE_ntree_update_tag_interface(ntree); -} - -/* ************ find stuff *************** */ - -bNode *ntreeFindType(bNodeTree *ntree, const int type) -{ - if (ntree) { - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { - if (node->type == type) { - return node; + if (link->tonode != node_start) { + continue; } } + + if (!callback(link->fromnode, link->tonode, userdata, reversed)) { + return; + } + nodeChainIter(ntree, reversed ? link->fromnode : link->tonode, callback, userdata, reversed); } - return nullptr; } -static bool ntree_contains_tree_exec(const bNodeTree *tree_to_search_in, - const bNodeTree *tree_to_search_for, - Set &already_passed) +void nodeChainIterBackwards(const bNodeTree *ntree, + const bNode *node_start, + bool (*callback)(bNode *, bNode *, void *), + void *userdata, + const int recursion_lvl) { - if (tree_to_search_in == tree_to_search_for) { - return true; + if (!node_start) { + return; } - tree_to_search_in->ensure_topology_cache(); - for (const bNode *node_group : tree_to_search_in->group_nodes()) { - const bNodeTree *sub_tree_search_in = reinterpret_cast(node_group->id); - if (!sub_tree_search_in) { - continue; + /* Limited by iter_flag type. */ + BLI_assert(recursion_lvl < 8); + const char recursion_mask = (1 << recursion_lvl); + + /* Reset flag. */ + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + node->runtime->iter_flag &= ~recursion_mask; + } + + iter_backwards_ex(ntree, node_start, callback, userdata, recursion_mask); +} + +void nodeParentsIter(bNode *node, bool (*callback)(bNode *, void *), void *userdata) +{ + if (node->parent) { + if (!callback(node->parent, userdata)) { + return; } - if (!already_passed.add(sub_tree_search_in)) { - continue; - } - if (ntree_contains_tree_exec(sub_tree_search_in, tree_to_search_for, already_passed)) { + nodeParentsIter(node->parent, callback, userdata); + } +} + +bool nodeIsDanglingReroute(const bNodeTree *ntree, const bNode *node) +{ + ntree->ensure_topology_cache(); + BLI_assert(node_tree_runtime::topology_cache_is_available(*ntree)); + BLI_assert(!ntree->has_available_link_cycle()); + + const bNode *iter_node = node; + if (!iter_node->is_reroute()) { + return false; + } + + while (true) { + const blender::Span links = + iter_node->input_socket(0).directly_linked_links(); + BLI_assert(links.size() <= 1); + if (links.is_empty()) { return true; } + const bNodeLink &link = *links[0]; + if (!link.is_available()) { + return false; + } + if (link.is_muted()) { + return false; + } + iter_node = link.fromnode; + if (!iter_node->is_reroute()) { + return false; + } } - - return false; -} - -bool ntreeContainsTree(const bNodeTree *tree_to_search_in, const bNodeTree *tree_to_search_for) -{ - if (tree_to_search_in == tree_to_search_for) { - return true; - } - - Set already_passed; - return ntree_contains_tree_exec(tree_to_search_in, tree_to_search_for, already_passed); } bNodeLink *nodeFindLink(bNodeTree *ntree, const bNodeSocket *from, const bNodeSocket *to) @@ -3723,103 +4122,6 @@ bNodeLink *nodeFindLink(bNodeTree *ntree, const bNodeSocket *from, const bNodeSo return nullptr; } -int nodeCountSocketLinks(const bNodeTree *ntree, const bNodeSocket *sock) -{ - int tot = 0; - LISTBASE_FOREACH (const bNodeLink *, link, &ntree->links) { - if (link->fromsock == sock || link->tosock == sock) { - tot++; - } - } - return tot; -} - -bNode *nodeGetActive(bNodeTree *ntree) -{ - if (ntree == nullptr) { - return nullptr; - } - - for (bNode *node : ntree->all_nodes()) { - if (node->flag & NODE_ACTIVE) { - return node; - } - } - return nullptr; -} - -void nodeSetSelected(bNode *node, const bool select) -{ - if (select) { - node->flag |= NODE_SELECT; - return; - } - node->flag &= ~NODE_SELECT; - /* deselect sockets too */ - LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { - sock->flag &= ~NODE_SELECT; - } - LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) { - sock->flag &= ~NODE_SELECT; - } -} - -void nodeClearActive(bNodeTree *ntree) -{ - if (ntree == nullptr) { - return; - } - - for (bNode *node : ntree->all_nodes()) { - node->flag &= ~NODE_ACTIVE; - } -} - -void nodeSetActive(bNodeTree *ntree, bNode *node) -{ - const bool is_paint_canvas = nodeSupportsActiveFlag(node, NODE_ACTIVE_PAINT_CANVAS); - const bool is_texture_class = nodeSupportsActiveFlag(node, NODE_ACTIVE_TEXTURE); - int flags_to_set = NODE_ACTIVE; - SET_FLAG_FROM_TEST(flags_to_set, is_paint_canvas, NODE_ACTIVE_PAINT_CANVAS); - SET_FLAG_FROM_TEST(flags_to_set, is_texture_class, NODE_ACTIVE_TEXTURE); - - /* Make sure only one node is active per node tree. */ - for (bNode *tnode : ntree->all_nodes()) { - tnode->flag &= ~flags_to_set; - } - node->flag |= flags_to_set; -} - -void nodeSetSocketAvailability(bNodeTree *ntree, bNodeSocket *sock, const bool is_available) -{ - if (is_available == sock->is_available()) { - return; - } - if (is_available) { - sock->flag &= ~SOCK_UNAVAIL; - } - else { - sock->flag |= SOCK_UNAVAIL; - } - BKE_ntree_update_tag_socket_availability(ntree, sock); -} - -int nodeSocketLinkLimit(const bNodeSocket *sock) -{ - if (sock->is_multi_input()) { - return 4095; - } - if (sock->typeinfo == nullptr) { - return sock->limit; - } - const bNodeSocketType &stype = *sock->typeinfo; - if (!stype.use_link_limits_of_type) { - return sock->limit; - } - return eNodeSocketInOut(sock->in_out) == SOCK_IN ? stype.input_link_limit : - stype.output_link_limit; -} - static void update_socket_declarations(ListBase *sockets, Span declarations) { @@ -3878,220 +4180,98 @@ bool nodeDeclarationEnsure(bNodeTree *ntree, bNode *node) return false; } -void nodeDimensionsGet(const bNode *node, float *r_width, float *r_height) +void nodeSetSocketAvailability(bNodeTree *ntree, bNodeSocket *sock, const bool is_available) { - *r_width = node->runtime->totr.xmax - node->runtime->totr.xmin; - *r_height = node->runtime->totr.ymax - node->runtime->totr.ymin; -} - -void nodeTagUpdateID(bNode *node) -{ - node->runtime->update |= NODE_UPDATE_ID; -} - -void nodeInternalLinks(bNode *node, bNodeLink **r_links, int *r_len) -{ - *r_links = node->runtime->internal_links.data(); - *r_len = node->runtime->internal_links.size(); -} - -/* Node Instance Hash */ - -const bNodeInstanceKey NODE_INSTANCE_KEY_BASE = {5381}; -const bNodeInstanceKey NODE_INSTANCE_KEY_NONE = {0}; - -/* Generate a hash key from ntree and node names - * Uses the djb2 algorithm with xor by Bernstein: - * http://www.cse.yorku.ca/~oz/hash.html - */ -static bNodeInstanceKey node_hash_int_str(bNodeInstanceKey hash, const char *str) -{ - char c; - - while ((c = *str++)) { - hash.value = ((hash.value << 5) + hash.value) ^ c; /* (hash * 33) ^ c */ + if (is_available == sock->is_available()) { + return; } - - /* separator '\0' character, to avoid ambiguity from concatenated strings */ - hash.value = (hash.value << 5) + hash.value; /* hash * 33 */ - - return hash; -} - -bNodeInstanceKey BKE_node_instance_key(bNodeInstanceKey parent_key, - const bNodeTree *ntree, - const bNode *node) -{ - bNodeInstanceKey key = node_hash_int_str(parent_key, ntree->id.name + 2); - - if (node) { - key = node_hash_int_str(key, node->name); + if (is_available) { + sock->flag &= ~SOCK_UNAVAIL; } - - return key; -} - -static uint node_instance_hash_key(const void *key) -{ - return static_cast(key)->value; -} - -static bool node_instance_hash_key_cmp(const void *a, const void *b) -{ - uint value_a = static_cast(a)->value; - uint value_b = static_cast(b)->value; - - return (value_a != value_b); -} - -bNodeInstanceHash *BKE_node_instance_hash_new(const char *info) -{ - bNodeInstanceHash *hash = static_cast( - MEM_mallocN(sizeof(bNodeInstanceHash), info)); - hash->ghash = BLI_ghash_new( - node_instance_hash_key, node_instance_hash_key_cmp, "node instance hash ghash"); - return hash; -} - -void BKE_node_instance_hash_free(bNodeInstanceHash *hash, bNodeInstanceValueFP valfreefp) -{ - BLI_ghash_free(hash->ghash, nullptr, reinterpret_cast(valfreefp)); - MEM_freeN(hash); -} - -void BKE_node_instance_hash_insert(bNodeInstanceHash *hash, bNodeInstanceKey key, void *value) -{ - bNodeInstanceHashEntry *entry = static_cast(value); - entry->key = key; - entry->tag = 0; - BLI_ghash_insert(hash->ghash, &entry->key, value); -} - -void *BKE_node_instance_hash_lookup(bNodeInstanceHash *hash, bNodeInstanceKey key) -{ - return BLI_ghash_lookup(hash->ghash, &key); -} - -int BKE_node_instance_hash_remove(bNodeInstanceHash *hash, - bNodeInstanceKey key, - bNodeInstanceValueFP valfreefp) -{ - return BLI_ghash_remove(hash->ghash, &key, nullptr, reinterpret_cast(valfreefp)); -} - -void BKE_node_instance_hash_clear(bNodeInstanceHash *hash, bNodeInstanceValueFP valfreefp) -{ - BLI_ghash_clear(hash->ghash, nullptr, reinterpret_cast(valfreefp)); -} - -void *BKE_node_instance_hash_pop(bNodeInstanceHash *hash, bNodeInstanceKey key) -{ - return BLI_ghash_popkey(hash->ghash, &key, nullptr); -} - -int BKE_node_instance_hash_haskey(bNodeInstanceHash *hash, bNodeInstanceKey key) -{ - return BLI_ghash_haskey(hash->ghash, &key); -} - -int BKE_node_instance_hash_size(bNodeInstanceHash *hash) -{ - return BLI_ghash_len(hash->ghash); -} - -void BKE_node_instance_hash_clear_tags(bNodeInstanceHash *hash) -{ - bNodeInstanceHashIterator iter; - - NODE_INSTANCE_HASH_ITER (iter, hash) { - bNodeInstanceHashEntry *value = static_cast( - BKE_node_instance_hash_iterator_get_value(&iter)); - - value->tag = 0; + else { + sock->flag |= SOCK_UNAVAIL; } + BKE_ntree_update_tag_socket_availability(ntree, sock); } -void BKE_node_instance_hash_tag(bNodeInstanceHash * /*hash*/, void *value) +void node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, bool remove_old) { - bNodeInstanceHashEntry *entry = static_cast(value); - entry->tag = 1; -} + if (remove_old || !to_ntree->previews) { + /* free old previews */ + if (to_ntree->previews) { + BKE_node_instance_hash_free(to_ntree->previews, + reinterpret_cast(node_preview_free)); + } -bool BKE_node_instance_hash_tag_key(bNodeInstanceHash *hash, bNodeInstanceKey key) -{ - bNodeInstanceHashEntry *entry = static_cast( - BKE_node_instance_hash_lookup(hash, key)); + /* transfer previews */ + to_ntree->previews = from_ntree->previews; + from_ntree->previews = nullptr; - if (entry) { - entry->tag = 1; - return true; + /* clean up, in case any to_ntree nodes have been removed */ + node_preview_remove_unused(to_ntree); } + else { + if (from_ntree->previews) { + bNodeInstanceHashIterator iter; + NODE_INSTANCE_HASH_ITER (iter, from_ntree->previews) { + bNodeInstanceKey key = node_instance_hash_iterator_get_key(&iter); + bNodePreview *preview = static_cast( + node_instance_hash_iterator_get_value(&iter)); - return false; -} + /* replace existing previews */ + BKE_node_instance_hash_remove( + to_ntree->previews, key, reinterpret_cast(node_preview_free)); + BKE_node_instance_hash_insert(to_ntree->previews, key, preview); + } -void BKE_node_instance_hash_remove_untagged(bNodeInstanceHash *hash, - bNodeInstanceValueFP valfreefp) -{ - /* NOTE: Hash must not be mutated during iterating! - * Store tagged entries in a separate list and remove items afterward. - */ - bNodeInstanceKey *untagged = static_cast( - MEM_mallocN(sizeof(bNodeInstanceKey) * BKE_node_instance_hash_size(hash), - "temporary node instance key list")); - bNodeInstanceHashIterator iter; - int num_untagged = 0; - NODE_INSTANCE_HASH_ITER (iter, hash) { - bNodeInstanceHashEntry *value = static_cast( - BKE_node_instance_hash_iterator_get_value(&iter)); - - if (!value->tag) { - untagged[num_untagged++] = BKE_node_instance_hash_iterator_get_key(&iter); + /* NOTE: null free function here, + * because pointers have already been moved over to to_ntree->previews! */ + BKE_node_instance_hash_free(from_ntree->previews, nullptr); + from_ntree->previews = nullptr; } } - - for (int i = 0; i < num_untagged; i++) { - BKE_node_instance_hash_remove(hash, untagged[i], valfreefp); - } - - MEM_freeN(untagged); } -void ntreeUpdateAllNew(Main *main) +void node_preview_clear(bNodePreview *preview) { - /* Update all new node trees on file read or append, to add/remove sockets - * in groups nodes if the group changed, and handle any update flags that - * might have been set in file reading or versioning. */ - FOREACH_NODETREE_BEGIN (main, ntree, owner_id) { - if (owner_id->tag & LIB_TAG_NEW) { - BKE_ntree_update_tag_all(ntree); - } + if (preview && preview->rect) { + memset(preview->rect, 0, MEM_allocN_len(preview->rect)); } - FOREACH_NODETREE_END; - BKE_ntree_update_main(main, nullptr); } -void ntreeUpdateAllUsers(Main *main, ID *id) +void node_preview_remove_unused(bNodeTree *ntree) { - if (id == nullptr) { + if (!ntree || !ntree->previews) { return; } - bool need_update = false; + /* use the instance hash functions for tagging and removing unused previews */ + BKE_node_instance_hash_clear_tags(ntree->previews); + node_preview_tag_used_recursive(ntree->previews, ntree, NODE_INSTANCE_KEY_BASE); - /* Update all users of ngroup, to add/remove sockets as needed. */ - FOREACH_NODETREE_BEGIN (main, ntree, owner_id) { - for (bNode *node : ntree->all_nodes()) { - if (node->id == id) { - BKE_ntree_update_tag_node_property(ntree, node); - need_update = true; - } - } + BKE_node_instance_hash_remove_untagged( + ntree->previews, reinterpret_cast(node_preview_free)); +} + +void node_preview_init_tree(bNodeTree *ntree, int xsize, int ysize) +{ + if (!ntree) { + return; } - FOREACH_NODETREE_END; - if (need_update) { - BKE_ntree_update_main(main, nullptr); + + if (!ntree->previews) { + ntree->previews = BKE_node_instance_hash_new("node previews"); } + + node_preview_init_tree_recursive(ntree->previews, ntree, NODE_INSTANCE_KEY_BASE, xsize, ysize); +} + +void node_preview_free(bNodePreview *preview) +{ + if (preview->rect) { + MEM_freeN(preview->rect); + } + MEM_freeN(preview); } /* ************* node type access ********** */ @@ -4124,21 +4304,22 @@ const char *nodeSocketLabel(const bNodeSocket *sock) return (sock->label[0] != '\0') ? sock->label : sock->name; } -static void node_type_base_defaults(bNodeType *ntype) +void node_type_size_preset(bNodeType *ntype, const eNodeSizePreset size) { - /* default size values */ - node_type_size_preset(ntype, NODE_SIZE_DEFAULT); - ntype->height = 100; - ntype->minheight = 30; - ntype->maxheight = FLT_MAX; -} - -/* allow this node for any tree type */ -static bool node_poll_default(const bNodeType * /*ntype*/, - const bNodeTree * /*ntree*/, - const char ** /*disabled_hint*/) -{ - return true; + switch (size) { + case eNodeSizePreset::DEFAULT: + node_type_size(ntype, 140, 100, NODE_DEFAULT_MAX_WIDTH); + break; + case eNodeSizePreset::SMALL: + node_type_size(ntype, 100, 80, NODE_DEFAULT_MAX_WIDTH); + break; + case eNodeSizePreset::MIDDLE: + node_type_size(ntype, 150, 120, NODE_DEFAULT_MAX_WIDTH); + break; + case eNodeSizePreset::LARGE: + node_type_size(ntype, 240, 140, NODE_DEFAULT_MAX_WIDTH); + break; + } } static bool node_poll_instance_default(const bNode *node, @@ -4182,57 +4363,6 @@ void node_type_base(bNodeType *ntype, const int type, const char *name, const sh ntype->poll_instance = node_poll_instance_default; } -void node_type_base_custom(bNodeType *ntype, - const char *idname, - const char *name, - const short nclass) -{ - STRNCPY(ntype->idname, idname); - ntype->type = NODE_CUSTOM; - STRNCPY(ntype->ui_name, name); - ntype->nclass = nclass; - - node_type_base_defaults(ntype); -} - -struct SocketTemplateIdentifierCallbackData { - bNodeSocketTemplate *list; - bNodeSocketTemplate *ntemp; -}; - -static bool unique_socket_template_identifier_check(void *arg, const char *name) -{ - const SocketTemplateIdentifierCallbackData *data = - static_cast(arg); - - for (bNodeSocketTemplate *ntemp = data->list; ntemp->type >= 0; ntemp++) { - if (ntemp != data->ntemp) { - if (STREQ(ntemp->identifier, name)) { - return true; - } - } - } - - return false; -} - -static void unique_socket_template_identifier(bNodeSocketTemplate *list, - bNodeSocketTemplate *ntemp, - const char defname[], - const char delim) -{ - SocketTemplateIdentifierCallbackData data; - data.list = list; - data.ntemp = ntemp; - - BLI_uniquename_cb(unique_socket_template_identifier_check, - &data, - defname, - delim, - ntemp->identifier, - sizeof(ntemp->identifier)); -} - void node_type_socket_templates(bNodeType *ntype, bNodeSocketTemplate *inputs, bNodeSocketTemplate *outputs) @@ -4277,168 +4407,38 @@ void node_type_size(bNodeType *ntype, const int width, const int minwidth, const } } -void node_type_size_preset(bNodeType *ntype, const eNodeSizePreset size) -{ - switch (size) { - case NODE_SIZE_DEFAULT: - node_type_size(ntype, 140, 100, NODE_DEFAULT_MAX_WIDTH); - break; - case NODE_SIZE_SMALL: - node_type_size(ntype, 100, 80, NODE_DEFAULT_MAX_WIDTH); - break; - case NODE_SIZE_MIDDLE: - node_type_size(ntype, 150, 120, NODE_DEFAULT_MAX_WIDTH); - break; - case NODE_SIZE_LARGE: - node_type_size(ntype, 240, 140, NODE_DEFAULT_MAX_WIDTH); - break; - } -} +} // namespace blender::bke -void node_type_storage(bNodeType *ntype, - const char *storagename, - void (*freefunc)(bNode *node), - void (*copyfunc)(bNodeTree *dest_ntree, - bNode *dest_node, - const bNode *src_node)) -{ - if (storagename) { - STRNCPY(ntype->storagename, storagename); - } - else { - ntype->storagename[0] = '\0'; - } - ntype->copyfunc = copyfunc; - ntype->freefunc = freefunc; -} +static AssetTypeInfo AssetType_NT = { + /*pre_save_fn*/ blender::bke::node_tree_asset_pre_save, +}; -void BKE_node_system_init() -{ - nodetreetypes_hash = BLI_ghash_str_new("nodetreetypes_hash gh"); - nodetypes_hash = BLI_ghash_str_new("nodetypes_hash gh"); - nodesockettypes_hash = BLI_ghash_str_new("nodesockettypes_hash gh"); +IDTypeInfo IDType_ID_NT = { + /*id_code*/ ID_NT, + /*id_filter*/ FILTER_ID_NT, + /*main_listbase_index*/ INDEX_ID_NT, + /*struct_size*/ sizeof(bNodeTree), + /*name*/ "NodeTree", + /*name_plural*/ "node_groups", + /*translation_context*/ BLT_I18NCONTEXT_ID_NODETREE, + /*flags*/ IDTYPE_FLAGS_APPEND_IS_REUSABLE, + /*asset_type_info*/ &AssetType_NT, - register_nodes(); -} + /*init_data*/ blender::bke::ntree_init_data, + /*copy_data*/ blender::bke::ntree_copy_data, + /*free_data*/ blender::bke::ntree_free_data, + /*make_local*/ nullptr, + /*foreach_id*/ blender::bke::node_foreach_id, + /*foreach_cache*/ blender::bke::node_foreach_cache, + /*foreach_path*/ blender::bke::node_foreach_path, + /*owner_pointer_get*/ blender::bke::node_owner_pointer_get, -void BKE_node_system_exit() -{ - if (nodetypes_hash) { - NODE_TYPES_BEGIN (nt) { - if (nt->rna_ext.free) { - nt->rna_ext.free(nt->rna_ext.data); - } - } - NODE_TYPES_END; + /*blend_write*/ blender::bke::ntree_blend_write, + /*blend_read_data*/ blender::bke::ntree_blend_read_data, + /*blend_read_lib*/ blender::bke::ntree_blend_read_lib, + /*blend_read_expand*/ blender::bke::ntree_blend_read_expand, - BLI_ghash_free(nodetypes_hash, nullptr, node_free_type); - nodetypes_hash = nullptr; - } + /*blend_read_undo_preserve*/ nullptr, - if (nodesockettypes_hash) { - NODE_SOCKET_TYPES_BEGIN (st) { - if (st->ext_socket.free) { - st->ext_socket.free(st->ext_socket.data); - } - if (st->ext_interface.free) { - st->ext_interface.free(st->ext_interface.data); - } - } - NODE_SOCKET_TYPES_END; - - BLI_ghash_free(nodesockettypes_hash, nullptr, node_free_socket_type); - nodesockettypes_hash = nullptr; - } - - if (nodetreetypes_hash) { - NODE_TREE_TYPES_BEGIN (nt) { - if (nt->rna_ext.free) { - nt->rna_ext.free(nt->rna_ext.data); - } - } - NODE_TREE_TYPES_END; - - BLI_ghash_free(nodetreetypes_hash, nullptr, ntree_free_type); - nodetreetypes_hash = nullptr; - } -} - -/* -------------------------------------------------------------------- */ -/* NodeTree Iterator Helpers (FOREACH_NODETREE_BEGIN) */ - -void BKE_node_tree_iter_init(NodeTreeIterStore *ntreeiter, Main *bmain) -{ - ntreeiter->ngroup = (bNodeTree *)bmain->nodetrees.first; - ntreeiter->scene = (Scene *)bmain->scenes.first; - ntreeiter->mat = (Material *)bmain->materials.first; - ntreeiter->tex = (Tex *)bmain->textures.first; - ntreeiter->light = (Light *)bmain->lights.first; - ntreeiter->world = (World *)bmain->worlds.first; - ntreeiter->linestyle = (FreestyleLineStyle *)bmain->linestyles.first; - ntreeiter->simulation = (Simulation *)bmain->simulations.first; -} -bool BKE_node_tree_iter_step(NodeTreeIterStore *ntreeiter, bNodeTree **r_nodetree, ID **r_id) -{ - if (ntreeiter->ngroup) { - bNodeTree &node_tree = *reinterpret_cast(ntreeiter->ngroup); - *r_nodetree = &node_tree; - *r_id = &node_tree.id; - ntreeiter->ngroup = reinterpret_cast(node_tree.id.next); - } - else if (ntreeiter->scene) { - *r_nodetree = reinterpret_cast(ntreeiter->scene->nodetree); - *r_id = &ntreeiter->scene->id; - ntreeiter->scene = reinterpret_cast(ntreeiter->scene->id.next); - } - else if (ntreeiter->mat) { - *r_nodetree = reinterpret_cast(ntreeiter->mat->nodetree); - *r_id = &ntreeiter->mat->id; - ntreeiter->mat = reinterpret_cast(ntreeiter->mat->id.next); - } - else if (ntreeiter->tex) { - *r_nodetree = reinterpret_cast(ntreeiter->tex->nodetree); - *r_id = &ntreeiter->tex->id; - ntreeiter->tex = reinterpret_cast(ntreeiter->tex->id.next); - } - else if (ntreeiter->light) { - *r_nodetree = reinterpret_cast(ntreeiter->light->nodetree); - *r_id = &ntreeiter->light->id; - ntreeiter->light = reinterpret_cast(ntreeiter->light->id.next); - } - else if (ntreeiter->world) { - *r_nodetree = reinterpret_cast(ntreeiter->world->nodetree); - *r_id = &ntreeiter->world->id; - ntreeiter->world = reinterpret_cast(ntreeiter->world->id.next); - } - else if (ntreeiter->linestyle) { - *r_nodetree = reinterpret_cast(ntreeiter->linestyle->nodetree); - *r_id = &ntreeiter->linestyle->id; - ntreeiter->linestyle = reinterpret_cast(ntreeiter->linestyle->id.next); - } - else if (ntreeiter->simulation) { - *r_nodetree = reinterpret_cast(ntreeiter->simulation->nodetree); - *r_id = &ntreeiter->simulation->id; - ntreeiter->simulation = reinterpret_cast(ntreeiter->simulation->id.next); - } - else { - return false; - } - - return true; -} - -void BKE_nodetree_remove_layer_n(bNodeTree *ntree, Scene *scene, const int layer_index) -{ - BLI_assert(layer_index != -1); - BLI_assert(scene != nullptr); - for (bNode *node : ntree->all_nodes()) { - if (node->type == CMP_NODE_R_LAYERS && node->id == &scene->id) { - if (node->custom1 == layer_index) { - node->custom1 = 0; - } - else if (node->custom1 > layer_index) { - node->custom1--; - } - } - } -} + /*lib_override_apply_post*/ nullptr, +}; \ No newline at end of file diff --git a/source/blender/blenkernel/intern/node_runtime.cc b/source/blender/blenkernel/intern/node_runtime.cc index 530cc3c07e7..7d9f2869896 100644 --- a/source/blender/blenkernel/intern/node_runtime.cc +++ b/source/blender/blenkernel/intern/node_runtime.cc @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "DNA_node_types.h" @@ -39,7 +39,7 @@ static void update_node_vector(const bNodeTree &ntree) bNode &node = *nodes[i]; node.runtime->index_in_tree = i; node.runtime->owner_tree = const_cast(&ntree); - tree_runtime.has_undefined_nodes_or_sockets |= node.typeinfo == &NodeTypeUndefined; + tree_runtime.has_undefined_nodes_or_sockets |= node.typeinfo == &bke::NodeTypeUndefined; if (node.is_group()) { tree_runtime.group_nodes.append(&node); } @@ -75,7 +75,8 @@ static void update_socket_vectors_and_owner_node(const bNodeTree &ntree) socket->runtime->index_in_inout_sockets = tree_runtime.input_sockets.append_and_get_index( socket); socket->runtime->owner_node = node; - tree_runtime.has_undefined_nodes_or_sockets |= socket->typeinfo == &NodeSocketTypeUndefined; + tree_runtime.has_undefined_nodes_or_sockets |= socket->typeinfo == + &bke::NodeSocketTypeUndefined; } LISTBASE_FOREACH (bNodeSocket *, socket, &node->outputs) { socket->runtime->index_in_node = node_runtime.outputs.append_and_get_index(socket); @@ -83,7 +84,8 @@ static void update_socket_vectors_and_owner_node(const bNodeTree &ntree) socket->runtime->index_in_inout_sockets = tree_runtime.output_sockets.append_and_get_index( socket); socket->runtime->owner_node = node; - tree_runtime.has_undefined_nodes_or_sockets |= socket->typeinfo == &NodeSocketTypeUndefined; + tree_runtime.has_undefined_nodes_or_sockets |= socket->typeinfo == + &bke::NodeSocketTypeUndefined; } } } diff --git a/source/blender/blenkernel/intern/node_tree_field_inferencing.cc b/source/blender/blenkernel/intern/node_tree_field_inferencing.cc index 61749d0b8f5..16ac230e45d 100644 --- a/source/blender/blenkernel/intern/node_tree_field_inferencing.cc +++ b/source/blender/blenkernel/intern/node_tree_field_inferencing.cc @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "NOD_node_declaration.hh" @@ -41,7 +41,7 @@ static InputSocketFieldType get_interface_input_field_type(const bNode &node, /* Outputs always support fields when the data type is correct. */ return InputSocketFieldType::IsSupported; } - if (node.typeinfo == &NodeTypeUndefined) { + if (node.typeinfo == &blender::bke::NodeTypeUndefined) { return InputSocketFieldType::None; } if (node.type == NODE_CUSTOM) { @@ -75,7 +75,7 @@ static OutputFieldDependency get_interface_output_field_dependency(const bNode & /* Input nodes get special treatment in #determine_group_input_states. */ return OutputFieldDependency::ForDependentField(); } - if (node.typeinfo == &NodeTypeUndefined) { + if (node.typeinfo == &blender::bke::NodeTypeUndefined) { return OutputFieldDependency::ForDataSource(); } if (node.type == NODE_CUSTOM) { diff --git a/source/blender/blenkernel/intern/node_tree_update.cc b/source/blender/blenkernel/intern/node_tree_update.cc index 1ab354f9771..c60785bcde4 100644 --- a/source/blender/blenkernel/intern/node_tree_update.cc +++ b/source/blender/blenkernel/intern/node_tree_update.cc @@ -15,7 +15,7 @@ #include "BKE_anim_data.h" #include "BKE_image.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" @@ -540,7 +540,7 @@ class NodeTreeMainUpdater { void update_individual_nodes(bNodeTree &ntree) { for (bNode *node : ntree.all_nodes()) { - nodeDeclarationEnsure(&ntree, node); + blender::bke::nodeDeclarationEnsure(&ntree, node); if (this->should_update_individual_node(ntree, *node)) { bNodeType &ntype = *node->typeinfo; if (ntype.group_update_func) { @@ -701,7 +701,7 @@ class NodeTreeMainUpdater { if ((ntree.runtime->changed_flag & allowed_flags) == ntree.runtime->changed_flag) { return; } - BKE_node_preview_remove_unused(&ntree); + blender::bke::node_preview_remove_unused(&ntree); } void propagate_runtime_flags(const bNodeTree &ntree) diff --git a/source/blender/blenkernel/intern/node_tree_zones.cc b/source/blender/blenkernel/intern/node_tree_zones.cc index f8301e3f8d8..f6f9fffbb32 100644 --- a/source/blender/blenkernel/intern/node_tree_zones.cc +++ b/source/blender/blenkernel/intern/node_tree_zones.cc @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_zones.hh" diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index 8fc0123a2f5..c19615ba252 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -109,7 +109,7 @@ #include "BKE_mesh_wrapper.h" #include "BKE_modifier.h" #include "BKE_multires.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_object.h" #include "BKE_object_facemap.h" #include "BKE_paint.h" diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc index 62fae8427fe..e59c45cbbcf 100644 --- a/source/blender/blenkernel/intern/scene.cc +++ b/source/blender/blenkernel/intern/scene.cc @@ -78,7 +78,7 @@ #include "BKE_linestyle.h" #include "BKE_main.h" #include "BKE_mask.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_object.h" #include "BKE_paint.h" diff --git a/source/blender/blenkernel/intern/simulation.cc b/source/blender/blenkernel/intern/simulation.cc index dabdad4b79f..9b234bbc524 100644 --- a/source/blender/blenkernel/intern/simulation.cc +++ b/source/blender/blenkernel/intern/simulation.cc @@ -30,7 +30,7 @@ #include "BKE_lib_query.h" #include "BKE_lib_remap.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_pointcache.h" #include "BKE_simulation.h" @@ -51,7 +51,7 @@ static void simulation_init_data(ID *id) MEMCPY_STRUCT_AFTER(simulation, DNA_struct_default_get(Simulation), id); - ntreeAddTreeEmbedded(nullptr, id, "Geometry Nodetree", ntreeType_Geometry->idname); + blender::bke::ntreeAddTreeEmbedded(nullptr, id, "Geometry Nodetree", ntreeType_Geometry->idname); } static void simulation_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int flag) diff --git a/source/blender/blenkernel/intern/texture.cc b/source/blender/blenkernel/intern/texture.cc index a42fdf906e0..65fef8ebac7 100644 --- a/source/blender/blenkernel/intern/texture.cc +++ b/source/blender/blenkernel/intern/texture.cc @@ -47,7 +47,7 @@ #include "BKE_lib_id.h" #include "BKE_lib_query.h" #include "BKE_material.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_scene.h" #include "BKE_texture.h" diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc index 07d8b94cb2e..1d5e83559dd 100644 --- a/source/blender/blenloader/intern/readfile.cc +++ b/source/blender/blenloader/intern/readfile.cc @@ -78,7 +78,7 @@ #include "BKE_material.h" #include "BKE_mesh.hh" #include "BKE_modifier.h" -#include "BKE_node.h" /* for tree type defines */ +#include "BKE_node.hh" /* for tree type defines */ #include "BKE_object.h" #include "BKE_packedFile.h" #include "BKE_report.h" @@ -1844,7 +1844,7 @@ static void lib_link_id_embedded_id(BlendLibReader *reader, ID *id) bNodeTree *nodetree = ntreeFromID(id); if (nodetree != nullptr) { lib_link_id(reader, &nodetree->id); - ntreeBlendReadLib(reader, nodetree); + blender::bke::ntreeBlendReadLib(reader, nodetree); } if (GS(id->name) == ID_SCE) { @@ -1915,7 +1915,7 @@ static void direct_link_id_embedded_id(BlendDataReader *reader, (ID *)*nodetree, id_old != nullptr ? (ID *)ntreeFromID(id_old) : nullptr, 0); - ntreeBlendReadData(reader, id, *nodetree); + blender::bke::ntreeBlendReadData(reader, id, *nodetree); } if (GS(id->name) == ID_SCE) { @@ -3950,7 +3950,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) /* After all data has been read and versioned, uses LIB_TAG_NEW. Theoretically this should * not be calculated in the undo case, but it is currently needed even on undo to recalculate * a cache. */ - ntreeUpdateAllNew(bfd->main); + blender::bke::ntreeUpdateAllNew(bfd->main); placeholders_ensure_valid(bfd->main); @@ -4287,7 +4287,7 @@ static void expand_id_embedded_id(BlendExpander *expander, ID *id) bNodeTree *nodetree = ntreeFromID(id); if (nodetree != nullptr) { expand_id(expander, &nodetree->id); - ntreeBlendReadExpand(expander, nodetree); + blender::bke::ntreeBlendReadExpand(expander, nodetree); } if (GS(id->name) == ID_SCE) { @@ -4606,7 +4606,7 @@ static void library_link_end(Main *mainl, FileData **fd, const int flag) BKE_main_id_refcount_recompute(mainvar, false); /* After all data has been read and versioned, uses LIB_TAG_NEW. */ - ntreeUpdateAllNew(mainvar); + blender::bke::ntreeUpdateAllNew(mainvar); placeholders_ensure_valid(mainvar); diff --git a/source/blender/blenloader/intern/versioning_290.cc b/source/blender/blenloader/intern/versioning_290.cc index a8e9e6bfb6d..fa4ab66eff4 100644 --- a/source/blender/blenloader/intern/versioning_290.cc +++ b/source/blender/blenloader/intern/versioning_290.cc @@ -51,7 +51,7 @@ #include "BKE_mesh.hh" #include "BKE_mesh_legacy_convert.h" #include "BKE_multires.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "IMB_imbuf.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index 5f5a3dbc481..163c11e7764 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -65,7 +65,7 @@ #include "BKE_main_namemap.h" #include "BKE_mesh.hh" #include "BKE_modifier.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_screen.h" #include "BKE_workspace.h" @@ -940,7 +940,7 @@ static void version_geometry_nodes_primitive_uv_maps(bNodeTree &ntree) BLI_addhead(&ntree.nodes, node); } if (!new_nodes.is_empty()) { - nodeRebuildIDVector(&ntree); + blender::bke::nodeRebuildIDVector(&ntree); } } @@ -1074,7 +1074,7 @@ static void version_geometry_nodes_extrude_smooth_propagation(bNodeTree &ntree) BLI_addhead(&ntree.nodes, node); } if (!new_nodes.is_empty()) { - nodeRebuildIDVector(&ntree); + blender::bke::nodeRebuildIDVector(&ntree); } } diff --git a/source/blender/blenloader/intern/versioning_common.cc b/source/blender/blenloader/intern/versioning_common.cc index 8bbc4166229..50b636356cf 100644 --- a/source/blender/blenloader/intern/versioning_common.cc +++ b/source/blender/blenloader/intern/versioning_common.cc @@ -20,7 +20,7 @@ #include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_main_namemap.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "MEM_guardedalloc.h" diff --git a/source/blender/blenloader/intern/versioning_defaults.cc b/source/blender/blenloader/intern/versioning_defaults.cc index 1f2990118a3..190ad7a597d 100644 --- a/source/blender/blenloader/intern/versioning_defaults.cc +++ b/source/blender/blenloader/intern/versioning_defaults.cc @@ -50,7 +50,7 @@ #include "BKE_main_namemap.h" #include "BKE_material.h" #include "BKE_mesh.hh" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" #include "BKE_paint.h" diff --git a/source/blender/blenloader/intern/writefile.cc b/source/blender/blenloader/intern/writefile.cc index 47cfe63fafe..df7fe0eecaf 100644 --- a/source/blender/blenloader/intern/writefile.cc +++ b/source/blender/blenloader/intern/writefile.cc @@ -104,7 +104,7 @@ #include "BKE_lib_override.h" #include "BKE_lib_query.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_packedFile.h" #include "BKE_report.h" #include "BKE_workspace.h" diff --git a/source/blender/blenloader/tests/blendfile_loading_base_test.cc b/source/blender/blenloader/tests/blendfile_loading_base_test.cc index 63f35d9c206..a645c54c7a1 100644 --- a/source/blender/blenloader/tests/blendfile_loading_base_test.cc +++ b/source/blender/blenloader/tests/blendfile_loading_base_test.cc @@ -15,7 +15,7 @@ #include "BKE_main.h" #include "BKE_mball_tessellate.h" #include "BKE_modifier.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_scene.h" #include "BKE_vfont.h" diff --git a/source/blender/compositor/intern/COM_Converter.cc b/source/blender/compositor/intern/COM_Converter.cc index 6d7341376e9..432311542c9 100644 --- a/source/blender/compositor/intern/COM_Converter.cc +++ b/source/blender/compositor/intern/COM_Converter.cc @@ -5,7 +5,7 @@ #include "DNA_node_types.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "COM_NodeOperationBuilder.h" @@ -130,7 +130,7 @@ Node *COM_convert_bnode(bNode *b_node) Node *node = nullptr; /* ignore undefined nodes with missing or invalid node data */ - if (nodeTypeUndefined(b_node)) { + if (blender::bke::node_type_is_undefined(b_node)) { return nullptr; } diff --git a/source/blender/compositor/intern/COM_Node.cc b/source/blender/compositor/intern/COM_Node.cc index c1a8740d8ea..8b17cc6d1da 100644 --- a/source/blender/compositor/intern/COM_Node.cc +++ b/source/blender/compositor/intern/COM_Node.cc @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-or-later * Copyright 2011 Blender Foundation. */ -#include "BKE_node.h" +#include "BKE_node.hh" #include "RNA_access.h" #include "RNA_prototypes.h" diff --git a/source/blender/compositor/intern/COM_NodeGraph.cc b/source/blender/compositor/intern/COM_NodeGraph.cc index 008a5a8dbec..ca946f5fe5c 100644 --- a/source/blender/compositor/intern/COM_NodeGraph.cc +++ b/source/blender/compositor/intern/COM_NodeGraph.cc @@ -5,7 +5,7 @@ #include "DNA_node_types.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "COM_Converter.h" diff --git a/source/blender/compositor/intern/COM_compositor.cc b/source/blender/compositor/intern/COM_compositor.cc index 35c3610dbbe..fa8c78b3ecd 100644 --- a/source/blender/compositor/intern/COM_compositor.cc +++ b/source/blender/compositor/intern/COM_compositor.cc @@ -5,7 +5,7 @@ #include "BLT_translation.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_scene.h" @@ -37,7 +37,7 @@ static void compositor_init_node_previews(const RenderData *render_data, bNodeTr preview_width = int(blender::compositor::COM_PREVIEW_SIZE / aspect); preview_height = blender::compositor::COM_PREVIEW_SIZE; } - BKE_node_preview_init_tree(node_tree, preview_width, preview_height); + blender::bke::node_preview_init_tree(node_tree, preview_width, preview_height); } static void compositor_reset_node_tree_status(bNodeTree *node_tree) diff --git a/source/blender/compositor/nodes/COM_ConvertColorSpaceNode.cc b/source/blender/compositor/nodes/COM_ConvertColorSpaceNode.cc index a0f6d946770..5409df6ffbe 100644 --- a/source/blender/compositor/nodes/COM_ConvertColorSpaceNode.cc +++ b/source/blender/compositor/nodes/COM_ConvertColorSpaceNode.cc @@ -3,7 +3,7 @@ #include "COM_ConvertColorSpaceNode.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BLI_utildefines.h" diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cc b/source/blender/compositor/nodes/COM_CryptomatteNode.cc index 74b709099ed..9630123d5b4 100644 --- a/source/blender/compositor/nodes/COM_CryptomatteNode.cc +++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cc @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-or-later * Copyright 2018 Blender Foundation. */ -#include "BKE_node.h" +#include "BKE_node.hh" #include "NOD_composite.h" diff --git a/source/blender/compositor/nodes/COM_FilterNode.cc b/source/blender/compositor/nodes/COM_FilterNode.cc index dce08b4cf2c..da67bff28d8 100644 --- a/source/blender/compositor/nodes/COM_FilterNode.cc +++ b/source/blender/compositor/nodes/COM_FilterNode.cc @@ -2,7 +2,7 @@ * Copyright 2011 Blender Foundation. */ #include "COM_FilterNode.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "COM_ConvolutionEdgeFilterOperation.h" namespace blender::compositor { diff --git a/source/blender/compositor/nodes/COM_InvertNode.cc b/source/blender/compositor/nodes/COM_InvertNode.cc index ce5c4f48f9e..fe530d89ad6 100644 --- a/source/blender/compositor/nodes/COM_InvertNode.cc +++ b/source/blender/compositor/nodes/COM_InvertNode.cc @@ -2,7 +2,7 @@ * Copyright 2011 Blender Foundation. */ #include "COM_InvertNode.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "COM_InvertOperation.h" namespace blender::compositor { diff --git a/source/blender/compositor/nodes/COM_ScaleNode.cc b/source/blender/compositor/nodes/COM_ScaleNode.cc index 1d613a030d7..82a5ea72a78 100644 --- a/source/blender/compositor/nodes/COM_ScaleNode.cc +++ b/source/blender/compositor/nodes/COM_ScaleNode.cc @@ -3,7 +3,7 @@ #include "COM_ScaleNode.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "COM_ScaleOperation.h" #include "COM_SetValueOperation.h" diff --git a/source/blender/compositor/nodes/COM_TrackPositionNode.cc b/source/blender/compositor/nodes/COM_TrackPositionNode.cc index 25daf3306a1..0bc3251e2e1 100644 --- a/source/blender/compositor/nodes/COM_TrackPositionNode.cc +++ b/source/blender/compositor/nodes/COM_TrackPositionNode.cc @@ -8,7 +8,7 @@ #include "DNA_movieclip_types.h" -#include "BKE_node.h" +#include "BKE_node.hh" namespace blender::compositor { diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cc b/source/blender/compositor/operations/COM_PreviewOperation.cc index 2b9fc7ddc8c..82a3fae4fbe 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.cc +++ b/source/blender/compositor/operations/COM_PreviewOperation.cc @@ -3,7 +3,7 @@ #include "COM_PreviewOperation.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "IMB_colormanagement.h" namespace blender::compositor { @@ -32,7 +32,7 @@ void PreviewOperation::verify_preview(bNodeInstanceHash *previews, bNodeInstance /* Size (0, 0) ensures the preview rect is not allocated in advance, * this is set later in init_execution once the resolution is determined. */ - preview_ = BKE_node_preview_verify(previews, key, 0, 0, true); + preview_ = blender::bke::node_preview_verify(previews, key, 0, 0, true); } void PreviewOperation::init_execution() diff --git a/source/blender/compositor/operations/COM_SMAAOperation.cc b/source/blender/compositor/operations/COM_SMAAOperation.cc index 2de5e6bdd5a..801e951ade2 100644 --- a/source/blender/compositor/operations/COM_SMAAOperation.cc +++ b/source/blender/compositor/operations/COM_SMAAOperation.cc @@ -2,7 +2,7 @@ * Copyright 2017 Blender Foundation. */ #include "COM_SMAAOperation.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "COM_SMAAAreaTexture.h" extern "C" { diff --git a/source/blender/compositor/operations/COM_TextureOperation.cc b/source/blender/compositor/operations/COM_TextureOperation.cc index 9ea9731047b..d1552a7a2b6 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.cc +++ b/source/blender/compositor/operations/COM_TextureOperation.cc @@ -5,7 +5,7 @@ #include "COM_WorkScheduler.h" #include "BKE_image.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_scene.h" #include "NOD_texture.h" diff --git a/source/blender/compositor/operations/COM_TrackPositionOperation.cc b/source/blender/compositor/operations/COM_TrackPositionOperation.cc index 6763293b519..2df0035ed7c 100644 --- a/source/blender/compositor/operations/COM_TrackPositionOperation.cc +++ b/source/blender/compositor/operations/COM_TrackPositionOperation.cc @@ -6,7 +6,7 @@ #include "DNA_defaults.h" #include "BKE_movieclip.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_tracking.h" namespace blender::compositor { diff --git a/source/blender/compositor/realtime_compositor/intern/scheduler.cc b/source/blender/compositor/realtime_compositor/intern/scheduler.cc index c1ec75057eb..b0ea2e4d310 100644 --- a/source/blender/compositor/realtime_compositor/intern/scheduler.cc +++ b/source/blender/compositor/realtime_compositor/intern/scheduler.cc @@ -8,7 +8,7 @@ #include "NOD_derived_node_tree.hh" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "COM_scheduler.hh" diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 44d76076994..041262957a1 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -78,7 +78,7 @@ #include "BKE_mesh.hh" #include "BKE_modifier.h" #include "BKE_movieclip.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_object.h" #include "BKE_particle.h" diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc index cace6e08e6e..2c3188fef7e 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc @@ -28,7 +28,7 @@ #include "BKE_layer.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 1d1e805552c..c353e2b2da5 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -71,7 +71,7 @@ #include "BKE_material.h" #include "BKE_mball.h" #include "BKE_modifier.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_object.h" #include "BKE_particle.h" diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc index adcbc42724c..d94d070e4ff 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc @@ -26,7 +26,7 @@ #include "BKE_layer.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc index 27e194230e0..8177cf4e9c4 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc @@ -16,7 +16,7 @@ #include "BKE_geometry_set.hh" #include "BKE_idprop.h" #include "BKE_layer.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_object.h" #include "BLI_math.h" diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index ddfa508def5..f8100479b1d 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -30,7 +30,7 @@ #include "BKE_anim_data.h" #include "BKE_global.h" #include "BKE_idtype.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_workspace.h" diff --git a/source/blender/draw/engines/eevee/eevee_shaders.cc b/source/blender/draw/engines/eevee/eevee_shaders.cc index 1cbcbd38337..279df8beb3d 100644 --- a/source/blender/draw/engines/eevee/eevee_shaders.cc +++ b/source/blender/draw/engines/eevee/eevee_shaders.cc @@ -8,7 +8,7 @@ #include "DRW_render.h" #include "BKE_lib_id.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BLI_dynstr.h" #include "BLI_string_utils.h" @@ -1029,7 +1029,7 @@ Material *EEVEE_material_default_diffuse_get(void) if (!e_data.diffuse_mat) { Material *ma = static_cast(BKE_id_new_nomain(ID_MA, "EEVEEE default diffuse")); - bNodeTree *ntree = ntreeAddTreeEmbedded( + bNodeTree *ntree = blender::bke::ntreeAddTreeEmbedded( nullptr, &ma->id, "Shader Nodetree", ntreeType_Shader->idname); ma->use_nodes = true; @@ -1056,7 +1056,7 @@ Material *EEVEE_material_default_glossy_get(void) if (!e_data.glossy_mat) { Material *ma = static_cast(BKE_id_new_nomain(ID_MA, "EEVEEE default metal")); - bNodeTree *ntree = ntreeAddTreeEmbedded( + bNodeTree *ntree = blender::bke::ntreeAddTreeEmbedded( nullptr, &ma->id, "Shader Nodetree", ntreeType_Shader->idname); ma->use_nodes = true; @@ -1085,7 +1085,7 @@ Material *EEVEE_material_default_error_get(void) if (!e_data.error_mat) { Material *ma = static_cast(BKE_id_new_nomain(ID_MA, "EEVEEE default error")); - bNodeTree *ntree = ntreeAddTreeEmbedded( + bNodeTree *ntree = blender::bke::ntreeAddTreeEmbedded( nullptr, &ma->id, "Shader Nodetree", ntreeType_Shader->idname); ma->use_nodes = true; diff --git a/source/blender/draw/engines/eevee_next/eevee_material.cc b/source/blender/draw/engines/eevee_next/eevee_material.cc index 321af18b933..34c5134f319 100644 --- a/source/blender/draw/engines/eevee_next/eevee_material.cc +++ b/source/blender/draw/engines/eevee_next/eevee_material.cc @@ -10,7 +10,7 @@ #include "BKE_lib_id.h" #include "BKE_material.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "NOD_shader.h" #include "eevee_instance.hh" @@ -73,7 +73,7 @@ MaterialModule::MaterialModule(Instance &inst) : inst_(inst) { { diffuse_mat = (::Material *)BKE_id_new_nomain(ID_MA, "EEVEE default diffuse"); - bNodeTree *ntree = ntreeAddTreeEmbedded( + bNodeTree *ntree = bke::ntreeAddTreeEmbedded( nullptr, &diffuse_mat->id, "Shader Nodetree", ntreeType_Shader->idname); diffuse_mat->use_nodes = true; /* To use the forward pipeline. */ @@ -95,7 +95,7 @@ MaterialModule::MaterialModule(Instance &inst) : inst_(inst) } { glossy_mat = (::Material *)BKE_id_new_nomain(ID_MA, "EEVEE default metal"); - bNodeTree *ntree = ntreeAddTreeEmbedded( + bNodeTree *ntree = bke::ntreeAddTreeEmbedded( nullptr, &glossy_mat->id, "Shader Nodetree", ntreeType_Shader->idname); glossy_mat->use_nodes = true; /* To use the forward pipeline. */ @@ -119,7 +119,7 @@ MaterialModule::MaterialModule(Instance &inst) : inst_(inst) } { error_mat_ = (::Material *)BKE_id_new_nomain(ID_MA, "EEVEE default error"); - bNodeTree *ntree = ntreeAddTreeEmbedded( + bNodeTree *ntree = bke::ntreeAddTreeEmbedded( nullptr, &error_mat_->id, "Shader Nodetree", ntreeType_Shader->idname); error_mat_->use_nodes = true; diff --git a/source/blender/draw/engines/eevee_next/eevee_world.cc b/source/blender/draw/engines/eevee_next/eevee_world.cc index 37f90570028..6c1b8748659 100644 --- a/source/blender/draw/engines/eevee_next/eevee_world.cc +++ b/source/blender/draw/engines/eevee_next/eevee_world.cc @@ -7,7 +7,7 @@ */ #include "BKE_lib_id.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_world.h" #include "DEG_depsgraph_query.h" #include "NOD_shader.h" diff --git a/source/blender/draw/engines/workbench/workbench_materials.cc b/source/blender/draw/engines/workbench/workbench_materials.cc index 4bb4ebeb6b2..e432720ed9c 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.cc +++ b/source/blender/draw/engines/workbench/workbench_materials.cc @@ -10,7 +10,7 @@ #include "BLI_memblock.h" #include "BKE_image.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BLI_dynstr.h" #include "BLI_hash.h" diff --git a/source/blender/draw/engines/workbench/workbench_materials_next.cc b/source/blender/draw/engines/workbench/workbench_materials_next.cc index f163c7e8891..46bdb529779 100644 --- a/source/blender/draw/engines/workbench/workbench_materials_next.cc +++ b/source/blender/draw/engines/workbench/workbench_materials_next.cc @@ -4,7 +4,7 @@ #include "BLI_hash.h" /* get_image */ -#include "BKE_node.h" +#include "BKE_node.hh" #include "DNA_node_types.h" #include "ED_uvedit.h" /* get_image */ diff --git a/source/blender/draw/tests/eevee_test.cc b/source/blender/draw/tests/eevee_test.cc index 40a26ecdcc5..3fbd965ec00 100644 --- a/source/blender/draw/tests/eevee_test.cc +++ b/source/blender/draw/tests/eevee_test.cc @@ -5,7 +5,7 @@ #include "BKE_context.h" #include "BKE_idtype.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_object.h" #include "DEG_depsgraph.h" #include "RNA_define.h" diff --git a/source/blender/editors/curves/intern/curves_add.cc b/source/blender/editors/curves/intern/curves_add.cc index 997d7a856f2..23d76a5f9e7 100644 --- a/source/blender/editors/curves/intern/curves_add.cc +++ b/source/blender/editors/curves/intern/curves_add.cc @@ -8,7 +8,7 @@ #include "BKE_context.h" #include "BKE_curves.hh" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "ED_curves.h" diff --git a/source/blender/editors/interface/eyedroppers/eyedropper_color.cc b/source/blender/editors/interface/eyedroppers/eyedropper_color.cc index 726cac2c3a0..a9b4db328ee 100644 --- a/source/blender/editors/interface/eyedroppers/eyedropper_color.cc +++ b/source/blender/editors/interface/eyedroppers/eyedropper_color.cc @@ -23,7 +23,7 @@ #include "BKE_cryptomatte.h" #include "BKE_image.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_screen.h" #include "NOD_composite.h" diff --git a/source/blender/editors/interface/interface_draw.cc b/source/blender/editors/interface/interface_draw.cc index 11830412b70..366b7c72856 100644 --- a/source/blender/editors/interface/interface_draw.cc +++ b/source/blender/editors/interface/interface_draw.cc @@ -25,7 +25,7 @@ #include "BKE_colorband.h" #include "BKE_colortools.h" #include "BKE_curveprofile.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_tracking.h" #include "IMB_colormanagement.h" diff --git a/source/blender/editors/interface/interface_ops.cc b/source/blender/editors/interface/interface_ops.cc index c364753f864..a471d98cc21 100644 --- a/source/blender/editors/interface/interface_ops.cc +++ b/source/blender/editors/interface/interface_ops.cc @@ -31,7 +31,7 @@ #include "BKE_lib_override.h" #include "BKE_lib_remap.h" #include "BKE_material.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_report.h" #include "BKE_screen.h" #include "BKE_text.h" diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc index aa4a9b23474..2cacdab3f5b 100644 --- a/source/blender/editors/object/object_add.cc +++ b/source/blender/editors/object/object_add.cc @@ -75,7 +75,7 @@ #include "BKE_mesh.hh" #include "BKE_mesh_runtime.h" #include "BKE_nla.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_pointcloud.h" diff --git a/source/blender/editors/object/object_bake_api.cc b/source/blender/editors/object/object_bake_api.cc index 78f7ef9a061..179fb3dff69 100644 --- a/source/blender/editors/object/object_bake_api.cc +++ b/source/blender/editors/object/object_bake_api.cc @@ -35,7 +35,7 @@ #include "BKE_mesh.hh" #include "BKE_mesh_mapping.h" #include "BKE_modifier.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_object.h" #include "BKE_report.h" #include "BKE_scene.h" @@ -516,7 +516,7 @@ static bool bake_object_check(const Scene *scene, if (image) { if (node) { - if (BKE_node_is_connected_to_output(ntree, node)) { + if (blender::bke::node_is_connected_to_output(ntree, node)) { /* we don't return false since this may be a false positive * this can't be RPT_ERROR though, otherwise it prevents * multiple highpoly objects to be baked at once */ diff --git a/source/blender/editors/render/render_internal.cc b/source/blender/editors/render/render_internal.cc index 0ceff7edc14..13f4f25b5ac 100644 --- a/source/blender/editors/render/render_internal.cc +++ b/source/blender/editors/render/render_internal.cc @@ -35,7 +35,7 @@ #include "BKE_layer.h" #include "BKE_lib_id.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_tree_update.h" #include "BKE_object.h" #include "BKE_report.h" diff --git a/source/blender/editors/render/render_preview.cc b/source/blender/editors/render/render_preview.cc index 2758c98fea8..092fa0d0d00 100644 --- a/source/blender/editors/render/render_preview.cc +++ b/source/blender/editors/render/render_preview.cc @@ -55,7 +55,7 @@ #include "BKE_light.h" #include "BKE_main.h" #include "BKE_material.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_object.h" #include "BKE_pose_backup.h" #include "BKE_scene.h" diff --git a/source/blender/editors/render/render_shading.cc b/source/blender/editors/render/render_shading.cc index 9022d5d80c1..a5594f874e4 100644 --- a/source/blender/editors/render/render_shading.cc +++ b/source/blender/editors/render/render_shading.cc @@ -41,7 +41,7 @@ #include "BKE_linestyle.h" #include "BKE_main.h" #include "BKE_material.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_object.h" #include "BKE_report.h" #include "BKE_scene.h" diff --git a/source/blender/editors/render/render_update.cc b/source/blender/editors/render/render_update.cc index 835698e9fd1..cf6faf74143 100644 --- a/source/blender/editors/render/render_update.cc +++ b/source/blender/editors/render/render_update.cc @@ -30,7 +30,7 @@ #include "BKE_icons.h" #include "BKE_main.h" #include "BKE_material.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_paint.h" #include "BKE_scene.h" diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.cc b/source/blender/editors/sculpt_paint/paint_image_proj.cc index 572a7c1e7e6..34e5a9d8d08 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.cc +++ b/source/blender/editors/sculpt_paint/paint_image_proj.cc @@ -63,7 +63,7 @@ #include "BKE_mesh.hh" #include "BKE_mesh_mapping.h" #include "BKE_mesh_runtime.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_paint.h" #include "BKE_report.h" #include "BKE_scene.h" @@ -6636,7 +6636,7 @@ static void default_paint_slot_color_get(int layer_type, Material *ma, float col case LAYER_ROUGHNESS: case LAYER_METALLIC: { bNodeTree *ntree = nullptr; - bNode *in_node = ma ? ntreeFindType(ma->nodetree, SH_NODE_BSDF_PRINCIPLED) : nullptr; + bNode *in_node = ma ? blender::bke::ntreeFindType(ma->nodetree, SH_NODE_BSDF_PRINCIPLED) : nullptr; if (!in_node) { /* An existing material or Principled BSDF node could not be found. * Copy default color values from a default Principled BSDF instead. */ @@ -6667,7 +6667,7 @@ static void default_paint_slot_color_get(int layer_type, Material *ma, float col } /* Cleanup */ if (ntree) { - ntreeFreeTree(ntree); + blender::bke::ntreeFreeTree(ntree); MEM_freeN(ntree); } return; @@ -6740,7 +6740,7 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op) nodeSetActive(ntree, new_node); /* Connect to first available principled BSDF node. */ - bNode *in_node = ntreeFindType(ntree, SH_NODE_BSDF_PRINCIPLED); + bNode *in_node = blender::bke::ntreeFindType(ntree, SH_NODE_BSDF_PRINCIPLED); bNode *out_node = new_node; if (in_node != nullptr) { @@ -6776,7 +6776,7 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op) } else if (type == LAYER_DISPLACEMENT) { /* Connect to the displacement output socket */ - in_node = ntreeFindType(ntree, SH_NODE_OUTPUT_MATERIAL); + in_node = blender::bke::ntreeFindType(ntree, SH_NODE_OUTPUT_MATERIAL); if (in_node != nullptr) { in_sock = nodeFindSocket(in_node, SOCK_IN, layer_type_items[type].name); @@ -6791,13 +6791,13 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op) if (in_sock != nullptr && link == nullptr) { nodeAddLink(ntree, out_node, out_sock, in_node, in_sock); - nodePositionRelative(out_node, in_node, out_sock, in_sock); + blender::bke::nodePositionRelative(out_node, in_node, out_sock, in_sock); } } ED_node_tree_propagate_change(C, bmain, ntree); /* In case we added more than one node, position them too. */ - nodePositionPropagate(out_node); + blender::bke::nodePositionPropagate(out_node); if (ima) { BKE_texpaint_slot_refresh_cache(scene, ma, ob); diff --git a/source/blender/editors/space_buttons/buttons_texture.cc b/source/blender/editors/space_buttons/buttons_texture.cc index 79ce0359beb..c1d42da2928 100644 --- a/source/blender/editors/space_buttons/buttons_texture.cc +++ b/source/blender/editors/space_buttons/buttons_texture.cc @@ -33,7 +33,7 @@ #include "BKE_layer.h" #include "BKE_linestyle.h" #include "BKE_modifier.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_paint.h" #include "BKE_particle.h" diff --git a/source/blender/editors/space_node/clipboard.cc b/source/blender/editors/space_node/clipboard.cc index 7f23b12067e..5ed91cd4fbe 100644 --- a/source/blender/editors/space_node/clipboard.cc +++ b/source/blender/editors/space_node/clipboard.cc @@ -6,7 +6,7 @@ #include "BKE_global.h" #include "BKE_lib_id.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" #include "BKE_report.h" @@ -315,7 +315,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) } for (bNode *new_node : node_map.values()) { - nodeDeclarationEnsure(&tree, new_node); + bke::nodeDeclarationEnsure(&tree, new_node); } remap_pairing(tree, node_map); diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index fbeb7dc0abc..ae46848cc1b 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -20,7 +20,7 @@ #include "BKE_curve.h" #include "BKE_image.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" #include "BKE_scene.h" @@ -1150,6 +1150,9 @@ void ED_node_init_butfuncs() * Defined in blenkernel, but not registered in type hashes. */ + using blender::bke::NodeTypeUndefined; + using blender::bke::NodeSocketTypeUndefined; + NodeTypeUndefined.draw_buttons = nullptr; NodeTypeUndefined.draw_buttons_ex = nullptr; diff --git a/source/blender/editors/space_node/link_drag_search.cc b/source/blender/editors/space_node/link_drag_search.cc index e656a709cfb..c95f01a3aa7 100644 --- a/source/blender/editors/space_node/link_drag_search.cc +++ b/source/blender/editors/space_node/link_drag_search.cc @@ -83,7 +83,7 @@ static void add_reroute_node_fn(nodes::LinkSearchOpParams ¶ms) static void add_group_input_node_fn(nodes::LinkSearchOpParams ¶ms) { /* Add a group input based on the connected socket, and add a new group input node. */ - bNodeSocket *interface_socket = ntreeAddSocketInterfaceFromSocket( + bNodeSocket *interface_socket = bke::ntreeAddSocketInterfaceFromSocket( ¶ms.node_tree, ¶ms.node, ¶ms.socket); const int group_input_index = BLI_findindex(¶ms.node_tree.inputs, interface_socket); diff --git a/source/blender/editors/space_node/node_add.cc b/source/blender/editors/space_node/node_add.cc index 72bd8940dac..ede12d0f520 100644 --- a/source/blender/editors/space_node/node_add.cc +++ b/source/blender/editors/space_node/node_add.cc @@ -23,7 +23,7 @@ #include "BKE_image.h" #include "BKE_lib_id.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" #include "BKE_report.h" diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index f9dec9d2a80..963972c60af 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -38,7 +38,7 @@ #include "BKE_idtype.h" #include "BKE_lib_id.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" #include "BKE_node_tree_zones.hh" @@ -312,7 +312,7 @@ static Array node_uiblocks_init(const bContext &C, const Spantypeinfo->draw((bContext *)&C, row, @@ -539,7 +539,7 @@ static void node_update_basis(const bContext &C, uiLayout *row = uiLayoutRow(layout, true); - const char *socket_label = nodeSocketLabel(socket); + const char *socket_label = bke::nodeSocketLabel(socket); const char *socket_translation_context = node_socket_get_translation_context(*socket); socket->typeinfo->draw((bContext *)&C, row, @@ -1162,7 +1162,7 @@ static char *node_socket_get_tooltip(const SpaceNode *snode, } if (output.str().empty()) { - output << nodeSocketLabel(&socket); + output << bke::nodeSocketLabel(&socket); } return BLI_strdup(output.str().c_str()); @@ -2322,7 +2322,7 @@ static void node_draw_basis(const bContext &C, } char showname[128]; - nodeLabel(&ntree, &node, showname, sizeof(showname)); + bke::nodeLabel(&ntree, &node, showname, sizeof(showname)); uiBut *but = uiDefBut(&block, UI_BTYPE_LABEL, @@ -2351,7 +2351,7 @@ static void node_draw_basis(const bContext &C, const float outline_width = 1.0f; { /* Use warning color to indicate undefined types. */ - if (nodeTypeUndefined(&node)) { + if (bke::node_type_is_undefined(&node)) { UI_GetThemeColorBlend4f(TH_REDALERT, TH_NODE, 0.4f, color); } /* Muted nodes get a mix of the background with the node color. */ @@ -2424,7 +2424,7 @@ static void node_draw_basis(const bContext &C, if (node.flag & SELECT) { UI_GetThemeColor4fv((node.flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, color_outline); } - else if (nodeTypeUndefined(&node)) { + else if (bke::node_type_is_undefined(&node)) { UI_GetThemeColor4fv(TH_REDALERT, color_outline); } else if (ELEM(node.type, GEO_NODE_SIMULATION_INPUT, GEO_NODE_SIMULATION_OUTPUT)) { @@ -2493,7 +2493,7 @@ static void node_draw_hidden(const bContext &C, /* Body. */ float color[4]; { - if (nodeTypeUndefined(&node)) { + if (bke::node_type_is_undefined(&node)) { /* Use warning color to indicate undefined types. */ UI_GetThemeColorBlend4f(TH_REDALERT, TH_NODE, 0.4f, color); } @@ -2557,7 +2557,7 @@ static void node_draw_hidden(const bContext &C, } char showname[128]; - nodeLabel(&ntree, &node, showname, sizeof(showname)); + bke::nodeLabel(&ntree, &node, showname, sizeof(showname)); uiBut *but = uiDefBut(&block, UI_BTYPE_LABEL, @@ -2590,7 +2590,7 @@ static void node_draw_hidden(const bContext &C, if (node.flag & SELECT) { UI_GetThemeColor4fv((node.flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, color_outline); } - else if (nodeTypeUndefined(&node)) { + else if (bke::node_type_is_undefined(&node)) { UI_GetThemeColor4fv(TH_REDALERT, color_outline); } else { @@ -2855,7 +2855,7 @@ static void frame_node_draw_label(TreeDrawContext &tree_draw_ctx, const float font_size = data->label_size / aspect; char label[MAX_NAME]; - nodeLabel(&ntree, &node, label, sizeof(label)); + bke::nodeLabel(&ntree, &node, label, sizeof(label)); BLF_enable(fontid, BLF_ASPECT); BLF_aspect(fontid, aspect, aspect, 1.0f); @@ -3247,14 +3247,14 @@ static void node_draw_nodetree(const bContext &C, nodelink_batch_start(snode); LISTBASE_FOREACH (const bNodeLink *, link, &ntree.links) { - if (!nodeLinkIsHidden(link) && !nodeLinkIsSelected(link)) { + if (!nodeLinkIsHidden(link) && !bke::nodeLinkIsSelected(link)) { node_draw_link(C, region.v2d, snode, *link, false); } } /* Draw selected node links after the unselected ones, so they are shown on top. */ LISTBASE_FOREACH (const bNodeLink *, link, &ntree.links) { - if (!nodeLinkIsHidden(link) && nodeLinkIsSelected(link)) { + if (!nodeLinkIsHidden(link) && bke::nodeLinkIsSelected(link)) { node_draw_link(C, region.v2d, snode, *link, true); } } diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index 878a69bd69a..c9c9f7e79d7 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -23,7 +23,7 @@ #include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_material.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" #include "BKE_report.h" @@ -206,7 +206,7 @@ static void compo_freejob(void *cjv) CompoJob *cj = (CompoJob *)cjv; if (cj->localtree) { - ntreeLocalMerge(cj->bmain, cj->localtree, cj->ntree); + bke::ntreeLocalMerge(cj->bmain, cj->localtree, cj->ntree); } if (cj->compositor_depsgraph != nullptr) { DEG_graph_free(cj->compositor_depsgraph); @@ -506,7 +506,7 @@ void ED_node_shader_default(const bContext *C, ID *id) ma_default = BKE_material_default_surface(); } - ma->nodetree = ntreeCopyTree(bmain, ma_default->nodetree); + ma->nodetree = blender::bke::ntreeCopyTree(bmain, ma_default->nodetree); ma->nodetree->owner_id = &ma->id; for (bNode *node_iter : ma->nodetree->all_nodes()) { STRNCPY_UTF8(node_iter->name, DATA_(node_iter->name)); @@ -517,7 +517,7 @@ void ED_node_shader_default(const bContext *C, ID *id) } else if (ELEM(GS(id->name), ID_WO, ID_LA)) { /* Emission */ - bNodeTree *ntree = ntreeAddTreeEmbedded( + bNodeTree *ntree = blender::bke::ntreeAddTreeEmbedded( nullptr, id, "Shader Nodetree", ntreeType_Shader->idname); bNode *shader, *output; @@ -568,7 +568,7 @@ void ED_node_composit_default(const bContext *C, Scene *sce) return; } - sce->nodetree = ntreeAddTreeEmbedded( + sce->nodetree = blender::bke::ntreeAddTreeEmbedded( nullptr, &sce->id, "Compositing Nodetree", ntreeType_Composite->idname); sce->nodetree->chunksize = 256; @@ -601,7 +601,7 @@ void ED_node_texture_default(const bContext *C, Tex *tex) return; } - tex->nodetree = ntreeAddTreeEmbedded( + tex->nodetree = blender::bke::ntreeAddTreeEmbedded( nullptr, &tex->id, "Texture Nodetree", ntreeType_Texture->idname); bNode *out = nodeAddStaticNode(C, tex->nodetree, TEX_NODE_OUTPUT); @@ -1354,7 +1354,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) } for (bNode *node : node_map.values()) { - nodeDeclarationEnsure(ntree, node); + blender::bke::nodeDeclarationEnsure(ntree, node); } /* Clear flags for recursive depth-first iteration. */ @@ -1899,7 +1899,7 @@ static int node_delete_reconnect_exec(bContext *C, wmOperator * /*op*/) LISTBASE_FOREACH_MUTABLE (bNode *, node, &snode->edittree->nodes) { if (node->flag & SELECT) { - nodeInternalRelink(snode->edittree, node); + blender::bke::nodeInternalRelink(snode->edittree, node); nodeRemoveNode(bmain, snode->edittree, node, true); } } @@ -2186,7 +2186,7 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op) bNodeSocket *sock; if (active_sock) { /* Insert a copy of the active socket right after it. */ - sock = ntreeInsertSocketInterface( + sock = blender::bke::ntreeInsertSocketInterface( ntree, in_out, active_sock->idname, active_sock->next, active_sock->name); /* XXX this only works for actual sockets, not interface templates! */ // nodeSocketCopyValue(sock, &ntree_ptr, active_sock, &ntree_ptr); @@ -2304,7 +2304,7 @@ static int ntree_socket_change_type_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - nodeModifySocketType(ntree, nullptr, iosock, socket_type->idname); + blender::bke::nodeModifySocketType(ntree, nullptr, iosock, socket_type->idname); /* Need the extra update here because the loop above does not check for valid links in the node * group we're currently editing. */ diff --git a/source/blender/editors/space_node/node_group.cc b/source/blender/editors/space_node/node_group.cc index 4e254cdb3f1..af0aa7879bd 100644 --- a/source/blender/editors/space_node/node_group.cc +++ b/source/blender/editors/space_node/node_group.cc @@ -250,7 +250,7 @@ static bool node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode) * - `ngroup` (i.e. the source NodeTree) is left unscathed. * - Temp copy. do change ID user-count for the copies. */ - bNodeTree *wgroup = ntreeCopyTree(bmain, ngroup); + bNodeTree *wgroup = bke::ntreeCopyTree(bmain, ngroup); /* Add the nodes into the `ntree`. */ Vector new_nodes; @@ -529,7 +529,7 @@ static bool node_group_separate_selected( } } if (!make_copy) { - nodeRebuildIDVector(&ngroup); + bke::nodeRebuildIDVector(&ngroup); } /* add internal links to the ntree */ @@ -562,7 +562,7 @@ static bool node_group_separate_selected( remap_pairing(ntree, nodes_to_move, node_identifier_map); for (bNode *node : node_map.values()) { - nodeDeclarationEnsure(&ntree, node); + bke::nodeDeclarationEnsure(&ntree, node); } /* and copy across the animation, @@ -697,7 +697,7 @@ static bool node_group_make_test_selected(bNodeTree &ntree, /* make a local pseudo node tree to pass to the node poll functions */ bNodeTree *ngroup = ntreeAddTree(nullptr, "Pseudo Node Group", ntree_idname); BLI_SCOPED_DEFER([&]() { - ntreeFreeTree(ngroup); + bke::ntreeFreeTree(ngroup); MEM_freeN(ngroup); }); @@ -791,7 +791,7 @@ static void get_min_max_of_nodes(const Span nodes, INIT_MINMAX2(min, max); for (const bNode *node : nodes) { float2 loc; - nodeToView(node, node->offsetx, node->offsety, &loc.x, &loc.y); + bke::nodeToView(node, node->offsetx, node->offsety, &loc.x, &loc.y); math::min_max(loc, min, max); if (use_size) { loc.x += node->width; @@ -844,11 +844,11 @@ static bNodeSocket *add_interface_from_socket(const bNodeTree &original_tree, const bNodeSocket &socket_for_name = prefer_node_for_interface_name(socket.owner_node()) ? socket : socket_for_io; - return ntreeAddSocketInterfaceFromSocketWithName(&tree_for_interface, - &node_for_io, - &socket_for_io, - socket_for_io.idname, - socket_for_name.name); + return bke::ntreeAddSocketInterfaceFromSocketWithName(&tree_for_interface, + &node_for_io, + &socket_for_io, + socket_for_io.idname, + socket_for_name.name); } static void node_group_make_insert_selected(const bContext &C, @@ -960,7 +960,8 @@ static void node_group_make_insert_selected(const bContext &C, if (socket->is_directly_linked()) { continue; } - const bNodeSocket *io_socket = ntreeAddSocketInterfaceFromSocket(&group, node, socket); + const bNodeSocket *io_socket = bke::ntreeAddSocketInterfaceFromSocket( + &group, node, socket); new_internal_links.append({node, socket, io_socket}); } }; @@ -1012,7 +1013,7 @@ static void node_group_make_insert_selected(const bContext &C, BKE_ntree_update_tag_node_removed(&ntree); BKE_ntree_update_tag_node_new(&group, node); } - nodeRebuildIDVector(&ntree); + bke::nodeRebuildIDVector(&ntree); /* Update input and output node first, since the group node declaration can depend on them. */ nodes::update_node_declaration_and_sockets(group, *input_node); diff --git a/source/blender/editors/space_node/node_intern.hh b/source/blender/editors/space_node/node_intern.hh index 8a03fb37634..cb93ff37533 100644 --- a/source/blender/editors/space_node/node_intern.hh +++ b/source/blender/editors/space_node/node_intern.hh @@ -12,7 +12,7 @@ #include "BLI_vector.hh" #include "BLI_vector_set.hh" -#include "BKE_node.h" +#include "BKE_node.hh" #include "UI_interface.h" #include "UI_interface.hh" diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index bd6d0594e6c..b31b38f4318 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -18,7 +18,7 @@ #include "BKE_curve.h" #include "BKE_lib_id.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" #include "BKE_screen.h" @@ -1643,7 +1643,7 @@ static int mute_links_exec(bContext *C, wmOperator *op) bke::node_tree_runtime::AllowUsingOutdatedInfo allow_outdated_info{ntree}; for (bNodeLink *link : affected_links) { - nodeLinkSetMute(&ntree, link, !(link->flag & NODE_LINK_MUTED)); + bke::nodeLinkSetMute(&ntree, link, !(link->flag & NODE_LINK_MUTED)); const bool muted = link->flag & NODE_LINK_MUTED; /* Propagate mute status downstream past reroute nodes. */ @@ -1652,7 +1652,7 @@ static int mute_links_exec(bContext *C, wmOperator *op) links.push_multiple(link->tonode->output_socket(0).directly_linked_links()); while (!links.is_empty()) { bNodeLink *link = links.pop(); - nodeLinkSetMute(&ntree, link, muted); + bke::nodeLinkSetMute(&ntree, link, muted); if (!link->tonode->is_reroute()) { continue; } @@ -1666,7 +1666,7 @@ static int mute_links_exec(bContext *C, wmOperator *op) links.push_multiple(link->fromnode->input_socket(0).directly_linked_links()); while (!links.is_empty()) { bNodeLink *link = links.pop(); - nodeLinkSetMute(&ntree, link, muted); + bke::nodeLinkSetMute(&ntree, link, muted); if (!link->fromnode->is_reroute()) { continue; } @@ -1722,7 +1722,7 @@ static int detach_links_exec(bContext *C, wmOperator * /*op*/) for (bNode *node : ntree.all_nodes()) { if (node->flag & SELECT) { - nodeInternalRelink(&ntree, node); + bke::nodeInternalRelink(&ntree, node); } } @@ -2254,7 +2254,7 @@ bNodeSocket *get_main_socket(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_ ListBase *sockets = (in_out == SOCK_IN) ? &node.inputs : &node.outputs; /* Try to get the main socket based on the socket declaration. */ - nodeDeclarationEnsure(&ntree, &node); + bke::nodeDeclarationEnsure(&ntree, &node); const nodes::NodeDeclaration *node_decl = node.declaration(); if (node_decl != nullptr) { Span socket_decls = (in_out == SOCK_IN) ? node_decl->inputs : @@ -2371,7 +2371,7 @@ static void node_link_insert_offset_frame_chains(bNodeTree *ntree, { for (bNode *node : ntree->all_nodes()) { if (nodeIsParentAndChild(parent, node)) { - nodeChainIter(ntree, node, node_link_insert_offset_frame_chain_cb, data, reversed); + bke::nodeChainIter(ntree, node, node_link_insert_offset_frame_chain_cb, data, reversed); } } } @@ -2402,7 +2402,7 @@ static bool node_link_insert_offset_chain_cb(bNode *fromnode, } } else if (ofs_node->parent) { - bNode *node = nodeFindRootParent(ofs_node); + bNode *node = bke::nodeFindRootParent(ofs_node); node_offset_apply(*node, data->offset_x); } else { @@ -2430,7 +2430,7 @@ static void node_link_insert_offset_ntree(NodeInsertOfsData *iofsd, float margin = width; /* NODE_TEST will be used later, so disable for all nodes */ - ntreeNodeFlagSet(ntree, NODE_TEST, false); + bke::ntreeNodeFlagSet(ntree, NODE_TEST, false); /* `insert.totr` isn't updated yet, * so `totr_insert` is used to get the correct world-space coords. */ @@ -2505,7 +2505,7 @@ static void node_link_insert_offset_ntree(NodeInsertOfsData *iofsd, node_offset_apply(*offs_node, addval); } else if (!insert.parent && offs_node->parent) { - node_offset_apply(*nodeFindRootParent(offs_node), addval); + node_offset_apply(*bke::nodeFindRootParent(offs_node), addval); } margin = addval; } @@ -2521,13 +2521,13 @@ static void node_link_insert_offset_ntree(NodeInsertOfsData *iofsd, iofsd->offset_x = margin; /* flag all parents of insert as offset to prevent them from being offset */ - nodeParentsIter(&insert, node_parents_offset_flag_enable_cb, nullptr); + bke::nodeParentsIter(&insert, node_parents_offset_flag_enable_cb, nullptr); /* iterate over entire chain and apply offsets */ - nodeChainIter(ntree, - right_alignment ? next : prev, - node_link_insert_offset_chain_cb, - iofsd, - !right_alignment); + bke::nodeChainIter(ntree, + right_alignment ? next : prev, + node_link_insert_offset_chain_cb, + iofsd, + !right_alignment); } insert.parent = init_parent; diff --git a/source/blender/editors/space_node/node_select.cc b/source/blender/editors/space_node/node_select.cc index f4f5ee8e94c..bc6601ed0bb 100644 --- a/source/blender/editors/space_node/node_select.cc +++ b/source/blender/editors/space_node/node_select.cc @@ -21,7 +21,7 @@ #include "BKE_context.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" #include "BKE_workspace.h" diff --git a/source/blender/editors/space_node/node_templates.cc b/source/blender/editors/space_node/node_templates.cc index 42afb4ae794..a72af23bfb7 100644 --- a/source/blender/editors/space_node/node_templates.cc +++ b/source/blender/editors/space_node/node_templates.cc @@ -236,7 +236,7 @@ static void node_socket_add_replace(const bContext *C, } else { sock_from_tmp = (bNodeSocket *)BLI_findlink(&node_from->outputs, item->socket_index); - nodePositionRelative(node_from, node_to, sock_from_tmp, sock_to); + bke::nodePositionRelative(node_from, node_to, sock_from_tmp, sock_to); } node_link_item_apply(ntree, node_from, item); @@ -468,7 +468,7 @@ static void ui_node_sock_name(const bNodeTree *ntree, bNode *node = sock->link->fromnode; char node_name[UI_MAX_NAME_STR]; - nodeLabel(ntree, node, node_name, sizeof(node_name)); + bke::nodeLabel(ntree, node, node_name, sizeof(node_name)); if (BLI_listbase_is_empty(&node->inputs) && node->outputs.first != node->outputs.last) { BLI_snprintf( @@ -834,7 +834,7 @@ static void ui_node_draw_input( sub = uiLayoutRow(sub, true); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); - uiItemL(sub, IFACE_(nodeSocketLabel(&input)), ICON_NONE); + uiItemL(sub, IFACE_(bke::nodeSocketLabel(&input)), ICON_NONE); } if (dependency_loop) { diff --git a/source/blender/editors/space_node/node_view.cc b/source/blender/editors/space_node/node_view.cc index d6b04eefa94..7ae833e8473 100644 --- a/source/blender/editors/space_node/node_view.cc +++ b/source/blender/editors/space_node/node_view.cc @@ -15,7 +15,7 @@ #include "BKE_context.h" #include "BKE_image.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_screen.h" diff --git a/source/blender/editors/space_node/space_node.cc b/source/blender/editors/space_node/space_node.cc index ace5c43a36e..b0a9bf97743 100644 --- a/source/blender/editors/space_node/space_node.cc +++ b/source/blender/editors/space_node/space_node.cc @@ -18,7 +18,7 @@ #include "BKE_gpencil_legacy.h" #include "BKE_lib_id.h" #include "BKE_lib_remap.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_screen.h" diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index 83f2bc83098..009835ef83f 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -39,7 +39,7 @@ #include "BKE_main.h" #include "BKE_main_namemap.h" #include "BKE_modifier.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_report.h" diff --git a/source/blender/editors/transform/transform_convert_node.cc b/source/blender/editors/transform/transform_convert_node.cc index 196873b3926..24e519dc412 100644 --- a/source/blender/editors/transform/transform_convert_node.cc +++ b/source/blender/editors/transform/transform_convert_node.cc @@ -14,7 +14,7 @@ #include "BLI_rect.h" #include "BKE_context.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" #include "BKE_report.h" @@ -48,7 +48,7 @@ static void create_transform_data_for_node(TransData &td, /* account for parents (nested nodes) */ if (node.parent) { - nodeToView(node.parent, + blender::bke::nodeToView(node.parent, node.locx + roundf(node.offsetx), node.locy + roundf(node.offsety), &locx, @@ -249,7 +249,7 @@ static void flushTransNodes(TransInfo *t) /* account for parents (nested nodes) */ if (node->parent) { - nodeFromView(node->parent, + blender::bke::nodeFromView(node->parent, loc[0] - roundf(node->offsetx), loc[1] - roundf(node->offsety), &node->locx, diff --git a/source/blender/editors/undo/memfile_undo.cc b/source/blender/editors/undo/memfile_undo.cc index 4d50fff4fbc..283de8ab66b 100644 --- a/source/blender/editors/undo/memfile_undo.cc +++ b/source/blender/editors/undo/memfile_undo.cc @@ -25,7 +25,7 @@ #include "BKE_lib_id.h" #include "BKE_lib_query.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_scene.h" #include "BKE_undo_system.h" diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index f00e97d3321..efdfabd5981 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -36,7 +36,7 @@ #include "BKE_main.h" #include "BKE_material.h" #include "BKE_mesh.hh" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_tree_update.h" #include "BKE_object.h" #include "BKE_scene.h" @@ -214,7 +214,7 @@ Material *BlenderStrokeRenderer::GetStrokeShader(Main *bmain, if (iNodeTree) { // make a copy of linestyle->nodetree - ntree = ntreeCopyTree_ex(iNodeTree, bmain, do_id_user); + ntree = blender::bke::ntreeCopyTree_ex(iNodeTree, bmain, do_id_user); // find the active Output Line Style node for (bNode *node = (bNode *)ntree->nodes.first; node; node = node->next) { @@ -226,7 +226,8 @@ Material *BlenderStrokeRenderer::GetStrokeShader(Main *bmain, ma->nodetree = ntree; } else { - ntree = ntreeAddTreeEmbedded(nullptr, &ma->id, "stroke_shader", "ShaderNodeTree"); + ntree = blender::bke::ntreeAddTreeEmbedded( + nullptr, &ma->id, "stroke_shader", "ShaderNodeTree"); } ma->use_nodes = true; ma->blend_method = MA_BM_HASHED; diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp index af1f5b851c0..13e27f3a3ba 100644 --- a/source/blender/freestyle/intern/stroke/Stroke.cpp +++ b/source/blender/freestyle/intern/stroke/Stroke.cpp @@ -11,7 +11,7 @@ #include "StrokeRenderer.h" #include "BKE_global.h" -#include "BKE_node.h" +#include "BKE_node.hh" namespace Freestyle { diff --git a/source/blender/gpu/intern/gpu_shader_builder_stubs.cc b/source/blender/gpu/intern/gpu_shader_builder_stubs.cc index b0ccc8844d6..ebcff8e3a29 100644 --- a/source/blender/gpu/intern/gpu_shader_builder_stubs.cc +++ b/source/blender/gpu/intern/gpu_shader_builder_stubs.cc @@ -17,7 +17,7 @@ #include "BKE_global.h" #include "BKE_material.h" #include "BKE_mesh.hh" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_paint.h" #include "BKE_pbvh.h" #include "BKE_subdiv_ccg.h" diff --git a/source/blender/io/collada/Materials.cpp b/source/blender/io/collada/Materials.cpp index d09b3b79fa7..3170af05817 100644 --- a/source/blender/io/collada/Materials.cpp +++ b/source/blender/io/collada/Materials.cpp @@ -2,6 +2,8 @@ #include "Materials.h" +#include "BKE_node.hh" + #include "BKE_node_tree_update.h" MaterialNode::MaterialNode(bContext *C, Material *ma, KeyImageMap &key_image_map) @@ -86,7 +88,7 @@ bNodeTree *MaterialNode::prepare_material_nodetree() return nullptr; } - ntreeAddTreeEmbedded(nullptr, &material->id, "Shader Nodetree", "ShaderNodeTree"); + blender::bke::ntreeAddTreeEmbedded(nullptr, &material->id, "Shader Nodetree", "ShaderNodeTree"); material->use_nodes = true; ntree = material->nodetree; return ntree; @@ -247,7 +249,7 @@ void MaterialNode::set_diffuse(COLLADAFW::ColorOrTexture &cot) Image *MaterialNode::get_diffuse_image() { - bNode *shader = ntreeFindType(ntree, SH_NODE_BSDF_PRINCIPLED); + bNode *shader = blender::bke::ntreeFindType(ntree, SH_NODE_BSDF_PRINCIPLED); if (shader == nullptr) { return nullptr; } diff --git a/source/blender/io/collada/collada_utils.cpp b/source/blender/io/collada/collada_utils.cpp index 0324d55ea0e..d1c8a34e7d6 100644 --- a/source/blender/io/collada/collada_utils.cpp +++ b/source/blender/io/collada/collada_utils.cpp @@ -42,7 +42,7 @@ #include "BKE_mesh.hh" #include "BKE_mesh_legacy_convert.h" #include "BKE_mesh_runtime.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_object.h" #include "BKE_scene.h" @@ -1114,7 +1114,7 @@ static std::string bc_get_uvlayer_name(Mesh *me, int layer) static bNodeTree *prepare_material_nodetree(Material *ma) { if (ma->nodetree == nullptr) { - ntreeAddTreeEmbedded(nullptr, &ma->id, "Shader Nodetree", "ShaderNodeTree"); + blender::bke::ntreeAddTreeEmbedded(nullptr, &ma->id, "Shader Nodetree", "ShaderNodeTree"); ma->use_nodes = true; } return ma->nodetree; diff --git a/source/blender/io/usd/intern/usd_capi_import.cc b/source/blender/io/usd/intern/usd_capi_import.cc index c9687e13a1f..c2d5aaeaab8 100644 --- a/source/blender/io/usd/intern/usd_capi_import.cc +++ b/source/blender/io/usd/intern/usd_capi_import.cc @@ -19,7 +19,7 @@ #include "BKE_lib_id.h" #include "BKE_library.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_object.h" #include "BKE_scene.h" #include "BKE_world.h" diff --git a/source/blender/io/usd/intern/usd_reader_material.cc b/source/blender/io/usd/intern/usd_reader_material.cc index d26c183acd0..ae474e01391 100644 --- a/source/blender/io/usd/intern/usd_reader_material.cc +++ b/source/blender/io/usd/intern/usd_reader_material.cc @@ -10,7 +10,7 @@ #include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_material.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_tree_update.h" #include "BLI_fileops.h" @@ -374,7 +374,7 @@ void USDMaterialReader::import_usd_preview(Material *mtl, * and output shaders. */ /* Add the node tree. */ - bNodeTree *ntree = ntreeAddTreeEmbedded(nullptr, &mtl->id, "Shader Nodetree", "ShaderNodeTree"); + bNodeTree *ntree = blender::bke::ntreeAddTreeEmbedded(nullptr, &mtl->id, "Shader Nodetree", "ShaderNodeTree"); mtl->use_nodes = true; /* Create the Principled BSDF shader node. */ diff --git a/source/blender/io/usd/intern/usd_writer_material.cc b/source/blender/io/usd/intern/usd_writer_material.cc index ed868338f91..31fffb63037 100644 --- a/source/blender/io/usd/intern/usd_writer_material.cc +++ b/source/blender/io/usd/intern/usd_writer_material.cc @@ -8,7 +8,7 @@ #include "BKE_image.h" #include "BKE_image_format.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "IMB_colormanagement.h" diff --git a/source/blender/io/usd/tests/usd_export_test.cc b/source/blender/io/usd/tests/usd_export_test.cc index fe9d35254ca..292dd580bd1 100644 --- a/source/blender/io/usd/tests/usd_export_test.cc +++ b/source/blender/io/usd/tests/usd_export_test.cc @@ -22,7 +22,7 @@ #include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_mesh.hh" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BLI_fileops.h" #include "BLI_math.h" #include "BLI_math_vector_types.hh" diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc b/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc index db92890df59..86bd796e8a7 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc @@ -5,7 +5,7 @@ */ #include "BKE_image.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BLI_map.hh" diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc b/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc index 50ed1e56711..3c9340ec92f 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc @@ -6,7 +6,7 @@ #include "BKE_image.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BLI_map.hh" #include "BLI_math_vector.h" @@ -410,7 +410,7 @@ bNodeTree *create_mtl_node_tree(Main *bmain, Material *mat, bool relative_paths) { - bNodeTree *ntree = ntreeAddTreeEmbedded( + bNodeTree *ntree = blender::bke::ntreeAddTreeEmbedded( nullptr, &mat->id, "Shader Nodetree", ntreeType_Shader->idname); bNode *bsdf = add_node(ntree, SH_NODE_BSDF_PRINCIPLED, node_locx_bsdf, node_locy_top); diff --git a/source/blender/makesrna/intern/rna_access.cc b/source/blender/makesrna/intern/rna_access.cc index f58b3ee77d6..0bcf768d126 100644 --- a/source/blender/makesrna/intern/rna_access.cc +++ b/source/blender/makesrna/intern/rna_access.cc @@ -37,7 +37,7 @@ #include "BKE_idtype.h" #include "BKE_lib_override.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_report.h" #include "DEG_depsgraph.h" diff --git a/source/blender/nodes/composite/node_composite_tree.cc b/source/blender/nodes/composite/node_composite_tree.cc index 9d442e8ea95..b07c38c8682 100644 --- a/source/blender/nodes/composite/node_composite_tree.cc +++ b/source/blender/nodes/composite/node_composite_tree.cc @@ -17,7 +17,7 @@ #include "BKE_global.h" #include "BKE_image.h" #include "BKE_main.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" #include "BKE_tracking.h" @@ -75,7 +75,7 @@ static void localize(bNodeTree *localtree, bNodeTree *ntree) local_node->runtime->original = node; /* move over the compbufs */ - /* right after #ntreeCopyTree() `oldsock` pointers are valid */ + /* right after #blender::bke::ntreeCopyTree() `oldsock` pointers are valid */ if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { if (node->id) { @@ -96,7 +96,7 @@ static void localize(bNodeTree *localtree, bNodeTree *ntree) static void local_merge(Main *bmain, bNodeTree *localtree, bNodeTree *ntree) { /* move over the compbufs and previews */ - BKE_node_preview_merge_tree(ntree, localtree, true); + blender::bke::node_preview_merge_tree(ntree, localtree, true); for (bNode *lnode = (bNode *)localtree->nodes.first; lnode; lnode = lnode->next) { if (bNode *orig_node = nodeFindNodebyName(ntree, lnode->name)) { @@ -142,7 +142,7 @@ static void composite_node_add_init(bNodeTree * /*bnodetree*/, bNode *bnode) static bool composite_node_tree_socket_type_valid(bNodeTreeType * /*ntreetype*/, bNodeSocketType *socket_type) { - return nodeIsStaticSocketType(socket_type) && + return blender::bke::nodeIsStaticSocketType(socket_type) && ELEM(socket_type->type, SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA); } diff --git a/source/blender/nodes/composite/node_composite_util.cc b/source/blender/nodes/composite/node_composite_util.cc index c09f6febbb8..3e74adfad45 100644 --- a/source/blender/nodes/composite/node_composite_util.cc +++ b/source/blender/nodes/composite/node_composite_util.cc @@ -30,7 +30,7 @@ void cmp_node_update_default(bNodeTree * /*ntree*/, bNode *node) void cmp_node_type_base(bNodeType *ntype, int type, const char *name, short nclass) { - node_type_base(ntype, type, name, nclass); + blender::bke::node_type_base(ntype, type, name, nclass); ntype->poll = cmp_node_poll_default; ntype->updatefunc = cmp_node_update_default; diff --git a/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc b/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc index 2784d92d884..346e70df78b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc +++ b/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc @@ -106,7 +106,7 @@ void register_node_type_cmp_antialiasing() ntype.declare = file_ns::cmp_node_antialiasing_declare; ntype.draw_buttons = file_ns::node_composit_buts_antialiasing; ntype.flag |= NODE_PREVIEW; - node_type_size(&ntype, 170, 140, 200); + blender::bke::node_type_size(&ntype, 170, 140, 200); ntype.initfunc = file_ns::node_composit_init_antialiasing; node_type_storage( &ntype, "NodeAntiAliasingData", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.cc b/source/blender/nodes/composite/nodes/node_composite_colorbalance.cc index 03fb050103c..28a803dae4f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.cc +++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.cc @@ -209,7 +209,7 @@ void register_node_type_cmp_colorbalance() ntype.declare = file_ns::cmp_node_colorbalance_declare; ntype.draw_buttons = file_ns::node_composit_buts_colorbalance; ntype.draw_buttons_ex = file_ns::node_composit_buts_colorbalance_ex; - node_type_size(&ntype, 400, 200, 400); + blender::bke::node_type_size(&ntype, 400, 200, 400); ntype.initfunc = file_ns::node_composit_init_colorbalance; node_type_storage( &ntype, "NodeColorBalance", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/composite/nodes/node_composite_colorcorrection.cc b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.cc index a6cebe6d3cb..4bca14d718a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorcorrection.cc +++ b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.cc @@ -352,7 +352,7 @@ void register_node_type_cmp_colorcorrection() ntype.declare = file_ns::cmp_node_colorcorrection_declare; ntype.draw_buttons = file_ns::node_composit_buts_colorcorrection; ntype.draw_buttons_ex = file_ns::node_composit_buts_colorcorrection_ex; - node_type_size(&ntype, 400, 200, 600); + blender::bke::node_type_size(&ntype, 400, 200, 600); ntype.initfunc = file_ns::node_composit_init_colorcorrection; node_type_storage( &ntype, "NodeColorCorrection", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/composite/nodes/node_composite_common.cc b/source/blender/nodes/composite/nodes/node_composite_common.cc index d3bb8b62a6e..093035c7a14 100644 --- a/source/blender/nodes/composite/nodes/node_composite_common.cc +++ b/source/blender/nodes/composite/nodes/node_composite_common.cc @@ -11,7 +11,7 @@ #include "node_common.h" #include "node_composite_util.hh" -#include "BKE_node.h" +#include "BKE_node.hh" #include "RNA_access.h" @@ -30,7 +30,7 @@ void register_node_type_cmp_group() BLI_assert(ntype.rna_ext.srna != nullptr); RNA_struct_blender_type_set(ntype.rna_ext.srna, &ntype); - node_type_size(&ntype, 140, 60, 400); + blender::bke::node_type_size(&ntype, 140, 60, 400); ntype.labelfunc = node_group_label; ntype.declare_dynamic = blender::nodes::node_group_declare_dynamic; diff --git a/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc b/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc index e4bdda692a5..3522793d099 100644 --- a/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc +++ b/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc @@ -159,7 +159,7 @@ void register_node_type_cmp_convert_color_space(void) &ntype, CMP_NODE_CONVERT_COLOR_SPACE, "Convert Colorspace", NODE_CLASS_CONVERTER); ntype.declare = file_ns::CMP_NODE_CONVERT_COLOR_SPACE_declare; ntype.draw_buttons = file_ns::node_composit_buts_convert_colorspace; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.initfunc = file_ns::node_composit_init_convert_colorspace; node_type_storage( &ntype, "NodeConvertColorSpace", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc index 24a53274b39..5203609ba30 100644 --- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc @@ -334,9 +334,9 @@ void register_node_type_cmp_cryptomatte() static bNodeType ntype; cmp_node_type_base(&ntype, CMP_NODE_CRYPTOMATTE, "Cryptomatte", NODE_CLASS_MATTE); - node_type_socket_templates( + blender::bke::node_type_socket_templates( &ntype, file_ns::cmp_node_cryptomatte_in, file_ns::cmp_node_cryptomatte_out); - node_type_size(&ntype, 240, 100, 700); + blender::bke::node_type_size(&ntype, 240, 100, 700); ntype.initfunc = file_ns::node_init_cryptomatte; ntype.initfunc_api = file_ns::node_init_api_cryptomatte; ntype.poll = file_ns::node_poll_cryptomatte; @@ -426,7 +426,7 @@ void register_node_type_cmp_cryptomatte_legacy() cmp_node_type_base( &ntype, CMP_NODE_CRYPTOMATTE_LEGACY, "Cryptomatte (Legacy)", NODE_CLASS_MATTE); - node_type_socket_templates(&ntype, nullptr, file_ns::cmp_node_cryptomatte_out); + blender::bke::node_type_socket_templates(&ntype, nullptr, file_ns::cmp_node_cryptomatte_out); ntype.initfunc = legacy_file_ns::node_init_cryptomatte_legacy; node_type_storage( &ntype, "NodeCryptomatte", file_ns::node_free_cryptomatte, file_ns::node_copy_cryptomatte); diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.cc b/source/blender/nodes/composite/nodes/node_composite_curves.cc index a5f52bbfe28..2e748ce99fa 100644 --- a/source/blender/nodes/composite/nodes/node_composite_curves.cc +++ b/source/blender/nodes/composite/nodes/node_composite_curves.cc @@ -99,7 +99,7 @@ void register_node_type_cmp_curve_time() cmp_node_type_base(&ntype, CMP_NODE_TIME, "Time Curve", NODE_CLASS_INPUT); ntype.declare = file_ns::cmp_node_time_declare; - node_type_size(&ntype, 200, 140, 320); + blender::bke::node_type_size(&ntype, 200, 140, 320); ntype.initfunc = file_ns::node_composit_init_curves_time; node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); ntype.get_compositor_operation = file_ns::get_compositor_operation; @@ -194,7 +194,7 @@ void register_node_type_cmp_curve_vec() cmp_node_type_base(&ntype, CMP_NODE_CURVE_VEC, "Vector Curves", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::cmp_node_curve_vec_declare; ntype.draw_buttons = file_ns::node_buts_curvevec; - node_type_size(&ntype, 200, 140, 320); + blender::bke::node_type_size(&ntype, 200, 140, 320); ntype.initfunc = file_ns::node_composit_init_curve_vec; node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; @@ -332,7 +332,7 @@ void register_node_type_cmp_curve_rgb() cmp_node_type_base(&ntype, CMP_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::cmp_node_rgbcurves_declare; - node_type_size(&ntype, 200, 140, 320); + blender::bke::node_type_size(&ntype, 200, 140, 320); ntype.initfunc = file_ns::node_composit_init_curve_rgb; node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.cc b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.cc index 8a755643d9d..ffe68317954 100644 --- a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.cc +++ b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.cc @@ -163,7 +163,7 @@ void register_node_type_cmp_ellipsemask() cmp_node_type_base(&ntype, CMP_NODE_MASK_ELLIPSE, "Ellipse Mask", NODE_CLASS_MATTE); ntype.declare = file_ns::cmp_node_ellipsemask_declare; ntype.draw_buttons = file_ns::node_composit_buts_ellipsemask; - node_type_size(&ntype, 260, 110, 320); + blender::bke::node_type_size(&ntype, 260, 110, 320); ntype.initfunc = file_ns::node_composit_init_ellipsemask; node_type_storage( &ntype, "NodeEllipseMask", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc b/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc index 7f72b637089..c00c662006e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc +++ b/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc @@ -105,7 +105,7 @@ void register_node_type_cmp_huecorrect() cmp_node_type_base(&ntype, CMP_NODE_HUECORRECT, "Hue Correct", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::cmp_node_huecorrect_declare; - node_type_size(&ntype, 320, 140, 500); + blender::bke::node_type_size(&ntype, 320, 140, 500); ntype.initfunc = file_ns::node_composit_init_huecorrect; node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_image.cc b/source/blender/nodes/composite/nodes/node_composite_image.cc index af5f4e75ad0..1d91dc52feb 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.cc +++ b/source/blender/nodes/composite/nodes/node_composite_image.cc @@ -375,7 +375,7 @@ static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node, bool rl sock_next = sock->next; if (BLI_linklist_index(available_sockets.list, sock) >= 0) { sock->flag &= ~SOCK_HIDDEN; - nodeSetSocketAvailability(ntree, sock, true); + blender::bke::nodeSetSocketAvailability(ntree, sock, true); } else { bNodeLink *link; @@ -389,7 +389,7 @@ static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node, bool rl nodeRemoveSocket(ntree, node, sock); } else { - nodeSetSocketAvailability(ntree, sock, false); + blender::bke::nodeSetSocketAvailability(ntree, sock, false); } } } @@ -918,7 +918,7 @@ void register_node_type_cmp_rlayers() static bNodeType ntype; cmp_node_type_base(&ntype, CMP_NODE_R_LAYERS, "Render Layers", NODE_CLASS_INPUT); - node_type_socket_templates(&ntype, nullptr, cmp_node_rlayers_out); + blender::bke::node_type_socket_templates(&ntype, nullptr, cmp_node_rlayers_out); ntype.draw_buttons = file_ns::node_composit_buts_viewlayers; ntype.initfunc_api = file_ns::node_composit_init_rlayers; ntype.poll = file_ns::node_composit_poll_rlayers; @@ -930,7 +930,7 @@ void register_node_type_cmp_rlayers() &ntype, nullptr, file_ns::node_composit_free_rlayers, file_ns::node_composit_copy_rlayers); ntype.updatefunc = file_ns::cmp_node_rlayers_update; ntype.initfunc = node_cmp_rlayers_outputs; - node_type_size_preset(&ntype, NODE_SIZE_LARGE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::LARGE); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_rgb.cc b/source/blender/nodes/composite/nodes/node_composite_rgb.cc index 5b52a233af4..1fc646b480a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_rgb.cc +++ b/source/blender/nodes/composite/nodes/node_composite_rgb.cc @@ -55,7 +55,7 @@ void register_node_type_cmp_rgb() cmp_node_type_base(&ntype, CMP_NODE_RGB, "RGB", NODE_CLASS_INPUT); ntype.declare = file_ns::cmp_node_rgb_declare; - node_type_size_preset(&ntype, NODE_SIZE_DEFAULT); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::DEFAULT); ntype.get_compositor_operation = file_ns::get_compositor_operation; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_scale.cc b/source/blender/nodes/composite/nodes/node_composite_scale.cc index addf3a905b2..22d8d76fb9f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_scale.cc +++ b/source/blender/nodes/composite/nodes/node_composite_scale.cc @@ -49,7 +49,7 @@ static void node_composite_update_scale(bNodeTree *ntree, bNode *node) /* Only show X/Y scale factor inputs for modes using them! */ for (sock = (bNodeSocket *)node->inputs.first; sock; sock = sock->next) { if (STR_ELEM(sock->name, "X", "Y")) { - nodeSetSocketAvailability(ntree, sock, use_xy_scale); + bke::nodeSetSocketAvailability(ntree, sock, use_xy_scale); } } } diff --git a/source/blender/nodes/composite/nodes/node_composite_switch.cc b/source/blender/nodes/composite/nodes/node_composite_switch.cc index c5eb19cb8ef..bde8429180b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_switch.cc +++ b/source/blender/nodes/composite/nodes/node_composite_switch.cc @@ -63,7 +63,7 @@ void register_node_type_cmp_switch() cmp_node_type_base(&ntype, CMP_NODE_SWITCH, "Switch", NODE_CLASS_LAYOUT); ntype.declare = file_ns::cmp_node_switch_declare; ntype.draw_buttons = file_ns::node_composit_buts_switch; - node_type_size_preset(&ntype, NODE_SIZE_DEFAULT); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::DEFAULT); ntype.get_compositor_operation = file_ns::get_compositor_operation; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_switchview.cc b/source/blender/nodes/composite/nodes/node_composite_switchview.cc index 4b3f5ab8b59..62050a78be2 100644 --- a/source/blender/nodes/composite/nodes/node_composite_switchview.cc +++ b/source/blender/nodes/composite/nodes/node_composite_switchview.cc @@ -53,7 +53,7 @@ static void cmp_node_switch_view_update(bNodeTree *ntree, bNode *node) } if (scene == nullptr) { - nodeRemoveAllSockets(ntree, node); + blender::bke::nodeRemoveAllSockets(ntree, node); /* make sure there is always one socket */ cmp_node_switch_view_sanitycheck(ntree, node); return; @@ -170,7 +170,7 @@ void register_node_type_cmp_switch_view() static bNodeType ntype; cmp_node_type_base(&ntype, CMP_NODE_SWITCH_VIEW, "Switch View", NODE_CLASS_CONVERTER); - node_type_socket_templates(&ntype, nullptr, file_ns::cmp_node_switch_view_out); + blender::bke::node_type_socket_templates(&ntype, nullptr, file_ns::cmp_node_switch_view_out); ntype.draw_buttons_ex = file_ns::node_composit_buts_switch_view_ex; ntype.initfunc_api = file_ns::init_switch_view; ntype.updatefunc = file_ns::cmp_node_switch_view_update; diff --git a/source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc b/source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc index 90db2cdc761..8379fd27193 100644 --- a/source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc +++ b/source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc @@ -137,7 +137,7 @@ void register_node_type_cmp_valtorgb() cmp_node_type_base(&ntype, CMP_NODE_VALTORGB, "Color Ramp", NODE_CLASS_CONVERTER); ntype.declare = file_ns::cmp_node_valtorgb_declare; - node_type_size(&ntype, 240, 200, 320); + blender::bke::node_type_size(&ntype, 240, 200, 320); ntype.initfunc = file_ns::node_composit_init_valtorgb; node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; @@ -195,7 +195,7 @@ void register_node_type_cmp_rgbtobw() cmp_node_type_base(&ntype, CMP_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTER); ntype.declare = file_ns::cmp_node_rgbtobw_declare; - node_type_size_preset(&ntype, NODE_SIZE_DEFAULT); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::DEFAULT); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_value.cc b/source/blender/nodes/composite/nodes/node_composite_value.cc index 6fdcc6aa4a9..462406a3462 100644 --- a/source/blender/nodes/composite/nodes/node_composite_value.cc +++ b/source/blender/nodes/composite/nodes/node_composite_value.cc @@ -51,7 +51,7 @@ void register_node_type_cmp_value() cmp_node_type_base(&ntype, CMP_NODE_VALUE, "Value", NODE_CLASS_INPUT); ntype.declare = file_ns::cmp_node_value_declare; - node_type_size_preset(&ntype, NODE_SIZE_DEFAULT); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::DEFAULT); ntype.get_compositor_operation = file_ns::get_compositor_operation; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/function/node_function_util.cc b/source/blender/nodes/function/node_function_util.cc index 3cee9cbf29e..3b5b050f480 100644 --- a/source/blender/nodes/function/node_function_util.cc +++ b/source/blender/nodes/function/node_function_util.cc @@ -20,7 +20,7 @@ static bool fn_node_poll_default(const bNodeType * /*ntype*/, void fn_node_type_base(bNodeType *ntype, int type, const char *name, short nclass) { - node_type_base(ntype, type, name, nclass); + blender::bke::node_type_base(ntype, type, name, nclass); ntype->poll = fn_node_poll_default; ntype->insert_link = node_insert_link_default; ntype->gather_link_search_ops = blender::nodes::search_link_ops_for_basic_node; diff --git a/source/blender/nodes/function/node_function_util.hh b/source/blender/nodes/function/node_function_util.hh index 67155332b02..6c740f834a3 100644 --- a/source/blender/nodes/function/node_function_util.hh +++ b/source/blender/nodes/function/node_function_util.hh @@ -11,7 +11,7 @@ #include "DNA_node_types.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BLT_translation.h" diff --git a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc index 74f551fa84a..3c9fa268e2d 100644 --- a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc +++ b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc @@ -32,7 +32,7 @@ static void node_update(bNodeTree *ntree, bNode *node) { bNodeSocket *sockB = (bNodeSocket *)BLI_findlink(&node->inputs, 1); - nodeSetSocketAvailability(ntree, sockB, !ELEM(node->custom1, NODE_BOOLEAN_MATH_NOT)); + bke::nodeSetSocketAvailability(ntree, sockB, !ELEM(node->custom1, NODE_BOOLEAN_MATH_NOT)); } static void node_label(const bNodeTree * /*tree*/, diff --git a/source/blender/nodes/function/nodes/node_fn_compare.cc b/source/blender/nodes/function/nodes/node_fn_compare.cc index 91433446837..b79a6433769 100644 --- a/source/blender/nodes/function/nodes/node_fn_compare.cc +++ b/source/blender/nodes/function/nodes/node_fn_compare.cc @@ -64,20 +64,20 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *sock_epsilon = (bNodeSocket *)BLI_findlink(&node->inputs, 12); LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) { - nodeSetSocketAvailability(ntree, socket, socket->type == (eNodeSocketDatatype)data->data_type); + bke::nodeSetSocketAvailability(ntree, socket, socket->type == (eNodeSocketDatatype)data->data_type); } - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, sock_epsilon, ELEM(data->operation, NODE_COMPARE_EQUAL, NODE_COMPARE_NOT_EQUAL) && !ELEM(data->data_type, SOCK_INT, SOCK_STRING)); - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, sock_comp, ELEM(data->mode, NODE_COMPARE_MODE_DOT_PRODUCT) && data->data_type == SOCK_VECTOR); - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, sock_angle, ELEM(data->mode, NODE_COMPARE_MODE_DIRECTION) && data->data_type == SOCK_VECTOR); diff --git a/source/blender/nodes/function/nodes/node_fn_random_value.cc b/source/blender/nodes/function/nodes/node_fn_random_value.cc index 416d0e754eb..c7fc567dd8a 100644 --- a/source/blender/nodes/function/nodes/node_fn_random_value.cc +++ b/source/blender/nodes/function/nodes/node_fn_random_value.cc @@ -72,18 +72,18 @@ static void fn_node_random_value_update(bNodeTree *ntree, bNode *node) bNodeSocket *sock_out_int = sock_out_float->next; bNodeSocket *sock_out_bool = sock_out_int->next; - nodeSetSocketAvailability(ntree, sock_min_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, sock_max_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, sock_min_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, sock_max_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, sock_min_int, data_type == CD_PROP_INT32); - nodeSetSocketAvailability(ntree, sock_max_int, data_type == CD_PROP_INT32); - nodeSetSocketAvailability(ntree, sock_probability, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, sock_min_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, sock_max_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, sock_min_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, sock_max_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, sock_min_int, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, sock_max_int, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, sock_probability, data_type == CD_PROP_BOOL); - nodeSetSocketAvailability(ntree, sock_out_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, sock_out_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, sock_out_int, data_type == CD_PROP_INT32); - nodeSetSocketAvailability(ntree, sock_out_bool, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, sock_out_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, sock_out_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, sock_out_int, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, sock_out_bool, data_type == CD_PROP_BOOL); } static std::optional node_type_from_other_socket(const bNodeSocket &socket) diff --git a/source/blender/nodes/function/nodes/node_fn_rotate_euler.cc b/source/blender/nodes/function/nodes/node_fn_rotate_euler.cc index 6cc3677df1f..c4cb0b9e904 100644 --- a/source/blender/nodes/function/nodes/node_fn_rotate_euler.cc +++ b/source/blender/nodes/function/nodes/node_fn_rotate_euler.cc @@ -38,11 +38,11 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *axis_socket = static_cast(BLI_findlink(&node->inputs, 2)); bNodeSocket *angle_socket = static_cast(BLI_findlink(&node->inputs, 3)); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, rotate_by_socket, ELEM(node->custom1, FN_NODE_ROTATE_EULER_TYPE_EULER)); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, axis_socket, ELEM(node->custom1, FN_NODE_ROTATE_EULER_TYPE_AXIS_ANGLE)); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, angle_socket, ELEM(node->custom1, FN_NODE_ROTATE_EULER_TYPE_AXIS_ANGLE)); } diff --git a/source/blender/nodes/geometry/node_geometry_tree.cc b/source/blender/nodes/geometry/node_geometry_tree.cc index c4bec7ede28..0afb7ffb920 100644 --- a/source/blender/nodes/geometry/node_geometry_tree.cc +++ b/source/blender/nodes/geometry/node_geometry_tree.cc @@ -8,7 +8,7 @@ #include "BKE_context.h" #include "BKE_layer.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_object.h" #include "BLT_translation.h" @@ -91,7 +91,7 @@ static bool geometry_node_tree_validate_link(eNodeSocketDatatype type_a, static bool geometry_node_tree_socket_type_valid(bNodeTreeType * /*treetype*/, bNodeSocketType *socket_type) { - return nodeIsStaticSocketType(socket_type) && ELEM(socket_type->type, + return blender::bke::nodeIsStaticSocketType(socket_type) && ELEM(socket_type->type, SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA, diff --git a/source/blender/nodes/geometry/node_geometry_util.cc b/source/blender/nodes/geometry/node_geometry_util.cc index bddd4775c85..00be2add1ad 100644 --- a/source/blender/nodes/geometry/node_geometry_util.cc +++ b/source/blender/nodes/geometry/node_geometry_util.cc @@ -55,7 +55,7 @@ bool geo_node_poll_default(const bNodeType * /*ntype*/, void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass) { - node_type_base(ntype, type, name, nclass); + blender::bke::node_type_base(ntype, type, name, nclass); ntype->poll = geo_node_poll_default; ntype->insert_link = node_insert_link_default; ntype->gather_link_search_ops = blender::nodes::search_link_ops_for_basic_node; diff --git a/source/blender/nodes/geometry/node_geometry_util.hh b/source/blender/nodes/geometry/node_geometry_util.hh index 25fae7f23fb..1c9265ea239 100644 --- a/source/blender/nodes/geometry/node_geometry_util.hh +++ b/source/blender/nodes/geometry/node_geometry_util.hh @@ -13,7 +13,7 @@ #include "DNA_node_types.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BLT_translation.h" diff --git a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc index 1fd4b0cefd9..1ef31407112 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc @@ -109,21 +109,21 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *sock_out_total_float = sock_out_total_vector->next; bNodeSocket *sock_out_total_int = sock_out_total_float->next; - nodeSetSocketAvailability(ntree, sock_in_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, sock_in_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, sock_in_int, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, sock_in_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, sock_in_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, sock_in_int, data_type == CD_PROP_INT32); - nodeSetSocketAvailability(ntree, sock_out_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, sock_out_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, sock_out_int, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, sock_out_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, sock_out_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, sock_out_int, data_type == CD_PROP_INT32); - nodeSetSocketAvailability(ntree, sock_out_first_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, sock_out_first_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, sock_out_first_int, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, sock_out_first_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, sock_out_first_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, sock_out_first_int, data_type == CD_PROP_INT32); - nodeSetSocketAvailability(ntree, sock_out_total_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, sock_out_total_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, sock_out_total_int, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, sock_out_total_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, sock_out_total_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, sock_out_total_int, data_type == CD_PROP_INT32); } enum class AccumulationMode { Leading = 0, Trailing = 1 }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc index 6d5596cda27..ff4e738014d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc @@ -59,11 +59,11 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *socket_value_boolean = socket_value_color4f->next; bNodeSocket *socket_value_int32 = socket_value_boolean->next; - nodeSetSocketAvailability(ntree, socket_value_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, socket_value_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, socket_value_color4f, data_type == CD_PROP_COLOR); - nodeSetSocketAvailability(ntree, socket_value_boolean, data_type == CD_PROP_BOOL); - nodeSetSocketAvailability(ntree, socket_value_int32, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, socket_value_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, socket_value_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, socket_value_color4f, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, socket_value_boolean, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, socket_value_int32, data_type == CD_PROP_INT32); bNodeSocket *out_socket_value_geometry = static_cast(node->outputs.first); bNodeSocket *out_socket_value_vector = out_socket_value_geometry->next; @@ -72,11 +72,11 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *out_socket_value_boolean = out_socket_value_color4f->next; bNodeSocket *out_socket_value_int32 = out_socket_value_boolean->next; - nodeSetSocketAvailability(ntree, out_socket_value_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, out_socket_value_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, out_socket_value_color4f, data_type == CD_PROP_COLOR); - nodeSetSocketAvailability(ntree, out_socket_value_boolean, data_type == CD_PROP_BOOL); - nodeSetSocketAvailability(ntree, out_socket_value_int32, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, out_socket_value_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, out_socket_value_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, out_socket_value_color4f, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, out_socket_value_boolean, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, out_socket_value_int32, data_type == CD_PROP_INT32); } static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc index 2960240bfdf..8bbd6dea4f4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc @@ -51,17 +51,17 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *spline_socket = face_corner_socket->next; bNodeSocket *instances_socket = spline_socket->next; - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, point_socket, ELEM(node->custom1, GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_CURVE, GEO_COMPONENT_TYPE_POINT_CLOUD)); - nodeSetSocketAvailability(ntree, edge_socket, node->custom1 == GEO_COMPONENT_TYPE_MESH); - nodeSetSocketAvailability(ntree, face_socket, node->custom1 == GEO_COMPONENT_TYPE_MESH); - nodeSetSocketAvailability(ntree, face_corner_socket, node->custom1 == GEO_COMPONENT_TYPE_MESH); - nodeSetSocketAvailability(ntree, spline_socket, node->custom1 == GEO_COMPONENT_TYPE_CURVE); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability(ntree, edge_socket, node->custom1 == GEO_COMPONENT_TYPE_MESH); + bke::nodeSetSocketAvailability(ntree, face_socket, node->custom1 == GEO_COMPONENT_TYPE_MESH); + bke::nodeSetSocketAvailability(ntree, face_corner_socket, node->custom1 == GEO_COMPONENT_TYPE_MESH); + bke::nodeSetSocketAvailability(ntree, spline_socket, node->custom1 == GEO_COMPONENT_TYPE_CURVE); + bke::nodeSetSocketAvailability( ntree, instances_socket, node->custom1 == GEO_COMPONENT_TYPE_INSTANCES); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc index 4874caf0beb..9555abaabe3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc @@ -79,25 +79,25 @@ static void node_update(bNodeTree *ntree, bNode *node) const eCustomDataType data_type = eCustomDataType(node->custom1); - nodeSetSocketAvailability(ntree, socket_float_attr, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, socket_float_mean, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, socket_float_median, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, socket_float_sum, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, socket_float_min, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, socket_float_max, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, socket_float_range, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, socket_float_std, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, socket_float_variance, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, socket_float_attr, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, socket_float_mean, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, socket_float_median, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, socket_float_sum, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, socket_float_min, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, socket_float_max, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, socket_float_range, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, socket_float_std, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, socket_float_variance, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, socket_float3_attr, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, socket_vector_mean, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, socket_vector_median, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, socket_vector_sum, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, socket_vector_min, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, socket_vector_max, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, socket_vector_range, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, socket_vector_std, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, socket_vector_variance, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, socket_float3_attr, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, socket_vector_mean, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, socket_vector_median, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, socket_vector_sum, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, socket_vector_min, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, socket_vector_max, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, socket_vector_range, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, socket_vector_std, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, socket_vector_variance, data_type == CD_PROP_FLOAT3); } static std::optional node_type_from_other_socket(const bNodeSocket &socket) diff --git a/source/blender/nodes/geometry/nodes/node_geo_blur_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_blur_attribute.cc index 5c81a25b9ee..29536c8b493 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_blur_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_blur_attribute.cc @@ -119,20 +119,20 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *socket_value_vector = socket_value_int32->next; bNodeSocket *socket_value_color4f = socket_value_vector->next; - nodeSetSocketAvailability(ntree, socket_value_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, socket_value_int32, data_type == CD_PROP_INT32); - nodeSetSocketAvailability(ntree, socket_value_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, socket_value_color4f, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, socket_value_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, socket_value_int32, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, socket_value_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, socket_value_color4f, data_type == CD_PROP_COLOR); bNodeSocket *out_socket_value_float = (bNodeSocket *)node->outputs.first; bNodeSocket *out_socket_value_int32 = out_socket_value_float->next; bNodeSocket *out_socket_value_vector = out_socket_value_int32->next; bNodeSocket *out_socket_value_color4f = out_socket_value_vector->next; - nodeSetSocketAvailability(ntree, out_socket_value_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, out_socket_value_int32, data_type == CD_PROP_INT32); - nodeSetSocketAvailability(ntree, out_socket_value_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, out_socket_value_color4f, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, out_socket_value_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, out_socket_value_int32, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, out_socket_value_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, out_socket_value_color4f, data_type == CD_PROP_COLOR); } static Array> build_vert_to_vert_by_edge_map(const Span edges, diff --git a/source/blender/nodes/geometry/nodes/node_geo_boolean.cc b/source/blender/nodes/geometry/nodes/node_geo_boolean.cc index 0457ab10f36..34f274d9d7c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_boolean.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_boolean.cc @@ -43,13 +43,13 @@ static void node_update(bNodeTree *ntree, bNode *node) switch (operation) { case GEO_NODE_BOOLEAN_INTERSECT: case GEO_NODE_BOOLEAN_UNION: - nodeSetSocketAvailability(ntree, geometry_1_socket, false); - nodeSetSocketAvailability(ntree, geometry_2_socket, true); + bke::nodeSetSocketAvailability(ntree, geometry_1_socket, false); + bke::nodeSetSocketAvailability(ntree, geometry_2_socket, true); node_sock_label(geometry_2_socket, N_("Mesh")); break; case GEO_NODE_BOOLEAN_DIFFERENCE: - nodeSetSocketAvailability(ntree, geometry_1_socket, true); - nodeSetSocketAvailability(ntree, geometry_2_socket, true); + bke::nodeSetSocketAvailability(ntree, geometry_1_socket, true); + bke::nodeSetSocketAvailability(ntree, geometry_2_socket, true); node_sock_label(geometry_2_socket, N_("Mesh 2")); break; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_common.cc b/source/blender/nodes/geometry/nodes/node_geo_common.cc index 1803ac1f83d..e74833553c8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_common.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_common.cc @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BKE_node.h" +#include "BKE_node.hh" #include "NOD_geometry.h" #include "NOD_node_declaration.hh" @@ -51,7 +51,7 @@ void register_node_type_geo_group() BLI_assert(ntype.rna_ext.srna != nullptr); RNA_struct_blender_type_set(ntype.rna_ext.srna, &ntype); - node_type_size(&ntype, 140, 60, 400); + blender::bke::node_type_size(&ntype, 140, 60, 400); ntype.labelfunc = node_group_label; ntype.declare_dynamic = blender::nodes::node_declare; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc index 959319f82ad..752a1ac3474 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc @@ -49,7 +49,7 @@ static void node_update(bNodeTree *ntree, bNode *node) const NodeGeometryCurveFillet &storage = node_storage(*node); const GeometryNodeCurveFilletMode mode = (GeometryNodeCurveFilletMode)storage.mode; bNodeSocket *poly_socket = static_cast(node->inputs.first)->next; - nodeSetSocketAvailability(ntree, poly_socket, mode == GEO_NODE_CURVE_FILLET_POLY); + bke::nodeSetSocketAvailability(ntree, poly_socket, mode == GEO_NODE_CURVE_FILLET_POLY); } static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc index 71c4621c325..a32b054fcb6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc @@ -123,19 +123,19 @@ static void node_update(bNodeTree *ntree, bNode *node) const bool radius_mode = (mode == GEO_NODE_CURVE_PRIMITIVE_ARC_TYPE_RADIUS); const bool points_mode = (mode == GEO_NODE_CURVE_PRIMITIVE_ARC_TYPE_POINTS); - nodeSetSocketAvailability(ntree, start_socket, points_mode); - nodeSetSocketAvailability(ntree, middle_socket, points_mode); - nodeSetSocketAvailability(ntree, end_socket, points_mode); + bke::nodeSetSocketAvailability(ntree, start_socket, points_mode); + bke::nodeSetSocketAvailability(ntree, middle_socket, points_mode); + bke::nodeSetSocketAvailability(ntree, end_socket, points_mode); - nodeSetSocketAvailability(ntree, radius_socket, radius_mode); - nodeSetSocketAvailability(ntree, start_angle_socket, radius_mode); - nodeSetSocketAvailability(ntree, sweep_angle_socket, radius_mode); + bke::nodeSetSocketAvailability(ntree, radius_socket, radius_mode); + bke::nodeSetSocketAvailability(ntree, start_angle_socket, radius_mode); + bke::nodeSetSocketAvailability(ntree, sweep_angle_socket, radius_mode); - nodeSetSocketAvailability(ntree, offset_angle_socket, points_mode); + bke::nodeSetSocketAvailability(ntree, offset_angle_socket, points_mode); - nodeSetSocketAvailability(ntree, center_out_socket, points_mode); - nodeSetSocketAvailability(ntree, normal_out_socket, points_mode); - nodeSetSocketAvailability(ntree, radius_out_socket, points_mode); + bke::nodeSetSocketAvailability(ntree, center_out_socket, points_mode); + bke::nodeSetSocketAvailability(ntree, normal_out_socket, points_mode); + bke::nodeSetSocketAvailability(ntree, radius_out_socket, points_mode); } static float3 rotate_vector_around_axis(const float3 vector, const float3 axis, const float angle) diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc index 1e358333a23..f203946e384 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc @@ -82,15 +82,15 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *center_socket = static_cast(node->outputs.first)->next; - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, start_socket, mode == GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_POINTS); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, middle_socket, mode == GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_POINTS); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, end_socket, mode == GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_POINTS); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, center_socket, mode == GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_POINTS); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, radius_socket, mode == GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_RADIUS); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc index 5e4661bcedf..6ab1f1e234e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc @@ -61,10 +61,10 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *direction_socket = p2_socket->next; bNodeSocket *length_socket = direction_socket->next; - nodeSetSocketAvailability(ntree, p2_socket, mode == GEO_NODE_CURVE_PRIMITIVE_LINE_MODE_POINTS); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability(ntree, p2_socket, mode == GEO_NODE_CURVE_PRIMITIVE_LINE_MODE_POINTS); + bke::nodeSetSocketAvailability( ntree, direction_socket, mode == GEO_NODE_CURVE_PRIMITIVE_LINE_MODE_DIRECTION); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, length_socket, mode == GEO_NODE_CURVE_PRIMITIVE_LINE_MODE_DIRECTION); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc index 3942b42b333..04dbaddd632 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc @@ -116,7 +116,7 @@ static void node_update(bNodeTree *ntree, bNode *node) } LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { - nodeSetSocketAvailability(ntree, sock, available_sockets.contains(sock)); + bke::nodeSetSocketAvailability(ntree, sock, available_sockets.contains(sock)); } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc index b34040b5b74..49b6cb2a81a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc @@ -47,8 +47,8 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *count_socket = static_cast(node->inputs.first)->next->next; bNodeSocket *length_socket = count_socket->next; - nodeSetSocketAvailability(ntree, count_socket, mode == GEO_NODE_CURVE_RESAMPLE_COUNT); - nodeSetSocketAvailability(ntree, length_socket, mode == GEO_NODE_CURVE_RESAMPLE_LENGTH); + bke::nodeSetSocketAvailability(ntree, count_socket, mode == GEO_NODE_CURVE_RESAMPLE_COUNT); + bke::nodeSetSocketAvailability(ntree, length_socket, mode == GEO_NODE_CURVE_RESAMPLE_LENGTH); } static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc index a4d5b7bfd79..1e74bc44387 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc @@ -86,15 +86,15 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *length = factor->next; bNodeSocket *curve_index = length->next; - nodeSetSocketAvailability(ntree, factor, mode == GEO_NODE_CURVE_SAMPLE_FACTOR); - nodeSetSocketAvailability(ntree, length, mode == GEO_NODE_CURVE_SAMPLE_LENGTH); - nodeSetSocketAvailability(ntree, curve_index, !storage.use_all_curves); + bke::nodeSetSocketAvailability(ntree, factor, mode == GEO_NODE_CURVE_SAMPLE_FACTOR); + bke::nodeSetSocketAvailability(ntree, length, mode == GEO_NODE_CURVE_SAMPLE_LENGTH); + bke::nodeSetSocketAvailability(ntree, curve_index, !storage.use_all_curves); - nodeSetSocketAvailability(ntree, in_socket_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, in_socket_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, in_socket_color4f, data_type == CD_PROP_COLOR); - nodeSetSocketAvailability(ntree, in_socket_bool, data_type == CD_PROP_BOOL); - nodeSetSocketAvailability(ntree, in_socket_int32, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, in_socket_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, in_socket_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, in_socket_color4f, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, in_socket_bool, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, in_socket_int32, data_type == CD_PROP_INT32); bNodeSocket *out_socket_float = static_cast(node->outputs.first); bNodeSocket *out_socket_int32 = out_socket_float->next; @@ -102,11 +102,11 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *out_socket_color4f = out_socket_vector->next; bNodeSocket *out_socket_bool = out_socket_color4f->next; - nodeSetSocketAvailability(ntree, out_socket_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, out_socket_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, out_socket_color4f, data_type == CD_PROP_COLOR); - nodeSetSocketAvailability(ntree, out_socket_bool, data_type == CD_PROP_BOOL); - nodeSetSocketAvailability(ntree, out_socket_int32, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, out_socket_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, out_socket_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, out_socket_color4f, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, out_socket_bool, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, out_socket_int32, data_type == CD_PROP_INT32); } static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc index bae8dc49ef2..d038b80befb 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc @@ -63,8 +63,8 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *count_socket = static_cast(node->inputs.first)->next; bNodeSocket *length_socket = count_socket->next; - nodeSetSocketAvailability(ntree, count_socket, mode == GEO_NODE_CURVE_RESAMPLE_COUNT); - nodeSetSocketAvailability(ntree, length_socket, mode == GEO_NODE_CURVE_RESAMPLE_LENGTH); + bke::nodeSetSocketAvailability(ntree, count_socket, mode == GEO_NODE_CURVE_RESAMPLE_COUNT); + bke::nodeSetSocketAvailability(ntree, length_socket, mode == GEO_NODE_CURVE_RESAMPLE_LENGTH); } static void fill_rotation_attribute(const Span tangents, diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc index 25e33ff8ea4..3287bd95a0c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc @@ -70,10 +70,10 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *start_len = end_fac->next; bNodeSocket *end_len = start_len->next; - nodeSetSocketAvailability(ntree, start_fac, mode == GEO_NODE_CURVE_SAMPLE_FACTOR); - nodeSetSocketAvailability(ntree, end_fac, mode == GEO_NODE_CURVE_SAMPLE_FACTOR); - nodeSetSocketAvailability(ntree, start_len, mode == GEO_NODE_CURVE_SAMPLE_LENGTH); - nodeSetSocketAvailability(ntree, end_len, mode == GEO_NODE_CURVE_SAMPLE_LENGTH); + bke::nodeSetSocketAvailability(ntree, start_fac, mode == GEO_NODE_CURVE_SAMPLE_FACTOR); + bke::nodeSetSocketAvailability(ntree, end_fac, mode == GEO_NODE_CURVE_SAMPLE_FACTOR); + bke::nodeSetSocketAvailability(ntree, start_len, mode == GEO_NODE_CURVE_SAMPLE_LENGTH); + bke::nodeSetSocketAvailability(ntree, end_len, mode == GEO_NODE_CURVE_SAMPLE_LENGTH); } class SocketSearchOp { diff --git a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc index 970d5517b33..e9ab0027eab 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc @@ -416,6 +416,6 @@ void register_node_type_geo_deform_curves_on_surface() &ntype, GEO_NODE_DEFORM_CURVES_ON_SURFACE, "Deform Curves on Surface", NODE_CLASS_GEOMETRY); ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.declare = file_ns::node_declare; - node_type_size(&ntype, 170, 120, 700); + blender::bke::node_type_size(&ntype, 170, 120, 700); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc index 6dfad57cada..2a605607db1 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc @@ -75,13 +75,13 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *sock_spacing = sock_seed->next; bNodeSocket *sock_threshold = sock_spacing->next; - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, sock_density, mode == GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME_DENSITY_RANDOM); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, sock_seed, mode == GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME_DENSITY_RANDOM); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, sock_spacing, mode == GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME_DENSITY_GRID); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, sock_threshold, mode == GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME_DENSITY_GRID); } @@ -279,7 +279,7 @@ void register_node_type_geo_distribute_points_in_volume() node_copy_standard_storage); ntype.initfunc = file_ns::node_init; ntype.updatefunc = file_ns::node_update; - node_type_size(&ntype, 170, 100, 320); + blender::bke::node_type_size(&ntype, 170, 100, 320); ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.draw_buttons = file_ns::node_layout; diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc index 16b84af3470..3c6f90ffa08 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc @@ -78,14 +78,14 @@ static void node_point_distribute_points_on_faces_update(bNodeTree *ntree, bNode bNodeSocket *sock_density_max = static_cast(sock_distance_min->next); bNodeSocket *sock_density = sock_density_max->next; bNodeSocket *sock_density_factor = sock_density->next; - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, sock_distance_min, node->custom1 == GEO_NODE_POINT_DISTRIBUTE_POINTS_ON_FACES_POISSON); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, sock_density_max, node->custom1 == GEO_NODE_POINT_DISTRIBUTE_POINTS_ON_FACES_POISSON); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, sock_density, node->custom1 == GEO_NODE_POINT_DISTRIBUTE_POINTS_ON_FACES_RANDOM); - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, sock_density_factor, node->custom1 == GEO_NODE_POINT_DISTRIBUTE_POINTS_ON_FACES_POISSON); } @@ -593,7 +593,7 @@ void register_node_type_geo_distribute_points_on_faces() "Distribute Points on Faces", NODE_CLASS_GEOMETRY); ntype.updatefunc = file_ns::node_point_distribute_points_on_faces_update; - node_type_size(&ntype, 170, 100, 320); + blender::bke::node_type_size(&ntype, 170, 100, 320); ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.draw_buttons = file_ns::node_layout; diff --git a/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc index 394ca2e1ce0..ad7d2c8b11a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc @@ -141,7 +141,7 @@ void register_node_type_geo_edge_paths_to_selection() geo_node_type_base( &ntype, GEO_NODE_EDGE_PATHS_TO_SELECTION, "Edge Paths to Selection", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; - node_type_size(&ntype, 150, 100, 300); + blender::bke::node_type_size(&ntype, 150, 100, 300); ntype.geometry_node_execute = file_ns::node_geo_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_evaluate_at_index.cc b/source/blender/nodes/geometry/nodes/node_geo_evaluate_at_index.cc index 5f593b44a54..46f0f1eb125 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_evaluate_at_index.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_evaluate_at_index.cc @@ -98,17 +98,17 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *sock_out_color = sock_out_vector->next; bNodeSocket *sock_out_bool = sock_out_color->next; - nodeSetSocketAvailability(ntree, sock_in_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, sock_in_int, data_type == CD_PROP_INT32); - nodeSetSocketAvailability(ntree, sock_in_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, sock_in_color, data_type == CD_PROP_COLOR); - nodeSetSocketAvailability(ntree, sock_in_bool, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, sock_in_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, sock_in_int, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, sock_in_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, sock_in_color, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, sock_in_bool, data_type == CD_PROP_BOOL); - nodeSetSocketAvailability(ntree, sock_out_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, sock_out_int, data_type == CD_PROP_INT32); - nodeSetSocketAvailability(ntree, sock_out_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, sock_out_color, data_type == CD_PROP_COLOR); - nodeSetSocketAvailability(ntree, sock_out_bool, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, sock_out_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, sock_out_int, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, sock_out_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, sock_out_color, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, sock_out_bool, data_type == CD_PROP_BOOL); } static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) diff --git a/source/blender/nodes/geometry/nodes/node_geo_evaluate_on_domain.cc b/source/blender/nodes/geometry/nodes/node_geo_evaluate_on_domain.cc index c2fa0e8258d..7143f38cc2e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_evaluate_on_domain.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_evaluate_on_domain.cc @@ -56,17 +56,17 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *sock_out_color = sock_out_vector->next; bNodeSocket *sock_out_bool = sock_out_color->next; - nodeSetSocketAvailability(ntree, sock_in_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, sock_in_int, data_type == CD_PROP_INT32); - nodeSetSocketAvailability(ntree, sock_in_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, sock_in_color, data_type == CD_PROP_COLOR); - nodeSetSocketAvailability(ntree, sock_in_bool, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, sock_in_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, sock_in_int, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, sock_in_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, sock_in_color, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, sock_in_bool, data_type == CD_PROP_BOOL); - nodeSetSocketAvailability(ntree, sock_out_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, sock_out_int, data_type == CD_PROP_INT32); - nodeSetSocketAvailability(ntree, sock_out_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, sock_out_color, data_type == CD_PROP_COLOR); - nodeSetSocketAvailability(ntree, sock_out_bool, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, sock_out_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, sock_out_int, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, sock_out_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, sock_out_color, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, sock_out_bool, data_type == CD_PROP_BOOL); } static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) diff --git a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc index 0d18833c66a..d2d0ea3dd04 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc @@ -60,7 +60,7 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *individual_socket = static_cast(node->inputs.last); - nodeSetSocketAvailability(ntree, individual_socket, mode == GEO_NODE_EXTRUDE_MESH_FACES); + bke::nodeSetSocketAvailability(ntree, individual_socket, mode == GEO_NODE_EXTRUDE_MESH_FACES); } struct AttributeOutputs { diff --git a/source/blender/nodes/geometry/nodes/node_geo_geometry_to_instance.cc b/source/blender/nodes/geometry/nodes/node_geo_geometry_to_instance.cc index ac415d079f2..ac155860b92 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_geometry_to_instance.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_geometry_to_instance.cc @@ -34,7 +34,7 @@ void register_node_type_geo_geometry_to_instance() geo_node_type_base( &ntype, GEO_NODE_GEOMETRY_TO_INSTANCE, "Geometry to Instance", NODE_CLASS_GEOMETRY); - node_type_size(&ntype, 160, 100, 300); + blender::bke::node_type_size(&ntype, 160, 100, 300); ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.declare = file_ns::node_declare; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/geometry/nodes/node_geo_image.cc b/source/blender/nodes/geometry/nodes/node_geo_image.cc index 027dc67e1da..6a008f3ead9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_image.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_image.cc @@ -45,6 +45,6 @@ void register_node_type_geo_image() ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.draw_buttons = file_ns::node_layout; ntype.declare = file_ns::node_declare; - node_type_size_preset(&ntype, NODE_SIZE_LARGE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::LARGE); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_image_info.cc b/source/blender/nodes/geometry/nodes/node_geo_image_info.cc index a1450f35800..826f85b8d85 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_image_info.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_image_info.cc @@ -90,6 +90,6 @@ void register_node_type_geo_image_info() geo_node_type_base(&ntype, GEO_NODE_IMAGE_INFO, "Image Info", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; - node_type_size_preset(&ntype, NODE_SIZE_LARGE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::LARGE); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc b/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc index 1ec2383ffb9..fb12fe2a4d9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc @@ -435,7 +435,7 @@ void register_node_type_geo_image_texture() ntype.initfunc = file_ns::node_init; node_type_storage( &ntype, "NodeGeometryImageTexture", node_free_standard_storage, node_copy_standard_storage); - node_type_size_preset(&ntype, NODE_SIZE_LARGE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::LARGE); ntype.geometry_node_execute = file_ns::node_geo_exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc b/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc index c830aa9f429..94b6947e14b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc @@ -114,7 +114,7 @@ void register_node_type_geo_input_curve_handles() static bNodeType ntype; geo_node_type_base( &ntype, GEO_NODE_INPUT_CURVE_HANDLES, "Curve Handle Positions", NODE_CLASS_INPUT); - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.declare = file_ns::node_declare; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc index f8b8b3d08f1..dbd3d7c475f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc @@ -130,7 +130,7 @@ void register_node_type_geo_input_mesh_face_neighbors() static bNodeType ntype; geo_node_type_base( &ntype, GEO_NODE_INPUT_MESH_FACE_NEIGHBORS, "Face Neighbors", NODE_CLASS_INPUT); - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc index c314d9499b0..f2287c0ac57 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc @@ -47,11 +47,11 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *socket_boolean = socket_color4f->next; bNodeSocket *socket_int32 = socket_boolean->next; - nodeSetSocketAvailability(ntree, socket_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, socket_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, socket_color4f, data_type == CD_PROP_COLOR); - nodeSetSocketAvailability(ntree, socket_boolean, data_type == CD_PROP_BOOL); - nodeSetSocketAvailability(ntree, socket_int32, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, socket_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, socket_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, socket_color4f, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, socket_boolean, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, socket_int32, data_type == CD_PROP_INT32); } static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) diff --git a/source/blender/nodes/geometry/nodes/node_geo_mean_filter_sdf_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_mean_filter_sdf_volume.cc index f1fb4527a1d..8c1dcee2f8d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mean_filter_sdf_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mean_filter_sdf_volume.cc @@ -100,7 +100,7 @@ void register_node_type_geo_mean_filter_sdf_volume() geo_node_type_base( &ntype, GEO_NODE_MEAN_FILTER_SDF_VOLUME, "Mean Filter SDF Volume", NODE_CLASS_GEOMETRY); - node_type_size(&ntype, 160, 120, 700); + blender::bke::node_type_size(&ntype, 160, 120, 700); ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.gather_add_node_search_ops = file_ns::search_node_add_ops; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_face_group_boundaries.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_face_group_boundaries.cc index db4cd400c8a..4c95ebfc091 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_face_group_boundaries.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_face_group_boundaries.cc @@ -91,7 +91,7 @@ void register_node_type_geo_mesh_face_group_boundaries() static bNodeType ntype; geo_node_type_base( &ntype, GEO_NODE_MESH_FACE_GROUP_BOUNDARIES, "Face Group Boundaries", NODE_CLASS_INPUT); - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc index 1d864d5e154..26d178c466f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc @@ -792,7 +792,7 @@ static void node_update(bNodeTree *ntree, bNode *node) const NodeGeometryMeshCone &storage = node_storage(*node); const GeometryNodeMeshCircleFillType fill = (GeometryNodeMeshCircleFillType)storage.fill_type; const bool has_fill = fill != GEO_NODE_MESH_CIRCLE_FILL_NONE; - nodeSetSocketAvailability(ntree, fill_subdiv_socket, has_fill); + bke::nodeSetSocketAvailability(ntree, fill_subdiv_socket, has_fill); } static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc index 37952f8cba0..0672bea4435 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc @@ -74,7 +74,7 @@ static void node_update(bNodeTree *ntree, bNode *node) const NodeGeometryMeshCylinder &storage = node_storage(*node); const GeometryNodeMeshCircleFillType fill = (GeometryNodeMeshCircleFillType)storage.fill_type; const bool has_fill = fill != GEO_NODE_MESH_CIRCLE_FILL_NONE; - nodeSetSocketAvailability(ntree, fill_subdiv_socket, has_fill); + bke::nodeSetSocketAvailability(ntree, fill_subdiv_socket, has_fill); } static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc index 9bf744d4895..e5b8f4019f0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc @@ -80,11 +80,11 @@ static void node_update(bNodeTree *ntree, bNode *node) (mode == GEO_NODE_MESH_LINE_MODE_END_POINTS) ? N_("End Location") : N_("Offset")); - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, resolution_socket, mode == GEO_NODE_MESH_LINE_MODE_END_POINTS && count_mode == GEO_NODE_MESH_LINE_COUNT_RESOLUTION); - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, count_socket, mode == GEO_NODE_MESH_LINE_MODE_OFFSET || count_mode == GEO_NODE_MESH_LINE_COUNT_TOTAL); diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_sdf_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_sdf_volume.cc index 05f096c1119..908c057ad73 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_sdf_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_sdf_volume.cc @@ -77,10 +77,10 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *voxel_size_socket = nodeFindSocket(node, SOCK_IN, "Voxel Size"); bNodeSocket *voxel_amount_socket = nodeFindSocket(node, SOCK_IN, "Voxel Amount"); - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, voxel_amount_socket, data.resolution_mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_AMOUNT); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, voxel_size_socket, data.resolution_mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_SIZE); } @@ -170,7 +170,7 @@ void register_node_type_geo_mesh_to_sdf_volume() geo_node_type_base( &ntype, GEO_NODE_MESH_TO_SDF_VOLUME, "Mesh to SDF Volume", NODE_CLASS_GEOMETRY); ntype.declare = file_ns::node_declare; - node_type_size(&ntype, 180, 120, 300); + blender::bke::node_type_size(&ntype, 180, 120, 300); ntype.initfunc = file_ns::node_init; ntype.updatefunc = file_ns::node_update; ntype.geometry_node_execute = file_ns::node_geo_exec; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc index 5c30986fca2..b64d7a6515f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc @@ -62,10 +62,10 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *voxel_size_socket = nodeFindSocket(node, SOCK_IN, "Voxel Size"); bNodeSocket *voxel_amount_socket = nodeFindSocket(node, SOCK_IN, "Voxel Amount"); - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, voxel_amount_socket, data.resolution_mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_AMOUNT); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, voxel_size_socket, data.resolution_mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_SIZE); } @@ -157,7 +157,7 @@ void register_node_type_geo_mesh_to_volume() geo_node_type_base(&ntype, GEO_NODE_MESH_TO_VOLUME, "Mesh to Volume", NODE_CLASS_GEOMETRY); ntype.declare = file_ns::node_declare; - node_type_size(&ntype, 200, 120, 700); + blender::bke::node_type_size(&ntype, 200, 120, 700); ntype.initfunc = file_ns::node_init; ntype.updatefunc = file_ns::node_update; ntype.geometry_node_execute = file_ns::node_geo_exec; diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_sdf_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_sdf_volume.cc index bdb297c11fc..d43235df6f9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points_to_sdf_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_sdf_volume.cc @@ -76,11 +76,11 @@ static void node_update(bNodeTree *ntree, bNode *node) const NodeGeometryPointsToVolume &storage = node_storage(*node); bNodeSocket *voxel_size_socket = nodeFindSocket(node, SOCK_IN, "Voxel Size"); bNodeSocket *voxel_amount_socket = nodeFindSocket(node, SOCK_IN, "Voxel Amount"); - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, voxel_amount_socket, storage.resolution_mode == GEO_NODE_POINTS_TO_VOLUME_RESOLUTION_MODE_AMOUNT); - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, voxel_size_socket, storage.resolution_mode == GEO_NODE_POINTS_TO_VOLUME_RESOLUTION_MODE_SIZE); @@ -117,7 +117,7 @@ void register_node_type_geo_points_to_sdf_volume() "NodeGeometryPointsToVolume", node_free_standard_storage, node_copy_standard_storage); - node_type_size(&ntype, 170, 120, 700); + blender::bke::node_type_size(&ntype, 170, 120, 700); ntype.initfunc = file_ns::node_init; ntype.updatefunc = file_ns::node_update; ntype.declare = file_ns::node_declare; diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc index af2aa10178c..05210ba9dda 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc @@ -184,11 +184,11 @@ static void node_update(bNodeTree *ntree, bNode *node) const NodeGeometryPointsToVolume &storage = node_storage(*node); bNodeSocket *voxel_size_socket = nodeFindSocket(node, SOCK_IN, "Voxel Size"); bNodeSocket *voxel_amount_socket = nodeFindSocket(node, SOCK_IN, "Voxel Amount"); - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, voxel_amount_socket, storage.resolution_mode == GEO_NODE_POINTS_TO_VOLUME_RESOLUTION_MODE_AMOUNT); - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, voxel_size_socket, storage.resolution_mode == GEO_NODE_POINTS_TO_VOLUME_RESOLUTION_MODE_SIZE); @@ -224,7 +224,7 @@ void register_node_type_geo_points_to_volume() "NodeGeometryPointsToVolume", node_free_standard_storage, node_copy_standard_storage); - node_type_size(&ntype, 170, 120, 700); + blender::bke::node_type_size(&ntype, 170, 120, 700); ntype.initfunc = file_ns::node_init; ntype.updatefunc = file_ns::node_update; ntype.declare = file_ns::node_declare; diff --git a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc index 8ac991498d3..c9f758cecde 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc @@ -80,11 +80,11 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *socket_boolean = socket_color4f->next; bNodeSocket *socket_int32 = socket_boolean->next; - nodeSetSocketAvailability(ntree, socket_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, socket_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, socket_color4f, data_type == CD_PROP_COLOR); - nodeSetSocketAvailability(ntree, socket_boolean, data_type == CD_PROP_BOOL); - nodeSetSocketAvailability(ntree, socket_int32, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, socket_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, socket_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, socket_color4f, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, socket_boolean, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, socket_int32, data_type == CD_PROP_INT32); bNodeSocket *out_socket_vector = static_cast(BLI_findlink(&node->outputs, 4)); bNodeSocket *out_socket_float = out_socket_vector->next; @@ -92,11 +92,11 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *out_socket_boolean = out_socket_color4f->next; bNodeSocket *out_socket_int32 = out_socket_boolean->next; - nodeSetSocketAvailability(ntree, out_socket_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, out_socket_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, out_socket_color4f, data_type == CD_PROP_COLOR); - nodeSetSocketAvailability(ntree, out_socket_boolean, data_type == CD_PROP_BOOL); - nodeSetSocketAvailability(ntree, out_socket_int32, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, out_socket_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, out_socket_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, out_socket_color4f, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, out_socket_boolean, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, out_socket_int32, data_type == CD_PROP_INT32); } static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) @@ -368,7 +368,7 @@ void register_node_type_geo_raycast() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_RAYCAST, "Raycast", NODE_CLASS_GEOMETRY); - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.initfunc = file_ns::node_init; ntype.updatefunc = file_ns::node_update; node_type_storage( diff --git a/source/blender/nodes/geometry/nodes/node_geo_remove_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_remove_attribute.cc index f20f8dacc28..4a72647ba4c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_remove_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_remove_attribute.cc @@ -85,7 +85,7 @@ void register_node_type_geo_remove_attribute() geo_node_type_base( &ntype, GEO_NODE_REMOVE_ATTRIBUTE, "Remove Named Attribute", NODE_CLASS_ATTRIBUTE); ntype.declare = file_ns::node_declare; - node_type_size(&ntype, 170, 100, 700); + blender::bke::node_type_size(&ntype, 170, 100, 700); ntype.geometry_node_execute = file_ns::node_geo_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_sample_index.cc b/source/blender/nodes/geometry/nodes/node_geo_sample_index.cc index 9723e32ac7d..ae0117f63a6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_sample_index.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_sample_index.cc @@ -103,11 +103,11 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *in_socket_color4f = in_socket_vector->next; bNodeSocket *in_socket_bool = in_socket_color4f->next; - nodeSetSocketAvailability(ntree, in_socket_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, in_socket_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, in_socket_color4f, data_type == CD_PROP_COLOR); - nodeSetSocketAvailability(ntree, in_socket_bool, data_type == CD_PROP_BOOL); - nodeSetSocketAvailability(ntree, in_socket_int32, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, in_socket_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, in_socket_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, in_socket_color4f, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, in_socket_bool, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, in_socket_int32, data_type == CD_PROP_INT32); bNodeSocket *out_socket_float = static_cast(node->outputs.first); bNodeSocket *out_socket_int32 = out_socket_float->next; @@ -115,11 +115,11 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *out_socket_color4f = out_socket_vector->next; bNodeSocket *out_socket_bool = out_socket_color4f->next; - nodeSetSocketAvailability(ntree, out_socket_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, out_socket_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, out_socket_color4f, data_type == CD_PROP_COLOR); - nodeSetSocketAvailability(ntree, out_socket_bool, data_type == CD_PROP_BOOL); - nodeSetSocketAvailability(ntree, out_socket_int32, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, out_socket_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, out_socket_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, out_socket_color4f, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, out_socket_bool, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, out_socket_int32, data_type == CD_PROP_INT32); } static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) diff --git a/source/blender/nodes/geometry/nodes/node_geo_sample_nearest_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_sample_nearest_surface.cc index f15a7cd68a1..097520f01f6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_sample_nearest_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_sample_nearest_surface.cc @@ -59,11 +59,11 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *in_socket_color4f = in_socket_vector->next; bNodeSocket *in_socket_bool = in_socket_color4f->next; - nodeSetSocketAvailability(ntree, in_socket_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, in_socket_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, in_socket_color4f, data_type == CD_PROP_COLOR); - nodeSetSocketAvailability(ntree, in_socket_bool, data_type == CD_PROP_BOOL); - nodeSetSocketAvailability(ntree, in_socket_int32, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, in_socket_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, in_socket_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, in_socket_color4f, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, in_socket_bool, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, in_socket_int32, data_type == CD_PROP_INT32); bNodeSocket *out_socket_float = static_cast(node->outputs.first); bNodeSocket *out_socket_int32 = out_socket_float->next; @@ -71,11 +71,11 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *out_socket_color4f = out_socket_vector->next; bNodeSocket *out_socket_bool = out_socket_color4f->next; - nodeSetSocketAvailability(ntree, out_socket_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, out_socket_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, out_socket_color4f, data_type == CD_PROP_COLOR); - nodeSetSocketAvailability(ntree, out_socket_bool, data_type == CD_PROP_BOOL); - nodeSetSocketAvailability(ntree, out_socket_int32, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, out_socket_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, out_socket_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, out_socket_color4f, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, out_socket_bool, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, out_socket_int32, data_type == CD_PROP_INT32); } static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) @@ -237,7 +237,7 @@ void register_node_type_geo_sample_nearest_surface() ntype.initfunc = file_ns::node_init; ntype.updatefunc = file_ns::node_update; ntype.declare = file_ns::node_declare; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.draw_buttons = file_ns::node_layout; ntype.gather_link_search_ops = file_ns::node_gather_link_searches; diff --git a/source/blender/nodes/geometry/nodes/node_geo_sample_uv_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_sample_uv_surface.cc index 974d3b4a29c..2b2e71356cc 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_sample_uv_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_sample_uv_surface.cc @@ -68,11 +68,11 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *in_socket_color4f = in_socket_vector->next; bNodeSocket *in_socket_bool = in_socket_color4f->next; - nodeSetSocketAvailability(ntree, in_socket_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, in_socket_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, in_socket_color4f, data_type == CD_PROP_COLOR); - nodeSetSocketAvailability(ntree, in_socket_bool, data_type == CD_PROP_BOOL); - nodeSetSocketAvailability(ntree, in_socket_int32, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, in_socket_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, in_socket_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, in_socket_color4f, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, in_socket_bool, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, in_socket_int32, data_type == CD_PROP_INT32); bNodeSocket *out_socket_float = static_cast(node->outputs.first); bNodeSocket *out_socket_int32 = out_socket_float->next; @@ -80,11 +80,11 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *out_socket_color4f = out_socket_vector->next; bNodeSocket *out_socket_bool = out_socket_color4f->next; - nodeSetSocketAvailability(ntree, out_socket_vector, data_type == CD_PROP_FLOAT3); - nodeSetSocketAvailability(ntree, out_socket_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, out_socket_color4f, data_type == CD_PROP_COLOR); - nodeSetSocketAvailability(ntree, out_socket_bool, data_type == CD_PROP_BOOL); - nodeSetSocketAvailability(ntree, out_socket_int32, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, out_socket_vector, data_type == CD_PROP_FLOAT3); + bke::nodeSetSocketAvailability(ntree, out_socket_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability(ntree, out_socket_color4f, data_type == CD_PROP_COLOR); + bke::nodeSetSocketAvailability(ntree, out_socket_bool, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, out_socket_int32, data_type == CD_PROP_INT32); } static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) diff --git a/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc index 7bb7be6a960..aa59d1ecd4f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc @@ -60,7 +60,7 @@ static void node_update(bNodeTree *ntree, bNode *node) const GeometryNodeScaleElementsMode mode = GeometryNodeScaleElementsMode(node->custom2); const bool use_single_axis = mode == GEO_NODE_SCALE_ELEMENTS_SINGLE_AXIS; - nodeSetSocketAvailability(ntree, axis_socket, use_single_axis); + bke::nodeSetSocketAvailability(ntree, axis_socket, use_single_axis); } struct UniformScaleFields { diff --git a/source/blender/nodes/geometry/nodes/node_geo_sdf_volume_sphere.cc b/source/blender/nodes/geometry/nodes/node_geo_sdf_volume_sphere.cc index 13bd5bc58c3..7176a41f46f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_sdf_volume_sphere.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_sdf_volume_sphere.cc @@ -94,7 +94,7 @@ void register_node_type_geo_sdf_volume_sphere() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_SDF_VOLUME_SPHERE, "SDF Volume Sphere", NODE_CLASS_GEOMETRY); ntype.declare = file_ns::node_declare; - node_type_size(&ntype, 180, 120, 300); + blender::bke::node_type_size(&ntype, 180, 120, 300); ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.gather_add_node_search_ops = file_ns::search_node_add_ops; ntype.gather_link_search_ops = file_ns::search_link_ops; diff --git a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc index 9e10aa7b7f2..4d2a7fb6a1c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc @@ -60,12 +60,12 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *socket_boolean = socket_color4f->next; bNodeSocket *socket_int32 = socket_boolean->next; - nodeSetSocketAvailability(ntree, socket_vector, ELEM(data_type, CD_PROP_FLOAT2, CD_PROP_FLOAT3)); - nodeSetSocketAvailability(ntree, socket_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability(ntree, socket_vector, ELEM(data_type, CD_PROP_FLOAT2, CD_PROP_FLOAT3)); + bke::nodeSetSocketAvailability(ntree, socket_float, data_type == CD_PROP_FLOAT); + bke::nodeSetSocketAvailability( ntree, socket_color4f, ELEM(data_type, CD_PROP_COLOR, CD_PROP_BYTE_COLOR)); - nodeSetSocketAvailability(ntree, socket_boolean, data_type == CD_PROP_BOOL); - nodeSetSocketAvailability(ntree, socket_int32, data_type == CD_PROP_INT32); + bke::nodeSetSocketAvailability(ntree, socket_boolean, data_type == CD_PROP_BOOL); + bke::nodeSetSocketAvailability(ntree, socket_int32, data_type == CD_PROP_INT32); } static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) @@ -204,7 +204,7 @@ void register_node_type_geo_store_named_attribute() "NodeGeometryStoreNamedAttribute", node_free_standard_storage, node_copy_standard_storage); - node_type_size(&ntype, 140, 100, 700); + blender::bke::node_type_size(&ntype, 140, 100, 700); ntype.initfunc = file_ns::node_init; ntype.updatefunc = file_ns::node_update; ntype.declare = file_ns::node_declare; diff --git a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc index 027a94c544e..f88ef1da302 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc @@ -88,11 +88,11 @@ static void node_update(bNodeTree *ntree, bNode *node) const GeometryNodeStringToCurvesOverflowMode overflow = (GeometryNodeStringToCurvesOverflowMode) storage.overflow; bNodeSocket *socket_remainder = static_cast(node->outputs.first)->next; - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, socket_remainder, overflow == GEO_NODE_STRING_TO_CURVES_MODE_TRUNCATE); bNodeSocket *height_socket = static_cast(node->inputs.last); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, height_socket, overflow != GEO_NODE_STRING_TO_CURVES_MODE_OVERFLOW); } @@ -397,7 +397,7 @@ void register_node_type_geo_string_to_curves() ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.initfunc = file_ns::node_init; ntype.updatefunc = file_ns::node_update; - node_type_size(&ntype, 190, 120, 700); + blender::bke::node_type_size(&ntype, 190, 120, 700); node_type_storage(&ntype, "NodeGeometryStringToCurves", node_free_standard_storage, diff --git a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc index a2ff39b5030..0dae3c0c3d8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc @@ -202,7 +202,7 @@ void register_node_type_geo_subdivision_surface() ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.draw_buttons = file_ns::node_layout; ntype.initfunc = file_ns::node_init; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); node_type_storage(&ntype, "NodeGeometrySubdivisionSurface", node_free_standard_storage, diff --git a/source/blender/nodes/geometry/nodes/node_geo_switch.cc b/source/blender/nodes/geometry/nodes/node_geo_switch.cc index fe64b799409..8f6a03a0234 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_switch.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_switch.cc @@ -90,18 +90,18 @@ static void node_update(bNodeTree *ntree, bNode *node) const bool fields_type = ELEM( storage.input_type, SOCK_FLOAT, SOCK_INT, SOCK_BOOLEAN, SOCK_VECTOR, SOCK_RGBA, SOCK_STRING); - nodeSetSocketAvailability(ntree, field_switch, fields_type); - nodeSetSocketAvailability(ntree, non_field_switch, !fields_type); + bke::nodeSetSocketAvailability(ntree, field_switch, fields_type); + bke::nodeSetSocketAvailability(ntree, non_field_switch, !fields_type); LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, &node->inputs, index) { if (index <= 1) { continue; } - nodeSetSocketAvailability(ntree, socket, socket->type == storage.input_type); + bke::nodeSetSocketAvailability(ntree, socket, socket->type == storage.input_type); } LISTBASE_FOREACH (bNodeSocket *, socket, &node->outputs) { - nodeSetSocketAvailability(ntree, socket, socket->type == storage.input_type); + bke::nodeSetSocketAvailability(ntree, socket, socket->type == storage.input_type); } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_viewer.cc b/source/blender/nodes/geometry/nodes/node_geo_viewer.cc index dd6bd6a0ebd..6335433622c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_viewer.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_viewer.cc @@ -74,7 +74,7 @@ static void node_update(bNodeTree *ntree, bNode *node) if (socket->type == SOCK_GEOMETRY) { continue; } - nodeSetSocketAvailability(ntree, socket, socket->type == socket_type); + bke::nodeSetSocketAvailability(ntree, socket, socket->type == socket_type); } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc index 02084cf0389..d0a68ccc721 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc @@ -70,11 +70,11 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *voxel_size_socket = nodeFindSocket(node, SOCK_IN, "Voxel Size"); bNodeSocket *voxel_amount_socket = nodeFindSocket(node, SOCK_IN, "Voxel Amount"); - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, voxel_amount_socket, storage.resolution_mode == VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_AMOUNT); - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, voxel_size_socket, storage.resolution_mode == VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_SIZE); } @@ -219,7 +219,7 @@ void register_node_type_geo_volume_to_mesh() ntype.declare = file_ns::node_declare; node_type_storage( &ntype, "NodeGeometryVolumeToMesh", node_free_standard_storage, node_copy_standard_storage); - node_type_size(&ntype, 170, 120, 700); + blender::bke::node_type_size(&ntype, 170, 120, 700); ntype.initfunc = file_ns::node_init; ntype.updatefunc = file_ns::node_update; ntype.geometry_node_execute = file_ns::node_geo_exec; diff --git a/source/blender/nodes/intern/add_node_search.cc b/source/blender/nodes/intern/add_node_search.cc index 2f58f1ecff0..8634cbd82c2 100644 --- a/source/blender/nodes/intern/add_node_search.cc +++ b/source/blender/nodes/intern/add_node_search.cc @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BKE_node.h" +#include "BKE_node.hh" #include "BLT_translation.h" diff --git a/source/blender/nodes/intern/derived_node_tree.cc b/source/blender/nodes/intern/derived_node_tree.cc index ff978efc14a..4af1ada4c21 100644 --- a/source/blender/nodes/intern/derived_node_tree.cc +++ b/source/blender/nodes/intern/derived_node_tree.cc @@ -2,7 +2,7 @@ #include "NOD_derived_node_tree.hh" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BLI_dot_export.hh" diff --git a/source/blender/nodes/intern/geometry_nodes_lazy_function.cc b/source/blender/nodes/intern/geometry_nodes_lazy_function.cc index a6d508288db..940dc2bbf5b 100644 --- a/source/blender/nodes/intern/geometry_nodes_lazy_function.cc +++ b/source/blender/nodes/intern/geometry_nodes_lazy_function.cc @@ -371,7 +371,7 @@ class LazyFunctionForMultiInput : public LazyFunction { const bNodeTree &btree = socket.owner_tree(); for (const bNodeLink *link : socket.directly_linked_links()) { if (link->is_muted() || !link->fromsock->is_available() || - nodeIsDanglingReroute(&btree, link->fromnode)) + bke::nodeIsDanglingReroute(&btree, link->fromnode)) { continue; } @@ -738,7 +738,7 @@ class LazyFunctionForViewerNode : public LazyFunction { continue; } const Span links = bsocket->directly_linked_links(); - if (links.is_empty() || nodeIsDanglingReroute(&bnode.owner_tree(), links.first()->fromnode)) + if (links.is_empty() || bke::nodeIsDanglingReroute(&bnode.owner_tree(), links.first()->fromnode)) { use_field_input_ = false; inputs_.pop_last(); @@ -1543,7 +1543,7 @@ struct GeometryNodesLazyFunctionGraphBuilder { this->handle_multi_function_node(*bnode, fn_item); break; } - if (node_type == &NodeTypeUndefined) { + if (node_type == &bke::NodeTypeUndefined) { this->handle_undefined_node(*bnode); break; } @@ -1908,7 +1908,7 @@ struct GeometryNodesLazyFunctionGraphBuilder { void insert_links_from_socket(const bNodeSocket &from_bsocket, lf::OutputSocket &from_lf_socket) { - if (nodeIsDanglingReroute(&btree_, &from_bsocket.owner_node())) { + if (bke::nodeIsDanglingReroute(&btree_, &from_bsocket.owner_node())) { return; } @@ -1974,7 +1974,7 @@ struct GeometryNodesLazyFunctionGraphBuilder { break; } if (multi_input_link->is_muted() || !multi_input_link->fromsock->is_available() || - nodeIsDanglingReroute(&btree_, multi_input_link->fromnode)) + bke::nodeIsDanglingReroute(&btree_, multi_input_link->fromnode)) { continue; } diff --git a/source/blender/nodes/intern/node_common.cc b/source/blender/nodes/intern/node_common.cc index 78e2dd47022..3dd8288b633 100644 --- a/source/blender/nodes/intern/node_common.cc +++ b/source/blender/nodes/intern/node_common.cc @@ -21,7 +21,7 @@ #include "BLT_translation.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" @@ -317,11 +317,11 @@ void register_node_type_frame() bNodeType *ntype = MEM_cnew("frame node type"); ntype->free_self = (void (*)(bNodeType *))MEM_freeN; - node_type_base(ntype, NODE_FRAME, "Frame", NODE_CLASS_LAYOUT); + blender::bke::node_type_base(ntype, NODE_FRAME, "Frame", NODE_CLASS_LAYOUT); ntype->initfunc = node_frame_init; ntype->gather_add_node_search_ops = blender::nodes::search_node_add_ops_for_basic_node; node_type_storage(ntype, "NodeFrame", node_free_standard_storage, node_copy_standard_storage); - node_type_size(ntype, 150, 100, 0); + blender::bke::node_type_size(ntype, 150, 100, 0); ntype->flag |= NODE_BACKGROUND; nodeRegisterType(ntype); @@ -348,7 +348,7 @@ void register_node_type_reroute() bNodeType *ntype = MEM_cnew("frame node type"); ntype->free_self = (void (*)(bNodeType *))MEM_freeN; - node_type_base(ntype, NODE_REROUTE, "Reroute", NODE_CLASS_LAYOUT); + blender::bke::node_type_base(ntype, NODE_REROUTE, "Reroute", NODE_CLASS_LAYOUT); ntype->initfunc = node_reroute_init; ntype->gather_add_node_search_ops = blender::nodes::search_node_add_ops_for_basic_node; @@ -438,15 +438,15 @@ void ntree_update_reroute_nodes(bNodeTree *ntree) bNodeSocket *output_socket = (bNodeSocket *)reroute_node->outputs.first; if (input_socket->typeinfo != socket_type) { - nodeModifySocketType(ntree, reroute_node, input_socket, socket_type->idname); + blender::bke::nodeModifySocketType(ntree, reroute_node, input_socket, socket_type->idname); } if (output_socket->typeinfo != socket_type) { - nodeModifySocketType(ntree, reroute_node, output_socket, socket_type->idname); + blender::bke::nodeModifySocketType(ntree, reroute_node, output_socket, socket_type->idname); } } } -bool BKE_node_is_connected_to_output(const bNodeTree *ntree, const bNode *node) +bool blender::bke::node_is_connected_to_output(const bNodeTree *ntree, const bNode *node) { ntree->ensure_topology_cache(); Stack nodes_to_check; @@ -523,7 +523,7 @@ static bool group_input_insert_link(bNodeTree *ntree, bNode *node, bNodeLink *li /* Don't connect to other "extend" sockets. */ return false; } - const bNodeSocket *io_socket = ntreeAddSocketInterfaceFromSocket( + const bNodeSocket *io_socket = blender::bke::ntreeAddSocketInterfaceFromSocket( ntree, link->tonode, link->tosock); if (!io_socket) { return false; @@ -544,7 +544,7 @@ static bool group_output_insert_link(bNodeTree *ntree, bNode *node, bNodeLink *l /* Don't connect to other "extend" sockets. */ return false; } - const bNodeSocket *io_socket = ntreeAddSocketInterfaceFromSocket( + const bNodeSocket *io_socket = blender::bke::ntreeAddSocketInterfaceFromSocket( ntree, link->fromnode, link->fromsock); if (!io_socket) { return false; @@ -562,8 +562,8 @@ void register_node_type_group_input() bNodeType *ntype = MEM_cnew("node type"); ntype->free_self = (void (*)(bNodeType *))MEM_freeN; - node_type_base(ntype, NODE_GROUP_INPUT, "Group Input", NODE_CLASS_INTERFACE); - node_type_size(ntype, 140, 80, 400); + blender::bke::node_type_base(ntype, NODE_GROUP_INPUT, "Group Input", NODE_CLASS_INTERFACE); + blender::bke::node_type_size(ntype, 140, 80, 400); ntype->gather_add_node_search_ops = blender::nodes::search_node_add_ops_for_basic_node; ntype->declare_dynamic = blender::nodes::group_input_declare_dynamic; ntype->insert_link = blender::nodes::group_input_insert_link; @@ -588,8 +588,8 @@ void register_node_type_group_output() bNodeType *ntype = MEM_cnew("node type"); ntype->free_self = (void (*)(bNodeType *))MEM_freeN; - node_type_base(ntype, NODE_GROUP_OUTPUT, "Group Output", NODE_CLASS_INTERFACE); - node_type_size(ntype, 140, 80, 400); + blender::bke::node_type_base(ntype, NODE_GROUP_OUTPUT, "Group Output", NODE_CLASS_INTERFACE); + blender::bke::node_type_size(ntype, 140, 80, 400); ntype->gather_add_node_search_ops = blender::nodes::search_node_add_ops_for_basic_node; ntype->declare_dynamic = blender::nodes::group_output_declare_dynamic; ntype->insert_link = blender::nodes::group_output_insert_link; diff --git a/source/blender/nodes/intern/node_declaration.cc b/source/blender/nodes/intern/node_declaration.cc index da51b760887..ad813be356b 100644 --- a/source/blender/nodes/intern/node_declaration.cc +++ b/source/blender/nodes/intern/node_declaration.cc @@ -5,7 +5,7 @@ #include "NOD_socket_declarations_geometry.hh" #include "BKE_geometry_fields.hh" -#include "BKE_node.h" +#include "BKE_node.hh" namespace blender::nodes { diff --git a/source/blender/nodes/intern/node_exec.cc b/source/blender/nodes/intern/node_exec.cc index b5b4cd0f707..3a258cc615b 100644 --- a/source/blender/nodes/intern/node_exec.cc +++ b/source/blender/nodes/intern/node_exec.cc @@ -11,7 +11,7 @@ #include "BLI_utildefines.h" #include "BKE_global.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" diff --git a/source/blender/nodes/intern/node_exec.hh b/source/blender/nodes/intern/node_exec.hh index 1cdddeb6efb..3e232b9810f 100644 --- a/source/blender/nodes/intern/node_exec.hh +++ b/source/blender/nodes/intern/node_exec.hh @@ -11,7 +11,7 @@ #include "BLI_utildefines.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "node_util.hh" diff --git a/source/blender/nodes/intern/node_multi_function.cc b/source/blender/nodes/intern/node_multi_function.cc index d731fe8f877..db2d33bdb79 100644 --- a/source/blender/nodes/intern/node_multi_function.cc +++ b/source/blender/nodes/intern/node_multi_function.cc @@ -2,7 +2,7 @@ #include "NOD_multi_function.hh" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" namespace blender::nodes { diff --git a/source/blender/nodes/intern/node_register.cc b/source/blender/nodes/intern/node_register.cc index 9653ded3438..65ffd8373ab 100644 --- a/source/blender/nodes/intern/node_register.cc +++ b/source/blender/nodes/intern/node_register.cc @@ -3,7 +3,7 @@ #include "NOD_register.hh" #include "NOD_socket.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "ED_node.hh" @@ -26,22 +26,22 @@ static void register_undefined_types() * they are just used as placeholders in case the actual types are not registered. */ - NodeTreeTypeUndefined.type = NTREE_UNDEFINED; - strcpy(NodeTreeTypeUndefined.idname, "NodeTreeUndefined"); - strcpy(NodeTreeTypeUndefined.ui_name, N_("Undefined")); - strcpy(NodeTreeTypeUndefined.ui_description, N_("Undefined Node Tree Type")); + blender::bke::NodeTreeTypeUndefined.type = NTREE_UNDEFINED; + strcpy(blender::bke::NodeTreeTypeUndefined.idname, "NodeTreeUndefined"); + strcpy(blender::bke::NodeTreeTypeUndefined.ui_name, N_("Undefined")); + strcpy(blender::bke::NodeTreeTypeUndefined.ui_description, N_("Undefined Node Tree Type")); - node_type_base_custom(&NodeTypeUndefined, "NodeUndefined", "Undefined", 0); - NodeTypeUndefined.poll = node_undefined_poll; + node_type_base_custom(&blender::bke::NodeTypeUndefined, "NodeUndefined", "Undefined", 0); + blender::bke::NodeTypeUndefined.poll = node_undefined_poll; - STRNCPY(NodeSocketTypeUndefined.idname, "NodeSocketUndefined"); + STRNCPY(blender::bke::NodeSocketTypeUndefined.idname, "NodeSocketUndefined"); /* extra type info for standard socket types */ - NodeSocketTypeUndefined.type = SOCK_CUSTOM; - NodeSocketTypeUndefined.subtype = PROP_NONE; + blender::bke::NodeSocketTypeUndefined.type = SOCK_CUSTOM; + blender::bke::NodeSocketTypeUndefined.subtype = PROP_NONE; - NodeSocketTypeUndefined.use_link_limits_of_type = true; - NodeSocketTypeUndefined.input_link_limit = 0xFFF; - NodeSocketTypeUndefined.output_link_limit = 0xFFF; + blender::bke::NodeSocketTypeUndefined.use_link_limits_of_type = true; + blender::bke::NodeSocketTypeUndefined.input_link_limit = 0xFFF; + blender::bke::NodeSocketTypeUndefined.output_link_limit = 0xFFF; } void register_nodes() diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc index e4f6e08dbcb..f581bfc8439 100644 --- a/source/blender/nodes/intern/node_socket.cc +++ b/source/blender/nodes/intern/node_socket.cc @@ -18,7 +18,7 @@ #include "BKE_geometry_set.hh" #include "BKE_lib_id.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" @@ -240,7 +240,7 @@ static void refresh_socket_list(bNodeTree &ntree, } LISTBASE_FOREACH_MUTABLE (bNodeSocket *, old_socket, &sockets) { if (!new_sockets.contains(old_socket)) { - nodeRemoveSocketEx(&ntree, &node, old_socket, do_id_user); + blender::bke::nodeRemoveSocketEx(&ntree, &node, old_socket, do_id_user); } } BLI_listbase_clear(&sockets); @@ -261,7 +261,7 @@ static void refresh_node(bNodeTree &ntree, refresh_socket_list(ntree, node, node.inputs, node_decl.inputs, do_id_user); refresh_socket_list(ntree, node, node.outputs, node_decl.outputs, do_id_user); } - nodeSocketDeclarationsUpdate(&node); + blender::bke::nodeSocketDeclarationsUpdate(&node); } void update_node_declaration_and_sockets(bNodeTree &ntree, bNode &node) @@ -284,7 +284,7 @@ void node_verify_sockets(bNodeTree *ntree, bNode *node, bool do_id_user) return; } if (ntype->declare || ntype->declare_dynamic) { - nodeDeclarationEnsureOnOutdatedNode(ntree, node); + blender::bke::nodeDeclarationEnsureOnOutdatedNode(ntree, node); refresh_node(*ntree, *node, *node->runtime->declaration, do_id_user); return; } @@ -537,7 +537,7 @@ static bNodeSocketType *make_standard_socket_type(int type, int subtype) const char *socket_idname = nodeStaticSocketType(type, subtype); const char *interface_idname = nodeStaticSocketInterfaceType(type, subtype); const char *socket_label = nodeStaticSocketLabel(type, subtype); - const char *socket_subtype_label = nodeSocketSubTypeLabel(subtype); + const char *socket_subtype_label = blender::bke::nodeSocketSubTypeLabel(subtype); bNodeSocketType *stype; StructRNA *srna; diff --git a/source/blender/nodes/intern/node_socket_declarations.cc b/source/blender/nodes/intern/node_socket_declarations.cc index 018be8eb896..496bd888be4 100644 --- a/source/blender/nodes/intern/node_socket_declarations.cc +++ b/source/blender/nodes/intern/node_socket_declarations.cc @@ -4,7 +4,7 @@ #include "NOD_socket_declarations_geometry.hh" #include "BKE_lib_id.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BLI_math_vector.h" diff --git a/source/blender/nodes/intern/node_util.cc b/source/blender/nodes/intern/node_util.cc index b0268b5e986..7983635073a 100644 --- a/source/blender/nodes/intern/node_util.cc +++ b/source/blender/nodes/intern/node_util.cc @@ -19,7 +19,7 @@ #include "BLT_translation.h" #include "BKE_colortools.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" @@ -90,7 +90,7 @@ void node_math_update(bNodeTree *ntree, bNode *node) bNodeSocket *sock1 = static_cast(BLI_findlink(&node->inputs, 0)); bNodeSocket *sock2 = static_cast(BLI_findlink(&node->inputs, 1)); bNodeSocket *sock3 = static_cast(BLI_findlink(&node->inputs, 2)); - nodeSetSocketAvailability(ntree, + blender::bke::nodeSetSocketAvailability(ntree, sock2, !ELEM(node->custom1, NODE_MATH_SQRT, @@ -115,7 +115,7 @@ void node_math_update(bNodeTree *ntree, bNode *node) NODE_MATH_COSH, NODE_MATH_SINH, NODE_MATH_TANH)); - nodeSetSocketAvailability(ntree, + blender::bke::nodeSetSocketAvailability(ntree, sock3, ELEM(node->custom1, NODE_MATH_COMPARE, @@ -195,7 +195,7 @@ void node_image_label(const bNodeTree * /*ntree*/, int label_maxncpy) { /* If there is no loaded image, return an empty string, - * and let nodeLabel() fill in the proper type translation. */ + * and let blender::bke::nodeLabel() fill in the proper type translation. */ BLI_strncpy(label, (node->id) ? node->id->name + 2 : "", label_maxncpy); } diff --git a/source/blender/nodes/intern/socket_search_link.cc b/source/blender/nodes/intern/socket_search_link.cc index 75a9f24ad53..29d9a718ed1 100644 --- a/source/blender/nodes/intern/socket_search_link.cc +++ b/source/blender/nodes/intern/socket_search_link.cc @@ -3,7 +3,7 @@ #include "BLI_set.hh" #include "BKE_context.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "UI_interface.h" diff --git a/source/blender/nodes/shader/node_shader_tree.cc b/source/blender/nodes/shader/node_shader_tree.cc index a138d7da5eb..cbb54ba95b7 100644 --- a/source/blender/nodes/shader/node_shader_tree.cc +++ b/source/blender/nodes/shader/node_shader_tree.cc @@ -29,7 +29,7 @@ #include "BKE_layer.h" #include "BKE_lib_id.h" #include "BKE_linestyle.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" #include "BKE_scene.h" @@ -128,8 +128,8 @@ static void localize(bNodeTree *localtree, bNodeTree * /*ntree*/) /* replace muted nodes and reroute nodes by internal links */ LISTBASE_FOREACH_MUTABLE (bNode *, node, &localtree->nodes) { if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) { - nodeInternalRelink(localtree, node); - ntreeFreeLocalNode(localtree, node); + blender::bke::nodeInternalRelink(localtree, node); + blender::bke::ntreeFreeLocalNode(localtree, node); } } } @@ -154,7 +154,7 @@ static bool shader_validate_link(eNodeSocketDatatype from, eNodeSocketDatatype t static bool shader_node_tree_socket_type_valid(bNodeTreeType * /*ntreetype*/, bNodeSocketType *socket_type) { - return nodeIsStaticSocketType(socket_type) && + return blender::bke::nodeIsStaticSocketType(socket_type) && ELEM(socket_type->type, SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA, SOCK_SHADER); } @@ -505,7 +505,7 @@ static void flatten_group_do(bNodeTree *ntree, bNode *gnode) while (group_interface_nodes) { bNode *node = static_cast(BLI_linklist_pop(&group_interface_nodes)); - ntreeFreeLocalNode(ntree, node); + blender::bke::ntreeFreeLocalNode(ntree, node); } BKE_ntree_update_tag_all(ntree); @@ -525,8 +525,8 @@ static void ntree_shader_groups_flatten(bNodeTree *localtree) node_next = node->next; /* delete the group instance and its localtree. */ bNodeTree *ngroup = (bNodeTree *)node->id; - ntreeFreeLocalNode(localtree, node); - ntreeFreeTree(ngroup); + blender::bke::ntreeFreeLocalNode(localtree, node); + blender::bke::ntreeFreeTree(ngroup); BLI_assert(!ngroup->id.py_instance); /* Or call #BKE_libblock_free_data_py. */ MEM_freeN(ngroup); } @@ -578,7 +578,7 @@ static bNode *ntree_shader_copy_branch(bNodeTree *ntree, branchIterData iter_data; iter_data.node_filter = node_filter; iter_data.node_count = 1; - nodeChainIterBackwards(ntree, start_node, ntree_branch_count_and_tag_nodes, &iter_data, 1); + blender::bke::nodeChainIterBackwards(ntree, start_node, ntree_branch_count_and_tag_nodes, &iter_data, 1); /* Make a full copy of the branch */ Array nodes_copy(iter_data.node_count); LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { @@ -721,7 +721,7 @@ static void ntree_shader_weight_tree_invert(bNodeTree *ntree, bNode *output_node /* Tag nodes from the weight tree. Only tag output node and mix/add shader nodes. */ output_node->runtime->tmp_flag = 0; int node_count = 1; - nodeChainIterBackwards(ntree, output_node, ntree_weight_tree_tag_nodes, &node_count, 0); + blender::bke::nodeChainIterBackwards(ntree, output_node, ntree_weight_tree_tag_nodes, &node_count, 0); /* Make a mirror copy of the weight tree. */ Array nodes_copy(node_count); LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { @@ -984,7 +984,7 @@ static void ntree_shader_shader_to_rgba_branch(bNodeTree *ntree, bNode *output_n /* First gather the shader_to_rgba nodes linked to the output. This is separate to avoid * conflicting usage of the `node->runtime->tmp_flag`. */ Vector shader_to_rgba_nodes; - nodeChainIterBackwards(ntree, output_node, shader_to_rgba_node_gather, &shader_to_rgba_nodes, 0); + blender::bke::nodeChainIterBackwards(ntree, output_node, shader_to_rgba_node_gather, &shader_to_rgba_nodes, 0); for (bNode *shader_to_rgba : shader_to_rgba_nodes) { bNodeSocket *closure_input = ntree_shader_node_input_get(shader_to_rgba, 0); @@ -1115,18 +1115,18 @@ static void ntree_shader_pruned_unused(bNodeTree *ntree, bNode *output_node) /* Avoid deleting the output node if it is the only node in the tree. */ output_node->runtime->tmp_flag = 1; - nodeChainIterBackwards(ntree, output_node, ntree_branch_node_tag, nullptr, 0); + blender::bke::nodeChainIterBackwards(ntree, output_node, ntree_branch_node_tag, nullptr, 0); LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_OUTPUT_AOV) { node->runtime->tmp_flag = 1; - nodeChainIterBackwards(ntree, node, ntree_branch_node_tag, nullptr, 0); + blender::bke::nodeChainIterBackwards(ntree, node, ntree_branch_node_tag, nullptr, 0); } } LISTBASE_FOREACH_MUTABLE (bNode *, node, &ntree->nodes) { if (node->runtime->tmp_flag == 0) { - ntreeFreeLocalNode(ntree, node); + blender::bke::ntreeFreeLocalNode(ntree, node); changed = true; } } diff --git a/source/blender/nodes/shader/node_shader_util.cc b/source/blender/nodes/shader/node_shader_util.cc index eb00a68bb18..e75b2e35481 100644 --- a/source/blender/nodes/shader/node_shader_util.cc +++ b/source/blender/nodes/shader/node_shader_util.cc @@ -44,7 +44,7 @@ static bool sh_fn_poll_default(const bNodeType * /*ntype*/, void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass) { - node_type_base(ntype, type, name, nclass); + blender::bke::node_type_base(ntype, type, name, nclass); ntype->poll = sh_node_poll_default; ntype->insert_link = node_insert_link_default; @@ -209,7 +209,7 @@ static void data_from_gpu_stack_list(ListBase *sockets, bNodeStack **ns, GPUNode } } -bool nodeSupportsActiveFlag(const bNode *node, int sub_activity) +bool blender::bke::nodeSupportsActiveFlag(const bNode *node, int sub_activity) { BLI_assert(ELEM(sub_activity, NODE_ACTIVE_TEXTURE, NODE_ACTIVE_PAINT_CANVAS)); switch (sub_activity) { @@ -240,7 +240,7 @@ static bNode *node_get_active(bNodeTree *ntree, int sub_activity) return node; } } - else if (!inactivenode && nodeSupportsActiveFlag(node, sub_activity)) { + else if (!inactivenode && blender::bke::nodeSupportsActiveFlag(node, sub_activity)) { inactivenode = node; } else if (node->type == NODE_GROUP) { @@ -286,10 +286,13 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree) return node_get_active(ntree, NODE_ACTIVE_TEXTURE); } +namespace blender::bke { + bNode *nodeGetActivePaintCanvas(bNodeTree *ntree) { return node_get_active(ntree, NODE_ACTIVE_PAINT_CANVAS); } +} void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node) { diff --git a/source/blender/nodes/shader/node_shader_util.hh b/source/blender/nodes/shader/node_shader_util.hh index 2e2f6f39a6b..3fa86d6fb14 100644 --- a/source/blender/nodes/shader/node_shader_util.hh +++ b/source/blender/nodes/shader/node_shader_util.hh @@ -28,7 +28,7 @@ #include "BKE_image.h" #include "BKE_main.h" #include "BKE_material.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_texture.h" #include "DNA_ID.h" diff --git a/source/blender/nodes/shader/nodes/node_shader_blackbody.cc b/source/blender/nodes/shader/nodes/node_shader_blackbody.cc index 415f1e67f33..1dfc5ce09de 100644 --- a/source/blender/nodes/shader/nodes/node_shader_blackbody.cc +++ b/source/blender/nodes/shader/nodes/node_shader_blackbody.cc @@ -41,7 +41,7 @@ void register_node_type_sh_blackbody() sh_node_type_base(&ntype, SH_NODE_BLACKBODY, "Blackbody", NODE_CLASS_CONVERTER); ntype.declare = file_ns::node_declare; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.gpu_fn = file_ns::node_shader_gpu_blackbody; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc index f28c31d0288..0d94bfb6d80 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc @@ -69,7 +69,7 @@ void register_node_type_sh_bsdf_anisotropic() ntype.declare = file_ns::node_declare; ntype.add_ui_poll = object_cycles_shader_nodes_poll; ntype.draw_buttons = file_ns::node_shader_buts_anisotropic; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.initfunc = file_ns::node_shader_init_anisotropic; ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_anisotropic; diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.cc index ba0ccb21720..13d89e76a17 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.cc @@ -45,7 +45,7 @@ void register_node_type_sh_bsdf_diffuse() sh_node_type_base(&ntype, SH_NODE_BSDF_DIFFUSE, "Diffuse BSDF", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; ntype.add_ui_poll = object_shader_nodes_poll; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_diffuse; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.cc index f243ccd3e41..ef949a0e295 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.cc @@ -57,7 +57,7 @@ void register_node_type_sh_bsdf_glass() sh_node_type_base(&ntype, SH_NODE_BSDF_GLASS, "Glass BSDF", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; ntype.add_ui_poll = object_shader_nodes_poll; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.initfunc = file_ns::node_shader_init_glass; ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_glass; diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.cc index c2a4d1d3501..9a25c326988 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.cc @@ -56,7 +56,7 @@ void register_node_type_sh_bsdf_glossy() sh_node_type_base(&ntype, SH_NODE_BSDF_GLOSSY, "Glossy BSDF", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; ntype.add_ui_poll = object_shader_nodes_poll; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.initfunc = file_ns::node_shader_init_glossy; ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_glossy; diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc index b167fb979e2..806a3ae15c0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc @@ -58,7 +58,7 @@ void register_node_type_sh_bsdf_hair() ntype.declare = file_ns::node_declare; ntype.add_ui_poll = object_cycles_shader_nodes_poll; ntype.draw_buttons = file_ns::node_shader_buts_hair; - node_type_size(&ntype, 150, 60, 200); + blender::bke::node_type_size(&ntype, 150, 60, 200); ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_hair; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc index 3712c53d2a3..d168f410072 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc @@ -81,26 +81,27 @@ static void node_shader_update_hair_principled(bNodeTree *ntree, bNode *node) LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { if (STREQ(sock->name, "Color")) { - nodeSetSocketAvailability(ntree, sock, parametrization == SHD_PRINCIPLED_HAIR_REFLECTANCE); + bke::nodeSetSocketAvailability( + ntree, sock, parametrization == SHD_PRINCIPLED_HAIR_REFLECTANCE); } else if (STREQ(sock->name, "Melanin")) { - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, sock, parametrization == SHD_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION); } else if (STREQ(sock->name, "Melanin Redness")) { - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, sock, parametrization == SHD_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION); } else if (STREQ(sock->name, "Tint")) { - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, sock, parametrization == SHD_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION); } else if (STREQ(sock->name, "Absorption Coefficient")) { - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, sock, parametrization == SHD_PRINCIPLED_HAIR_DIRECT_ABSORPTION); } else if (STREQ(sock->name, "Random Color")) { - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, sock, parametrization == SHD_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION); } } @@ -129,7 +130,7 @@ void register_node_type_sh_bsdf_hair_principled() ntype.declare = file_ns::node_declare; ntype.add_ui_poll = object_cycles_shader_nodes_poll; ntype.draw_buttons = file_ns::node_shader_buts_principled_hair; - node_type_size_preset(&ntype, NODE_SIZE_LARGE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::LARGE); ntype.initfunc = file_ns::node_shader_init_hair_principled; ntype.updatefunc = file_ns::node_shader_update_hair_principled; ntype.gpu_fn = file_ns::node_shader_gpu_hair_principled; diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc index 8cb4e3ad632..dcd4f6141ea 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc @@ -225,11 +225,11 @@ static void node_shader_update_principled(bNodeTree *ntree, bNode *node) LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { if (STREQ(sock->name, "Transmission Roughness")) { - nodeSetSocketAvailability(ntree, sock, distribution == SHD_GLOSSY_GGX); + bke::nodeSetSocketAvailability(ntree, sock, distribution == SHD_GLOSSY_GGX); } if (STR_ELEM(sock->name, "Subsurface IOR", "Subsurface Anisotropy")) { - nodeSetSocketAvailability(ntree, sock, sss_method != SHD_SUBSURFACE_BURLEY); + bke::nodeSetSocketAvailability(ntree, sock, sss_method != SHD_SUBSURFACE_BURLEY); } } } @@ -247,7 +247,7 @@ void register_node_type_sh_bsdf_principled() ntype.declare = file_ns::node_declare; ntype.add_ui_poll = object_shader_nodes_poll; ntype.draw_buttons = file_ns::node_shader_buts_principled; - node_type_size_preset(&ntype, NODE_SIZE_LARGE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::LARGE); ntype.initfunc = file_ns::node_shader_init_principled; ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_principled; ntype.updatefunc = file_ns::node_shader_update_principled; diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.cc index 21cfe4eb6af..368553ad7b7 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.cc @@ -55,7 +55,7 @@ void register_node_type_sh_bsdf_refraction() sh_node_type_base(&ntype, SH_NODE_BSDF_REFRACTION, "Refraction BSDF", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; ntype.add_ui_poll = object_shader_nodes_poll; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.initfunc = file_ns::node_shader_init_refraction; ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_refraction; diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc index adc02379926..51847e43b46 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc @@ -59,7 +59,7 @@ void register_node_type_sh_bsdf_toon() ntype.declare = file_ns::node_declare; ntype.add_ui_poll = object_cycles_shader_nodes_poll; ntype.draw_buttons = file_ns::node_shader_buts_toon; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_toon; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc b/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc index 46a8417a624..2138c44d71b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc +++ b/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc @@ -139,7 +139,7 @@ void register_node_type_sh_valtorgb() sh_fn_node_type_base(&ntype, SH_NODE_VALTORGB, "Color Ramp", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_valtorgb_declare; ntype.initfunc = file_ns::node_shader_init_valtorgb; - node_type_size_preset(&ntype, NODE_SIZE_LARGE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::LARGE); node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage); ntype.gpu_fn = file_ns::gpu_shader_valtorgb; ntype.build_multi_function = file_ns::sh_node_valtorgb_build_multi_function; diff --git a/source/blender/nodes/shader/nodes/node_shader_common.cc b/source/blender/nodes/shader/nodes/node_shader_common.cc index 54b36d78180..9a7692bbc99 100644 --- a/source/blender/nodes/shader/nodes/node_shader_common.cc +++ b/source/blender/nodes/shader/nodes/node_shader_common.cc @@ -9,7 +9,7 @@ #include "BLI_utildefines.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "NOD_common.h" @@ -93,7 +93,7 @@ void register_node_type_sh_group() BLI_assert(ntype.rna_ext.srna != nullptr); RNA_struct_blender_type_set(ntype.rna_ext.srna, &ntype); - node_type_size(&ntype, 140, 60, 400); + blender::bke::node_type_size(&ntype, 140, 60, 400); ntype.labelfunc = node_group_label; ntype.declare_dynamic = blender::nodes::node_group_declare_dynamic; ntype.gpu_fn = gpu_group_execute; diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.cc b/source/blender/nodes/shader/nodes/node_shader_curves.cc index 9933e367f90..537ec289d5e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.cc +++ b/source/blender/nodes/shader/nodes/node_shader_curves.cc @@ -115,7 +115,7 @@ void register_node_type_sh_curve_vec() sh_fn_node_type_base(&ntype, SH_NODE_CURVE_VEC, "Vector Curves", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::sh_node_curve_vec_declare; ntype.initfunc = file_ns::node_shader_init_curve_vec; - node_type_size_preset(&ntype, NODE_SIZE_LARGE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::LARGE); node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); ntype.gpu_fn = file_ns::gpu_shader_curve_vec; ntype.build_multi_function = file_ns::sh_node_curve_vec_build_multi_function; @@ -261,7 +261,7 @@ void register_node_type_sh_curve_rgb() sh_fn_node_type_base(&ntype, SH_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::sh_node_curve_rgb_declare; ntype.initfunc = file_ns::node_shader_init_curve_rgb; - node_type_size_preset(&ntype, NODE_SIZE_LARGE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::LARGE); node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); ntype.gpu_fn = file_ns::gpu_shader_curve_rgb; ntype.build_multi_function = file_ns::sh_node_curve_rgb_build_multi_function; @@ -379,7 +379,7 @@ void register_node_type_sh_curve_float() sh_fn_node_type_base(&ntype, SH_NODE_CURVE_FLOAT, "Float Curve", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_curve_float_declare; ntype.initfunc = file_ns::node_shader_init_curve_float; - node_type_size_preset(&ntype, NODE_SIZE_LARGE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::LARGE); node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); ntype.gpu_fn = file_ns::gpu_shader_curve_float; ntype.build_multi_function = file_ns::sh_node_curve_float_build_multi_function; diff --git a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.cc b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.cc index 696bc12c7c1..2970c59e378 100644 --- a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.cc +++ b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.cc @@ -42,7 +42,7 @@ void register_node_type_sh_hue_sat() sh_node_type_base(&ntype, SH_NODE_HUE_SAT, "Hue/Saturation/Value", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::node_declare; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.gpu_fn = file_ns::gpu_shader_hue_sat; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_light_falloff.cc b/source/blender/nodes/shader/nodes/node_shader_light_falloff.cc index 9c742a5097a..a662f2fb155 100644 --- a/source/blender/nodes/shader/nodes/node_shader_light_falloff.cc +++ b/source/blender/nodes/shader/nodes/node_shader_light_falloff.cc @@ -34,7 +34,7 @@ void register_node_type_sh_light_falloff() sh_node_type_base(&ntype, SH_NODE_LIGHT_FALLOFF, "Light Falloff", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::node_declare; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.gpu_fn = file_ns::node_shader_gpu_light_falloff; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_map_range.cc b/source/blender/nodes/shader/nodes/node_shader_map_range.cc index 80c4331a492..8645bd1cb2e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_map_range.cc +++ b/source/blender/nodes/shader/nodes/node_shader_map_range.cc @@ -88,10 +88,10 @@ static void node_shader_update_map_range(bNodeTree *ntree, bNode *node) } LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, &node->inputs, index) { - nodeSetSocketAvailability(ntree, socket, new_input_availability[index]); + bke::nodeSetSocketAvailability(ntree, socket, new_input_availability[index]); } LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, &node->outputs, index) { - nodeSetSocketAvailability(ntree, socket, new_output_availability[index]); + bke::nodeSetSocketAvailability(ntree, socket, new_output_availability[index]); } } diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.cc b/source/blender/nodes/shader/nodes/node_shader_mapping.cc index f7c1eb3b7ad..6573784a3a6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mapping.cc +++ b/source/blender/nodes/shader/nodes/node_shader_mapping.cc @@ -72,7 +72,7 @@ static int gpu_shader_mapping(GPUMaterial *mat, static void node_shader_update_mapping(bNodeTree *ntree, bNode *node) { bNodeSocket *sock = nodeFindSocket(node, SOCK_IN, "Location"); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, sock, ELEM(node->custom1, NODE_MAPPING_TYPE_POINT, NODE_MAPPING_TYPE_TEXTURE)); } diff --git a/source/blender/nodes/shader/nodes/node_shader_mix.cc b/source/blender/nodes/shader/nodes/node_shader_mix.cc index 5235475adad..b6e9a0c9972 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mix.cc +++ b/source/blender/nodes/shader/nodes/node_shader_mix.cc @@ -116,16 +116,16 @@ static void sh_node_mix_update(bNodeTree *ntree, bNode *node) bool use_vector_factor = data_type == SOCK_VECTOR && storage.factor_mode != NODE_MIX_MODE_UNIFORM; - nodeSetSocketAvailability(ntree, sock_factor, !use_vector_factor); + bke::nodeSetSocketAvailability(ntree, sock_factor, !use_vector_factor); - nodeSetSocketAvailability(ntree, sock_factor_vec, use_vector_factor); + bke::nodeSetSocketAvailability(ntree, sock_factor_vec, use_vector_factor); for (bNodeSocket *socket = sock_factor_vec->next; socket != nullptr; socket = socket->next) { - nodeSetSocketAvailability(ntree, socket, socket->type == data_type); + bke::nodeSetSocketAvailability(ntree, socket, socket->type == data_type); } LISTBASE_FOREACH (bNodeSocket *, socket, &node->outputs) { - nodeSetSocketAvailability(ntree, socket, socket->type == data_type); + bke::nodeSetSocketAvailability(ntree, socket, socket->type == data_type); } } diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.cc b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc index acac0f60d83..d1f65c539ac 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal_map.cc +++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc @@ -126,7 +126,7 @@ void register_node_type_sh_normal_map() sh_node_type_base(&ntype, SH_NODE_NORMAL_MAP, "Normal Map", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_normal_map; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.initfunc = file_ns::node_shader_init_normal_map; node_type_storage( &ntype, "NodeShaderNormalMap", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc index 3278907b9b8..28722e4df3c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc +++ b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc @@ -70,7 +70,7 @@ static void node_shader_update_subsurface_scattering(bNodeTree *ntree, bNode *no LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { if (STR_ELEM(sock->name, "IOR", "Anisotropy")) { - nodeSetSocketAvailability(ntree, sock, sss_method != SHD_SUBSURFACE_BURLEY); + bke::nodeSetSocketAvailability(ntree, sock, sss_method != SHD_SUBSURFACE_BURLEY); } } } @@ -89,7 +89,7 @@ void register_node_type_sh_subsurface_scattering() ntype.declare = file_ns::node_declare; ntype.add_ui_poll = object_shader_nodes_poll; ntype.draw_buttons = file_ns::node_shader_buts_subsurface; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.initfunc = file_ns::node_shader_init_subsurface_scattering; ntype.gpu_fn = file_ns::node_shader_gpu_subsurface_scattering; ntype.updatefunc = file_ns::node_shader_update_subsurface_scattering; diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.cc b/source/blender/nodes/shader/nodes/node_shader_tangent.cc index d2a62916024..6e4f7db178a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tangent.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tangent.cc @@ -94,7 +94,7 @@ void register_node_type_sh_tangent() sh_node_type_base(&ntype, SH_NODE_TANGENT, "Tangent", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_tangent; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.initfunc = file_ns::node_shader_init_tangent; ntype.gpu_fn = file_ns::node_shader_gpu_tangent; node_type_storage( diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc b/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc index 73d9c08116e..67c474b61e6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc @@ -278,7 +278,7 @@ void register_node_type_sh_tex_brick() sh_fn_node_type_base(&ntype, SH_NODE_TEX_BRICK, "Brick Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_brick_declare; ntype.draw_buttons = file_ns::node_shader_buts_tex_brick; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.initfunc = file_ns::node_shader_init_tex_brick; node_type_storage( &ntype, "NodeTexBrick", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc b/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc index ce98ffb0616..0c666ee8c14 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc @@ -137,7 +137,7 @@ void register_node_type_sh_tex_environment() &ntype, "NodeTexEnvironment", node_free_standard_storage, node_copy_standard_storage); ntype.gpu_fn = file_ns::node_shader_gpu_tex_environment; ntype.labelfunc = node_image_label; - node_type_size_preset(&ntype, NODE_SIZE_LARGE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::LARGE); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.cc b/source/blender/nodes/shader/nodes/node_shader_tex_image.cc index 78b3233b879..75d8447c664 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.cc @@ -181,7 +181,7 @@ void register_node_type_sh_tex_image() &ntype, "NodeTexImage", node_free_standard_storage, node_copy_standard_storage); ntype.gpu_fn = file_ns::node_shader_gpu_tex_image; ntype.labelfunc = node_image_label; - node_type_size_preset(&ntype, NODE_SIZE_LARGE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::LARGE); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc index 589dbbd46d2..03dfe447561 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc @@ -110,16 +110,18 @@ static void node_shader_update_tex_musgrave(bNodeTree *ntree, bNode *node) bNodeSocket *inOffsetSock = nodeFindSocket(node, SOCK_IN, "Offset"); bNodeSocket *inGainSock = nodeFindSocket(node, SOCK_IN, "Gain"); - nodeSetSocketAvailability(ntree, inVectorSock, storage.dimensions != 1); - nodeSetSocketAvailability(ntree, inWSock, storage.dimensions == 1 || storage.dimensions == 4); - nodeSetSocketAvailability(ntree, - inOffsetSock, - storage.musgrave_type != SHD_MUSGRAVE_MULTIFRACTAL && - storage.musgrave_type != SHD_MUSGRAVE_FBM); - nodeSetSocketAvailability(ntree, - inGainSock, - storage.musgrave_type == SHD_MUSGRAVE_HYBRID_MULTIFRACTAL || - storage.musgrave_type == SHD_MUSGRAVE_RIDGED_MULTIFRACTAL); + bke::nodeSetSocketAvailability(ntree, inVectorSock, storage.dimensions != 1); + bke::nodeSetSocketAvailability( + ntree, inWSock, storage.dimensions == 1 || storage.dimensions == 4); + bke::nodeSetSocketAvailability(ntree, + inOffsetSock, + storage.musgrave_type != SHD_MUSGRAVE_MULTIFRACTAL && + storage.musgrave_type != SHD_MUSGRAVE_FBM); + bke::nodeSetSocketAvailability( + ntree, + inGainSock, + storage.musgrave_type == SHD_MUSGRAVE_HYBRID_MULTIFRACTAL || + storage.musgrave_type == SHD_MUSGRAVE_RIDGED_MULTIFRACTAL); bNodeSocket *outFacSock = nodeFindSocket(node, SOCK_OUT, "Fac"); node_sock_label(outFacSock, "Height"); @@ -536,7 +538,7 @@ void register_node_type_sh_tex_musgrave() sh_fn_node_type_base(&ntype, SH_NODE_TEX_MUSGRAVE, "Musgrave Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_musgrave_declare; ntype.draw_buttons = file_ns::node_shader_buts_tex_musgrave; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.initfunc = file_ns::node_shader_init_tex_musgrave; node_type_storage( &ntype, "NodeTexMusgrave", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc b/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc index 85d702567fe..0c6e67b1686 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc @@ -77,8 +77,9 @@ static void node_shader_update_tex_noise(bNodeTree *ntree, bNode *node) bNodeSocket *sockW = nodeFindSocket(node, SOCK_IN, "W"); const NodeTexNoise &storage = node_storage(*node); - nodeSetSocketAvailability(ntree, sockVector, storage.dimensions != 1); - nodeSetSocketAvailability(ntree, sockW, storage.dimensions == 1 || storage.dimensions == 4); + bke::nodeSetSocketAvailability(ntree, sockVector, storage.dimensions != 1); + bke::nodeSetSocketAvailability( + ntree, sockW, storage.dimensions == 1 || storage.dimensions == 4); } class NoiseFunction : public mf::MultiFunction { diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc index 55f5fda3317..5066713b54c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc @@ -275,7 +275,8 @@ static void node_shader_update_sky(bNodeTree *ntree, bNode *node) bNodeSocket *sockVector = nodeFindSocket(node, SOCK_IN, "Vector"); NodeTexSky *tex = (NodeTexSky *)node->storage; - nodeSetSocketAvailability(ntree, sockVector, !(tex->sky_model == 2 && tex->sun_disc == 1)); + bke::nodeSetSocketAvailability( + ntree, sockVector, !(tex->sky_model == 2 && tex->sun_disc == 1)); } static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) @@ -309,7 +310,7 @@ void register_node_type_sh_tex_sky() sh_node_type_base(&ntype, SH_NODE_TEX_SKY, "Sky Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_tex_sky; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.initfunc = file_ns::node_shader_init_tex_sky; node_type_storage(&ntype, "NodeTexSky", node_free_standard_storage, node_copy_standard_storage); ntype.gpu_fn = file_ns::node_shader_gpu_tex_sky; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc index 42932c11241..c982de4b72c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc @@ -152,32 +152,35 @@ static void node_shader_update_tex_voronoi(bNodeTree *ntree, bNode *node) const NodeTexVoronoi &storage = node_storage(*node); - nodeSetSocketAvailability(ntree, inWSock, storage.dimensions == 1 || storage.dimensions == 4); - nodeSetSocketAvailability(ntree, inVectorSock, storage.dimensions != 1); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( + ntree, inWSock, storage.dimensions == 1 || storage.dimensions == 4); + bke::nodeSetSocketAvailability(ntree, inVectorSock, storage.dimensions != 1); + bke::nodeSetSocketAvailability( ntree, inExponentSock, storage.distance == SHD_VORONOI_MINKOWSKI && storage.dimensions != 1 && !ELEM(storage.feature, SHD_VORONOI_DISTANCE_TO_EDGE, SHD_VORONOI_N_SPHERE_RADIUS)); - nodeSetSocketAvailability(ntree, inSmoothnessSock, storage.feature == SHD_VORONOI_SMOOTH_F1); + bke::nodeSetSocketAvailability( + ntree, inSmoothnessSock, storage.feature == SHD_VORONOI_SMOOTH_F1); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, outDistanceSock, storage.feature != SHD_VORONOI_N_SPHERE_RADIUS); - nodeSetSocketAvailability(ntree, - outColorSock, - storage.feature != SHD_VORONOI_DISTANCE_TO_EDGE && - storage.feature != SHD_VORONOI_N_SPHERE_RADIUS); - nodeSetSocketAvailability(ntree, - outPositionSock, - storage.feature != SHD_VORONOI_DISTANCE_TO_EDGE && - storage.feature != SHD_VORONOI_N_SPHERE_RADIUS && - storage.dimensions != 1); - nodeSetSocketAvailability(ntree, - outWSock, - storage.feature != SHD_VORONOI_DISTANCE_TO_EDGE && - storage.feature != SHD_VORONOI_N_SPHERE_RADIUS && - ELEM(storage.dimensions, 1, 4)); - nodeSetSocketAvailability(ntree, outRadiusSock, storage.feature == SHD_VORONOI_N_SPHERE_RADIUS); + bke::nodeSetSocketAvailability(ntree, + outColorSock, + storage.feature != SHD_VORONOI_DISTANCE_TO_EDGE && + storage.feature != SHD_VORONOI_N_SPHERE_RADIUS); + bke::nodeSetSocketAvailability(ntree, + outPositionSock, + storage.feature != SHD_VORONOI_DISTANCE_TO_EDGE && + storage.feature != SHD_VORONOI_N_SPHERE_RADIUS && + storage.dimensions != 1); + bke::nodeSetSocketAvailability(ntree, + outWSock, + storage.feature != SHD_VORONOI_DISTANCE_TO_EDGE && + storage.feature != SHD_VORONOI_N_SPHERE_RADIUS && + ELEM(storage.dimensions, 1, 4)); + bke::nodeSetSocketAvailability( + ntree, outRadiusSock, storage.feature == SHD_VORONOI_N_SPHERE_RADIUS); } static mf::MultiFunction::ExecutionHints voronoi_execution_hints{50, false}; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc b/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc index 42c373f0dd3..87271d60258 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc @@ -221,7 +221,7 @@ void register_node_type_sh_tex_wave() sh_fn_node_type_base(&ntype, SH_NODE_TEX_WAVE, "Wave Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_wave_declare; ntype.draw_buttons = file_ns::node_shader_buts_tex_wave; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.initfunc = file_ns::node_shader_init_tex_wave; node_type_storage(&ntype, "NodeTexWave", node_free_standard_storage, node_copy_standard_storage); ntype.gpu_fn = file_ns::node_shader_gpu_tex_wave; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc index d0b03cad79e..d9b3bc32955 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc @@ -59,8 +59,8 @@ static void node_shader_update_tex_white_noise(bNodeTree *ntree, bNode *node) bNodeSocket *sockVector = nodeFindSocket(node, SOCK_IN, "Vector"); bNodeSocket *sockW = nodeFindSocket(node, SOCK_IN, "W"); - nodeSetSocketAvailability(ntree, sockVector, node->custom1 != 1); - nodeSetSocketAvailability(ntree, sockW, node->custom1 == 1 || node->custom1 == 4); + bke::nodeSetSocketAvailability(ntree, sockVector, node->custom1 != 1); + bke::nodeSetSocketAvailability(ntree, sockW, node->custom1 == 1 || node->custom1 == 4); } class WhiteNoiseFunction : public mf::MultiFunction { diff --git a/source/blender/nodes/shader/nodes/node_shader_uvmap.cc b/source/blender/nodes/shader/nodes/node_shader_uvmap.cc index d4ef8d3fb28..5c92ba8001f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_uvmap.cc +++ b/source/blender/nodes/shader/nodes/node_shader_uvmap.cc @@ -75,7 +75,7 @@ void register_node_type_sh_uvmap() sh_node_type_base(&ntype, SH_NODE_UVMAP, "UV Map", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_uvmap; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.initfunc = file_ns::node_shader_init_uvmap; node_type_storage( &ntype, "NodeShaderUVMap", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc index 665395de156..fa91ec9b4e0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc @@ -165,7 +165,7 @@ static void node_shader_update_vector_math(bNodeTree *ntree, bNode *node) bNodeSocket *sockVector = nodeFindSocket(node, SOCK_OUT, "Vector"); bNodeSocket *sockValue = nodeFindSocket(node, SOCK_OUT, "Value"); - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, sockB, !ELEM(node->custom1, NODE_VECTOR_MATH_SINE, @@ -178,21 +178,21 @@ static void node_shader_update_vector_math(bNodeTree *ntree, bNode *node) NODE_VECTOR_MATH_ABSOLUTE, NODE_VECTOR_MATH_FRACTION, NODE_VECTOR_MATH_NORMALIZE)); - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, sockC, ELEM(node->custom1, NODE_VECTOR_MATH_WRAP, NODE_VECTOR_MATH_FACEFORWARD, NODE_VECTOR_MATH_MULTIPLY_ADD)); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, sockScale, ELEM(node->custom1, NODE_VECTOR_MATH_SCALE, NODE_VECTOR_MATH_REFRACT)); - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, sockVector, !ELEM(node->custom1, NODE_VECTOR_MATH_LENGTH, NODE_VECTOR_MATH_DISTANCE, NODE_VECTOR_MATH_DOT_PRODUCT)); - nodeSetSocketAvailability(ntree, + bke::nodeSetSocketAvailability(ntree, sockValue, ELEM(node->custom1, NODE_VECTOR_MATH_LENGTH, diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc index 50769406a14..5f91572634d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc @@ -192,12 +192,12 @@ static void sh_node_vector_rotate_build_multi_function(NodeMultiFunctionBuilder static void node_shader_update_vector_rotate(bNodeTree *ntree, bNode *node) { bNodeSocket *sock_rotation = nodeFindSocket(node, SOCK_IN, "Rotation"); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, sock_rotation, ELEM(node->custom1, NODE_VECTOR_ROTATE_TYPE_EULER_XYZ)); bNodeSocket *sock_axis = nodeFindSocket(node, SOCK_IN, "Axis"); - nodeSetSocketAvailability(ntree, sock_axis, ELEM(node->custom1, NODE_VECTOR_ROTATE_TYPE_AXIS)); + bke::nodeSetSocketAvailability(ntree, sock_axis, ELEM(node->custom1, NODE_VECTOR_ROTATE_TYPE_AXIS)); bNodeSocket *sock_angle = nodeFindSocket(node, SOCK_IN, "Angle"); - nodeSetSocketAvailability( + bke::nodeSetSocketAvailability( ntree, sock_angle, !ELEM(node->custom1, NODE_VECTOR_ROTATE_TYPE_EULER_XYZ)); } diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_principled.cc b/source/blender/nodes/shader/nodes/node_shader_volume_principled.cc index 4bf3ee76c0b..633d5a7471e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_volume_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_volume_principled.cc @@ -130,7 +130,7 @@ void register_node_type_sh_volume_principled() sh_node_type_base(&ntype, SH_NODE_VOLUME_PRINCIPLED, "Principled Volume", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; - node_type_size_preset(&ntype, NODE_SIZE_LARGE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::LARGE); ntype.gpu_fn = file_ns::node_shader_gpu_volume_principled; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_wavelength.cc b/source/blender/nodes/shader/nodes/node_shader_wavelength.cc index a77e1b2df5a..4d7bfda393f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_wavelength.cc +++ b/source/blender/nodes/shader/nodes/node_shader_wavelength.cc @@ -40,7 +40,7 @@ void register_node_type_sh_wavelength() sh_node_type_base(&ntype, SH_NODE_WAVELENGTH, "Wavelength", NODE_CLASS_CONVERTER); ntype.declare = file_ns::node_declare; - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.gpu_fn = file_ns::node_shader_gpu_wavelength; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/texture/node_texture_tree.cc b/source/blender/nodes/texture/node_texture_tree.cc index 2f3fa8a508b..c67c77cf09d 100644 --- a/source/blender/nodes/texture/node_texture_tree.cc +++ b/source/blender/nodes/texture/node_texture_tree.cc @@ -20,7 +20,7 @@ #include "BKE_context.h" #include "BKE_layer.h" #include "BKE_linestyle.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_paint.h" #include "NOD_texture.h" @@ -107,8 +107,8 @@ static void localize(bNodeTree *localtree, bNodeTree * /*ntree*/) node_next = node->next; if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) { - nodeInternalRelink(localtree, node); - ntreeFreeLocalNode(localtree, node); + blender::bke::nodeInternalRelink(localtree, node); + blender::bke::ntreeFreeLocalNode(localtree, node); } } } @@ -124,7 +124,7 @@ static void update(bNodeTree *ntree) static bool texture_node_tree_socket_type_valid(bNodeTreeType * /*ntreetype*/, bNodeSocketType *socket_type) { - return nodeIsStaticSocketType(socket_type) && + return blender::bke::nodeIsStaticSocketType(socket_type) && ELEM(socket_type->type, SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA); } diff --git a/source/blender/nodes/texture/node_texture_util.cc b/source/blender/nodes/texture/node_texture_util.cc index c76664ef1a3..b6435aa1862 100644 --- a/source/blender/nodes/texture/node_texture_util.cc +++ b/source/blender/nodes/texture/node_texture_util.cc @@ -38,7 +38,7 @@ bool tex_node_poll_default(const bNodeType * /*ntype*/, void tex_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass) { - node_type_base(ntype, type, name, nclass); + blender::bke::node_type_base(ntype, type, name, nclass); ntype->poll = tex_node_poll_default; ntype->insert_link = node_insert_link_default; diff --git a/source/blender/nodes/texture/node_texture_util.hh b/source/blender/nodes/texture/node_texture_util.hh index b862241d039..ee01820e38a 100644 --- a/source/blender/nodes/texture/node_texture_util.hh +++ b/source/blender/nodes/texture/node_texture_util.hh @@ -32,7 +32,7 @@ #include "BKE_image.h" #include "BKE_main.h" #include "BKE_material.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_texture.h" diff --git a/source/blender/nodes/texture/nodes/node_texture_at.cc b/source/blender/nodes/texture/nodes/node_texture_at.cc index 0c2d5f6fb3a..e37cf5bde02 100644 --- a/source/blender/nodes/texture/nodes/node_texture_at.cc +++ b/source/blender/nodes/texture/nodes/node_texture_at.cc @@ -43,8 +43,8 @@ void register_node_type_tex_at() static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_AT, "At", NODE_CLASS_DISTORT); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_size(&ntype, 140, 100, 320); + blender::bke::node_type_socket_templates(&ntype, inputs, outputs); + blender::bke::node_type_size(&ntype, 140, 100, 320); ntype.exec_fn = exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.cc b/source/blender/nodes/texture/nodes/node_texture_bricks.cc index f0cee1d995d..30afbd9f047 100644 --- a/source/blender/nodes/texture/nodes/node_texture_bricks.cc +++ b/source/blender/nodes/texture/nodes/node_texture_bricks.cc @@ -105,8 +105,8 @@ void register_node_type_tex_bricks() static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_BRICKS, "Bricks", NODE_CLASS_PATTERN); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_socket_templates(&ntype, inputs, outputs); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.initfunc = init; ntype.exec_fn = exec; ntype.flag |= NODE_PREVIEW; diff --git a/source/blender/nodes/texture/nodes/node_texture_checker.cc b/source/blender/nodes/texture/nodes/node_texture_checker.cc index daff29133c8..7debf71c128 100644 --- a/source/blender/nodes/texture/nodes/node_texture_checker.cc +++ b/source/blender/nodes/texture/nodes/node_texture_checker.cc @@ -55,7 +55,7 @@ void register_node_type_tex_checker() static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_CHECKER, "Checker", NODE_CLASS_PATTERN); - node_type_socket_templates(&ntype, inputs, outputs); + blender::bke::node_type_socket_templates(&ntype, inputs, outputs); ntype.exec_fn = exec; ntype.flag |= NODE_PREVIEW; diff --git a/source/blender/nodes/texture/nodes/node_texture_combine_color.cc b/source/blender/nodes/texture/nodes/node_texture_combine_color.cc index ebcd62685bb..0a023dea162 100644 --- a/source/blender/nodes/texture/nodes/node_texture_combine_color.cc +++ b/source/blender/nodes/texture/nodes/node_texture_combine_color.cc @@ -68,7 +68,7 @@ void register_node_type_tex_combine_color() static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_COMBINE_COLOR, "Combine Color", NODE_CLASS_OP_COLOR); - node_type_socket_templates(&ntype, inputs, outputs); + blender::bke::node_type_socket_templates(&ntype, inputs, outputs); ntype.exec_fn = exec; ntype.updatefunc = update; diff --git a/source/blender/nodes/texture/nodes/node_texture_common.cc b/source/blender/nodes/texture/nodes/node_texture_common.cc index 0019f1b7065..ae63fb3326d 100644 --- a/source/blender/nodes/texture/nodes/node_texture_common.cc +++ b/source/blender/nodes/texture/nodes/node_texture_common.cc @@ -9,7 +9,7 @@ #include "BLI_utildefines.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "NOD_common.h" #include "node_common.h" @@ -155,7 +155,7 @@ void register_node_type_tex_group(void) BLI_assert(ntype.rna_ext.srna != nullptr); RNA_struct_blender_type_set(ntype.rna_ext.srna, &ntype); - node_type_size(&ntype, 140, 60, 400); + blender::bke::node_type_size(&ntype, 140, 60, 400); ntype.labelfunc = node_group_label; ntype.declare_dynamic = blender::nodes::node_group_declare_dynamic; ntype.init_exec_fn = group_initexec; diff --git a/source/blender/nodes/texture/nodes/node_texture_compose.cc b/source/blender/nodes/texture/nodes/node_texture_compose.cc index 09b27010753..2653e25c7d8 100644 --- a/source/blender/nodes/texture/nodes/node_texture_compose.cc +++ b/source/blender/nodes/texture/nodes/node_texture_compose.cc @@ -44,7 +44,7 @@ void register_node_type_tex_compose() tex_node_type_base( &ntype, TEX_NODE_COMPOSE_LEGACY, "Combine RGBA (Legacy)", NODE_CLASS_OP_COLOR); - node_type_socket_templates(&ntype, inputs, outputs); + blender::bke::node_type_socket_templates(&ntype, inputs, outputs); ntype.exec_fn = exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/texture/nodes/node_texture_coord.cc b/source/blender/nodes/texture/nodes/node_texture_coord.cc index 5b63f30da2d..90c8b7ced92 100644 --- a/source/blender/nodes/texture/nodes/node_texture_coord.cc +++ b/source/blender/nodes/texture/nodes/node_texture_coord.cc @@ -34,7 +34,7 @@ void register_node_type_tex_coord() static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_COORD, "Coordinates", NODE_CLASS_INPUT); - node_type_socket_templates(&ntype, nullptr, outputs); + blender::bke::node_type_socket_templates(&ntype, nullptr, outputs); ntype.exec_fn = exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.cc b/source/blender/nodes/texture/nodes/node_texture_curves.cc index 6f74b6efbeb..96689b36eee 100644 --- a/source/blender/nodes/texture/nodes/node_texture_curves.cc +++ b/source/blender/nodes/texture/nodes/node_texture_curves.cc @@ -51,8 +51,8 @@ void register_node_type_tex_curve_time() static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_CURVE_TIME, "Time", NODE_CLASS_INPUT); - node_type_socket_templates(&ntype, nullptr, time_outputs); - node_type_size_preset(&ntype, NODE_SIZE_LARGE); + blender::bke::node_type_socket_templates(&ntype, nullptr, time_outputs); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::LARGE); ntype.initfunc = time_init; node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); ntype.init_exec_fn = node_initexec_curves; @@ -101,8 +101,8 @@ void register_node_type_tex_curve_rgb() static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR); - node_type_socket_templates(&ntype, rgb_inputs, rgb_outputs); - node_type_size_preset(&ntype, NODE_SIZE_LARGE); + blender::bke::node_type_socket_templates(&ntype, rgb_inputs, rgb_outputs); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::LARGE); ntype.initfunc = rgb_init; node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); ntype.init_exec_fn = node_initexec_curves; diff --git a/source/blender/nodes/texture/nodes/node_texture_decompose.cc b/source/blender/nodes/texture/nodes/node_texture_decompose.cc index 3285d30e325..0cc59b8e110 100644 --- a/source/blender/nodes/texture/nodes/node_texture_decompose.cc +++ b/source/blender/nodes/texture/nodes/node_texture_decompose.cc @@ -64,7 +64,7 @@ void register_node_type_tex_decompose() static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_DECOMPOSE_LEGACY, "Separate RGBA", NODE_CLASS_OP_COLOR); - node_type_socket_templates(&ntype, inputs, outputs); + blender::bke::node_type_socket_templates(&ntype, inputs, outputs); ntype.exec_fn = exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/texture/nodes/node_texture_distance.cc b/source/blender/nodes/texture/nodes/node_texture_distance.cc index 438a84d3849..daeda15365c 100644 --- a/source/blender/nodes/texture/nodes/node_texture_distance.cc +++ b/source/blender/nodes/texture/nodes/node_texture_distance.cc @@ -45,7 +45,7 @@ void register_node_type_tex_distance(void) static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_DISTANCE, "Distance", NODE_CLASS_CONVERTER); - node_type_socket_templates(&ntype, inputs, outputs); + blender::bke::node_type_socket_templates(&ntype, inputs, outputs); ntype.exec_fn = exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.cc b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.cc index 30be3d801cf..16ecea3f6a4 100644 --- a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.cc +++ b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.cc @@ -92,8 +92,8 @@ void register_node_type_tex_hue_sat() static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_HUE_SAT, "Hue/Saturation/Value", NODE_CLASS_OP_COLOR); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_socket_templates(&ntype, inputs, outputs); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.exec_fn = exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/texture/nodes/node_texture_image.cc b/source/blender/nodes/texture/nodes/node_texture_image.cc index aba9af70b62..3df6e0d1b30 100644 --- a/source/blender/nodes/texture/nodes/node_texture_image.cc +++ b/source/blender/nodes/texture/nodes/node_texture_image.cc @@ -92,7 +92,7 @@ void register_node_type_tex_image() static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_IMAGE, "Image", NODE_CLASS_INPUT); - node_type_socket_templates(&ntype, nullptr, outputs); + blender::bke::node_type_socket_templates(&ntype, nullptr, outputs); ntype.initfunc = init; node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage); ntype.exec_fn = exec; diff --git a/source/blender/nodes/texture/nodes/node_texture_invert.cc b/source/blender/nodes/texture/nodes/node_texture_invert.cc index 46e29a63b3a..ee998c57a23 100644 --- a/source/blender/nodes/texture/nodes/node_texture_invert.cc +++ b/source/blender/nodes/texture/nodes/node_texture_invert.cc @@ -48,7 +48,7 @@ void register_node_type_tex_invert() static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_INVERT, "Invert Color", NODE_CLASS_OP_COLOR); - node_type_socket_templates(&ntype, inputs, outputs); + blender::bke::node_type_socket_templates(&ntype, inputs, outputs); ntype.exec_fn = exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/texture/nodes/node_texture_math.cc b/source/blender/nodes/texture/nodes/node_texture_math.cc index b5a307c00a3..1c31dc1fcea 100644 --- a/source/blender/nodes/texture/nodes/node_texture_math.cc +++ b/source/blender/nodes/texture/nodes/node_texture_math.cc @@ -320,7 +320,7 @@ void register_node_type_tex_math() static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_MATH, "Math", NODE_CLASS_CONVERTER); - node_type_socket_templates(&ntype, inputs, outputs); + blender::bke::node_type_socket_templates(&ntype, inputs, outputs); ntype.labelfunc = node_math_label; ntype.exec_fn = exec; ntype.updatefunc = node_math_update; diff --git a/source/blender/nodes/texture/nodes/node_texture_mixRgb.cc b/source/blender/nodes/texture/nodes/node_texture_mixRgb.cc index 847df030fa8..effe5ef479f 100644 --- a/source/blender/nodes/texture/nodes/node_texture_mixRgb.cc +++ b/source/blender/nodes/texture/nodes/node_texture_mixRgb.cc @@ -54,7 +54,7 @@ void register_node_type_tex_mix_rgb(void) static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR); - node_type_socket_templates(&ntype, inputs, outputs); + blender::bke::node_type_socket_templates(&ntype, inputs, outputs); ntype.labelfunc = node_blend_label; ntype.exec_fn = exec; diff --git a/source/blender/nodes/texture/nodes/node_texture_output.cc b/source/blender/nodes/texture/nodes/node_texture_output.cc index fe53d237896..86620b1afd1 100644 --- a/source/blender/nodes/texture/nodes/node_texture_output.cc +++ b/source/blender/nodes/texture/nodes/node_texture_output.cc @@ -136,8 +136,8 @@ void register_node_type_tex_output(void) static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_OUTPUT, "Output", NODE_CLASS_OUTPUT); - node_type_socket_templates(&ntype, inputs, nullptr); - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + blender::bke::node_type_socket_templates(&ntype, inputs, nullptr); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); ntype.initfunc = init; node_type_storage(&ntype, "TexNodeOutput", node_free_standard_storage, copy); ntype.exec_fn = exec; diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.cc b/source/blender/nodes/texture/nodes/node_texture_proc.cc index 91faa4a9cfb..2c4a769dfd3 100644 --- a/source/blender/nodes/texture/nodes/node_texture_proc.cc +++ b/source/blender/nodes/texture/nodes/node_texture_proc.cc @@ -252,8 +252,8 @@ static void init(bNodeTree * /*ntree*/, bNode *node) static bNodeType ntype; \ \ tex_node_type_base(&ntype, TEX_NODE_PROC + TEXTYPE, Name, NODE_CLASS_TEXTURE); \ - node_type_socket_templates(&ntype, name##_inputs, outputs); \ - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); \ + blender::bke::node_type_socket_templates(&ntype, name##_inputs, outputs); \ + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); \ ntype.initfunc = init; \ node_type_storage(&ntype, "Tex", node_free_standard_storage, node_copy_standard_storage); \ ntype.exec_fn = name##_exec; \ diff --git a/source/blender/nodes/texture/nodes/node_texture_rotate.cc b/source/blender/nodes/texture/nodes/node_texture_rotate.cc index 14b0a1fc1b5..6bb4f0ead91 100644 --- a/source/blender/nodes/texture/nodes/node_texture_rotate.cc +++ b/source/blender/nodes/texture/nodes/node_texture_rotate.cc @@ -80,7 +80,7 @@ void register_node_type_tex_rotate() static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_ROTATE, "Rotate", NODE_CLASS_DISTORT); - node_type_socket_templates(&ntype, inputs, outputs); + blender::bke::node_type_socket_templates(&ntype, inputs, outputs); ntype.exec_fn = exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/texture/nodes/node_texture_scale.cc b/source/blender/nodes/texture/nodes/node_texture_scale.cc index f5ae1715b73..c30511f83a7 100644 --- a/source/blender/nodes/texture/nodes/node_texture_scale.cc +++ b/source/blender/nodes/texture/nodes/node_texture_scale.cc @@ -53,7 +53,7 @@ void register_node_type_tex_scale() static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_SCALE, "Scale", NODE_CLASS_DISTORT); - node_type_socket_templates(&ntype, inputs, outputs); + blender::bke::node_type_socket_templates(&ntype, inputs, outputs); ntype.exec_fn = exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/texture/nodes/node_texture_separate_color.cc b/source/blender/nodes/texture/nodes/node_texture_separate_color.cc index 1cfb2776dca..dc63957de5d 100644 --- a/source/blender/nodes/texture/nodes/node_texture_separate_color.cc +++ b/source/blender/nodes/texture/nodes/node_texture_separate_color.cc @@ -95,7 +95,7 @@ void register_node_type_tex_separate_color() static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_SEPARATE_COLOR, "Separate Color", NODE_CLASS_OP_COLOR); - node_type_socket_templates(&ntype, inputs, outputs); + blender::bke::node_type_socket_templates(&ntype, inputs, outputs); ntype.exec_fn = exec; ntype.updatefunc = update; diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.cc b/source/blender/nodes/texture/nodes/node_texture_texture.cc index 32e1cd5f6ea..caaf17f2e62 100644 --- a/source/blender/nodes/texture/nodes/node_texture_texture.cc +++ b/source/blender/nodes/texture/nodes/node_texture_texture.cc @@ -78,7 +78,7 @@ void register_node_type_tex_texture(void) static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_TEXTURE, "Texture", NODE_CLASS_INPUT); - node_type_socket_templates(&ntype, inputs, outputs); + blender::bke::node_type_socket_templates(&ntype, inputs, outputs); ntype.exec_fn = exec; ntype.flag |= NODE_PREVIEW; diff --git a/source/blender/nodes/texture/nodes/node_texture_translate.cc b/source/blender/nodes/texture/nodes/node_texture_translate.cc index 7ca61d6fd3a..0bd02b97ce1 100644 --- a/source/blender/nodes/texture/nodes/node_texture_translate.cc +++ b/source/blender/nodes/texture/nodes/node_texture_translate.cc @@ -49,7 +49,7 @@ void register_node_type_tex_translate(void) static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_TRANSLATE, "Translate", NODE_CLASS_DISTORT); - node_type_socket_templates(&ntype, inputs, outputs); + blender::bke::node_type_socket_templates(&ntype, inputs, outputs); ntype.exec_fn = exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/texture/nodes/node_texture_valToNor.cc b/source/blender/nodes/texture/nodes/node_texture_valToNor.cc index 7a894e5ef9b..4a854fd3626 100644 --- a/source/blender/nodes/texture/nodes/node_texture_valToNor.cc +++ b/source/blender/nodes/texture/nodes/node_texture_valToNor.cc @@ -65,7 +65,7 @@ void register_node_type_tex_valtonor(void) static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_VALTONOR, "Value to Normal", NODE_CLASS_CONVERTER); - node_type_socket_templates(&ntype, inputs, outputs); + blender::bke::node_type_socket_templates(&ntype, inputs, outputs); ntype.exec_fn = exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/texture/nodes/node_texture_valToRgb.cc b/source/blender/nodes/texture/nodes/node_texture_valToRgb.cc index 2f6900bcbaf..6901046f29f 100644 --- a/source/blender/nodes/texture/nodes/node_texture_valToRgb.cc +++ b/source/blender/nodes/texture/nodes/node_texture_valToRgb.cc @@ -48,8 +48,8 @@ void register_node_type_tex_valtorgb(void) static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_VALTORGB, "Color Ramp", NODE_CLASS_CONVERTER); - node_type_socket_templates(&ntype, valtorgb_in, valtorgb_out); - node_type_size_preset(&ntype, NODE_SIZE_LARGE); + blender::bke::node_type_socket_templates(&ntype, valtorgb_in, valtorgb_out); + blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::LARGE); ntype.initfunc = valtorgb_init; node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage); ntype.exec_fn = valtorgb_exec; @@ -90,7 +90,7 @@ void register_node_type_tex_rgbtobw(void) static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTER); - node_type_socket_templates(&ntype, rgbtobw_in, rgbtobw_out); + blender::bke::node_type_socket_templates(&ntype, rgbtobw_in, rgbtobw_out); ntype.exec_fn = rgbtobw_exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/texture/nodes/node_texture_viewer.cc b/source/blender/nodes/texture/nodes/node_texture_viewer.cc index 1cce189ee99..17ceccd4f02 100644 --- a/source/blender/nodes/texture/nodes/node_texture_viewer.cc +++ b/source/blender/nodes/texture/nodes/node_texture_viewer.cc @@ -37,7 +37,7 @@ void register_node_type_tex_viewer(void) static bNodeType ntype; tex_node_type_base(&ntype, TEX_NODE_VIEWER, "Viewer", NODE_CLASS_OUTPUT); - node_type_socket_templates(&ntype, inputs, nullptr); + blender::bke::node_type_socket_templates(&ntype, inputs, nullptr); ntype.exec_fn = exec; ntype.no_muting = true; diff --git a/source/blender/render/intern/bake.cc b/source/blender/render/intern/bake.cc index 22efdcb60bc..cc2b542e9d6 100644 --- a/source/blender/render/intern/bake.cc +++ b/source/blender/render/intern/bake.cc @@ -64,7 +64,7 @@ #include "BKE_mesh.hh" #include "BKE_mesh_runtime.h" #include "BKE_mesh_tangent.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" diff --git a/source/blender/render/intern/engine.cc b/source/blender/render/intern/engine.cc index e49cf35059d..a1a8fa98c74 100644 --- a/source/blender/render/intern/engine.cc +++ b/source/blender/render/intern/engine.cc @@ -26,7 +26,7 @@ #include "BKE_colortools.h" #include "BKE_global.h" #include "BKE_layer.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_report.h" #include "BKE_scene.h" diff --git a/source/blender/render/intern/pipeline.cc b/source/blender/render/intern/pipeline.cc index 2ab3e5f1e2b..0f677d95ac4 100644 --- a/source/blender/render/intern/pipeline.cc +++ b/source/blender/render/intern/pipeline.cc @@ -52,7 +52,7 @@ #include "BKE_main.h" #include "BKE_mask.h" #include "BKE_modifier.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_object.h" #include "BKE_pointcache.h" diff --git a/source/blender/windowmanager/intern/wm_init_exit.cc b/source/blender/windowmanager/intern/wm_init_exit.cc index fdcdcef488d..22987d0631d 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.cc +++ b/source/blender/windowmanager/intern/wm_init_exit.cc @@ -48,7 +48,7 @@ #include "BKE_lib_remap.h" #include "BKE_main.h" #include "BKE_mball_tessellate.h" -#include "BKE_node.h" +#include "BKE_node.hh" #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_screen.h"