From c6b68d52c456d7024e82fdf45ce0cefdd4a30b48 Mon Sep 17 00:00:00 2001 From: illua1 Date: Sun, 19 Feb 2023 02:19:04 +0300 Subject: [PATCH 1/9] cleanup: try to use const allways --- source/blender/blenkernel/BKE_node.h | 77 +++++++------ source/blender/blenkernel/intern/node.cc | 133 ++++++++++++----------- 2 files changed, 111 insertions(+), 99 deletions(-) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index a0f6405a6ac..2716baa7e83 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -439,7 +439,7 @@ typedef struct bNodeTreeType { struct bNodeTreeType *ntreeTypeFind(const char *idname); void ntreeTypeAdd(struct bNodeTreeType *nt); void ntreeTypeFreeLink(const struct bNodeTreeType *nt); -bool ntreeIsRegistered(struct bNodeTree *ntree); +bool ntreeIsRegistered(const struct bNodeTree *ntree); struct GHashIterator *ntreeTypeGetIterator(void); /* Helper macros for iterating over tree types. */ @@ -503,7 +503,7 @@ 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); +struct bNode *ntreeFindType(struct bNodeTree *ntree, const int type); /** * Check recursively if a node tree contains another. @@ -553,14 +553,14 @@ void ntreeBlendReadExpand(struct BlendExpander *expander, struct bNodeTree *ntre * \{ */ struct bNodeSocket *ntreeFindSocketInterface(struct bNodeTree *ntree, - eNodeSocketInOut in_out, + const eNodeSocketInOut in_out, const char *identifier); struct bNodeSocket *ntreeAddSocketInterface(struct bNodeTree *ntree, - eNodeSocketInOut in_out, + const eNodeSocketInOut in_out, const char *idname, const char *name); struct bNodeSocket *ntreeInsertSocketInterface(struct bNodeTree *ntree, - eNodeSocketInOut in_out, + const eNodeSocketInOut in_out, const char *idname, struct bNodeSocket *next_sock, const char *name); @@ -607,14 +607,14 @@ struct GHashIterator *nodeTypeGetIterator(void); struct bNodeSocketType *nodeSocketTypeFind(const char *idname); void nodeRegisterSocketType(struct bNodeSocketType *stype); void nodeUnregisterSocketType(struct bNodeSocketType *stype); -bool nodeSocketIsRegistered(struct bNodeSocket *sock); +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 *nodeStaticSocketType(const int type, const int subtype); +const char *nodeStaticSocketInterfaceType(const int type, const int subtype); +const char *nodeStaticSocketLabel(const int type, const int subtype); /* Helper macros for iterating over node types. */ #define NODE_SOCKET_TYPES_BEGIN(stype) \ @@ -631,12 +631,12 @@ const char *nodeStaticSocketLabel(int type, int subtype); } \ ((void)0) -struct bNodeSocket *nodeFindSocket(struct bNode *node, - eNodeSocketInOut in_out, +struct bNodeSocket *nodeFindSocket(const struct bNode *node, + const eNodeSocketInOut in_out, const char *identifier); struct bNodeSocket *nodeAddSocket(struct bNodeTree *ntree, struct bNode *node, - eNodeSocketInOut in_out, + const eNodeSocketInOut in_out, const char *idname, const char *identifier, const char *name); @@ -651,21 +651,24 @@ void nodeRemoveSocket(struct bNodeTree *ntree, struct bNode *node, struct bNodeS void nodeRemoveSocketEx(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *sock, - bool do_id_user); + const 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); +void nodeModifySocketTypeStatic(struct bNodeTree *ntree, + struct bNode *node, + struct bNodeSocket *sock, + const int type, + const 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); +struct bNode *nodeAddStaticNode(const struct bContext *C, struct bNodeTree *ntree, const int type); /** * \note Goes over entire tree. */ -void nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node); +void nodeUnlinkNode(struct bNodeTree *ntree, const struct bNode *node); /** * Find the first available, non-duplicate name for a given node. */ @@ -689,7 +692,7 @@ void nodeRebuildIDVector(struct bNodeTree *node_tree); void nodeRemoveNode(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node, - bool do_id_user); + const bool do_id_user); void nodeDimensionsGet(const struct bNode *node, float *r_width, float *r_height); void nodeTagUpdateID(struct bNode *node); @@ -742,16 +745,16 @@ 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); +void nodeToView(const struct bNode *node, const float x, const float y, float *rx, float *ry); +void nodeFromView(const struct bNode *node, const float x, const float y, float *rx, float *ry); bool nodeAttachNodeCheck(const struct bNode *node, const struct bNode *parent); 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, - struct bNode *to_node, - struct bNodeSocket *from_sock, - struct bNodeSocket *to_sock); + const struct bNode *to_node, + const struct bNodeSocket *from_sock, + const struct bNodeSocket *to_sock); void nodePositionPropagate(struct bNode *node); /** @@ -810,7 +813,7 @@ void nodeChainIterBackwards(const bNodeTree *ntree, const bNode *node_start, bool (*callback)(bNode *, bNode *, void *), void *userdata, - int recursion_lvl); + const int recursion_lvl); /** * Iterate over all parents of \a node, executing \a callback for each parent * (which can return false to end iterator) @@ -852,7 +855,7 @@ bool nodeSupportsActiveFlag(const struct bNode *node, int sub_active); void nodeSetSocketAvailability(struct bNodeTree *ntree, struct bNodeSocket *sock, - bool is_available); + const bool is_available); int nodeSocketLinkLimit(const struct bNodeSocket *sock); @@ -970,7 +973,10 @@ void BKE_node_preview_merge_tree(struct bNodeTree *to_ntree, /** \name Node Type Access * \{ */ -void nodeLabel(const struct bNodeTree *ntree, const struct bNode *node, char *label, int maxlen); +void nodeLabel(const struct bNodeTree *ntree, + const struct bNode *node, + char *label, + const int maxlen); /** * Get node socket label if it is set. */ @@ -983,16 +989,19 @@ bool nodeGroupPoll(const struct bNodeTree *nodetree, /** * 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(struct bNodeType *ntype, const int type, const char *name, const short nclass); void node_type_base_custom(struct bNodeType *ntype, const char *idname, const char *name, - short nclass); + const 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); +void node_type_size(struct bNodeType *ntype, + const int width, + const int minwidth, + const int maxwidth); +void node_type_size_preset(struct bNodeType *ntype, const eNodeSizePreset size); /** * \warning Nodes defining a storage type _must_ allocate this for new nodes. * Otherwise nodes will reload as undefined (#46619). @@ -1585,9 +1594,11 @@ extern struct bNodeSocketType NodeSocketTypeUndefined; 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); +bNodeSocket *node_find_enabled_socket(bNode &node, + const eNodeSocketInOut in_out, + const StringRef name); +bNodeSocket *node_find_enabled_input_socket(bNode &node, const StringRef name); +bNodeSocket *node_find_enabled_output_socket(bNode &node, const StringRef name); } // namespace blender::bke diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 1783a8b1fb1..a8d5bddd3b2 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -1229,7 +1229,7 @@ static void update_typeinfo(Main *bmain, bNodeTreeType *treetype, bNodeType *nodetype, bNodeSocketType *socktype, - bool unregister) + const bool unregister) { if (!bmain) { return; @@ -1337,7 +1337,7 @@ void ntreeTypeFreeLink(const bNodeTreeType *nt) BLI_ghash_remove(nodetreetypes_hash, nt->idname, nullptr, ntree_free_type); } -bool ntreeIsRegistered(bNodeTree *ntree) +bool ntreeIsRegistered(const bNodeTree *ntree) { return (ntree->typeinfo != &NodeTreeTypeUndefined); } @@ -1450,7 +1450,7 @@ void nodeUnregisterSocketType(bNodeSocketType *st) BLI_ghash_remove(nodesockettypes_hash, st->idname, nullptr, node_free_socket_type); } -bool nodeSocketIsRegistered(bNodeSocket *sock) +bool nodeSocketIsRegistered(const bNodeSocket *sock) { return (sock->typeinfo != &NodeSocketTypeUndefined); } @@ -1466,7 +1466,9 @@ const char *nodeSocketTypeLabel(const bNodeSocketType *stype) return stype->label[0] != '\0' ? stype->label : RNA_struct_ui_name(stype->ext_socket.srna); } -bNodeSocket *nodeFindSocket(bNode *node, eNodeSocketInOut in_out, const char *identifier) +bNodeSocket *nodeFindSocket(const bNode *node, + const eNodeSocketInOut in_out, + const char *identifier) { const ListBase *sockets = (in_out == SOCK_IN) ? &node->inputs : &node->outputs; LISTBASE_FOREACH (bNodeSocket *, sock, sockets) { @@ -1492,12 +1494,12 @@ bNodeSocket *node_find_enabled_socket(bNode &node, return nullptr; } -bNodeSocket *node_find_enabled_input_socket(bNode &node, StringRef name) +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, StringRef name) +bNodeSocket *node_find_enabled_output_socket(bNode &node, const StringRef name) { return node_find_enabled_socket(node, SOCK_OUT, name); } @@ -1517,7 +1519,7 @@ static bool unique_identifier_check(void *arg, const char *identifier) static bNodeSocket *make_socket(bNodeTree *ntree, bNode * /*node*/, - int in_out, + const int in_out, ListBase *lb, const char *idname, const char *identifier, @@ -1681,7 +1683,7 @@ void nodeModifySocketType(bNodeTree *ntree, } void nodeModifySocketTypeStatic( - bNodeTree *ntree, bNode *node, bNodeSocket *sock, int type, int subtype) + bNodeTree *ntree, bNode *node, bNodeSocket *sock, const int type, const int subtype) { const char *idname = nodeStaticSocketType(type, subtype); @@ -1695,7 +1697,7 @@ void nodeModifySocketTypeStatic( bNodeSocket *nodeAddSocket(bNodeTree *ntree, bNode *node, - eNodeSocketInOut in_out, + const eNodeSocketInOut in_out, const char *idname, const char *identifier, const char *name) @@ -1724,7 +1726,7 @@ bool nodeIsStaticSocketType(const bNodeSocketType *stype) return RNA_struct_is_a(stype->ext_socket.srna, &RNA_NodeSocketStandard); } -const char *nodeStaticSocketType(int type, int subtype) +const char *nodeStaticSocketType(const int type, const int subtype) { switch (type) { case SOCK_FLOAT: @@ -1801,7 +1803,7 @@ const char *nodeStaticSocketType(int type, int subtype) return nullptr; } -const char *nodeStaticSocketInterfaceType(int type, int subtype) +const char *nodeStaticSocketInterfaceType(const int type, const int subtype) { switch (type) { case SOCK_FLOAT: @@ -1878,7 +1880,7 @@ const char *nodeStaticSocketInterfaceType(int type, int subtype) return nullptr; } -const char *nodeStaticSocketLabel(int type, int /*subtype*/) +const char *nodeStaticSocketLabel(const int type, const int /*subtype*/) { switch (type) { case SOCK_FLOAT: @@ -1955,7 +1957,7 @@ void nodeRemoveSocket(bNodeTree *ntree, bNode *node, bNodeSocket *sock) nodeRemoveSocketEx(ntree, node, sock, true); } -void nodeRemoveSocketEx(bNodeTree *ntree, bNode *node, bNodeSocket *sock, bool do_id_user) +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) { @@ -2019,7 +2021,7 @@ void nodeFindNode(bNodeTree *ntree, bNodeSocket *sock, bNode **r_node, int *r_so bNode *node = &sock->owner_node(); *r_node = node; if (r_sockindex) { - ListBase *sockets = (sock->in_out == SOCK_IN) ? &node->inputs : &node->outputs; + const ListBase *sockets = (sock->in_out == SOCK_IN) ? &node->inputs : &node->outputs; *r_sockindex = BLI_findindex(sockets, sock); } return; @@ -2032,9 +2034,9 @@ void nodeFindNode(bNodeTree *ntree, bNodeSocket *sock, bNode **r_node, int *r_so bool nodeFindNodeTry(bNodeTree *ntree, bNodeSocket *sock, bNode **r_node, int *r_sockindex) { for (bNode *node : ntree->all_nodes()) { - ListBase *sockets = (sock->in_out == SOCK_IN) ? &node->inputs : &node->outputs; + const ListBase *sockets = (sock->in_out == SOCK_IN) ? &node->inputs : &node->outputs; int i; - LISTBASE_FOREACH_INDEX (bNodeSocket *, tsock, sockets, i) { + LISTBASE_FOREACH_INDEX (const bNodeSocket *, tsock, sockets, i) { if (sock == tsock) { if (r_node != nullptr) { *r_node = node; @@ -2098,7 +2100,7 @@ static void iter_backwards_ex(const bNodeTree *ntree, const bNode *node_start, bool (*callback)(bNode *, bNode *, void *), void *userdata, - char recursion_mask) + const char recursion_mask) { LISTBASE_FOREACH (bNodeSocket *, sock, &node_start->inputs) { bNodeLink *link = sock->link; @@ -2126,7 +2128,7 @@ void nodeChainIterBackwards(const bNodeTree *ntree, const bNode *node_start, bool (*callback)(bNode *, bNode *, void *), void *userdata, - int recursion_lvl) + const int recursion_lvl) { if (!node_start) { return; @@ -2134,7 +2136,7 @@ void nodeChainIterBackwards(const bNodeTree *ntree, /* Limited by iter_flag type. */ BLI_assert(recursion_lvl < 8); - char recursion_mask = (1 << recursion_lvl); + const char recursion_mask = (1 << recursion_lvl); /* Reset flag. */ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { @@ -2229,7 +2231,7 @@ bNode *nodeAddNode(const bContext *C, bNodeTree *ntree, const char *idname) return node; } -bNode *nodeAddStaticNode(const bContext *C, bNodeTree *ntree, int type) +bNode *nodeAddStaticNode(const bContext *C, bNodeTree *ntree, const int type) { const char *idname = nullptr; @@ -2459,8 +2461,8 @@ bool nodeLinkIsSelected(const bNodeLink *link) /* 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, - bNodeSocket *sock, - int deleted_index) + 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 @@ -2547,7 +2549,7 @@ void nodeInternalRelink(bNodeTree *ntree, bNode *node) } } -void nodeToView(const bNode *node, float x, float y, float *rx, float *ry) +void nodeToView(const bNode *node, const float x, const float y, float *rx, float *ry) { if (node->parent) { nodeToView(node->parent, x + node->locx, y + node->locy, rx, ry); @@ -2558,7 +2560,7 @@ 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 nodeFromView(const bNode *node, const float x, const float y, float *rx, float *ry) { if (node->parent) { nodeFromView(node->parent, x, y, rx, ry); @@ -2612,9 +2614,9 @@ void nodeDetachNode(bNodeTree *ntree, bNode *node) } void nodePositionRelative(bNode *from_node, - bNode *to_node, - bNodeSocket *from_sock, - bNodeSocket *to_sock) + const bNode *to_node, + const bNodeSocket *from_sock, + const bNodeSocket *to_sock) { float offset_x; int tot_sock_idx; @@ -2912,37 +2914,31 @@ void BKE_node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, boo } } -void nodeUnlinkNode(bNodeTree *ntree, bNode *node) +void nodeUnlinkNode(bNodeTree *ntree, const bNode *node) { LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) { - ListBase *lb; - if (link->fromnode == node) { - lb = &node->outputs; - } - else if (link->tonode == node) { - lb = &node->inputs; - } - else { - lb = nullptr; + if (!ELEM(node, link->fromnode, link->tonode)) { + continue; } - if (lb) { - /* Only bother adjusting if the socket is not on the node we're deleting. */ - if (link->tonode != node && link->tosock->flag & SOCK_MULTI_INPUT) { - adjust_multi_input_indices_after_removed_link( - ntree, link->tosock, link->multi_input_socket_index); - } - LISTBASE_FOREACH (bNodeSocket *, sock, lb) { - if (link->fromsock == sock || link->tosock == sock) { - nodeRemLink(ntree, link); - break; - } + /* Only bother adjusting if the socket is not on the node we're deleting. */ + if (link->tonode != node && link->tosock->flag & SOCK_MULTI_INPUT) { + adjust_multi_input_indices_after_removed_link( + ntree, link->tosock, link->multi_input_socket_index); + } + + const bool validate_outputs = node == link->fromnode; + const ListBase *sockets = validate_outputs ? &node->outputs : &node->inputs; + LISTBASE_FOREACH (const bNodeSocket *, sock, sockets) { + if (link->fromsock == sock || link->tosock == sock) { + nodeRemLink(ntree, link); + break; } } } } -static void node_unlink_attached(bNodeTree *ntree, bNode *parent) +static void node_unlink_attached(bNodeTree *ntree, const bNode *parent) { for (bNode *node : ntree->all_nodes()) { if (node->parent == parent) { @@ -3030,7 +3026,7 @@ void ntreeFreeLocalNode(bNodeTree *ntree, bNode *node) nodeRebuildIDVector(ntree); } -void nodeRemoveNode(Main *bmain, bNodeTree *ntree, bNode *node, bool do_id_user) +void nodeRemoveNode(Main *bmain, bNodeTree *ntree, bNode *node, const bool do_id_user) { /* This function is not for localized node trees, we do not want * do to ID user reference-counting and removal of animdation data then. */ @@ -3313,7 +3309,7 @@ void ntreeLocalMerge(Main *bmain, bNodeTree *localtree, bNodeTree *ntree) /* ************ NODE TREE INTERFACE *************** */ static bNodeSocket *make_socket_interface(bNodeTree *ntree, - eNodeSocketInOut in_out, + const eNodeSocketInOut in_out, const char *idname, const char *name) { @@ -3349,7 +3345,7 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree, } bNodeSocket *ntreeFindSocketInterface(bNodeTree *ntree, - eNodeSocketInOut in_out, + const eNodeSocketInOut in_out, const char *identifier) { ListBase *sockets = (in_out == SOCK_IN) ? &ntree->inputs : &ntree->outputs; @@ -3362,7 +3358,7 @@ bNodeSocket *ntreeFindSocketInterface(bNodeTree *ntree, } bNodeSocket *ntreeAddSocketInterface(bNodeTree *ntree, - eNodeSocketInOut in_out, + const eNodeSocketInOut in_out, const char *idname, const char *name) { @@ -3378,7 +3374,7 @@ bNodeSocket *ntreeAddSocketInterface(bNodeTree *ntree, } bNodeSocket *ntreeInsertSocketInterface(bNodeTree *ntree, - eNodeSocketInOut in_out, + const eNodeSocketInOut in_out, const char *idname, bNodeSocket *next_sock, const char *name) @@ -3451,7 +3447,7 @@ void ntreeRemoveSocketInterface(bNodeTree *ntree, bNodeSocket *sock) /* ************ find stuff *************** */ -bNode *ntreeFindType(bNodeTree *ntree, int type) +bNode *ntreeFindType(bNodeTree *ntree, const int type) { if (ntree) { LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { @@ -3536,7 +3532,7 @@ bNode *nodeGetActive(bNodeTree *ntree) return nullptr; } -void nodeSetSelected(bNode *node, bool select) +void nodeSetSelected(bNode *node, const bool select) { if (select) { node->flag |= NODE_SELECT; @@ -3580,7 +3576,7 @@ void nodeSetActive(bNodeTree *ntree, bNode *node) node->flag |= flags_to_set; } -void nodeSetSocketAvailability(bNodeTree *ntree, bNodeSocket *sock, bool is_available) +void nodeSetSocketAvailability(bNodeTree *ntree, bNodeSocket *sock, const bool is_available) { const bool was_available = (sock->flag & SOCK_UNAVAIL) == 0; if (is_available == was_available) { @@ -3597,12 +3593,13 @@ void nodeSetSocketAvailability(bNodeTree *ntree, bNodeSocket *sock, bool is_avai int nodeSocketLinkLimit(const bNodeSocket *sock) { - bNodeSocketType *stype = sock->typeinfo; + const bNodeSocketType *stype = sock->typeinfo; if (sock->flag & SOCK_MULTI_INPUT) { return 4095; } if (stype != nullptr && stype->use_link_limits_of_type) { - int limit = (sock->in_out == SOCK_IN) ? stype->input_link_limit : stype->output_link_limit; + const int limit = (sock->in_out == SOCK_IN) ? stype->input_link_limit : + stype->output_link_limit; return limit; } @@ -3886,7 +3883,7 @@ void ntreeUpdateAllUsers(Main *main, ID *id) /* ************* node type access ********** */ -void nodeLabel(const bNodeTree *ntree, const bNode *node, char *label, int maxlen) +void nodeLabel(const bNodeTree *ntree, const bNode *node, char *label, const int maxlen) { label[0] = '\0'; @@ -3937,7 +3934,7 @@ static bool node_poll_instance_default(const bNode *node, return node->typeinfo->poll(node->typeinfo, ntree, disabled_hint); } -void node_type_base(bNodeType *ntype, int type, const char *name, short nclass) +void node_type_base(bNodeType *ntype, const int type, const char *name, const short nclass) { /* Use static type info header to map static int type to identifier string and RNA struct type. * Associate the RNA struct type with the bNodeType. @@ -3971,7 +3968,10 @@ void node_type_base(bNodeType *ntype, int type, const char *name, short nclass) ntype->poll_instance = node_poll_instance_default; } -void node_type_base_custom(bNodeType *ntype, const char *idname, const char *name, short nclass) +void node_type_base_custom(bNodeType *ntype, + const char *idname, + const char *name, + const short nclass) { BLI_strncpy(ntype->idname, idname, sizeof(ntype->idname)); ntype->type = NODE_CUSTOM; @@ -3988,7 +3988,8 @@ struct SocketTemplateIdentifierCallbackData { static bool unique_socket_template_identifier_check(void *arg, const char *name) { - SocketTemplateIdentifierCallbackData *data = (SocketTemplateIdentifierCallbackData *)arg; + const SocketTemplateIdentifierCallbackData *data = (const SocketTemplateIdentifierCallbackData *) + arg; for (bNodeSocketTemplate *ntemp = data->list; ntemp->type >= 0; ntemp++) { if (ntemp != data->ntemp) { @@ -4004,7 +4005,7 @@ static bool unique_socket_template_identifier_check(void *arg, const char *name) static void unique_socket_template_identifier(bNodeSocketTemplate *list, bNodeSocketTemplate *ntemp, const char defname[], - char delim) + const char delim) { SocketTemplateIdentifierCallbackData data; data.list = list; @@ -4050,7 +4051,7 @@ void node_type_socket_templates(bNodeType *ntype, } } -void node_type_size(bNodeType *ntype, int width, int minwidth, int maxwidth) +void node_type_size(bNodeType *ntype, const int width, const int minwidth, const int maxwidth) { ntype->width = width; ntype->minwidth = minwidth; @@ -4062,7 +4063,7 @@ void node_type_size(bNodeType *ntype, int width, int minwidth, int maxwidth) } } -void node_type_size_preset(bNodeType *ntype, eNodeSizePreset size) +void node_type_size_preset(bNodeType *ntype, const eNodeSizePreset size) { switch (size) { case NODE_SIZE_DEFAULT: -- 2.30.2 From 90c1420a0ce544b8fdb08d375349ba080b2b2707 Mon Sep 17 00:00:00 2001 From: illua1 Date: Mon, 20 Feb 2023 22:04:45 +0300 Subject: [PATCH 2/9] merge with main, delete const's for by-valuy passed args in declarations, other changes --- source/blender/blenkernel/BKE_node.h | 61 ++++++++++-------------- source/blender/blenkernel/intern/node.cc | 31 ++++++------ 2 files changed, 42 insertions(+), 50 deletions(-) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 2716baa7e83..6fbcd11530f 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -503,7 +503,7 @@ 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, const int type); +struct bNode *ntreeFindType(struct bNodeTree *ntree, int type); /** * Check recursively if a node tree contains another. @@ -553,14 +553,14 @@ void ntreeBlendReadExpand(struct BlendExpander *expander, struct bNodeTree *ntre * \{ */ struct bNodeSocket *ntreeFindSocketInterface(struct bNodeTree *ntree, - const eNodeSocketInOut in_out, + eNodeSocketInOut in_out, const char *identifier); struct bNodeSocket *ntreeAddSocketInterface(struct bNodeTree *ntree, - const eNodeSocketInOut in_out, + eNodeSocketInOut in_out, const char *idname, const char *name); struct bNodeSocket *ntreeInsertSocketInterface(struct bNodeTree *ntree, - const eNodeSocketInOut in_out, + eNodeSocketInOut in_out, const char *idname, struct bNodeSocket *next_sock, const char *name); @@ -612,9 +612,9 @@ struct GHashIterator *nodeSocketTypeGetIterator(void); const char *nodeSocketTypeLabel(const bNodeSocketType *stype); bool nodeIsStaticSocketType(const struct bNodeSocketType *stype); -const char *nodeStaticSocketType(const int type, const int subtype); -const char *nodeStaticSocketInterfaceType(const int type, const int subtype); -const char *nodeStaticSocketLabel(const int type, const int subtype); +const char *nodeStaticSocketType(int type, int subtype); +const char *nodeStaticSocketInterfaceType(int type, int subtype); +const char *nodeStaticSocketLabel(int type, int subtype); /* Helper macros for iterating over node types. */ #define NODE_SOCKET_TYPES_BEGIN(stype) \ @@ -632,11 +632,11 @@ const char *nodeStaticSocketLabel(const int type, const int subtype); ((void)0) struct bNodeSocket *nodeFindSocket(const struct bNode *node, - const eNodeSocketInOut in_out, + eNodeSocketInOut in_out, const char *identifier); struct bNodeSocket *nodeAddSocket(struct bNodeTree *ntree, struct bNode *node, - const eNodeSocketInOut in_out, + eNodeSocketInOut in_out, const char *idname, const char *identifier, const char *name); @@ -651,17 +651,14 @@ void nodeRemoveSocket(struct bNodeTree *ntree, struct bNode *node, struct bNodeS void nodeRemoveSocketEx(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *sock, - const bool do_id_user); + 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, - const int type, - const int subtype); +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, const int type); @@ -692,7 +689,7 @@ void nodeRebuildIDVector(struct bNodeTree *node_tree); void nodeRemoveNode(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node, - const bool do_id_user); + bool do_id_user); void nodeDimensionsGet(const struct bNode *node, float *r_width, float *r_height); void nodeTagUpdateID(struct bNode *node); @@ -745,8 +742,8 @@ 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, const float x, const float y, float *rx, float *ry); -void nodeFromView(const struct bNode *node, const float x, const float y, float *rx, float *ry); +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 nodeAttachNodeCheck(const struct bNode *node, const struct bNode *parent); void nodeAttachNode(struct bNodeTree *ntree, struct bNode *node, struct bNode *parent); void nodeDetachNode(struct bNodeTree *ntree, struct bNode *node); @@ -813,7 +810,7 @@ void nodeChainIterBackwards(const bNodeTree *ntree, const bNode *node_start, bool (*callback)(bNode *, bNode *, void *), void *userdata, - const int recursion_lvl); + int recursion_lvl); /** * Iterate over all parents of \a node, executing \a callback for each parent * (which can return false to end iterator) @@ -855,7 +852,7 @@ bool nodeSupportsActiveFlag(const struct bNode *node, int sub_active); void nodeSetSocketAvailability(struct bNodeTree *ntree, struct bNodeSocket *sock, - const bool is_available); + bool is_available); int nodeSocketLinkLimit(const struct bNodeSocket *sock); @@ -973,10 +970,7 @@ void BKE_node_preview_merge_tree(struct bNodeTree *to_ntree, /** \name Node Type Access * \{ */ -void nodeLabel(const struct bNodeTree *ntree, - const struct bNode *node, - char *label, - const int maxlen); +void nodeLabel(const struct bNodeTree *ntree, const struct bNode *node, char *label, int maxlen); /** * Get node socket label if it is set. */ @@ -989,19 +983,16 @@ bool nodeGroupPoll(const struct bNodeTree *nodetree, /** * Initialize a new node type struct with default values and callbacks. */ -void node_type_base(struct bNodeType *ntype, const int type, const char *name, const short nclass); +void node_type_base(struct bNodeType *ntype, int type, const char *name, const short nclass); void node_type_base_custom(struct bNodeType *ntype, const char *idname, const char *name, - const short nclass); + short nclass); void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs); -void node_type_size(struct bNodeType *ntype, - const int width, - const int minwidth, - const int maxwidth); -void node_type_size_preset(struct bNodeType *ntype, const eNodeSizePreset size); +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). @@ -1594,11 +1585,9 @@ extern struct bNodeSocketType NodeSocketTypeUndefined; namespace blender::bke { -bNodeSocket *node_find_enabled_socket(bNode &node, - const eNodeSocketInOut in_out, - const StringRef name); -bNodeSocket *node_find_enabled_input_socket(bNode &node, const StringRef name); -bNodeSocket *node_find_enabled_output_socket(bNode &node, const StringRef name); +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 diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index a8d5bddd3b2..1c290497197 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -2917,22 +2917,25 @@ void BKE_node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, boo void nodeUnlinkNode(bNodeTree *ntree, const bNode *node) { LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) { - if (!ELEM(node, link->fromnode, link->tonode)) { - continue; + ListBase const *lb = nullptr; + if (link->fromnode == node) { + lb = &node->outputs; + } + else if (link->tonode == node) { + lb = &node->inputs; } - /* Only bother adjusting if the socket is not on the node we're deleting. */ - if (link->tonode != node && link->tosock->flag & SOCK_MULTI_INPUT) { - adjust_multi_input_indices_after_removed_link( - ntree, link->tosock, link->multi_input_socket_index); - } - - const bool validate_outputs = node == link->fromnode; - const ListBase *sockets = validate_outputs ? &node->outputs : &node->inputs; - LISTBASE_FOREACH (const bNodeSocket *, sock, sockets) { - if (link->fromsock == sock || link->tosock == sock) { - nodeRemLink(ntree, link); - break; + if (lb) { + /* Only bother adjusting if the socket is not on the node we're deleting. */ + if (link->tonode != node && link->tosock->flag & SOCK_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; + } } } } -- 2.30.2 From 0842acd101059469cba4c03d5f4a8727b63aaf87 Mon Sep 17 00:00:00 2001 From: illua1 Date: Mon, 20 Feb 2023 22:20:22 +0300 Subject: [PATCH 3/9] delete one missing/ --- source/blender/blenkernel/BKE_node.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 24d95173f8a..677d327557a 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -996,7 +996,7 @@ bool nodeGroupPoll(const struct bNodeTree *nodetree, /** * Initialize a new node type struct with default values and callbacks. */ -void node_type_base(struct bNodeType *ntype, int type, const char *name, const short nclass); +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, -- 2.30.2 From 7936795011b8562a28d49535038ecdbcdb68fbb3 Mon Sep 17 00:00:00 2001 From: illua1 Date: Mon, 20 Feb 2023 22:22:05 +0300 Subject: [PATCH 4/9] delete one missing// --- source/blender/blenkernel/BKE_node.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 677d327557a..5b0fa51c253 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -674,7 +674,7 @@ 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, const int type); +struct bNode *nodeAddStaticNode(const struct bContext *C, struct bNodeTree *ntree, int type); /** * \note Goes over entire tree. */ -- 2.30.2 From f38f25f4f45ee7c01500b749d07a75f510ccb8a6 Mon Sep 17 00:00:00 2001 From: illua1 Date: Tue, 28 Feb 2023 20:23:48 +0300 Subject: [PATCH 5/9] delete nodeUnlinkNode from this commit --- source/blender/blenkernel/BKE_node.h | 2 +- source/blender/blenkernel/intern/node.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 5b0fa51c253..ec211c9a6b4 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -678,7 +678,7 @@ struct bNode *nodeAddStaticNode(const struct bContext *C, struct bNodeTree *ntre /** * \note Goes over entire tree. */ -void nodeUnlinkNode(struct bNodeTree *ntree, const struct bNode *node); +void nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node); /** * Find the first available, non-duplicate name for a given node. */ diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 1c290497197..eccc790d68a 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -2914,10 +2914,10 @@ void BKE_node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, boo } } -void nodeUnlinkNode(bNodeTree *ntree, const bNode *node) +void nodeUnlinkNode(bNodeTree *ntree, bNode *node) { LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) { - ListBase const *lb = nullptr; + ListBase *lb = nullptr; if (link->fromnode == node) { lb = &node->outputs; } -- 2.30.2 From 652360c42c4bc930c1aeeb4d6f09904df73ad8db Mon Sep 17 00:00:00 2001 From: illua1 Date: Thu, 2 Mar 2023 22:44:59 +0300 Subject: [PATCH 6/9] init commit --- source/blender/blenkernel/intern/node.cc | 69 ++++++++++++++++-------- 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 1783a8b1fb1..f4e85996803 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -2051,10 +2051,16 @@ bool nodeFindNodeTry(bNodeTree *ntree, bNodeSocket *sock, bNode **r_node, int *r bNode *nodeFindRootParent(bNode *node) { - if (node->parent) { - return nodeFindRootParent(node->parent); + bNode *t_node = node; + while (t_node->parent != nullptr) { + t_node = t_node->parent; } - return node->type == NODE_FRAME ? node : nullptr; + + if (t_node->type != NODE_FRAME) { + return nullptr; + } + + return t_node; } bool nodeIsChildOf(const bNode *parent, const bNode *child) @@ -2062,9 +2068,16 @@ bool nodeIsChildOf(const bNode *parent, const bNode *child) if (parent == child) { return true; } - if (child->parent) { - return nodeIsChildOf(parent, child->parent); + + const bNode *t_child = child; + while (t_child->parent != nullptr) { + t_child = t_child->parent; + + if (t_child == parent) { + return true; + } } + return false; } @@ -2547,28 +2560,42 @@ void nodeInternalRelink(bNodeTree *ntree, bNode *node) } } +/** + * Location mapping in parent frame node space. + */ +static void nodeViewMapping(const bNode *node, float &mapping_x, float &mapping_y) +{ + const bNode *t_node = node; + + mapping_x += t_node->locx; + mapping_y += t_node->locy; + + while (t_node->parent != nullptr) { + t_node = t_node->parent; + + mapping_x += t_node->locx; + mapping_y += t_node->locy; + } +} + void nodeToView(const bNode *node, float x, float y, float *rx, float *ry) { - if (node->parent) { - nodeToView(node->parent, x + node->locx, y + node->locy, rx, ry); - } - else { - *rx = x + node->locx; - *ry = y + node->locy; - } + float mapping_x = 0.0f; + float mapping_y = 0.0f; + nodeViewMapping(node, mapping_x, mapping_y); + + *rx = mapping_x + x; + *ry = mapping_y + y; } void nodeFromView(const bNode *node, float x, float y, float *rx, float *ry) { - if (node->parent) { - nodeFromView(node->parent, x, y, rx, ry); - *rx -= node->locx; - *ry -= node->locy; - } - else { - *rx = x - node->locx; - *ry = y - node->locy; - } + float mapping_x = 0.0f; + float mapping_y = 0.0f; + nodeViewMapping(node, mapping_x, mapping_y); + + *rx = -mapping_x + x; + *ry = -mapping_y + y; } bool nodeAttachNodeCheck(const bNode *node, const bNode *parent) -- 2.30.2 From 998a044cf8b633cb4ac834d1eef2029f21e1f902 Mon Sep 17 00:00:00 2001 From: illua1 Date: Fri, 3 Mar 2023 21:58:31 +0300 Subject: [PATCH 7/9] some vars renaming, reuse nodeIsChildOf in nodeAttachNodeCheck --- source/blender/blenkernel/intern/node.cc | 42 +++++++----------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 006dd8d8c43..78cdb8aa619 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -2053,29 +2053,22 @@ bool nodeFindNodeTry(bNodeTree *ntree, bNodeSocket *sock, bNode **r_node, int *r bNode *nodeFindRootParent(bNode *node) { - bNode *t_node = node; - while (t_node->parent != nullptr) { - t_node = t_node->parent; + bNode *parent_iter = node; + while (parent_iter->parent != nullptr) { + parent_iter = parent_iter->parent; } - if (t_node->type != NODE_FRAME) { + if (parent_iter->type != NODE_FRAME) { return nullptr; } - return t_node; + return parent_iter; } bool nodeIsChildOf(const bNode *parent, const bNode *child) { - if (parent == child) { - return true; - } - - const bNode *t_child = child; - while (t_child->parent != nullptr) { - t_child = t_child->parent; - - if (t_child == parent) { + for (const bNode *parent_iter = child; parent_iter; parent_iter = parent_iter->parent) { + if (parent_iter == parent) { return true; } } @@ -2567,16 +2560,9 @@ void nodeInternalRelink(bNodeTree *ntree, bNode *node) */ static void nodeViewMapping(const bNode *node, float &mapping_x, float &mapping_y) { - const bNode *t_node = node; - - mapping_x += t_node->locx; - mapping_y += t_node->locy; - - while (t_node->parent != nullptr) { - t_node = t_node->parent; - - mapping_x += t_node->locx; - mapping_y += t_node->locy; + for (const bNode *node_iter = node; node_iter; node_iter = node_iter->parent) { + mapping_x += node_iter->locx; + mapping_y += node_iter->locy; } } @@ -2602,13 +2588,7 @@ void nodeFromView(const bNode *node, const float x, const float y, float *rx, fl bool nodeAttachNodeCheck(const bNode *node, const bNode *parent) { - for (const bNode *parent_iter = node; parent_iter; parent_iter = parent_iter->parent) { - if (parent_iter == parent) { - return true; - } - } - - return false; + return nodeIsChildOf(parent, node); } void nodeAttachNode(bNodeTree *ntree, bNode *node, bNode *parent) -- 2.30.2 From ed5d5c9fed5c6d31937041db1da3cf7ae4175469 Mon Sep 17 00:00:00 2001 From: illua1 Date: Sun, 5 Mar 2023 19:27:36 +0300 Subject: [PATCH 8/9] some little changes --- source/blender/blenkernel/intern/node.cc | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index d7425c7c67d..7a3b2ef7c28 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -2555,22 +2555,14 @@ void nodeInternalRelink(bNodeTree *ntree, bNode *node) } } -/** - * Location mapping in parent frame node space. - */ -static void nodeViewMapping(const bNode *node, float &mapping_x, float &mapping_y) -{ - for (const bNode *node_iter = node; node_iter; node_iter = node_iter->parent) { - mapping_x += node_iter->locx; - mapping_y += node_iter->locy; - } -} - void nodeToView(const bNode *node, const float x, const float y, float *rx, float *ry) { float mapping_x = 0.0f; float mapping_y = 0.0f; - nodeViewMapping(node, mapping_x, mapping_y); + for (const bNode *node_iter = node; node_iter; node_iter = node_iter->parent) { + mapping_x += node_iter->locx; + mapping_y += node_iter->locy; + } *rx = mapping_x + x; *ry = mapping_y + y; @@ -2580,7 +2572,10 @@ void nodeFromView(const bNode *node, const float x, const float y, float *rx, fl { float mapping_x = 0.0f; float mapping_y = 0.0f; - nodeViewMapping(node, mapping_x, mapping_y); + for (const bNode *node_iter = node; node_iter; node_iter = node_iter->parent) { + mapping_x += node_iter->locx; + mapping_y += node_iter->locy; + } *rx = -mapping_x + x; *ry = -mapping_y + y; -- 2.30.2 From 63b717b40f7bb749a3cb28dbb81219d2658194d4 Mon Sep 17 00:00:00 2001 From: illua1 Date: Mon, 6 Mar 2023 20:30:42 +0300 Subject: [PATCH 9/9] delete extra whitespaces --- source/blender/blenkernel/intern/node.cc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 7a3b2ef7c28..82589e65e97 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -2057,11 +2057,9 @@ bNode *nodeFindRootParent(bNode *node) while (parent_iter->parent != nullptr) { parent_iter = parent_iter->parent; } - if (parent_iter->type != NODE_FRAME) { return nullptr; } - return parent_iter; } @@ -2072,7 +2070,6 @@ bool nodeIsParentAndChild(const bNode *parent, const bNode *child) return true; } } - return false; } @@ -2563,7 +2560,6 @@ void nodeToView(const bNode *node, const float x, const float y, float *rx, floa mapping_x += node_iter->locx; mapping_y += node_iter->locy; } - *rx = mapping_x + x; *ry = mapping_y + y; } @@ -2576,7 +2572,6 @@ void nodeFromView(const bNode *node, const float x, const float y, float *rx, fl mapping_x += node_iter->locx; mapping_y += node_iter->locy; } - *rx = -mapping_x + x; *ry = -mapping_y + y; } -- 2.30.2