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:
Diffstat (limited to 'source/blender/editors/animation')
-rw-r--r--source/blender/editors/animation/anim_intern.h2
-rw-r--r--source/blender/editors/animation/anim_ops.c1
-rw-r--r--source/blender/editors/animation/keyframing.c125
3 files changed, 103 insertions, 25 deletions
diff --git a/source/blender/editors/animation/anim_intern.h b/source/blender/editors/animation/anim_intern.h
index cf84eb04b10..bc07bf091de 100644
--- a/source/blender/editors/animation/anim_intern.h
+++ b/source/blender/editors/animation/anim_intern.h
@@ -50,7 +50,9 @@ void ANIM_OT_keyframe_delete(struct wmOperatorType *ot);
* required for each space.
*/
void ANIM_OT_keyframe_insert_menu(struct wmOperatorType *ot);
+
void ANIM_OT_keyframe_delete_v3d(struct wmOperatorType *ot);
+void ANIM_OT_keyframe_clear_v3d(struct wmOperatorType *ot);
/* Keyframe managment operators for UI buttons (RMB menu). */
void ANIM_OT_keyframe_insert_button(struct wmOperatorType *ot);
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index e24a4d49a05..f2711ec3bb5 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -290,6 +290,7 @@ void ED_operatortypes_anim(void)
WM_operatortype_append(ANIM_OT_keyframe_delete);
WM_operatortype_append(ANIM_OT_keyframe_insert_menu);
WM_operatortype_append(ANIM_OT_keyframe_delete_v3d);
+ WM_operatortype_append(ANIM_OT_keyframe_clear_v3d);
WM_operatortype_append(ANIM_OT_keyframe_insert_button);
WM_operatortype_append(ANIM_OT_keyframe_delete_button);
WM_operatortype_append(ANIM_OT_keyframe_clear_button);
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 1791d84d90b..0454e88e320 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -1186,10 +1186,9 @@ static int modify_key_op_poll(bContext *C)
/* if Outliner, don't allow in some views */
if (so) {
- if (ELEM4(so->outlinevis, SO_GROUPS, SO_LIBRARIES, SO_VERSE_SESSION, SO_VERSE_SESSION))
- return 0;
- if (ELEM3(so->outlinevis, SO_SEQUENCE, SO_USERDEF, SO_KEYMAP))
+ if (ELEM5(so->outlinevis, SO_GROUPS, SO_LIBRARIES, SO_SEQUENCE, SO_USERDEF, SO_KEYMAP)) {
return 0;
+ }
}
/* TODO: checks for other space types can be added here */
@@ -1440,46 +1439,122 @@ void ANIM_OT_keyframe_delete(wmOperatorType *ot)
}
/* Delete Key Operator ------------------------ */
-
-/* XXX WARNING:
- * This is currently just a basic operator, which work in 3d-view context on objects only.
- * Should this be kept? It does have advantages over a version which requires selecting a keyingset to use...
- * -- Joshua Leung, Jan 2009
+/* NOTE: Although this version is simpler than the more generic version for KeyingSets,
+ * it is more useful for animators working in the 3D view.
*/
+static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Main *bmain = CTX_data_main(C);
+
+ CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
+ {
+ /* just those in active action... */
+ if ((ob->adt) && (ob->adt->action)) {
+ AnimData *adt = ob->adt;
+ bAction *act = adt->action;
+ FCurve *fcu, *fcn;
+
+ for (fcu = act->curves.first; fcu; fcu = fcn) {
+ short can_delete = FALSE;
+
+ fcn = fcu->next;
+
+ /* in pose mode, only delete the F-Curve if it belongs to a selected bone */
+ if (ob->mode & OB_MODE_POSE) {
+ if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones[")) {
+ bPoseChannel *pchan;
+ char *bone_name;
+
+ /* get bone-name, and check if this bone is selected */
+ bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
+ pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
+ if (bone_name) MEM_freeN(bone_name);
+
+ /* delete if bone is selected*/
+ if ((pchan) && (pchan->bone)) {
+ if (pchan->bone->flag & BONE_SELECTED)
+ can_delete = TRUE;
+ }
+ }
+ }
+ else {
+ /* object mode - all of Object's F-Curves are affected */
+ can_delete = TRUE;
+ }
+
+ /* delete F-Curve completely */
+ if (can_delete) {
+ ANIM_fcurve_delete_from_animdata(NULL, adt, fcu);
+ }
+ }
+ }
+
+ /* update... */
+ ob->recalc |= OB_RECALC_OB;
+ }
+ CTX_DATA_END;
+
+ /* send updates */
+ DAG_ids_flush_update(bmain, 0);
+ WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void ANIM_OT_keyframe_clear_v3d(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Remove Animation";
+ ot->description = "Remove all keyframe animation for selected objects";
+ ot->idname = "ANIM_OT_keyframe_clear_v3d";
+
+ /* callbacks */
+ ot->invoke = WM_operator_confirm;
+ ot->exec = clear_anim_v3d_exec;
+
+ ot->poll = ED_operator_areaactive;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+
static int delete_key_v3d_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
+ float cfra = (float)CFRA;
- // XXX more comprehensive tests will be needed
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
{
- ID *id = (ID *)ob;
- FCurve *fcu, *fcn;
- short success = 0;
+ ID *id = &ob->id;
+ int success = 0;
- /* loop through all curves in animdata and delete keys on this frame */
+ /* just those in active action... */
if ((ob->adt) && (ob->adt->action)) {
AnimData *adt = ob->adt;
bAction *act = adt->action;
+ FCurve *fcu, *fcn;
for (fcu = act->curves.first; fcu; fcu = fcn) {
fcn = fcu->next;
+
+ /* delete keyframes on current frame
+ * WARNING: this can delete the next F-Curve, hence the "fcn" copying
+ */
success += delete_keyframe(op->reports, id, NULL, NULL, fcu->rna_path, fcu->array_index, cfra, 0);
}
}
- BKE_reportf(op->reports, RPT_INFO, "Ob '%s' - Successfully had %d keyframes removed", id->name + 2, success);
-
+ /* report success (or failure) */
+ BKE_reportf(op->reports, RPT_INFO, "Object '%s' successfully had %d keyframes removed", id->name + 2, success);
ob->recalc |= OB_RECALC_OB;
}
CTX_DATA_END;
/* send updates */
DAG_ids_flush_update(bmain, 0);
-
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL);
return OPERATOR_FINISHED;
@@ -1489,7 +1564,7 @@ void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Delete Keyframe";
- ot->description = "Remove keyframes on current frame for selected object";
+ ot->description = "Remove keyframes on current frame for selected objects";
ot->idname = "ANIM_OT_keyframe_delete_v3d";
/* callbacks */
@@ -1512,7 +1587,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
PointerRNA ptr = {{NULL}};
PropertyRNA *prop = NULL;
char *path;
- float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
+ float cfra = (float)CFRA;
short success = 0;
int a, index, length, all = RNA_boolean_get(op->ptr, "all");
short flag = 0;
@@ -1683,20 +1758,20 @@ static int clear_key_button_exec(bContext *C, wmOperator *op)
if (ptr.id.data && ptr.data && prop) {
path = RNA_path_from_ID_to_property(&ptr, prop);
-
+
if (path) {
if (all) {
length = RNA_property_array_length(&ptr, prop);
-
+
if (length) index = 0;
else length = 1;
}
else
length = 1;
-
+
for (a = 0; a < length; a++)
success += clear_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index + a, 0);
-
+
MEM_freeN(path);
}
else if (G.debug & G_DEBUG)
@@ -1710,9 +1785,9 @@ static int clear_key_button_exec(bContext *C, wmOperator *op)
if (success) {
/* send updates */
uiContextAnimUpdate(C);
-
+
DAG_ids_flush_update(bmain, 0);
-
+
/* send notifiers that keyframes have been changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}