From efefb16d4b465593f44801a5e2dec82a385428c0 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 9 May 2025 05:47:30 +0200 Subject: [PATCH] Nodes: draw frame outline over zone backgrounds Previously, the outline of frames was sometimes unexpectedly invisible. The solution is to draw the frame outlines together with the zone outlines after all the zone and frame backgrounds have been drawn already. Pull Request: https://projects.blender.org/blender/blender/pulls/138645 --- .../blender/editors/space_node/node_draw.cc | 53 +++++++++++-------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 37e4e9a6ccc..394a383dc5f 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -4279,8 +4279,17 @@ static void frame_node_draw_background(const ARegion ®ion, const rctf &rct = node.runtime->draw_bounds; UI_draw_roundbox_corner_set(UI_CNR_ALL); UI_draw_roundbox_4fv(&rct, true, BASIS_RAD, color); +} - /* Outline active and selected emphasis. */ +static void frame_node_draw_outline(const ARegion ®ion, const bNode &node) +{ + /* Skip if out of view. */ + const rctf &rct = node.runtime->draw_bounds; + if (BLI_rctf_isect(&rct, ®ion.v2d.cur, nullptr) == false) { + return; + } + + float color[4]; if (node.flag & SELECT) { if (node.flag & NODE_ACTIVE) { UI_GetThemeColorShadeAlpha4fv(TH_ACTIVE, 0, -40, color); @@ -4770,28 +4779,30 @@ static void node_draw_zones_and_frames(const ARegion ®ion, /* Draw all the contour lines after to prevent them from getting hidden by overlapping zones. */ for (const ZoneOrNode &zone_or_node : draw_order) { - const bNodeTreeZone *const *zone_p = std::get_if(&zone_or_node); - if (!zone_p) { - continue; + if (const bNodeTreeZone *const *zone_p = std::get_if(&zone_or_node)) { + const bNodeTreeZone &zone = **zone_p; + const int zone_i = zone.index; + const Span fillet_boundary_positions = fillet_curve_by_zone[zone_i].positions(); + /* Draw the contour lines. */ + immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR); + + immUniform2fv("viewportSize", &viewport[2]); + immUniform1f("lineWidth", line_width * U.pixelsize); + + immUniformThemeColorAlpha(get_theme_id(zone_i), 1.0f); + immBegin(GPU_PRIM_LINE_STRIP, fillet_boundary_positions.size() + 1); + for (const float3 &p : fillet_boundary_positions) { + immVertex3fv(pos, p); + } + immVertex3fv(pos, fillet_boundary_positions[0]); + immEnd(); + + immUnbindProgram(); } - const bNodeTreeZone &zone = **zone_p; - const int zone_i = zone.index; - const Span fillet_boundary_positions = fillet_curve_by_zone[zone_i].positions(); - /* Draw the contour lines. */ - immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR); - - immUniform2fv("viewportSize", &viewport[2]); - immUniform1f("lineWidth", line_width * U.pixelsize); - - immUniformThemeColorAlpha(get_theme_id(zone_i), 1.0f); - immBegin(GPU_PRIM_LINE_STRIP, fillet_boundary_positions.size() + 1); - for (const float3 &p : fillet_boundary_positions) { - immVertex3fv(pos, p); + if (const bNode *const *node_p = std::get_if(&zone_or_node)) { + const bNode &node = **node_p; + frame_node_draw_outline(region, node); } - immVertex3fv(pos, fillet_boundary_positions[0]); - immEnd(); - - immUnbindProgram(); } GPU_blend(GPU_BLEND_NONE);