diff options
Diffstat (limited to 'source/blender/editors/space_node/drawnode.cc')
-rw-r--r-- | source/blender/editors/space_node/drawnode.cc | 70 |
1 files changed, 58 insertions, 12 deletions
diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index afe36922b09..7bb35ab37d5 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -3944,15 +3944,17 @@ static struct { GPUBatch *batch_single; /* for single line */ GPUVertBuf *inst_vbo; uint p0_id, p1_id, p2_id, p3_id; - uint colid_id, muted_id; + uint colid_id, muted_id, start_color_id, end_color_id; uint dim_factor_id; uint thickness_id; uint dash_factor_id; + uint dash_alpha_id; GPUVertBufRaw p0_step, p1_step, p2_step, p3_step; - GPUVertBufRaw colid_step, muted_step; + GPUVertBufRaw colid_step, muted_step, start_color_step, end_color_step; GPUVertBufRaw dim_factor_step; GPUVertBufRaw thickness_step; GPUVertBufRaw dash_factor_step; + GPUVertBufRaw dash_alpha_step; uint count; bool enabled; } g_batch_link; @@ -3973,6 +3975,12 @@ static void nodelink_batch_reset() g_batch_link.inst_vbo, g_batch_link.thickness_id, &g_batch_link.thickness_step); GPU_vertbuf_attr_get_raw_data( g_batch_link.inst_vbo, g_batch_link.dash_factor_id, &g_batch_link.dash_factor_step); + GPU_vertbuf_attr_get_raw_data( + g_batch_link.inst_vbo, g_batch_link.dash_alpha_id, &g_batch_link.dash_alpha_step); + GPU_vertbuf_attr_get_raw_data( + g_batch_link.inst_vbo, g_batch_link.start_color_id, &g_batch_link.start_color_step); + GPU_vertbuf_attr_get_raw_data( + g_batch_link.inst_vbo, g_batch_link.end_color_id, &g_batch_link.end_color_step); g_batch_link.count = 0; } @@ -4088,6 +4096,10 @@ static void nodelink_batch_init() &format_inst, "P3", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); g_batch_link.colid_id = GPU_vertformat_attr_add( &format_inst, "colid_doarrow", GPU_COMP_U8, 4, GPU_FETCH_INT); + g_batch_link.start_color_id = GPU_vertformat_attr_add( + &format_inst, "start_color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); + g_batch_link.end_color_id = GPU_vertformat_attr_add( + &format_inst, "end_color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); g_batch_link.muted_id = GPU_vertformat_attr_add( &format_inst, "domuted", GPU_COMP_U8, 2, GPU_FETCH_INT); g_batch_link.dim_factor_id = GPU_vertformat_attr_add( @@ -4096,6 +4108,8 @@ static void nodelink_batch_init() &format_inst, "thickness", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); g_batch_link.dash_factor_id = GPU_vertformat_attr_add( &format_inst, "dash_factor", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + g_batch_link.dash_alpha_id = GPU_vertformat_attr_add( + &format_inst, "dash_alpha", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); g_batch_link.inst_vbo = GPU_vertbuf_create_with_format_ex(&format_inst, GPU_USAGE_STREAM); /* Alloc max count but only draw the range we need. */ GPU_vertbuf_data_alloc(g_batch_link.inst_vbo, NODELINK_GROUP_SIZE); @@ -4170,11 +4184,14 @@ static void nodelink_batch_add_link(const SpaceNode *snode, int th_col1, int th_col2, int th_col3, + const float start_color[4], + const float end_color[4], bool drawarrow, bool drawmuted, float dim_factor, float thickness, - float dash_factor) + float dash_factor, + float dash_alpha) { /* Only allow these colors. If more is needed, you need to modify the shader accordingly. */ BLI_assert(ELEM(th_col1, TH_WIRE_INNER, TH_WIRE, TH_ACTIVE, TH_EDGE_SELECT, TH_REDALERT)); @@ -4191,11 +4208,14 @@ static void nodelink_batch_add_link(const SpaceNode *snode, colid[1] = nodelink_get_color_id(th_col2); colid[2] = nodelink_get_color_id(th_col3); colid[3] = drawarrow; + copy_v4_v4((float *)GPU_vertbuf_raw_step(&g_batch_link.start_color_step), start_color); + copy_v4_v4((float *)GPU_vertbuf_raw_step(&g_batch_link.end_color_step), end_color); char *muted = (char *)GPU_vertbuf_raw_step(&g_batch_link.muted_step); muted[0] = drawmuted; *(float *)GPU_vertbuf_raw_step(&g_batch_link.dim_factor_step) = dim_factor; *(float *)GPU_vertbuf_raw_step(&g_batch_link.thickness_step) = thickness; *(float *)GPU_vertbuf_raw_step(&g_batch_link.dash_factor_step) = dash_factor; + *(float *)GPU_vertbuf_raw_step(&g_batch_link.dash_alpha_step) = dash_alpha; if (g_batch_link.count == NODELINK_GROUP_SIZE) { nodelink_batch_draw(snode); @@ -4213,6 +4233,10 @@ void node_draw_link_bezier(const View2D *v2d, const float dim_factor = node_link_dim_factor(v2d, link); float thickness = 1.5f; float dash_factor = 1.0f; + + bTheme *btheme = UI_GetTheme(); + const float dash_alpha = btheme->space_node.dash_alpha; + if (snode->edittree->type == NTREE_GEOMETRY) { if (link->fromsock && link->fromsock->display_shape == SOCK_DISPLAY_SHAPE_DIAMOND) { /* Make field links a bit thinner. */ @@ -4231,6 +4255,32 @@ void node_draw_link_bezier(const View2D *v2d, if (g_batch_link.batch == nullptr) { nodelink_batch_init(); } + /* Draw single link. */ + float colors[3][4] = {{0.0f}}; + if (th_col3 != -1) { + UI_GetThemeColor4fv(th_col3, colors[0]); + } + + if (snode->overlay.flag & SN_OVERLAY_SHOW_OVERLAYS && + snode->overlay.flag & SN_OVERLAY_SHOW_WIRE_COLORS) { + if (link->fromsock) { + copy_v4_v4(colors[1], std_node_socket_colors[link->fromsock->typeinfo->type]); + } + else { + copy_v4_v4(colors[1], std_node_socket_colors[link->tosock->typeinfo->type]); + } + + if (link->tosock) { + copy_v4_v4(colors[2], std_node_socket_colors[link->tosock->typeinfo->type]); + } + else { + copy_v4_v4(colors[2], std_node_socket_colors[link->fromsock->typeinfo->type]); + } + } + else { + UI_GetThemeColor4fv(th_col1, colors[1]); + UI_GetThemeColor4fv(th_col2, colors[2]); + } if (g_batch_link.enabled && !highlighted) { /* Add link to batch. */ @@ -4242,21 +4292,16 @@ void node_draw_link_bezier(const View2D *v2d, th_col1, th_col2, th_col3, + colors[1], + colors[2], drawarrow, drawmuted, dim_factor, thickness, - dash_factor); + dash_factor, + dash_alpha); } else { - /* Draw single link. */ - float colors[3][4] = {{0.0f}}; - if (th_col3 != -1) { - UI_GetThemeColor4fv(th_col3, colors[0]); - } - UI_GetThemeColor4fv(th_col1, colors[1]); - UI_GetThemeColor4fv(th_col2, colors[2]); - if (highlighted) { float link_preselection_highlight_color[4]; UI_GetThemeColor4fv(TH_SELECT, link_preselection_highlight_color); @@ -4274,6 +4319,7 @@ void node_draw_link_bezier(const View2D *v2d, GPU_batch_uniform_1f(batch, "dim_factor", dim_factor); GPU_batch_uniform_1f(batch, "thickness", thickness); GPU_batch_uniform_1f(batch, "dash_factor", dash_factor); + GPU_batch_uniform_1f(batch, "dash_alpha", dash_alpha); GPU_batch_draw(batch); } } |