Fix #110562: Crash animating node property affecting socket visibility

For various reasons, the animation system can't properly update the node tree
so that the socket availability caused by changing node enum properties
propagates completely. So animating node properties that affect
socket visibility to change isn't possible without issues like crashes.
Unfortunately that wasn't disallowed before. In this commit there is
a balance of disabling animation on sockets that could reasonably expected
to affect socket visibility, and minimizing breaking changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/119221
This commit is contained in:
Hans Goudey
2024-03-11 19:26:58 +01:00
committed by Hans Goudey
parent bca31c3846
commit dc9249c97f
15 changed files with 64 additions and 18 deletions

View File

@@ -8919,6 +8919,7 @@ static void def_geo_curve_sample(StructRNA *srna)
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, mode_items);
RNA_def_property_ui_text(prop, "Mode", "Method for sampling input");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
prop = RNA_def_property(srna, "use_all_curves", PROP_BOOLEAN, PROP_NONE);
@@ -8926,6 +8927,7 @@ static void def_geo_curve_sample(StructRNA *srna)
"All Curves",
"Sample lengths based on the total length of all curves, rather than "
"using a length inside each selected curve");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
@@ -8934,6 +8936,7 @@ static void def_geo_curve_sample(StructRNA *srna)
prop, nullptr, nullptr, "rna_GeometryNodeAttributeType_type_with_socket_itemf");
RNA_def_property_enum_default(prop, CD_PROP_FLOAT);
RNA_def_property_ui_text(prop, "Data Type", "");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
}
@@ -8976,6 +8979,7 @@ static void def_geo_distribute_points_on_faces(StructRNA *srna)
RNA_def_property_enum_items(prop, rna_node_geometry_distribute_points_on_faces_mode_items);
RNA_def_property_enum_default(prop, GEO_NODE_POINT_DISTRIBUTE_POINTS_ON_FACES_RANDOM);
RNA_def_property_ui_text(prop, "Distribution Method", "Method to use for scattering points");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
prop = RNA_def_property(srna, "use_legacy_normal", PROP_BOOLEAN, PROP_NONE);
@@ -8984,6 +8988,7 @@ static void def_geo_distribute_points_on_faces(StructRNA *srna)
"Legacy Normal",
"Output the normal and rotation values that have been output "
"before the node started taking smooth normals into account");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
}
@@ -8997,12 +9002,14 @@ static void def_geo_curve_set_handle_type(StructRNA *srna)
RNA_def_property_enum_sdna(prop, nullptr, "handle_type");
RNA_def_property_ui_text(prop, "Handle Type", "");
RNA_def_property_enum_items(prop, rna_node_geometry_curve_handle_type_items);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_node_geometry_curve_handle_side_items);
RNA_def_property_ui_text(prop, "Mode", "Whether to update left and right handles");
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
}
@@ -9345,6 +9352,7 @@ static void rna_def_geo_bake(StructRNA *srna)
nullptr,
nullptr);
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NO_DEG_UPDATE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Active Item Index", "Index of the active item");
RNA_def_property_update(prop, NC_NODE, nullptr);
}
@@ -9474,6 +9482,7 @@ static void def_geo_sample_index(StructRNA *srna)
prop, nullptr, nullptr, "rna_GeometryNodeAttributeType_type_with_socket_itemf");
RNA_def_property_enum_default(prop, CD_PROP_FLOAT);
RNA_def_property_ui_text(prop, "Data Type", "");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
prop = RNA_def_property(srna, "domain", PROP_ENUM, PROP_NONE);

View File

@@ -68,6 +68,7 @@ PropertyRNA *RNA_def_node_enum(StructRNA *srna,
const EnumPropertyItem *static_items,
const EnumRNAAccessors accessors,
std::optional<int> default_value = std::nullopt,
const EnumPropertyItemFunc item_func = nullptr);
const EnumPropertyItemFunc item_func = nullptr,
bool allow_animation = false);
} // namespace blender::nodes

View File

@@ -241,14 +241,20 @@ static void node_rna(StructRNA *srna)
"Axis",
"Axis to align to the vector",
axis_items,
NOD_inline_enum_accessors(custom1));
NOD_inline_enum_accessors(custom1),
std::nullopt,
nullptr,
true);
RNA_def_node_enum(srna,
"pivot_axis",
"Pivot Axis",
"Axis to rotate around",
pivot_axis_items,
NOD_inline_enum_accessors(custom2));
NOD_inline_enum_accessors(custom2),
std::nullopt,
nullptr,
true);
}
static void node_register()

View File

@@ -389,7 +389,8 @@ static void node_rna(StructRNA *srna)
rna_enum_attribute_domain_items,
NOD_storage_enum_accessors(domain),
int(AttrDomain::Point),
enums::domain_experimental_grease_pencil_version3_fn);
enums::domain_experimental_grease_pencil_version3_fn,
true);
}
static void node_register()

View File

@@ -184,7 +184,8 @@ static void node_rna(StructRNA *srna)
rna_enum_attribute_domain_items,
NOD_storage_enum_accessors(domain),
int8_t(AttrDomain::Point),
enums::domain_experimental_grease_pencil_version3_fn);
enums::domain_experimental_grease_pencil_version3_fn,
true);
}
static void node_register()

View File

@@ -356,7 +356,8 @@ static void node_rna(StructRNA *srna)
rna_enum_attribute_domain_items,
NOD_inline_enum_accessors(custom2),
int(AttrDomain::Point),
enums::domain_experimental_grease_pencil_version3_fn);
enums::domain_experimental_grease_pencil_version3_fn,
true);
}
static void node_register()

View File

@@ -93,7 +93,9 @@ static void node_rna(StructRNA *srna)
"The curve type to change the selected curves to",
rna_enum_curves_type_items,
NOD_storage_enum_accessors(spline_type),
CURVE_TYPE_POLY);
CURVE_TYPE_POLY,
nullptr,
true);
}
static void node_register()

View File

@@ -1063,7 +1063,9 @@ static void node_rna(StructRNA *srna)
"Which domain to duplicate",
domain_items,
NOD_storage_enum_accessors(domain),
int(AttrDomain::Point));
int(AttrDomain::Point),
nullptr,
true);
}
static void node_register()

View File

@@ -212,7 +212,9 @@ static void node_rna(StructRNA *srna)
"",
rna_enum_node_geometry_mesh_circle_fill_type_items,
NOD_storage_enum_accessors(fill_type),
GEO_NODE_MESH_CIRCLE_FILL_NONE);
GEO_NODE_MESH_CIRCLE_FILL_NONE,
nullptr,
true);
}
static void node_register()

View File

@@ -148,7 +148,9 @@ static void node_rna(StructRNA *srna)
"",
rna_enum_node_geometry_mesh_circle_fill_type_items,
NOD_storage_enum_accessors(fill_type),
GEO_NODE_MESH_CIRCLE_FILL_NGON);
GEO_NODE_MESH_CIRCLE_FILL_NGON,
nullptr,
true);
}
static void node_register()

View File

@@ -139,7 +139,9 @@ static void node_rna(StructRNA *srna)
"",
rna_enum_node_geometry_mesh_circle_fill_type_items,
NOD_storage_enum_accessors(fill_type),
GEO_NODE_MESH_CIRCLE_FILL_NGON);
GEO_NODE_MESH_CIRCLE_FILL_NGON,
nullptr,
true);
}
static void node_register()

View File

@@ -234,7 +234,9 @@ static void node_rna(StructRNA *srna)
"",
mode_items,
NOD_storage_enum_accessors(mode),
GEO_NODE_MESH_TO_POINTS_VERTICES);
GEO_NODE_MESH_TO_POINTS_VERTICES,
nullptr,
true);
}
static void node_register()

View File

@@ -206,7 +206,9 @@ static void node_rna(StructRNA *srna)
"Controls how smoothing is applied to UVs",
rna_enum_subdivision_uv_smooth_items,
NOD_storage_enum_accessors(uv_smooth),
SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES);
SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES,
nullptr,
true);
RNA_def_node_enum(srna,
"boundary_smooth",
@@ -214,7 +216,9 @@ static void node_rna(StructRNA *srna)
"Controls how open boundaries are smoothed",
rna_enum_subdivision_boundary_smooth_items,
NOD_storage_enum_accessors(boundary_smooth),
SUBSURF_BOUNDARY_SMOOTH_ALL);
SUBSURF_BOUNDARY_SMOOTH_ALL,
nullptr,
true);
}
static void node_register()

View File

@@ -156,7 +156,9 @@ static void node_rna(StructRNA *srna)
"Method for splitting the quads into triangles",
rna_node_geometry_triangulate_quad_method_items,
NOD_inline_enum_accessors(custom1),
GEO_NODE_POINTS_TO_VOLUME_RESOLUTION_MODE_AMOUNT);
GEO_NODE_POINTS_TO_VOLUME_RESOLUTION_MODE_AMOUNT,
nullptr,
true);
RNA_def_node_enum(srna,
"ngon_method",
@@ -164,7 +166,9 @@ static void node_rna(StructRNA *srna)
"Method for splitting the n-gons into triangles",
rna_node_geometry_triangulate_ngon_method_items,
NOD_inline_enum_accessors(custom2),
GEO_NODE_POINTS_TO_VOLUME_RESOLUTION_MODE_AMOUNT);
GEO_NODE_POINTS_TO_VOLUME_RESOLUTION_MODE_AMOUNT,
nullptr,
true);
}
static void node_register()

View File

@@ -29,7 +29,8 @@ PropertyRNA *RNA_def_node_enum(StructRNA *srna,
const EnumPropertyItem *static_items,
const EnumRNAAccessors accessors,
std::optional<int> default_value,
const EnumPropertyItemFunc item_func)
const EnumPropertyItemFunc item_func,
const bool allow_animation)
{
PropertyRNA *prop = RNA_def_property(srna, identifier, PROP_ENUM, PROP_NONE);
RNA_def_property_enum_funcs_runtime(prop, accessors.getter, accessors.setter, item_func);
@@ -38,7 +39,13 @@ PropertyRNA *RNA_def_node_enum(StructRNA *srna,
RNA_def_property_enum_default(prop, *default_value);
}
RNA_def_property_ui_text(prop, ui_name, ui_description);
RNA_def_property_update_runtime(prop, rna_Node_socket_update);
if (allow_animation) {
RNA_def_property_update_runtime(prop, rna_Node_update);
}
else {
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update_runtime(prop, rna_Node_socket_update);
}
RNA_def_property_update_notifier(prop, NC_NODE | NA_EDITED);
return prop;
}