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:
authorSybren A. Stüvel <sybren@blender.org>2020-09-25 12:07:32 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-09-25 15:20:59 +0300
commit64583f3e8d0f337a977c9a90b874bee733a37402 (patch)
tree3356dd4b14ed5f0cbaf0236b2ac51f7f4dad1ec0 /source/blender/makesrna/intern/rna_space.c
parent5419f9a845ed58205ffbf38497ce9ff595499466 (diff)
Animation: set Action `idroot` at assignment instead of just at evaluation
Actions are either locked to a specific ID type, or "floating". Actions in the floating state are now locked when they are assigned to an ID block. Previously (rB94b99b5d4a7c20cf2) this was done at evaluation time, which caused various problems: - The ID type was set on the evaluated copy, and inconsistently flushed back to the original. - A newly created Action could not be assigned to an Action constraint, unless a depsgraph evaluation was be forced first. This is now resolved by calling `BKE_animdata_set_action()` to set the action (instead of direct assignment) where possible, and calling `BKE_animdata_action_ensure_idroot()` otherwise. Manifest Task: https://developer.blender.org/T80986
Diffstat (limited to 'source/blender/makesrna/intern/rna_space.c')
-rw-r--r--source/blender/makesrna/intern/rna_space.c51
1 files changed, 19 insertions, 32 deletions
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 59a974b8b0b..3fa577d4230 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1929,10 +1929,12 @@ static void rna_SpaceDopeSheetEditor_action_update(bContext *C, PointerRNA *ptr)
}
AnimData *adt = NULL;
+ ID *id = NULL;
switch (saction->mode) {
case SACTCONT_ACTION:
/* TODO: context selector could help decide this with more control? */
adt = BKE_animdata_add_id(&obact->id);
+ id = &obact->id;
break;
case SACTCONT_SHAPEKEY: {
Key *key = BKE_key_from_object(obact);
@@ -1940,6 +1942,7 @@ static void rna_SpaceDopeSheetEditor_action_update(bContext *C, PointerRNA *ptr)
return;
}
adt = BKE_animdata_add_id(&key->id);
+ id = &key->id;
break;
}
case SACTCONT_GPENCIL:
@@ -1963,40 +1966,24 @@ static void rna_SpaceDopeSheetEditor_action_update(bContext *C, PointerRNA *ptr)
/* Exit editmode first - we cannot change actions while in tweakmode. */
BKE_nla_tweakmode_exit(adt);
- /* NLA Tweak Mode needs special handling... */
- if (adt->flag & ADT_NLA_EDIT_ON) {
- /* Assign new action, and adjust the usercounts accordingly */
- adt->action = saction->action;
- id_us_plus((ID *)adt->action);
+ /* To prevent data loss (i.e. if users flip between actions using the Browse menu),
+ * stash this action if nothing else uses it.
+ *
+ * EXCEPTION:
+ * This callback runs when unlinking actions. In that case, we don't want to
+ * stash the action, as the user is signaling that they want to detach it.
+ * This can be reviewed again later,
+ * but it could get annoying if we keep these instead.
+ */
+ if (adt->action != NULL && adt->action->id.us <= 0 && saction->action != NULL) {
+ /* XXX: Things here get dodgy if this action is only partially completed,
+ * and the user then uses the browse menu to get back to this action,
+ * assigning it as the active action (i.e. the stash strip gets out of sync)
+ */
+ BKE_nla_action_stash(adt);
}
- else {
- /* Handle old action... */
- if (adt->action) {
- /* Fix id-count of action we're replacing */
- id_us_min(&adt->action->id);
-
- /* To prevent data loss (i.e. if users flip between actions using the Browse menu),
- * stash this action if nothing else uses it.
- *
- * EXCEPTION:
- * This callback runs when unlinking actions. In that case, we don't want to
- * stash the action, as the user is signaling that they want to detach it.
- * This can be reviewed again later,
- * but it could get annoying if we keep these instead.
- */
- if ((adt->action->id.us <= 0) && (saction->action != NULL)) {
- /* XXX: Things here get dodgy if this action is only partially completed,
- * and the user then uses the browse menu to get back to this action,
- * assigning it as the active action (i.e. the stash strip gets out of sync)
- */
- BKE_nla_action_stash(adt);
- }
- }
- /* Assign new action, and adjust the usercounts accordingly */
- adt->action = saction->action;
- id_us_plus((ID *)adt->action);
- }
+ BKE_animdata_set_action(NULL, id, saction->action);
DEG_id_tag_update(&obact->id, ID_RECALC_ANIMATION | ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);