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 | |
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')
-rw-r--r-- | source/blender/editors/object/object_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_shapekey.c | 35 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 2 |
4 files changed, 38 insertions, 1 deletions
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 73c5c50f448..b1738a960ce 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -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); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 12387f36ca4..138cbad0a68 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -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); 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); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index a87268a2402..e4b8e21c13a 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.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; |