From 2a54ef044258f8f5555c718a018371c1aedccb5e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Apr 2012 06:10:15 +0000 Subject: there was no way to reset timing for absolute shape keys, add an operator to do so. --- .../scripts/startup/bl_ui/properties_data_mesh.py | 5 +++- source/blender/editors/object/object_intern.h | 1 + source/blender/editors/object/object_ops.c | 1 + source/blender/editors/object/object_shapekey.c | 35 ++++++++++++++++++++++ source/blender/editors/object/object_vgroup.c | 2 +- 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index 2e485a42968..fd96fa4a0ce 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -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") 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; -- cgit v1.2.3