Cleanup: Don't do recursion where possible in node.cc #105394
|
@ -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
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue