Fix T89592: Can't remove keyframes without active keying set

Partially revert 7fc220517f, as it
introduced two issues:

- Deleting keys without active keying set was no longer possible, and
- there was no more confirmation popup.

Pressing {key Alt I} in the 3D Viewport now executes
`ANIM_OT_keyframe_delete_v3d`, adjusted to suit both T88068 and T89592:

- If there is an active keying set, delete keys according to that keying
  set.
- Otherwise, behave as `ANIM_OT_keyframe_delete_v3d` did before, that
  is, delete all keyframes of the selected object and in pose-mode also
  of selected bones.
This commit is contained in:
2021-07-06 17:21:21 +02:00
parent 563ef943c7
commit 1364f1e35c
3 changed files with 29 additions and 14 deletions

View File

@@ -85,6 +85,8 @@ static KeyingSet *keyingset_get_from_op_with_error(wmOperator *op,
PropertyRNA *prop,
Scene *scene);
static int delete_key_using_keying_set(bContext *C, wmOperator *op, KeyingSet *ks);
/* ************************************************** */
/* Keyframing Setting Wrangling */
@@ -2079,19 +2081,19 @@ void ANIM_OT_keyframe_insert_menu(wmOperatorType *ot)
static int delete_key_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
float cfra = (float)CFRA; /* XXX for now, don't bother about all the yucky offset crap */
int num_channels;
KeyingSet *ks = keyingset_get_from_op_with_error(op, op->type->prop, scene);
if (ks == NULL) {
return OPERATOR_CANCELLED;
}
/* report failure */
if (ks == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active Keying Set");
return OPERATOR_CANCELLED;
}
return delete_key_using_keying_set(C, op, ks);
}
static int delete_key_using_keying_set(bContext *C, wmOperator *op, KeyingSet *ks)
{
Scene *scene = CTX_data_scene(C);
float cfra = (float)CFRA; /* XXX for now, don't bother about all the yucky offset crap */
int num_channels;
/* try to delete keyframes for the channels specified by KeyingSet */
num_channels = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_DELETE, cfra);
@@ -2107,7 +2109,8 @@ static int delete_key_exec(bContext *C, wmOperator *op)
if (num_channels > 0) {
/* if the appropriate properties have been set, make a note that we've inserted something */
if (RNA_boolean_get(op->ptr, "confirm_success")) {
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "confirm_success");
if (prop != NULL && RNA_property_boolean_get(op->ptr, prop)) {
BKE_reportf(op->reports,
RPT_INFO,
"Successfully removed %d keyframes for keying set '%s'",
@@ -2278,7 +2281,7 @@ void ANIM_OT_keyframe_clear_v3d(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int delete_key_v3d_exec(bContext *C, wmOperator *op)
static int delete_key_v3d_without_keying_set(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
float cfra = (float)CFRA;
@@ -2385,6 +2388,18 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static int delete_key_v3d_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
KeyingSet *ks = ANIM_scene_get_active_keyingset(scene);
if (ks == NULL) {
return delete_key_v3d_without_keying_set(C, op);
}
return delete_key_using_keying_set(C, op, ks);
}
void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot)
{
/* identifiers */