LibOverride: Refactor collection items 'local' helper functions.
It's easier to read and less 'weird' to check that an item is non-local in a liboverride data-block, than the other way around. Thanks to @sybren for noticing it.
This commit is contained in:
parent
5f1a155a5e
commit
682ccd770c
|
@ -177,8 +177,8 @@ struct bConstraint *BKE_constraint_find_from_target(struct Object *ob,
|
|||
struct bConstraintTarget *tgt,
|
||||
struct bPoseChannel **r_pchan);
|
||||
|
||||
bool BKE_constraint_is_local_in_liboverride(const struct Object *ob,
|
||||
const struct bConstraint *con);
|
||||
bool BKE_constraint_is_nonlocal_in_liboverride(const struct Object *ob,
|
||||
const struct bConstraint *con);
|
||||
|
||||
struct bConstraint *BKE_constraint_add_for_object(struct Object *ob, const char *name, short type);
|
||||
struct bConstraint *BKE_constraint_add_for_pose(struct Object *ob,
|
||||
|
|
|
@ -278,8 +278,8 @@ void BKE_gpencil_modifiers_foreach_tex_link(struct Object *ob,
|
|||
GreasePencilTexWalkFunc walk,
|
||||
void *userData);
|
||||
|
||||
bool BKE_gpencil_modifier_is_local_in_liboverride(const struct Object *ob,
|
||||
const struct GpencilModifierData *gmd);
|
||||
bool BKE_gpencil_modifier_is_nonlocal_in_liboverride(const struct Object *ob,
|
||||
const struct GpencilModifierData *gmd);
|
||||
|
||||
typedef struct GpencilVirtualModifierData {
|
||||
ArmatureGpencilModifierData amd;
|
||||
|
|
|
@ -431,7 +431,8 @@ bool BKE_modifier_is_non_geometrical(ModifierData *md);
|
|||
bool BKE_modifier_is_enabled(const struct Scene *scene,
|
||||
struct ModifierData *md,
|
||||
int required_mode);
|
||||
bool BKE_modifier_is_local_in_liboverride(const struct Object *ob, const struct ModifierData *md);
|
||||
bool BKE_modifier_is_nonlocal_in_liboverride(const struct Object *ob,
|
||||
const struct ModifierData *md);
|
||||
void BKE_modifier_set_error(const struct Object *ob,
|
||||
struct ModifierData *md,
|
||||
const char *format,
|
||||
|
|
|
@ -5963,10 +5963,10 @@ static bConstraint *constraint_find_original_for_update(bConstraintOb *cob, bCon
|
|||
*
|
||||
* \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)
|
||||
bool BKE_constraint_is_nonlocal_in_liboverride(const Object *ob, const bConstraint *con)
|
||||
{
|
||||
return (!ID_IS_OVERRIDE_LIBRARY(ob) ||
|
||||
(con != NULL && (con->flag & CONSTRAINT_OVERRIDE_LIBRARY_LOCAL) != 0));
|
||||
return (ID_IS_OVERRIDE_LIBRARY(ob) &&
|
||||
(con == NULL || (con->flag & CONSTRAINT_OVERRIDE_LIBRARY_LOCAL) == 0));
|
||||
}
|
||||
|
||||
/* -------- Constraints and Proxies ------- */
|
||||
|
|
|
@ -531,16 +531,16 @@ void BKE_gpencil_modifier_set_error(GpencilModifierData *md, const char *_format
|
|||
}
|
||||
|
||||
/**
|
||||
* Check whether given modifier is local when the object is a library override.
|
||||
* Check whether given modifier is not local (i.e. from linked data) 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)
|
||||
bool BKE_gpencil_modifier_is_nonlocal_in_liboverride(const Object *ob,
|
||||
const GpencilModifierData *gmd)
|
||||
{
|
||||
return (!ID_IS_OVERRIDE_LIBRARY(ob) ||
|
||||
(gmd != NULL && (gmd->flag & eGpencilModifierFlag_OverrideLibrary_Local) != 0));
|
||||
return (ID_IS_OVERRIDE_LIBRARY(ob) &&
|
||||
(gmd == NULL || (gmd->flag & eGpencilModifierFlag_OverrideLibrary_Local) == 0));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -581,10 +581,10 @@ bool BKE_modifier_is_enabled(const struct Scene *scene, ModifierData *md, int re
|
|||
*
|
||||
* \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)
|
||||
bool BKE_modifier_is_nonlocal_in_liboverride(const Object *ob, const ModifierData *md)
|
||||
{
|
||||
return (!ID_IS_OVERRIDE_LIBRARY(ob) ||
|
||||
(md != NULL && (md->flag & eModifierFlag_OverrideLibrary_Local) != 0));
|
||||
return (ID_IS_OVERRIDE_LIBRARY(ob) &&
|
||||
(md == NULL || (md->flag & eModifierFlag_OverrideLibrary_Local) == 0));
|
||||
}
|
||||
|
||||
CDMaskLink *BKE_modifier_calc_data_masks(struct Scene *scene,
|
||||
|
|
|
@ -706,8 +706,9 @@ static bool edit_constraint_poll_generic(bContext *C,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!is_liboverride_allowed && !BKE_constraint_is_local_in_liboverride(ob, con)) {
|
||||
CTX_wm_operator_poll_msg_set(C, "Cannot edit constraints coming from library override");
|
||||
if (!is_liboverride_allowed && BKE_constraint_is_nonlocal_in_liboverride(ob, con)) {
|
||||
CTX_wm_operator_poll_msg_set(
|
||||
C, "Cannot edit constraints coming from linked data in a library override");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -443,9 +443,9 @@ static bool gpencil_edit_modifier_poll_generic(bContext *C,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!is_liboverride_allowed &&
|
||||
(mod == NULL || !BKE_gpencil_modifier_is_local_in_liboverride(ob, mod))) {
|
||||
CTX_wm_operator_poll_msg_set(C, "Cannot edit modifiers coming from library override");
|
||||
if (!is_liboverride_allowed && BKE_gpencil_modifier_is_nonlocal_in_liboverride(ob, mod)) {
|
||||
CTX_wm_operator_poll_msg_set(
|
||||
C, "Cannot edit modifiers coming from linked data in a library override");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1052,8 +1052,9 @@ bool edit_modifier_poll_generic(bContext *C,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!is_liboverride_allowed && !BKE_modifier_is_local_in_liboverride(ob, mod)) {
|
||||
CTX_wm_operator_poll_msg_set(C, "Cannot edit modifiers coming from library override");
|
||||
if (!is_liboverride_allowed && BKE_modifier_is_nonlocal_in_liboverride(ob, mod)) {
|
||||
CTX_wm_operator_poll_msg_set(
|
||||
C, "Cannot edit modifiers coming from linked data in a library override");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue