diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-05 10:10:15 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-05 10:10:15 +0400 |
commit | 2a54ef044258f8f5555c718a018371c1aedccb5e (patch) | |
tree | c904dbc88dbb084e8b6c3ba432eaaebda73a791d /source/blender/editors/object/object_shapekey.c | |
parent | f4ccee2785f91efd4acceeae0713b93b7afaeccd (diff) |
there was no way to reset timing for absolute shape keys, add an operator to do so.
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); |