diff options
author | Bastien Montagne <bastien@blender.org> | 2022-03-28 18:34:36 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-03-29 18:59:55 +0300 |
commit | 5596f79821caae3d4c1eb608ce77371904f74b80 (patch) | |
tree | 92dbb06728dd7bbecfa71d17dbe25cde49dfdeb5 /source/blender/blenkernel | |
parent | 354db59fb12a5ee595ae650ac3a736e3cc6df39d (diff) |
LibOverride: Massive edits to 'editable' IDs checks in editors code.
Add new `BKE_id_is_editable` helper in `BKE_lib_id.h`, that supercedes
previous check (simple `ID_IS_LINKED()` macro) for many editing cases.
This allows to also take into account 'system override' (aka
non-editable override) case.
Ref: {T95707}.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_lib_id.h | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lib_id.c | 5 |
2 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_lib_id.h b/source/blender/blenkernel/BKE_lib_id.h index c3122758a72..b81c8ef136f 100644 --- a/source/blender/blenkernel/BKE_lib_id.h +++ b/source/blender/blenkernel/BKE_lib_id.h @@ -594,6 +594,16 @@ bool BKE_id_is_in_global_main(struct ID *id); bool BKE_id_can_be_asset(const struct ID *id); +/** Check if that ID can be considered as editable from a high-level (editor) perspective. + * + * NOTE: This used to be done with a check on whether ID was linked or not, but now with system + * overrides this is not enough anymore. + * + * NOTE: Execution of this function can be somewhat expensive currently. If this becomes an issue, + * we should either cache that status info also in virtual override IDs, or address the + * long-standing TODO of geting an efficient 'owner_id' access for all embeded ID types. */ +bool BKE_id_is_editable(struct Main *bmain, struct ID *id); + /** * Returns ordered list of data-blocks for display in the UI. * Result is list of #LinkData of IDs that must be freed. diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c index 28745f1d2c7..27427b1fb44 100644 --- a/source/blender/blenkernel/intern/lib_id.c +++ b/source/blender/blenkernel/intern/lib_id.c @@ -2165,6 +2165,11 @@ bool BKE_id_can_be_asset(const ID *id) BKE_idtype_idcode_is_linkable(GS(id->name)); } +bool BKE_id_is_editable(Main *bmain, ID *id) +{ + return !(ID_IS_LINKED(id) || BKE_lib_override_library_is_system_defined(bmain, id)); +} + /************************* Datablock order in UI **************************/ static int *id_order_get(ID *id) |