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:
authorJoshua Leung <aligorith@gmail.com>2015-04-03 15:05:52 +0300
committerJoshua Leung <aligorith@gmail.com>2015-04-03 15:39:59 +0300
commitb30836dad742f4f6c72e0b5b58cf1abe2fcef09d (patch)
tree2801d9f8fa775bc4d923f7c83901f8eb622646d6
parent5681b4fc83c4ce96ae15a0ab63bea94a9b53b142 (diff)
Fix: Action/NLA Tweakmode Checks
Made all action management operators use the AnimData-local flag instead of the scene global one. Technically, this is more accurate and results in less blocking situations (i.e. another object may be in tweakmode, but because of that, the active object's action couldn't be stashed). The main impetus for this though was that the Action Up/Down feature doesn't clear the global flag, since it is not in a position to do so (since it can't load up everything to clear it). TODO: I'll need to review how this global flag works and/or potentially ditch it (or perhaps add some better ways to ensure that it stays valid), since while thinking this over, I've noticed a few problems here. But, for the meantime, this commit at least makes things more usable here in the short term.
-rw-r--r--source/blender/editors/space_action/action_data.c77
1 files changed, 44 insertions, 33 deletions
diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c
index e141789d7a9..f7e110e3b90 100644
--- a/source/blender/editors/space_action/action_data.c
+++ b/source/blender/editors/space_action/action_data.c
@@ -182,25 +182,29 @@ static int action_new_poll(bContext *C)
Scene *scene = CTX_data_scene(C);
/* Check tweakmode is off (as you don't want to be tampering with the action in that case) */
- /* NOTE: unlike for pushdown, this operator needs to be run when creating an action from nothing... */
- if (!(scene->flag & SCE_NLA_EDIT_ON)) {
- if (ED_operator_action_active(C)) {
- SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
- Object *ob = CTX_data_active_object(C);
-
- /* For now, actions are only for the active object, and on object and shapekey levels... */
- if (saction->mode == SACTCONT_ACTION) {
- /* XXX: This assumes that actions are assigned to the active object */
- if (ob)
+ /* NOTE: unlike for pushdown, this operator needs to be run when creating an action from nothing... */
+ if (ED_operator_action_active(C)) {
+ SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
+ Object *ob = CTX_data_active_object(C);
+
+ /* For now, actions are only for the active object, and on object and shapekey levels... */
+ if (saction->mode == SACTCONT_ACTION) {
+ /* XXX: This assumes that actions are assigned to the active object in this mode */
+ if (ob) {
+ if ((ob->adt == NULL) || (ob->adt->flag & ADT_NLA_EDIT_ON) == 0)
return true;
}
- else if (saction->mode == SACTCONT_SHAPEKEY) {
- Key *key = BKE_key_from_object(ob);
- if (key)
+ }
+ else if (saction->mode == SACTCONT_SHAPEKEY) {
+ Key *key = BKE_key_from_object(ob);
+ if (key) {
+ if ((key->adt == NULL) || (key->adt->flag & ADT_NLA_EDIT_ON) == 0)
return true;
}
}
- else if (ED_operator_nla_active(C)) {
+ }
+ else if (ED_operator_nla_active(C)) {
+ if (!(scene->flag & SCE_NLA_EDIT_ON)) {
return true;
}
}
@@ -297,21 +301,16 @@ static int action_pushdown_poll(bContext *C)
{
if (ED_operator_action_active(C)) {
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
- Scene *scene = CTX_data_scene(C);
- Object *ob = CTX_data_active_object(C);
+ AnimData *adt = actedit_animdata_from_context(C);
- /* Check for actions and that tweakmode is off */
- if ((saction->action) && !(scene->flag & SCE_NLA_EDIT_ON)) {
- /* For now, actions are only for the active object, and on object and shapekey levels... */
- if (saction->mode == SACTCONT_ACTION) {
- return (ob->adt != NULL);
- }
- else if (saction->mode == SACTCONT_SHAPEKEY) {
- Key *key = BKE_key_from_object(ob);
-
- return (key && key->adt);
- }
- }
+ /* Check for AnimData, Actions, and that tweakmode is off */
+ if (adt && saction->action) {
+ /* NOTE: We check this for the AnimData block in question and not the global flag,
+ * as the global flag may be left dirty by some of the browsing ops here.
+ */
+ if (!(adt->flag & ADT_NLA_EDIT_ON))
+ return true;
+ }
}
/* something failed... */
@@ -432,14 +431,26 @@ void ACTION_OT_stash(wmOperatorType *ot)
static int action_stash_create_poll(bContext *C)
{
if (ED_operator_action_active(C)) {
- SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
- Scene *scene = CTX_data_scene(C);
+ AnimData *adt = actedit_animdata_from_context(C);
/* Check tweakmode is off (as you don't want to be tampering with the action in that case) */
/* NOTE: unlike for pushdown, this operator needs to be run when creating an action from nothing... */
- if (!(scene->flag & SCE_NLA_EDIT_ON)) {
- /* For now, actions are only for the active object, and on object and shapekey levels... */
- return ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY);
+ if (adt) {
+ if (!(adt->flag & ADT_NLA_EDIT_ON))
+ return true;
+ }
+ else {
+ /* There may not be any action/animdata yet, so, just fallback to the global setting
+ * (which may not be totally valid yet if the action editor was used and things are
+ * now in an inconsistent state)
+ */
+ SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
+ Scene *scene = CTX_data_scene(C);
+
+ if (!(scene->flag & SCE_NLA_EDIT_ON)) {
+ /* For now, actions are only for the active object, and on object and shapekey levels... */
+ return ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY);
+ }
}
}