there was no way to reset timing for absolute shape keys, add an operator to do so.

This commit is contained in:
Campbell Barton 2012-04-05 06:10:15 +00:00
parent f4ccee2785
commit 2a54ef0442
5 changed files with 42 additions and 2 deletions

@ -233,7 +233,10 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
sub.prop(ob, "use_shape_key_edit_mode", text="")
sub = row.row()
sub.operator("object.shape_key_clear", icon='X', text="")
if key.use_relative:
sub.operator("object.shape_key_clear", icon='X', text="")
else:
sub.operator("object.shape_key_retime", icon='RECOVER_LAST', text="")
row = layout.row()
row.prop(kb, "name")

@ -214,6 +214,7 @@ void OBJECT_OT_vertex_group_move(struct wmOperatorType *ot);
void OBJECT_OT_shape_key_add(struct wmOperatorType *ot);
void OBJECT_OT_shape_key_remove(struct wmOperatorType *ot);
void OBJECT_OT_shape_key_clear(struct wmOperatorType *ot);
void OBJECT_OT_shape_key_retime(struct wmOperatorType *ot);
void OBJECT_OT_shape_key_mirror(struct wmOperatorType *ot);
void OBJECT_OT_shape_key_move(struct wmOperatorType *ot);

@ -194,6 +194,7 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_shape_key_add);
WM_operatortype_append(OBJECT_OT_shape_key_remove);
WM_operatortype_append(OBJECT_OT_shape_key_clear);
WM_operatortype_append(OBJECT_OT_shape_key_retime);
WM_operatortype_append(OBJECT_OT_shape_key_mirror);
WM_operatortype_append(OBJECT_OT_shape_key_move);

@ -371,6 +371,41 @@ void OBJECT_OT_shape_key_clear(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/* starting point and step size could be optional */
static int shape_key_retime_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_object_context(C);
Key *key = ob_get_key(ob);
KeyBlock *kb = ob_get_keyblock(ob);
float cfra = 0.0f;
if (!key || !kb)
return OPERATOR_CANCELLED;
for (kb=key->block.first; kb; kb=kb->next)
kb->pos = (cfra += 0.1f);
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
return OPERATOR_FINISHED;
}
void OBJECT_OT_shape_key_retime(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Re-Time Shape Keys";
ot->description = "Resets the timing for absolute shape keys";
ot->idname = "OBJECT_OT_shape_key_retime";
/* api callbacks */
ot->poll = shape_key_poll;
ot->exec = shape_key_retime_exec;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int shape_key_mirror_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= ED_object_context(C);

@ -2079,7 +2079,7 @@ static int vertex_group_poll(bContext *C)
return (ob && !ob->id.lib && OB_TYPE_SUPPORT_VGROUP(ob->type) && data && !data->lib);
}
static int vertex_group_poll_edit(bContext *C)
static int UNUSED_FUNCTION(vertex_group_poll_edit)(bContext *C)
{
Object *ob= ED_object_context(C);
ID *data= (ob)? ob->data: NULL;