diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 69e06e25bd7..14c1b9d2a94 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -869,7 +869,7 @@ const bTheme U_theme_default = { .nodeclass_layout = RGBA(0x6c696fff), .nodeclass_geometry = RGBA(0x00d6a3ff), .nodeclass_attribute = RGBA(0x001566ff), - .node_zone_simulation = RGBA(0x00000011), + .node_zone_simulation = RGBA(0x66416233), .movie = RGBA(0x0f0f0fcc), .gp_vertex_size = 3, .gp_vertex = RGBA(0x97979700), diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index 399e7b6366b..ea61273ca39 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -108,10 +108,7 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme) */ { /* Keep this block, even when empty. */ - - if (btheme->space_node.node_zone_simulation[3] == 0) { - btheme->space_node.node_zone_simulation[3] = 0x11; - } + FROM_DEFAULT_V4_UCHAR(space_node.node_zone_simulation); } #undef FROM_DEFAULT_V4_UCHAR diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index ccd48a748a7..63eb4e19c6a 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -3122,6 +3122,7 @@ static void find_bounds_by_zone_recursive(const SpaceNode &snode, } static void node_draw_zones(TreeDrawContext & /*tree_draw_ctx*/, + const ARegion ®ion, const SpaceNode &snode, const bNodeTree &ntree) { @@ -3131,6 +3132,8 @@ static void node_draw_zones(TreeDrawContext & /*tree_draw_ctx*/, } Array> bounds_by_zone(zones->zones.size()); + Array fillet_curve_by_zone(zones->zones.size()); + for (const int zone_i : zones->zones.index_range()) { const TreeZone &zone = *zones->zones[zone_i]; @@ -3151,27 +3154,56 @@ static void node_draw_zones(TreeDrawContext & /*tree_draw_ctx*/, } boundary_curve.tag_topology_changed(); - bke::CurvesGeometry fillet_curve = geometry::fillet_curves_poly( + fillet_curve_by_zone[zone_i] = geometry::fillet_curves_poly( boundary_curve, IndexRange(1), - VArray::ForSingle(UI_UNIT_X / 2, boundary_positions_num), + VArray::ForSingle(BASIS_RAD, boundary_positions_num), VArray::ForSingle(5, boundary_positions_num), true, {}); - const Span fillet_boundary_positions = fillet_curve.positions(); + } - const uint pos = GPU_vertformat_attr_add( - immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + const View2D &v2d = region.v2d; + float scale; + UI_view2d_scale_get(&v2d, &scale, nullptr); + float line_width = 1.0f * scale; + float viewport[4] = {}; + GPU_viewport_size_get_f(viewport); + float zone_color[4]; + UI_GetThemeColor4fv(TH_NODE_ZONE_SIMULATION, zone_color); + + const uint pos = GPU_vertformat_attr_add( + immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + + /** + * Draw all the countour lines after to prevent them from getting hidden. + * Once we support other zones (e.g., for loops) we will need to sort them in a smarter way. + */ + for (const int zone_i : zones->zones.index_range()) { + if (zone_color[3] == 0.0f) { + break; + } + const Span fillet_boundary_positions = fillet_curve_by_zone[zone_i].positions(); + /* Draw the background. */ immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + immUniformThemeColorBlend(TH_BACK, TH_NODE_ZONE_SIMULATION, zone_color[3]); - GPU_blend(GPU_BLEND_ALPHA); - immUniformThemeColor(TH_NODE_ZONE_SIMULATION); immBegin(GPU_PRIM_TRI_FAN, fillet_boundary_positions.size() + 1); for (const float3 &p : fillet_boundary_positions) { immVertex3fv(pos, p); } immVertex3fv(pos, fillet_boundary_positions[0]); immEnd(); + } + + for (const int zone_i : zones->zones.index_range()) { + const Span fillet_boundary_positions = fillet_curve_by_zone[zone_i].positions(); + /* Draw the countour lines. */ + immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR); + + immUniform2fv("viewportSize", &viewport[2]); + immUniform1f("lineWidth", line_width * U.pixelsize); + immUniformThemeColorAlpha(TH_NODE_ZONE_SIMULATION, 1.0f); immBegin(GPU_PRIM_LINE_STRIP, fillet_boundary_positions.size() + 1); for (const float3 &p : fillet_boundary_positions) { @@ -3181,7 +3213,6 @@ static void node_draw_zones(TreeDrawContext & /*tree_draw_ctx*/, immEnd(); immUnbindProgram(); - GPU_blend(GPU_BLEND_NONE); } } @@ -3352,7 +3383,7 @@ static void draw_nodetree(const bContext &C, } node_update_nodetree(C, tree_draw_ctx, ntree, nodes, blocks); - node_draw_zones(tree_draw_ctx, *snode, ntree); + node_draw_zones(tree_draw_ctx, region, *snode, ntree); node_draw_nodetree(C, tree_draw_ctx, region, *snode, ntree, nodes, blocks, parent_key); } diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 6b6b6eb52ab..e0ebc2f916d 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -3057,7 +3057,7 @@ static void rna_def_userdef_theme_space_node(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Attribute Node", ""); RNA_def_property_update(prop, 0, "rna_userdef_theme_update"); - prop = RNA_def_property(srna, "simulation_region", PROP_FLOAT, PROP_COLOR_GAMMA); + prop = RNA_def_property(srna, "simulation_zone", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "node_zone_simulation"); RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Simulation Zone", "");