diff options
author | Bastien Montagne <bastien@blender.org> | 2020-12-07 18:52:45 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-12-07 18:55:51 +0300 |
commit | bab57550b69b8429bb2f081fbc75f1d1ca035a34 (patch) | |
tree | 2a92f1ea9a693b32bc22dea73d1dfe7bdfb4506b /source/blender/blenkernel/intern | |
parent | 513578b182fd0c427b9da653b715f8bfb16faec1 (diff) |
LibOverride: Abstract a bit handling of local items of RNA collections.
RNA collections that support insertion of new items in liboverride
data-block need a special way to distiguish between locale and
orig-from-linked items (since some operations are allowed on the forer,
but no the latter).
In future we want a proper solution to abstract that at the
`BKE_lib_override` level, but for now we need to add some code for each
case.
Note that this commit also fixes a few potential issues with GPencil
modifiers, and constraints, regarding their handling of local overrides.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 15 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/gpencil_modifier.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 13 |
3 files changed, 41 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 28121206a90..982e91dd1e0 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -5754,6 +5754,7 @@ bConstraint *BKE_constraint_duplicate_ex(bConstraint *src, const int flag, const bConstraint *dst = MEM_dupallocN(src); constraint_copy_data_ex(dst, src, flag, do_extern); dst->next = dst->prev = NULL; + dst->flag |= CONSTRAINT_OVERRIDE_LIBRARY_LOCAL; return dst; } @@ -5788,6 +5789,7 @@ void BKE_constraints_copy_ex(ListBase *dst, const ListBase *src, const int flag, for (con = dst->first, srccon = src->first; con && srccon; srccon = srccon->next, con = con->next) { constraint_copy_data_ex(con, srccon, flag, do_extern); + con->flag |= CONSTRAINT_OVERRIDE_LIBRARY_LOCAL; } } @@ -5954,6 +5956,19 @@ static bConstraint *constraint_find_original_for_update(bConstraintOb *cob, bCon return orig_con; } +/** + * Check whether given constraint is local when the object is a library override. + * + * \param con May be NULL, in which case we consider it as a non-local constraint case. + * + * \note This check is only valid for a liboverride data-block, it always return \a true otherwise. + */ +bool BKE_constraint_is_local_in_liboverride(const Object *ob, const bConstraint *con) +{ + return (!ID_IS_OVERRIDE_LIBRARY(ob) || + (con != NULL && (con->flag & CONSTRAINT_OVERRIDE_LIBRARY_LOCAL) != 0)); +} + /* -------- Constraints and Proxies ------- */ /* Rescue all constraints tagged as being CONSTRAINT_PROXY_LOCAL diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c index 09f9e9e891c..7425a1a5f7a 100644 --- a/source/blender/blenkernel/intern/gpencil_modifier.c +++ b/source/blender/blenkernel/intern/gpencil_modifier.c @@ -531,6 +531,19 @@ void BKE_gpencil_modifier_set_error(GpencilModifierData *md, const char *_format } /** + * Check whether given modifier is local when the object is a library override. + * + * \param gmd May be NULL, in which case we consider it as a non-local modifier case. + * + * \note This check is only valid for a liboverride data-block, it always return \a true otherwise. + */ +bool BKE_gpencil_modifier_is_local_in_liboverride(const Object *ob, const GpencilModifierData *gmd) +{ + return (!ID_IS_OVERRIDE_LIBRARY(ob) || + (gmd != NULL && (gmd->flag & eGpencilModifierFlag_OverrideLibrary_Local) != 0)); +} + +/** * Link grease pencil modifier related IDs. * \param ob: Grease pencil object * \param walk: Walk option diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index c9bdaecfa2a..7865d44c446 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -574,6 +574,19 @@ bool BKE_modifier_is_enabled(const struct Scene *scene, ModifierData *md, int re return true; } +/** + * Check whether given modifier is local when the object is a library override. + * + * \param md May be NULL, in which case we consider it as a non-local modifier case. + * + * \note This check is only valid for a liboverride data-block, it always return \a true otherwise. + */ +bool BKE_modifier_is_local_in_liboverride(const Object *ob, const ModifierData *md) +{ + return (!ID_IS_OVERRIDE_LIBRARY(ob) || + (md != NULL && (md->flag & eModifierFlag_OverrideLibrary_Local) != 0)); +} + CDMaskLink *BKE_modifier_calc_data_masks(struct Scene *scene, Object *ob, ModifierData *md, |