Commit: 69e34df379b6a052a0d59e383919fa71962142d4 Author: Bastien Montagne Date: Tue Feb 22 17:20:18 2022 +0100 Branches: liboverride-systemoverrides https://developer.blender.org/rB69e34df379b6a052a0d59e383919fa71962142d4
LibOverride: Add initial System Override flag. This merely adds the flag, exposes it in RMA, and uses it in some of the most common 'is editable' checks (RNA, `BASE_EDITABLE` macro...). Next step: do_version and defining systemoverrides at creation. =================================================================== M source/blender/blenkernel/BKE_lib_override.h M source/blender/blenkernel/intern/lib_override.c M source/blender/makesdna/DNA_ID.h M source/blender/makesdna/DNA_scene_types.h M source/blender/makesrna/intern/rna_ID.c M source/blender/makesrna/intern/rna_access.c =================================================================== diff --git a/source/blender/blenkernel/BKE_lib_override.h b/source/blender/blenkernel/BKE_lib_override.h index 98301ca7a70..daa94031489 100644 --- a/source/blender/blenkernel/BKE_lib_override.h +++ b/source/blender/blenkernel/BKE_lib_override.h @@ -64,6 +64,11 @@ void BKE_lib_override_library_free(struct IDOverrideLibrary **override, bool do_ */ bool BKE_lib_override_library_is_user_edited(struct ID *id); +/** + * Check if given ID is a system override. + */ +bool BKE_lib_override_library_is_system_defined(struct Main *bmain, struct ID *id); + /** * Create an overridden local copy of linked reference. * diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c index 922c1beda38..1ca34f40218 100644 --- a/source/blender/blenkernel/intern/lib_override.c +++ b/source/blender/blenkernel/intern/lib_override.c @@ -275,6 +275,18 @@ bool BKE_lib_override_library_is_user_edited(struct ID *id) return false; } +bool BKE_lib_override_library_is_system_defined(Main *bmain, ID *id) +{ + + if (ID_IS_OVERRIDE_LIBRARY(id)) { + ID *override_owner_id; + lib_override_get(bmain, id, &override_owner_id); + return (override_owner_id->override_library->flag & IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED) != + 0; + } + return false; +} + ID *BKE_lib_override_library_create_from_id(Main *bmain, ID *reference_id, const bool do_tagged_remap) diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 011f3618e15..f00594da80e 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -319,6 +319,11 @@ enum { * because it was created as an single override, outside of any hierarchy consideration). */ IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY = 1 << 0, + /** + * The override ID is required for the system to work (because of ID dependencies), but is not + * seen as editable by the user. + */ + IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED = 1 << 1, }; /* watch it: Sequence has identical beginning. */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index daecb3d7a31..3c79e69350c 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1991,7 +1991,10 @@ extern const char *RE_engine_id_CYCLES; ((v3d == NULL) || (((1 << (base)->object->type) & (v3d)->object_type_exclude_select) == 0)) && \ (((base)->flag & BASE_SELECTABLE) != 0)) #define BASE_SELECTED(v3d, base) (BASE_VISIBLE(v3d, base) && (((base)->flag & BASE_SELECTED) != 0)) -#define BASE_EDITABLE(v3d, base) (BASE_VISIBLE(v3d, base) && !ID_IS_LINKED((base)->object)) +#define BASE_EDITABLE(v3d, base) \ + (BASE_VISIBLE(v3d, base) && !ID_IS_LINKED((base)->object) && \ + (!ID_IS_OVERRIDE_LIBRARY_REAL((base)->object) || \ + ((base)->object->id.override_library->flag & IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED) == 0)) #define BASE_SELECTED_EDITABLE(v3d, base) \ (BASE_EDITABLE(v3d, base) && (((base)->flag & BASE_SELECTED) != 0)) diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 94ffa330064..e3e9a234ac9 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -1824,6 +1824,15 @@ static void rna_def_ID_override_library(BlenderRNA *brna) RNA_def_property_update(prop, NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY); + prop = RNA_def_boolean(srna, + "is_system_override", + false, + "Is System Override", + "Whether this library override exists only for the override hierarchy, " + "or if it is actually editable by the user"); + RNA_def_property_update(prop, NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL); + RNA_def_property_boolean_sdna(prop, NULL, "flag", IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED); + prop = RNA_def_collection(srna, "properties", "IDOverrideLibraryProperty", diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 7ccb8181b51..68758842e8d 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -32,8 +32,10 @@ #include "BKE_collection.h" #include "BKE_context.h" #include "BKE_fcurve.h" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_idtype.h" +#include "BKE_lib_override.h" #include "BKE_main.h" #include "BKE_node.h" #include "BKE_report.h" @@ -1936,11 +1938,21 @@ static bool rna_property_editable_do(PointerRNA *ptr, } return false; } - if (ID_IS_OVERRIDE_LIBRARY(id) && !RNA_property_overridable_get(ptr, prop_orig)) { - if (r_info != NULL && (*r_info)[0] == '\0') { - *r_info = N_("Can't edit this property from an override data-block"); + const bool is_liboverride_system_defined = BKE_lib_override_library_is_system_defined(G_MAIN, + id); + if (ID_IS_OVERRIDE_LIBRARY(id)) { + if (!RNA_property_overridable_get(ptr, prop_orig)) { + if (r_info != NULL && (*r_info)[0] == '\0') { + *r_info = N_("Can't edit this property from an override data-block"); + } + return false; + } + if (is_liboverride_system_defined && !is_linked_prop_exception) { + if (r_info != NULL && (*r_info)[0] == '\0') { + *r_info = N_("Can't edit this property from a system override data-block"); + } + return false; } - return false; } /* At this point, property is owned by a local ID and therefore fully editable. */ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs