diff options
Diffstat (limited to 'source/blender/editors/object/object_shapekey.c')
-rw-r--r-- | source/blender/editors/object/object_shapekey.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 98a7eca5068..ba613db1740 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -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); |