Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/drawnode.cc
| Show First 20 Lines • Show All 4,262 Lines • ▼ Show 20 Lines | static void nodelink_batch_add_link(const SpaceNode *snode, | ||||
| *(float *)GPU_vertbuf_raw_step(&g_batch_link.dash_alpha_step) = dash_alpha; | *(float *)GPU_vertbuf_raw_step(&g_batch_link.dash_alpha_step) = dash_alpha; | ||||
| if (g_batch_link.count == NODELINK_GROUP_SIZE) { | if (g_batch_link.count == NODELINK_GROUP_SIZE) { | ||||
| nodelink_batch_draw(snode); | nodelink_batch_draw(snode); | ||||
| } | } | ||||
| } | } | ||||
| /* don't do shadows if th_col3 is -1. */ | /* don't do shadows if th_col3 is -1. */ | ||||
| void node_draw_link_bezier(const View2D *v2d, | void node_draw_link_bezier(const bContext *C, | ||||
| const View2D *v2d, | |||||
| const SpaceNode *snode, | const SpaceNode *snode, | ||||
| const bNodeLink *link, | const bNodeLink *link, | ||||
| int th_col1, | int th_col1, | ||||
| int th_col2, | int th_col2, | ||||
| int th_col3) | int th_col3) | ||||
| { | { | ||||
| const float dim_factor = node_link_dim_factor(v2d, link); | const float dim_factor = node_link_dim_factor(v2d, link); | ||||
| float thickness = 1.5f; | float thickness = 1.5f; | ||||
| Show All 25 Lines | if (node_link_bezier_handles(v2d, snode, link, vec)) { | ||||
| if (th_col3 != -1) { | if (th_col3 != -1) { | ||||
| UI_GetThemeColor4fv(th_col3, colors[0]); | UI_GetThemeColor4fv(th_col3, colors[0]); | ||||
| } | } | ||||
| if (snode->overlay.flag & SN_OVERLAY_SHOW_OVERLAYS && | if (snode->overlay.flag & SN_OVERLAY_SHOW_OVERLAYS && | ||||
| snode->overlay.flag & SN_OVERLAY_SHOW_WIRE_COLORS && | snode->overlay.flag & SN_OVERLAY_SHOW_WIRE_COLORS && | ||||
| ((link->fromsock == nullptr || link->fromsock->typeinfo->type >= 0) && | ((link->fromsock == nullptr || link->fromsock->typeinfo->type >= 0) && | ||||
| (link->tosock == nullptr || link->tosock->typeinfo->type >= 0))) { | (link->tosock == nullptr || link->tosock->typeinfo->type >= 0))) { | ||||
| PointerRNA from_node_ptr, to_node_ptr; | |||||
| RNA_pointer_create((ID *)snode->edittree, &RNA_Node, link->fromnode, &from_node_ptr); | |||||
| RNA_pointer_create((ID *)snode->edittree, &RNA_Node, link->tonode, &to_node_ptr); | |||||
| if (link->fromsock) { | if (link->fromsock) { | ||||
| copy_v4_v4(colors[1], std_node_socket_colors[link->fromsock->typeinfo->type]); | node_socket_color_get(C, snode->edittree, &from_node_ptr, link->fromsock, colors[1]); | ||||
| } | } | ||||
HooglyBoogly: Maybe it makes a little more sense to have the const cast in one place: `node_socket_color_get`. | |||||
| else { | else { | ||||
| copy_v4_v4(colors[1], std_node_socket_colors[link->tosock->typeinfo->type]); | node_socket_color_get(C, snode->edittree, &to_node_ptr, link->tosock, colors[1]); | ||||
| } | } | ||||
| if (link->tosock) { | if (link->tosock) { | ||||
| copy_v4_v4(colors[2], std_node_socket_colors[link->tosock->typeinfo->type]); | node_socket_color_get(C, snode->edittree, &to_node_ptr, link->tosock, colors[2]); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v4_v4(colors[2], std_node_socket_colors[link->fromsock->typeinfo->type]); | node_socket_color_get(C, snode->edittree, &from_node_ptr, link->fromsock, colors[2]); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| UI_GetThemeColor4fv(th_col1, colors[1]); | UI_GetThemeColor4fv(th_col1, colors[1]); | ||||
| UI_GetThemeColor4fv(th_col2, colors[2]); | UI_GetThemeColor4fv(th_col2, colors[2]); | ||||
| } | } | ||||
| /* Highlight links connected to selected nodes. */ | /* Highlight links connected to selected nodes. */ | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | else { | ||||
| GPU_batch_uniform_1f(batch, "dash_factor", dash_factor); | GPU_batch_uniform_1f(batch, "dash_factor", dash_factor); | ||||
| GPU_batch_uniform_1f(batch, "dash_alpha", dash_alpha); | GPU_batch_uniform_1f(batch, "dash_alpha", dash_alpha); | ||||
| GPU_batch_draw(batch); | GPU_batch_draw(batch); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* NOTE: this is used for fake links in groups too. */ | /* NOTE: this is used for fake links in groups too. */ | ||||
| void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) | void node_draw_link(const bContext *C, View2D *v2d, SpaceNode *snode, bNodeLink *link) | ||||
| { | { | ||||
| int th_col1 = TH_WIRE_INNER, th_col2 = TH_WIRE_INNER, th_col3 = TH_WIRE; | int th_col1 = TH_WIRE_INNER, th_col2 = TH_WIRE_INNER, th_col3 = TH_WIRE; | ||||
| if (link->fromsock == nullptr && link->tosock == nullptr) { | if (link->fromsock == nullptr && link->tosock == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* new connection */ | /* new connection */ | ||||
| Show All 27 Lines | void node_draw_link(const bContext *C, View2D *v2d, SpaceNode *snode, bNodeLink *link) | ||||
| /* Links from field to non-field sockets are not allowed. */ | /* Links from field to non-field sockets are not allowed. */ | ||||
| if (snode->edittree->type == NTREE_GEOMETRY && !(link->flag & NODE_LINK_DRAGGED)) { | if (snode->edittree->type == NTREE_GEOMETRY && !(link->flag & NODE_LINK_DRAGGED)) { | ||||
| if ((link->fromsock && link->fromsock->display_shape == SOCK_DISPLAY_SHAPE_DIAMOND) && | if ((link->fromsock && link->fromsock->display_shape == SOCK_DISPLAY_SHAPE_DIAMOND) && | ||||
| (link->tosock && link->tosock->display_shape == SOCK_DISPLAY_SHAPE_CIRCLE)) { | (link->tosock && link->tosock->display_shape == SOCK_DISPLAY_SHAPE_CIRCLE)) { | ||||
| th_col1 = th_col2 = th_col3 = TH_REDALERT; | th_col1 = th_col2 = th_col3 = TH_REDALERT; | ||||
| } | } | ||||
| } | } | ||||
| node_draw_link_bezier(v2d, snode, link, th_col1, th_col2, th_col3); | node_draw_link_bezier(C, v2d, snode, link, th_col1, th_col2, th_col3); | ||||
| } | } | ||||
| void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder border, uint pos) | void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder border, uint pos) | ||||
| { | { | ||||
| immBegin(GPU_PRIM_LINES, 4); | immBegin(GPU_PRIM_LINES, 4); | ||||
| if (border & (NODE_LEFT | NODE_RIGHT)) { | if (border & (NODE_LEFT | NODE_RIGHT)) { | ||||
| immVertex2f(pos, cent[0], v2d->cur.ymin); | immVertex2f(pos, cent[0], v2d->cur.ymin); | ||||
| Show All 18 Lines | |||||
Maybe it makes a little more sense to have the const cast in one place: node_socket_color_get. Eventually I'd hope the function in the type info could get a const context argument.