Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2022-04-01 13:21:00 +0300
committerBastien Montagne <bastien@blender.org>2022-04-01 13:35:25 +0300
commit1264142f78302dcecd229b3dd72544470e553964 (patch)
tree418b7bbf1f83c17b64eb524a7cef8ea6159de894
parentd34c4089f18f4ec6c6f8f79b95146195d065ec1e (diff)
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.
-rw-r--r--source/blender/makesrna/intern/rna_access_compare_override.c4
-rw-r--r--source/blender/makesrna/intern/rna_animation.c8
-rw-r--r--source/blender/makesrna/intern/rna_collection.c6
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c3
-rw-r--r--source/blender/makesrna/intern/rna_object.c14
-rw-r--r--source/blender/makesrna/intern/rna_pose.c5
-rw-r--r--source/blender/makesrna/intern/rna_rna.c28
7 files changed, 43 insertions, 25 deletions
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c
index cce310e4b6d..5974788884e 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -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;
}
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index ba7f3c55460..4f07cb235fa 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -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;
}
diff --git a/source/blender/makesrna/intern/rna_collection.c b/source/blender/makesrna/intern/rna_collection.c
index eceabe65a67..599d36c0af7 100644
--- a/source/blender/makesrna/intern/rna_collection.c
+++ b/source/blender/makesrna/intern/rna_collection.c
@@ -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;
}
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 922e0204299..4f9a10c9993 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -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;
}
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 0b39c8e27c7..3334022e202 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -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;
}
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 8b59962d858..2390fdd72f0 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -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;
}
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index 8f1847c00f4..373df6b7444 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -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