Fix #110516: Geometry nodes use attribute toggle boolean values broken

The toggle was added before boolean IDProperties were added. The fix is
to support both integer types and boolean types, similar to a recent
change for other inputs, 9f30555faf.

Pull Request: https://projects.blender.org/blender/blender/pulls/111433
This commit is contained in:
Hans Goudey
2023-08-24 13:36:25 +02:00
committed by Hans Goudey
parent 4b26fbbd02
commit a1dceeec00
4 changed files with 54 additions and 31 deletions

View File

@@ -1121,8 +1121,6 @@ static void add_attribute_search_or_value_buttons(const bContext &C,
char socket_id_esc[sizeof(socket.identifier) * 2];
BLI_str_escape(socket_id_esc, socket.identifier, sizeof(socket_id_esc));
const std::string rna_path = "[\"" + std::string(socket_id_esc) + "\"]";
const std::string rna_path_use_attribute = "[\"" + std::string(socket_id_esc) +
nodes::input_use_attribute_suffix() + "\"]";
const std::string rna_path_attribute_name = "[\"" + std::string(socket_id_esc) +
nodes::input_attribute_name_suffix() + "\"]";
@@ -1133,8 +1131,9 @@ static void add_attribute_search_or_value_buttons(const bContext &C,
uiLayout *name_row = uiLayoutRow(split, false);
uiLayoutSetAlignment(name_row, UI_LAYOUT_ALIGN_RIGHT);
const int use_attribute = RNA_int_get(md_ptr, rna_path_use_attribute.c_str()) != 0;
if (socket.type == SOCK_BOOLEAN && !use_attribute) {
const std::optional<StringRef> attribute_name = nodes::input_attribute_name_get(
*nmd.settings.properties, socket);
if (socket.type == SOCK_BOOLEAN && !attribute_name) {
uiItemL(name_row, "", ICON_NONE);
}
else {
@@ -1147,7 +1146,7 @@ static void add_attribute_search_or_value_buttons(const bContext &C,
uiLayoutSetAlignment(prop_row, UI_LAYOUT_ALIGN_EXPAND);
}
if (use_attribute) {
if (attribute_name) {
add_attribute_search_button(C, prop_row, nmd, md_ptr, rna_path_attribute_name, socket, false);
uiItemL(layout, "", ICON_BLANK1);
}
@@ -1167,7 +1166,7 @@ static void add_attribute_search_or_value_buttons(const bContext &C,
UI_ITEM_NONE,
&props);
RNA_string_set(&props, "modifier_name", nmd.modifier.name);
RNA_string_set(&props, "prop_path", rna_path_use_attribute.c_str());
RNA_string_set(&props, "input_name", socket.identifier);
}
/* Drawing the properties manually with #uiItemR instead of #uiDefAutoButsRNA allows using