LibOverride: RNA Apply: let apply function responsible for calling update or not on overridden properties.
While this is the desired behavior in almost cases, there are a few hairy nightmares that may require not to do so. NOTE: this change should should not modify any current behavior at all.
This commit is contained in:
parent
d34c4089f1
commit
1264142f78
|
@ -612,10 +612,6 @@ static bool rna_property_override_operation_apply(Main *bmain,
|
|||
ptr_item_src,
|
||||
ptr_item_storage,
|
||||
opop);
|
||||
if (success) {
|
||||
RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
|
@ -680,7 +680,7 @@ static FCurve *rna_Driver_find(AnimData *adt,
|
|||
return BKE_fcurve_find(&adt->drivers, data_path, index);
|
||||
}
|
||||
|
||||
bool rna_AnimaData_override_apply(Main *UNUSED(bmain),
|
||||
bool rna_AnimaData_override_apply(Main *bmain,
|
||||
PointerRNA *ptr_dst,
|
||||
PointerRNA *ptr_src,
|
||||
PointerRNA *ptr_storage,
|
||||
|
@ -707,11 +707,13 @@ bool rna_AnimaData_override_apply(Main *UNUSED(bmain),
|
|||
if (adt_dst == NULL && adt_src != NULL) {
|
||||
/* Copy anim data from reference into final local ID. */
|
||||
BKE_animdata_copy_id(NULL, ptr_dst->owner_id, ptr_src->owner_id, 0);
|
||||
RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);
|
||||
return true;
|
||||
}
|
||||
else if (adt_dst != NULL && adt_src == NULL) {
|
||||
/* Override has cleared/removed anim data from its reference. */
|
||||
BKE_animdata_free(ptr_dst->owner_id, true);
|
||||
RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -722,7 +724,7 @@ bool rna_NLA_tracks_override_apply(Main *bmain,
|
|||
PointerRNA *ptr_dst,
|
||||
PointerRNA *ptr_src,
|
||||
PointerRNA *UNUSED(ptr_storage),
|
||||
PropertyRNA *UNUSED(prop_dst),
|
||||
PropertyRNA *prop_dst,
|
||||
PropertyRNA *UNUSED(prop_src),
|
||||
PropertyRNA *UNUSED(prop_storage),
|
||||
const int UNUSED(len_dst),
|
||||
|
@ -771,6 +773,8 @@ bool rna_NLA_tracks_override_apply(Main *bmain,
|
|||
BLI_insertlinkafter(&anim_data_dst->nla_tracks, nla_track_anchor, nla_track_dst);
|
||||
|
||||
// printf("%s: We inserted a NLA Track...\n", __func__);
|
||||
|
||||
RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ static bool rna_Collection_objects_override_apply(Main *bmain,
|
|||
PointerRNA *ptr_dst,
|
||||
PointerRNA *UNUSED(ptr_src),
|
||||
PointerRNA *UNUSED(ptr_storage),
|
||||
PropertyRNA *UNUSED(prop_dst),
|
||||
PropertyRNA *prop_dst,
|
||||
PropertyRNA *UNUSED(prop_src),
|
||||
PropertyRNA *UNUSED(prop_storage),
|
||||
const int UNUSED(len_dst),
|
||||
|
@ -185,6 +185,7 @@ static bool rna_Collection_objects_override_apply(Main *bmain,
|
|||
BKE_main_collection_sync(bmain);
|
||||
}
|
||||
|
||||
RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -245,7 +246,7 @@ static bool rna_Collection_children_override_apply(Main *bmain,
|
|||
PointerRNA *ptr_dst,
|
||||
PointerRNA *UNUSED(ptr_src),
|
||||
PointerRNA *UNUSED(ptr_storage),
|
||||
PropertyRNA *UNUSED(prop_dst),
|
||||
PropertyRNA *prop_dst,
|
||||
PropertyRNA *UNUSED(prop_src),
|
||||
PropertyRNA *UNUSED(prop_storage),
|
||||
const int UNUSED(len_dst),
|
||||
|
@ -287,6 +288,7 @@ static bool rna_Collection_children_override_apply(Main *bmain,
|
|||
BKE_collection_object_cache_free(coll_dst);
|
||||
BKE_main_collection_sync(bmain);
|
||||
|
||||
RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -895,7 +895,7 @@ static void rna_HookModifier_object_set(PointerRNA *ptr,
|
|||
BKE_object_modifier_hook_reset(owner, hmd);
|
||||
}
|
||||
|
||||
static bool rna_HookModifier_object_override_apply(Main *UNUSED(bmain),
|
||||
static bool rna_HookModifier_object_override_apply(Main *bmain,
|
||||
PointerRNA *ptr_dst,
|
||||
PointerRNA *ptr_src,
|
||||
PointerRNA *ptr_storage,
|
||||
|
@ -933,6 +933,7 @@ static bool rna_HookModifier_object_override_apply(Main *UNUSED(bmain),
|
|||
/* The only case where we do want default behavior (with matrix reset). */
|
||||
BKE_object_modifier_hook_reset(owner, hmd);
|
||||
}
|
||||
RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -646,7 +646,7 @@ static void rna_Object_parent_set(PointerRNA *ptr,
|
|||
}
|
||||
}
|
||||
|
||||
static bool rna_Object_parent_override_apply(Main *UNUSED(bmain),
|
||||
static bool rna_Object_parent_override_apply(Main *bmain,
|
||||
PointerRNA *ptr_dst,
|
||||
PointerRNA *ptr_src,
|
||||
PointerRNA *ptr_storage,
|
||||
|
@ -683,6 +683,7 @@ static bool rna_Object_parent_override_apply(Main *UNUSED(bmain),
|
|||
else {
|
||||
ob->parent = parent_src;
|
||||
}
|
||||
RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1667,11 +1668,11 @@ static bConstraint *rna_Object_constraints_copy(Object *object, Main *bmain, Poi
|
|||
return new_con;
|
||||
}
|
||||
|
||||
bool rna_Object_constraints_override_apply(Main *UNUSED(bmain),
|
||||
bool rna_Object_constraints_override_apply(Main *bmain,
|
||||
PointerRNA *ptr_dst,
|
||||
PointerRNA *ptr_src,
|
||||
PointerRNA *UNUSED(ptr_storage),
|
||||
PropertyRNA *UNUSED(prop_dst),
|
||||
PropertyRNA *prop_dst,
|
||||
PropertyRNA *UNUSED(prop_src),
|
||||
PropertyRNA *UNUSED(prop_storage),
|
||||
const int UNUSED(len_dst),
|
||||
|
@ -1716,6 +1717,7 @@ bool rna_Object_constraints_override_apply(Main *UNUSED(bmain),
|
|||
BKE_constraint_unique_name(con_dst, &ob_dst->constraints);
|
||||
|
||||
// printf("%s: We inserted a constraint...\n", __func__);
|
||||
RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1786,7 +1788,7 @@ bool rna_Object_modifiers_override_apply(Main *bmain,
|
|||
PointerRNA *ptr_dst,
|
||||
PointerRNA *ptr_src,
|
||||
PointerRNA *UNUSED(ptr_storage),
|
||||
PropertyRNA *UNUSED(prop_dst),
|
||||
PropertyRNA *prop_dst,
|
||||
PropertyRNA *UNUSED(prop_src),
|
||||
PropertyRNA *UNUSED(prop_storage),
|
||||
const int UNUSED(len_dst),
|
||||
|
@ -1847,6 +1849,7 @@ bool rna_Object_modifiers_override_apply(Main *bmain,
|
|||
BLI_insertlinkafter(&ob_dst->modifiers, mod_anchor, mod_dst);
|
||||
|
||||
// printf("%s: We inserted a modifier '%s'...\n", __func__, mod_dst->name);
|
||||
RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1883,7 +1886,7 @@ bool rna_Object_greasepencil_modifiers_override_apply(Main *bmain,
|
|||
PointerRNA *ptr_dst,
|
||||
PointerRNA *ptr_src,
|
||||
PointerRNA *UNUSED(ptr_storage),
|
||||
PropertyRNA *UNUSED(prop_dst),
|
||||
PropertyRNA *prop_dst,
|
||||
PropertyRNA *UNUSED(prop_src),
|
||||
PropertyRNA *UNUSED(prop_storage),
|
||||
const int UNUSED(len_dst),
|
||||
|
@ -1932,6 +1935,7 @@ bool rna_Object_greasepencil_modifiers_override_apply(Main *bmain,
|
|||
BLI_insertlinkafter(&ob_dst->greasepencil_modifiers, mod_anchor, mod_dst);
|
||||
|
||||
// printf("%s: We inserted a gpencil modifier '%s'...\n", __func__, mod_dst->name);
|
||||
RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -644,11 +644,11 @@ static bConstraint *rna_PoseChannel_constraints_copy(ID *id,
|
|||
return new_con;
|
||||
}
|
||||
|
||||
bool rna_PoseChannel_constraints_override_apply(Main *UNUSED(bmain),
|
||||
bool rna_PoseChannel_constraints_override_apply(Main *bmain,
|
||||
PointerRNA *ptr_dst,
|
||||
PointerRNA *ptr_src,
|
||||
PointerRNA *UNUSED(ptr_storage),
|
||||
PropertyRNA *UNUSED(prop_dst),
|
||||
PropertyRNA *prop_dst,
|
||||
PropertyRNA *UNUSED(prop_src),
|
||||
PropertyRNA *UNUSED(prop_storage),
|
||||
const int UNUSED(len_dst),
|
||||
|
@ -694,6 +694,7 @@ bool rna_PoseChannel_constraints_override_apply(Main *UNUSED(bmain),
|
|||
BKE_constraint_unique_name(con_dst, &pchan_dst->constraints);
|
||||
|
||||
// printf("%s: We inserted a constraint...\n", __func__);
|
||||
RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -2297,7 +2297,7 @@ bool rna_property_override_store_default(Main *UNUSED(bmain),
|
|||
return changed;
|
||||
}
|
||||
|
||||
bool rna_property_override_apply_default(Main *UNUSED(bmain),
|
||||
bool rna_property_override_apply_default(Main *bmain,
|
||||
PointerRNA *ptr_dst,
|
||||
PointerRNA *ptr_src,
|
||||
PointerRNA *ptr_storage,
|
||||
|
@ -2319,6 +2319,8 @@ bool rna_property_override_apply_default(Main *UNUSED(bmain),
|
|||
const int index = is_array ? opop->subitem_reference_index : 0;
|
||||
const short override_op = opop->operation;
|
||||
|
||||
bool ret_success = true;
|
||||
|
||||
switch (RNA_property_type(prop_dst)) {
|
||||
case PROP_BOOLEAN:
|
||||
if (is_array && index == -1) {
|
||||
|
@ -2355,7 +2357,7 @@ bool rna_property_override_apply_default(Main *UNUSED(bmain),
|
|||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
case PROP_INT:
|
||||
if (is_array && index == -1) {
|
||||
int array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY];
|
||||
|
@ -2434,7 +2436,7 @@ bool rna_property_override_apply_default(Main *UNUSED(bmain),
|
|||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
case PROP_FLOAT:
|
||||
if (is_array && index == -1) {
|
||||
float array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY];
|
||||
|
@ -2527,7 +2529,7 @@ bool rna_property_override_apply_default(Main *UNUSED(bmain),
|
|||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
case PROP_ENUM: {
|
||||
const int value = RNA_property_enum_get(ptr_src, prop_src);
|
||||
|
||||
|
@ -2540,7 +2542,7 @@ bool rna_property_override_apply_default(Main *UNUSED(bmain),
|
|||
BLI_assert_msg(0, "Unsupported RNA override operation on enum");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case PROP_POINTER: {
|
||||
PointerRNA value = RNA_property_pointer_get(ptr_src, prop_src);
|
||||
|
@ -2553,7 +2555,7 @@ bool rna_property_override_apply_default(Main *UNUSED(bmain),
|
|||
BLI_assert_msg(0, "Unsupported RNA override operation on pointer");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case PROP_STRING: {
|
||||
char buff[256];
|
||||
|
@ -2571,7 +2573,7 @@ bool rna_property_override_apply_default(Main *UNUSED(bmain),
|
|||
if (value != buff) {
|
||||
MEM_freeN(value);
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case PROP_COLLECTION: {
|
||||
/* We only support IDProperty-based collection insertion here. */
|
||||
|
@ -2636,19 +2638,27 @@ bool rna_property_override_apply_default(Main *UNUSED(bmain),
|
|||
IDProperty *item_idprop_dst = item_ptr_dst.data;
|
||||
IDP_CopyPropertyContent(item_idprop_dst, item_idprop_src);
|
||||
|
||||
return RNA_property_collection_move(ptr_dst, prop_dst, item_index_added, item_index_dst);
|
||||
ret_success = RNA_property_collection_move(
|
||||
ptr_dst, prop_dst, item_index_added, item_index_dst);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BLI_assert_msg(0, "Unsupported RNA override operation on collection");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BLI_assert(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
/* Default apply callback always call property update. */
|
||||
if (ret_success) {
|
||||
RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);
|
||||
}
|
||||
|
||||
return ret_success;
|
||||
}
|
||||
|
||||
# undef RNA_PROPERTY_GET_SINGLE
|
||||
|
|
Loading…
Reference in New Issue