Merge branch 'blender-v4.5-release'

This commit is contained in:
Jeroen Bakker
2025-07-03 09:56:23 +02:00
4 changed files with 66 additions and 25 deletions

View File

@@ -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)) {
@@ -135,7 +151,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);
@@ -149,8 +165,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++) {
@@ -161,12 +176,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);
@@ -181,6 +193,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);

View File

@@ -1401,7 +1401,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 */

View File

@@ -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<StringRefNull> 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<StringRef> 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);
layout->decorator(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<StringRefNull> 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: {
row->prop_search(
@@ -564,7 +583,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);
@@ -629,10 +648,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<StringRefNull> parent_name = std::nullopt)
{
for (const bNodeTreeInterfaceItem *item : interface_panel.items().drop_front(skip_first ? 1 : 0))
{
@@ -688,7 +709,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;
}
@@ -696,7 +718,7 @@ static void draw_interface_panel_content(DrawGroupInputsContext &ctx,
const auto &interface_socket = *reinterpret_cast<const bNodeTreeInterfaceSocket *>(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;

View File

@@ -677,6 +677,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);
@@ -784,6 +785,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();