|
|
|
@@ -1440,46 +1440,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 delete_key_v3d_exec(bContext *C, wmOperator *op)
|
|
|
|
|
static int clear_anim_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
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
|
|
/* 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) {
|
|
|
|
|
short can_delete = FALSE;
|
|
|
|
|
|
|
|
|
|
fcn = fcu->next;
|
|
|
|
|
success += delete_keyframe(op->reports, id, NULL, NULL, fcu->rna_path, fcu->array_index, cfra, 0);
|
|
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_reportf(op->reports, RPT_INFO, "Ob '%s' - Successfully had %d keyframes removed", id->name + 2, success);
|
|
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
|
|
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
|
|
|
|
|
{
|
|
|
|
|
ID *id = &ob->id;
|
|
|
|
|
size_t success = 0;
|
|
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* report success (or failure) */
|
|
|
|
|
BKE_reportf(op->reports, RPT_INFO, "Object '%s' successfully had %u 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 +1565,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 */
|
|
|
|
|