From 95259228d9394477d1dda6d56e37b79bd55905de Mon Sep 17 00:00:00 2001 From: YimingWu Date: Thu, 3 Jul 2025 08:58:34 +0200 Subject: [PATCH 1/4] Fix #140430: Nodes: Hide panel names when socket is shown on modifier UI Previously, if a socket inside a panel has the same name prefix as the panel name, the panel name will be removed from socket names when displayed inside nodes, but this is not done when displaying them on the modifier interface, which is too verbose visually. Now panel names are removed from these property labels as well. Pull Request: https://projects.blender.org/blender/blender/pulls/140448 --- .../nodes/intern/geometry_nodes_caller_ui.cc | 52 +++++++++++++------ 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/source/blender/nodes/intern/geometry_nodes_caller_ui.cc b/source/blender/nodes/intern/geometry_nodes_caller_ui.cc index 4c0cd679438..0c399b568fd 100644 --- a/source/blender/nodes/intern/geometry_nodes_caller_ui.cc +++ b/source/blender/nodes/intern/geometry_nodes_caller_ui.cc @@ -403,10 +403,12 @@ static void add_attribute_search_button(DrawGroupInputsContext &ctx, } } -static void add_attribute_search_or_value_buttons(DrawGroupInputsContext &ctx, - uiLayout *layout, - const StringRefNull rna_path, - const bNodeTreeInterfaceSocket &socket) +static void add_attribute_search_or_value_buttons( + DrawGroupInputsContext &ctx, + uiLayout *layout, + const StringRefNull rna_path, + const bNodeTreeInterfaceSocket &socket, + const std::optional use_name = std::nullopt) { const bke::bNodeSocketType *typeinfo = socket.socket_typeinfo(); const eNodeSocketDatatype type = typeinfo ? typeinfo->type : SOCK_CUSTOM; @@ -424,6 +426,9 @@ static void add_attribute_search_or_value_buttons(DrawGroupInputsContext &ctx, const std::optional attribute_name = nodes::input_attribute_name_get(ctx.properties, socket); + const StringRefNull socket_name = use_name.has_value() ? + (*use_name) : + (socket.name ? IFACE_(socket.name) : ""); if (type == SOCK_BOOLEAN && !attribute_name) { name_row->label("", ICON_NONE); prop_row = &split->row(true); @@ -438,13 +443,13 @@ static void add_attribute_search_or_value_buttons(DrawGroupInputsContext &ctx, } if (attribute_name) { - name_row->label(socket.name ? IFACE_(socket.name) : "", ICON_NONE); + name_row->label(IFACE_(socket_name), ICON_NONE); prop_row = &split->row(true); add_attribute_search_button(ctx, prop_row, rna_path_attribute_name, socket); layout->label("", ICON_BLANK1); } else { - const char *name = socket.name ? IFACE_(socket.name) : ""; + const char *name = IFACE_(socket_name.c_str()); prop_row->prop(ctx.properties_ptr, rna_path, UI_ITEM_NONE, name, ICON_NONE); uiItemDecoratorR(layout, ctx.properties_ptr, rna_path.c_str(), -1); } @@ -467,7 +472,8 @@ static NodesModifierPanel *find_panel_by_id(NodesModifierData &nmd, const int id * the correct label displayed in the UI. */ static void draw_property_for_socket(DrawGroupInputsContext &ctx, uiLayout *layout, - const bNodeTreeInterfaceSocket &socket) + const bNodeTreeInterfaceSocket &socket, + const std::optional parent_name = std::nullopt) { const StringRefNull identifier = socket.identifier; /* The property should be created in #MOD_nodes_update_interface with the correct type. */ @@ -499,7 +505,20 @@ static void draw_property_for_socket(DrawGroupInputsContext &ctx, * pointer IDProperties contain no information about their type. */ const bke::bNodeSocketType *typeinfo = socket.socket_typeinfo(); const eNodeSocketDatatype type = typeinfo ? typeinfo->type : SOCK_CUSTOM; - const char *name = socket.name ? IFACE_(socket.name) : ""; + std::string name = socket.name ? IFACE_(socket.name) : ""; + + /* If the property has a prefix that's the same string as the name of the panel it's in, remove + * the prefix so it appears less verbose. */ + if (parent_name.has_value()) { + const StringRefNull prefix_to_remove = *parent_name; + int pos = name.find(prefix_to_remove); + if (pos == 0) { + /* Needs to trim remainig space characters if any. Use the `trim()` from `StringRefNull` + * because std::string doesn't have a built-in `trim()` yet. */ + name = StringRefNull(name.substr(prefix_to_remove.size())).trim(); + } + } + switch (type) { case SOCK_OBJECT: { uiItemPointerR( @@ -565,7 +584,7 @@ static void draw_property_for_socket(DrawGroupInputsContext &ctx, } default: { if (nodes::input_has_attribute_toggle(*ctx.tree, input_index)) { - add_attribute_search_or_value_buttons(ctx, row, rna_path, socket); + add_attribute_search_or_value_buttons(ctx, row, rna_path, socket, name); } else { row->prop(ctx.properties_ptr, rna_path, UI_ITEM_NONE, name, ICON_NONE); @@ -630,10 +649,12 @@ static bool interface_panel_affects_output(DrawGroupInputsContext &ctx, return false; } -static void draw_interface_panel_content(DrawGroupInputsContext &ctx, - uiLayout *layout, - const bNodeTreeInterfacePanel &interface_panel, - const bool skip_first = false) +static void draw_interface_panel_content( + DrawGroupInputsContext &ctx, + uiLayout *layout, + const bNodeTreeInterfacePanel &interface_panel, + const bool skip_first = false, + const std::optional parent_name = std::nullopt) { for (const bNodeTreeInterfaceItem *item : interface_panel.items().drop_front(skip_first ? 1 : 0)) { @@ -689,7 +710,8 @@ static void draw_interface_panel_content(DrawGroupInputsContext &ctx, nullptr, nullptr); if (panel_layout.body) { - draw_interface_panel_content(ctx, panel_layout.body, sub_interface_panel, skip_first); + draw_interface_panel_content( + ctx, panel_layout.body, sub_interface_panel, skip_first, sub_interface_panel.name); } break; } @@ -697,7 +719,7 @@ static void draw_interface_panel_content(DrawGroupInputsContext &ctx, const auto &interface_socket = *reinterpret_cast(item); if (interface_socket.flag & NODE_INTERFACE_SOCKET_INPUT) { if (!(interface_socket.flag & NODE_INTERFACE_SOCKET_HIDE_IN_MODIFIER)) { - draw_property_for_socket(ctx, layout, interface_socket); + draw_property_for_socket(ctx, layout, interface_socket, parent_name); } } break; From 2d0058047139b370c72f3350b438f68dd8ccd82c Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 3 Jul 2025 09:54:21 +0200 Subject: [PATCH 2/4] Fix #141274: Assert drawing debug drivers Fixes an assert when drawing debug drivers. Here a poly shader was used to draw points. This isn't valid and Vulkan backend warns developers about it. Pull Request: https://projects.blender.org/blender/blender/pulls/141372 --- source/blender/editors/space_graph/graph_draw.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_graph/graph_draw.cc b/source/blender/editors/space_graph/graph_draw.cc index 0a2fd921020..976e2be3397 100644 --- a/source/blender/editors/space_graph/graph_draw.cc +++ b/source/blender/editors/space_graph/graph_draw.cc @@ -1398,7 +1398,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) immUnbindProgram(); /* GPU_PRIM_POINTS do not survive dashed line geometry shader... */ - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + immBindBuiltinProgram(GPU_SHADER_3D_POINT_UNIFORM_COLOR); /* x marks the spot .................................................... */ /* -> outer frame */ From 5e17f5f41a7280bf55a8366fcc226ac192224343 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 3 Jul 2025 09:54:45 +0200 Subject: [PATCH 3/4] Fix #141347: Assert in polybuild Polybuild didn't select a point shaders when drawing points. Pull Request: https://projects.blender.org/blender/blender/pulls/141373 --- .../editors/mesh/editmesh_preselect_elem.cc | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_preselect_elem.cc b/source/blender/editors/mesh/editmesh_preselect_elem.cc index 0e001f464bb..fdd6fe879b1 100644 --- a/source/blender/editors/mesh/editmesh_preselect_elem.cc +++ b/source/blender/editors/mesh/editmesh_preselect_elem.cc @@ -119,6 +119,22 @@ void EDBM_preselect_elem_clear(EditMesh_PreSelElem *psel) psel->verts_len = 0; } +enum class PreselectColor { Polygons, LinesOrPoints, Delete }; +static void edbm_preselect_imm_color(PreselectColor preselect_color) +{ + switch (preselect_color) { + case PreselectColor::Polygons: + immUniformColor4ub(141, 171, 186, 100); + break; + case PreselectColor::LinesOrPoints: + immUniformColor4ub(3, 161, 252, 200); + break; + case PreselectColor::Delete: + immUniformColor4ub(252, 49, 10, 200); + break; + } +} + void EDBM_preselect_elem_draw(EditMesh_PreSelElem *psel, const float matrix[4][4]) { if ((psel->edges_len == 0) && (psel->verts_len == 0)) { @@ -134,7 +150,7 @@ void EDBM_preselect_elem_draw(EditMesh_PreSelElem *psel, const float matrix[4][4 immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - immUniformColor4ub(141, 171, 186, 100); + edbm_preselect_imm_color(PreselectColor::Polygons); if (psel->preview_action != PRESELECT_ACTION_TRANSFORM) { if (psel->preview_tris_len > 0) { immBegin(GPU_PRIM_TRIS, psel->preview_tris_len * 3); @@ -148,8 +164,7 @@ void EDBM_preselect_elem_draw(EditMesh_PreSelElem *psel, const float matrix[4][4 } if (psel->preview_lines_len > 0) { - - immUniformColor4ub(3, 161, 252, 200); + edbm_preselect_imm_color(PreselectColor::LinesOrPoints); GPU_line_width(2.0f); immBegin(GPU_PRIM_LINES, psel->preview_lines_len * 2); for (int i = 0; i < psel->preview_lines_len; i++) { @@ -160,12 +175,9 @@ void EDBM_preselect_elem_draw(EditMesh_PreSelElem *psel, const float matrix[4][4 } } - if (psel->preview_action == PRESELECT_ACTION_DELETE) { - immUniformColor4ub(252, 49, 10, 200); - } - else { - immUniformColor4ub(3, 161, 252, 200); - } + edbm_preselect_imm_color(psel->preview_action == PRESELECT_ACTION_DELETE ? + PreselectColor::Delete : + PreselectColor::LinesOrPoints); if (psel->edges_len > 0) { GPU_line_width(3.0f); @@ -180,6 +192,11 @@ void EDBM_preselect_elem_draw(EditMesh_PreSelElem *psel, const float matrix[4][4 } if (psel->verts_len > 0) { + immUnbindProgram(); + immBindBuiltinProgram(GPU_SHADER_3D_POINT_UNIFORM_COLOR); + edbm_preselect_imm_color(psel->preview_action == PRESELECT_ACTION_DELETE ? + PreselectColor::Delete : + PreselectColor::LinesOrPoints); GPU_point_size(4.0f); immBegin(GPU_PRIM_POINTS, psel->verts_len); From eeb2dc8a9eb4e65c4fc3996a013fc80d6f07cc75 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 3 Jul 2025 09:55:09 +0200 Subject: [PATCH 4/4] Fix #141305: Vulkan: Animation player memory leak When playing back render result a separate process is started for playback. This process didn't call the GPU_context_frame_begin/end functions resulting in post-poning destroying discarded resources until the playback process was 'exited'. Pull Request: https://projects.blender.org/blender/blender/pulls/141376 --- source/blender/windowmanager/intern/wm_playanim.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/windowmanager/intern/wm_playanim.cc b/source/blender/windowmanager/intern/wm_playanim.cc index a120f0155a6..1143624f9fb 100644 --- a/source/blender/windowmanager/intern/wm_playanim.cc +++ b/source/blender/windowmanager/intern/wm_playanim.cc @@ -675,6 +675,7 @@ static void playanim_toscreen_ex(GhostData &ghost_data, GPUContext *restore_context = GPU_context_active_get(); GPU_context_active_set(ghost_data.gpu_context); + GPU_context_begin_frame(ghost_data.gpu_context); GPU_clear_color(0.1f, 0.1f, 0.1f, 0.0f); @@ -781,6 +782,7 @@ static void playanim_toscreen_ex(GhostData &ghost_data, GPU_flush(); } + GPU_context_end_frame(ghost_data.gpu_context); GHOST_SwapWindowBuffers(ghost_data.window); GPU_context_active_set(restore_context); GPU_render_end();