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>2009-12-04 06:51:52 +0300
committerJoshua Leung <aligorith@gmail.com>2009-12-04 06:51:52 +0300
commit45955fef18c57a5d5633b88e823a9bb9d86b38e4 (patch)
tree3388b4df8b3fb6f42108bd0ae2894f22c22e0046 /source/blender/editors/animation/anim_channels_edit.c
parenta9b9993414e0b2b6154fae78c7bbce4f5fdb20f8 (diff)
Bugfixes: Deleting Keyframes + F-Curves
This commit fixes #19908 and #20239. Deleting keyframes will now delete the F-Curves they came from too, if the F-Curves don't have any more keyframes and/or F-Modifiers providing any further motion info.
Diffstat (limited to 'source/blender/editors/animation/anim_channels_edit.c')
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c59
1 files changed, 35 insertions, 24 deletions
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index 5842f476bc6..4be9cb2cd9d 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -86,9 +86,9 @@
#include "WM_types.h"
/* ************************************************************************** */
-/* CHANNELS API */
+/* CHANNELS API - Exposed API */
-/* -------------------------- Exposed API ----------------------------------- */
+/* -------------------------- Selection ------------------------------------- */
/* Set the given animation-channel as the active one for the active context */
// TODO: extend for animdata types...
@@ -352,6 +352,8 @@ void ANIM_deselect_anim_channels (void *data, short datatype, short test, short
BLI_freelistN(&anim_data);
}
+/* ---------------------------- Graph Editor ------------------------------------- */
+
/* Flush visibility (for Graph Editor) changes up/down hierarchy for changes in the given setting
* - anim_data: list of the all the anim channels that can be chosen
* -> filtered using ANIMFILTER_CHANNELS only, since if we took VISIBLE too,
@@ -452,6 +454,35 @@ void ANIM_visibility_flush_anim_channels (bAnimContext *ac, ListBase *anim_data,
}
}
+/* -------------------------- F-Curves ------------------------------------- */
+
+/* Delete the given F-Curve from its AnimData block */
+void ANIM_fcurve_delete_from_animdata (bAnimContext *ac, AnimData *adt, FCurve *fcu)
+{
+ /* - if no AnimData, we've got nowhere to remove the F-Curve from
+ * (this doesn't guarantee that the F-Curve is in there, but at least we tried
+ * - if no F-Curve, there is nothing to remove
+ */
+ if (ELEM(NULL, adt, fcu))
+ return;
+
+ /* remove from whatever list it came from
+ * - Action Group
+ * - Action
+ * - Drivers
+ * - TODO... some others?
+ */
+ if (fcu->grp)
+ action_groups_remove_channel(adt->action, fcu);
+ else if ((ac) && (ac->datatype == ANIMCONT_DRIVERS))
+ BLI_remlink(&adt->drivers, fcu);
+ else if (adt->action)
+ BLI_remlink(&adt->action->curves, fcu);
+
+ /* free the F-Curve itself */
+ free_fcurve(fcu);
+}
+
/* ************************************************************************** */
/* OPERATORS */
@@ -945,28 +976,8 @@ static int animchannels_delete_exec(bContext *C, wmOperator *op)
AnimData *adt= ale->adt;
FCurve *fcu= (FCurve *)ale->data;
- /* if no AnimData, we've got nowhere to remove the F-Curve from */
- if (adt == NULL)
- continue;
-
- /* remove from whatever list it came from
- * - Action Group
- * - Action
- * - Drivers
- * - TODO... some others?
- *
- * note: this isn't well tested, we could also try remove
- * from all lists just to be safe - campbell
- */
- if (fcu->grp)
- action_groups_remove_channel(adt->action, fcu);
- else if (ac.datatype == ANIMCONT_DRIVERS)
- BLI_remlink(&adt->drivers, fcu);
- else if (adt->action)
- BLI_remlink(&adt->action->curves, fcu);
-
- /* free the F-Curve itself */
- free_fcurve(fcu);
+ /* try to free F-Curve */
+ ANIM_fcurve_delete_from_animdata(&ac, adt, fcu);
}
}