Blender  V2.93
Classes | Macros | Typedefs | Functions
node_relationships.c File Reference
#include "MEM_guardedalloc.h"
#include "DNA_anim_types.h"
#include "DNA_node_types.h"
#include "BLI_blenlib.h"
#include "BLI_easing.h"
#include "BLI_math.h"
#include "BKE_anim_data.h"
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_node.h"
#include "ED_node.h"
#include "ED_render.h"
#include "ED_screen.h"
#include "ED_util.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "WM_api.h"
#include "WM_types.h"
#include "UI_resources.h"
#include "UI_view2d.h"
#include "BLT_translation.h"
#include "node_intern.h"

Go to the source code of this file.

Classes

struct  bNodeListItem
 
struct  NodeInsertOfsData
 
struct  LinkAndPosition
 

Macros

#define NODE_JOIN_DONE   1
 
#define NODE_JOIN_IS_DESCENDANT   2
 
#define NODE_DETACH_DONE   1
 
#define NODE_DETACH_IS_DESCENDANT   2
 
#define NODE_INSOFS_ANIM_DURATION   0.25f
 

Typedefs

typedef struct bNodeListItem bNodeListItem
 
typedef struct NodeInsertOfsData NodeInsertOfsData
 
typedef struct LinkAndPosition LinkAndPosition
 

Functions

static bool ntree_has_drivers (bNodeTree *ntree)
 
static bool ntree_check_nodes_connected_dfs (bNodeTree *ntree, bNode *from, bNode *to)
 
static bool ntree_check_nodes_connected (bNodeTree *ntree, bNode *from, bNode *to)
 
static bool node_group_has_output_dfs (bNode *node)
 
static bool node_group_has_output (Main *bmain, bNode *node)
 
bool node_connected_to_output (Main *bmain, bNodeTree *ntree, bNode *node)
 
static void clear_picking_highlight (ListBase *links)
 
static LinkDatacreate_drag_link (Main *bmain, SpaceNode *snode, bNode *node, bNodeSocket *sock)
 
static void pick_link (const bContext *C, wmOperator *op, bNodeLinkDrag *nldrag, SpaceNode *snode, bNode *node, bNodeLink *link_to_pick)
 
static void pick_input_link_by_link_intersect (const bContext *C, wmOperator *op, bNodeLinkDrag *nldrag, const float *cursor)
 
static int sort_nodes_locx (const void *a, const void *b)
 
static bool socket_is_available (bNodeTree *UNUSED(ntree), bNodeSocket *sock, const bool allow_used)
 
static bNodeSocketbest_socket_output (bNodeTree *ntree, bNode *node, bNodeSocket *sock_target, const bool allow_multiple)
 
static bNodeSocketbest_socket_input (bNodeTree *ntree, bNode *node, int num, int replace)
 
static bool snode_autoconnect_input (SpaceNode *snode, bNode *node_fr, bNodeSocket *sock_fr, bNode *node_to, bNodeSocket *sock_to, int replace)
 
static int compare_link_by_y_position (const void *a, const void *b)
 
void sort_multi_input_socket_links (SpaceNode *snode, bNode *node, bNodeLink *drag_link, float cursor[2])
 
static void snode_autoconnect (Main *bmain, SpaceNode *snode, const bool allow_multiple, const bool replace)
 
static int node_link_viewer (const bContext *C, bNode *tonode)
 
static int node_active_link_viewer_exec (bContext *C, wmOperator *UNUSED(op))
 
void NODE_OT_link_viewer (wmOperatorType *ot)
 
static void node_link_update_header (bContext *C, bNodeLinkDrag *UNUSED(nldrag))
 
static int node_count_links (const bNodeTree *ntree, const bNodeSocket *socket)
 
static void node_remove_extra_links (SpaceNode *snode, bNodeLink *link)
 
static void node_link_exit (bContext *C, wmOperator *op, bool apply_links)
 
static void node_link_find_socket (bContext *C, wmOperator *op, float cursor[2])
 
static int node_link_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
static bNodeLinkDragnode_link_init (Main *bmain, SpaceNode *snode, float cursor[2], bool detach)
 
static int node_link_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static void node_link_cancel (bContext *C, wmOperator *op)
 
void NODE_OT_link (wmOperatorType *ot)
 
static int node_make_link_exec (bContext *C, wmOperator *op)
 
void NODE_OT_link_make (wmOperatorType *ot)
 
static bool node_links_intersect (bNodeLink *link, const float mcoords[][2], int tot)
 
static int cut_links_exec (bContext *C, wmOperator *op)
 
void NODE_OT_links_cut (wmOperatorType *ot)
 
static int mute_links_exec (bContext *C, wmOperator *op)
 
void NODE_OT_links_mute (wmOperatorType *ot)
 
static int detach_links_exec (bContext *C, wmOperator *UNUSED(op))
 
void NODE_OT_links_detach (wmOperatorType *ot)
 
static int node_parent_set_exec (bContext *C, wmOperator *UNUSED(op))
 
void NODE_OT_parent_set (wmOperatorType *ot)
 
static void node_join_attach_recursive (bNode *node, bNode *frame)
 
static int node_join_exec (bContext *C, wmOperator *UNUSED(op))
 
void NODE_OT_join (wmOperatorType *ot)
 
static bNodenode_find_frame_to_attach (ARegion *region, const bNodeTree *ntree, const int mouse_xy[2])
 
static int node_attach_invoke (bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
 
void NODE_OT_attach (wmOperatorType *ot)
 
static void node_detach_recursive (bNode *node)
 
static int node_detach_exec (bContext *C, wmOperator *UNUSED(op))
 
void NODE_OT_detach (wmOperatorType *ot)
 
static bool ed_node_link_conditions (ScrArea *area, bool test, SpaceNode **r_snode, bNode **r_select)
 
void ED_node_link_intersect_test (ScrArea *area, int test)
 
static bNodeSocketsocket_best_match (ListBase *sockets)
 
static bool node_parents_offset_flag_enable_cb (bNode *parent, void *UNUSED(userdata))
 
static void node_offset_apply (bNode *node, const float offset_x)
 
static void node_parent_offset_apply (NodeInsertOfsData *data, bNode *parent, const float offset_x)
 
static bool node_link_insert_offset_frame_chain_cb (bNode *fromnode, bNode *tonode, void *userdata, const bool reversed)
 
static void node_link_insert_offset_frame_chains (const bNodeTree *ntree, const bNode *parent, NodeInsertOfsData *data, const bool reversed)
 
static bool node_link_insert_offset_chain_cb (bNode *fromnode, bNode *tonode, void *userdata, const bool reversed)
 
static void node_link_insert_offset_ntree (NodeInsertOfsData *iofsd, ARegion *region, const int mouse_xy[2], const bool right_alignment)
 
static int node_insert_offset_modal (bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
 
static int node_insert_offset_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
void NODE_OT_insert_offset (wmOperatorType *ot)
 
void ED_node_link_insert (Main *bmain, ScrArea *area)
 

Macro Definition Documentation

◆ NODE_DETACH_DONE

#define NODE_DETACH_DONE   1

Definition at line 1699 of file node_relationships.c.

◆ NODE_DETACH_IS_DESCENDANT

#define NODE_DETACH_IS_DESCENDANT   2

Definition at line 1700 of file node_relationships.c.

◆ NODE_INSOFS_ANIM_DURATION

#define NODE_INSOFS_ANIM_DURATION   0.25f

Definition at line 1948 of file node_relationships.c.

◆ NODE_JOIN_DONE

#define NODE_JOIN_DONE   1

Definition at line 1523 of file node_relationships.c.

◆ NODE_JOIN_IS_DESCENDANT

#define NODE_JOIN_IS_DESCENDANT   2

Definition at line 1524 of file node_relationships.c.

Typedef Documentation

◆ bNodeListItem

typedef struct bNodeListItem bNodeListItem

◆ LinkAndPosition

◆ NodeInsertOfsData

Function Documentation

◆ best_socket_input()

static bNodeSocket* best_socket_input ( bNodeTree ntree,
bNode node,
int  num,
int  replace 
)
static

Definition at line 385 of file node_relationships.c.

References Freestyle::a, LISTBASE_FOREACH, max_ii(), node, ntree, NULL, and socket_is_available().

Referenced by snode_autoconnect().

◆ best_socket_output()

static bNodeSocket* best_socket_output ( bNodeTree ntree,
bNode node,
bNodeSocket sock_target,
const bool  allow_multiple 
)
static

◆ clear_picking_highlight()

static void clear_picking_highlight ( ListBase links)
static

◆ compare_link_by_y_position()

static int compare_link_by_y_position ( const void *  a,
const void *  b 
)
static

◆ create_drag_link()

static LinkData* create_drag_link ( Main bmain,
SpaceNode snode,
bNode node,
bNodeSocket sock 
)
static

◆ cut_links_exec()

static int cut_links_exec ( bContext C,
wmOperator op 
)
static

◆ detach_links_exec()

static int detach_links_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ ed_node_link_conditions()

static bool ed_node_link_conditions ( ScrArea area,
bool  test,
SpaceNode **  r_snode,
bNode **  r_select 
)
static

◆ ED_node_link_insert()

void ED_node_link_insert ( Main bmain,
ScrArea area 
)

◆ ED_node_link_intersect_test()

void ED_node_link_intersect_test ( ScrArea area,
int  test 
)

◆ mute_links_exec()

static int mute_links_exec ( bContext C,
wmOperator op 
)
static

◆ node_active_link_viewer_exec()

static int node_active_link_viewer_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ node_attach_invoke()

static int node_attach_invoke ( bContext C,
wmOperator UNUSEDop,
const wmEvent event 
)
static

◆ node_connected_to_output()

bool node_connected_to_output ( Main bmain,
bNodeTree ntree,
bNode node 
)

◆ node_count_links()

static int node_count_links ( const bNodeTree ntree,
const bNodeSocket socket 
)
static

◆ node_detach_exec()

static int node_detach_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ node_detach_recursive()

static void node_detach_recursive ( bNode node)
static

◆ node_find_frame_to_attach()

static bNode* node_find_frame_to_attach ( ARegion region,
const bNodeTree ntree,
const int  mouse_xy[2] 
)
static

◆ node_group_has_output()

static bool node_group_has_output ( Main bmain,
bNode node 
)
static

◆ node_group_has_output_dfs()

static bool node_group_has_output_dfs ( bNode node)
static

◆ node_insert_offset_invoke()

static int node_insert_offset_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ node_insert_offset_modal()

static int node_insert_offset_modal ( bContext C,
wmOperator UNUSEDop,
const wmEvent event 
)
static

◆ node_join_attach_recursive()

static void node_join_attach_recursive ( bNode node,
bNode frame 
)
static

◆ node_join_exec()

static int node_join_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ node_link_cancel()

static void node_link_cancel ( bContext C,
wmOperator op 
)
static

◆ node_link_exit()

static void node_link_exit ( bContext C,
wmOperator op,
bool  apply_links 
)
static

◆ node_link_find_socket()

static void node_link_find_socket ( bContext C,
wmOperator op,
float  cursor[2] 
)
static

◆ node_link_init()

static bNodeLinkDrag* node_link_init ( Main bmain,
SpaceNode snode,
float  cursor[2],
bool  detach 
)
static

◆ node_link_insert_offset_chain_cb()

static bool node_link_insert_offset_chain_cb ( bNode fromnode,
bNode tonode,
void *  userdata,
const bool  reversed 
)
static

Callback that applies NodeInsertOfsData.offset_x to a node or its parent, considering the logic needed for offsetting nodes after link insert

Definition at line 1991 of file node_relationships.c.

References data, bNode::flag, node, node_link_insert_offset_frame_chains(), node_offset_apply(), node_parent_offset_apply(), NODE_TEST, nodeFindRootParent(), nodeIsChildOf(), NULL, and bNode::parent.

Referenced by node_link_insert_offset_ntree().

◆ node_link_insert_offset_frame_chain_cb()

static bool node_link_insert_offset_frame_chain_cb ( bNode fromnode,
bNode tonode,
void *  userdata,
const bool  reversed 
)
static

Callback that applies NodeInsertOfsData.offset_x to a node or its parent, similar to node_link_insert_offset_output_chain_cb below, but with slightly different logic

Definition at line 1954 of file node_relationships.c.

References data, node_offset_apply(), and bNode::parent.

Referenced by node_link_insert_offset_frame_chains().

◆ node_link_insert_offset_frame_chains()

static void node_link_insert_offset_frame_chains ( const bNodeTree ntree,
const bNode parent,
NodeInsertOfsData data,
const bool  reversed 
)
static

◆ node_link_insert_offset_ntree()

static void node_link_insert_offset_ntree ( NodeInsertOfsData iofsd,
ARegion region,
const int  mouse_xy[2],
const bool  right_alignment 
)
static

◆ node_link_invoke()

static int node_link_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ node_link_modal()

static int node_link_modal ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ node_link_update_header()

static void node_link_update_header ( bContext C,
bNodeLinkDrag UNUSEDnldrag 
)
static

Definition at line 746 of file node_relationships.c.

References BLI_strncpy(), C, ED_workspace_status_text(), TIP_, and UI_MAX_DRAW_STR.

Referenced by node_link_modal().

◆ node_link_viewer()

static int node_link_viewer ( const bContext C,
bNode tonode 
)
static

◆ node_links_intersect()

static bool node_links_intersect ( bNodeLink link,
const float  mcoords[][2],
int  tot 
)
static

◆ node_make_link_exec()

static int node_make_link_exec ( bContext C,
wmOperator op 
)
static

◆ node_offset_apply()

static void node_offset_apply ( bNode node,
const float  offset_x 
)
static

◆ NODE_OT_attach()

void NODE_OT_attach ( wmOperatorType ot)

◆ NODE_OT_detach()

void NODE_OT_detach ( wmOperatorType ot)

◆ NODE_OT_insert_offset()

void NODE_OT_insert_offset ( wmOperatorType ot)

◆ NODE_OT_join()

void NODE_OT_join ( wmOperatorType ot)

◆ NODE_OT_link()

void NODE_OT_link ( wmOperatorType ot)

◆ NODE_OT_link_make()

void NODE_OT_link_make ( wmOperatorType ot)

◆ NODE_OT_link_viewer()

void NODE_OT_link_viewer ( wmOperatorType ot)

◆ NODE_OT_links_cut()

void NODE_OT_links_cut ( wmOperatorType ot)

◆ NODE_OT_links_detach()

void NODE_OT_links_detach ( wmOperatorType ot)

◆ NODE_OT_links_mute()

void NODE_OT_links_mute ( wmOperatorType ot)

◆ NODE_OT_parent_set()

void NODE_OT_parent_set ( wmOperatorType ot)

◆ node_parent_offset_apply()

static void node_parent_offset_apply ( NodeInsertOfsData data,
bNode parent,
const float  offset_x 
)
static

◆ node_parent_set_exec()

static int node_parent_set_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ node_parents_offset_flag_enable_cb()

static bool node_parents_offset_flag_enable_cb ( bNode parent,
void *  UNUSEDuserdata 
)
static

Definition at line 1916 of file node_relationships.c.

References bNode::flag, and NODE_TEST.

Referenced by node_link_insert_offset_ntree().

◆ node_remove_extra_links()

static void node_remove_extra_links ( SpaceNode snode,
bNodeLink link 
)
static

◆ ntree_check_nodes_connected()

static bool ntree_check_nodes_connected ( bNodeTree ntree,
bNode from,
bNode to 
)
static

◆ ntree_check_nodes_connected_dfs()

static bool ntree_check_nodes_connected_dfs ( bNodeTree ntree,
bNode from,
bNode to 
)
static

Definition at line 69 of file node_relationships.c.

References from, bNodeTree::links, LISTBASE_FOREACH, NODE_TEST, and ntree.

Referenced by ntree_check_nodes_connected().

◆ ntree_has_drivers()

static bool ntree_has_drivers ( bNodeTree ntree)
static

◆ pick_input_link_by_link_intersect()

static void pick_input_link_by_link_intersect ( const bContext C,
wmOperator op,
bNodeLinkDrag nldrag,
const float cursor 
)
static

◆ pick_link()

static void pick_link ( const bContext C,
wmOperator op,
bNodeLinkDrag nldrag,
SpaceNode snode,
bNode node,
bNodeLink link_to_pick 
)
static

◆ snode_autoconnect()

static void snode_autoconnect ( Main bmain,
SpaceNode snode,
const bool  allow_multiple,
const bool  replace 
)
static

◆ snode_autoconnect_input()

static bool snode_autoconnect_input ( SpaceNode snode,
bNode node_fr,
bNodeSocket sock_fr,
bNode node_to,
bNodeSocket sock_to,
int  replace 
)
static

Definition at line 415 of file node_relationships.c.

References SpaceNode::edittree, nodeAddLink(), nodeRemSocketLinks(), and ntree.

Referenced by snode_autoconnect().

◆ socket_best_match()

static bNodeSocket* socket_best_match ( ListBase sockets)
static

Definition at line 1886 of file node_relationships.c.

References LISTBASE_FOREACH, max_ii(), nodeSocketIsHidden(), NULL, SOCK_HIDDEN, and type.

Referenced by ED_node_link_insert().

◆ socket_is_available()

static bool socket_is_available ( bNodeTree UNUSEDntree,
bNodeSocket sock,
const bool  allow_used 
)
static

◆ sort_multi_input_socket_links()

void sort_multi_input_socket_links ( SpaceNode snode,
bNode node,
bNodeLink drag_link,
float  cursor[2] 
)

◆ sort_nodes_locx()

static int sort_nodes_locx ( const void *  a,
const void *  b 
)
static

Definition at line 306 of file node_relationships.c.

References Freestyle::a, bNode::locx, and bNodeListItem::node.

Referenced by snode_autoconnect().