Added a button to clear the weights of all shape keys, useful
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 16 Oct 2009 10:29:41 +0000 (10:29 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 16 Oct 2009 10:29:41 +0000 (10:29 +0000)
when editing shapes and doing blending tests.

release/scripts/ui/buttons_data_mesh.py
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_ops.c
source/blender/editors/object/object_select.c
source/blender/editors/object/object_shapekey.c

index 8dc5af5..81e2ac1 100644 (file)
@@ -146,6 +146,7 @@ class DATA_PT_shape_keys(DataButtonsPanel):
                                        row = layout.row()
                                        row.enabled = ob.shape_key_lock == False
                                        row.itemR(kb, "value", slider=True)
+                                       row.itemO("object.shape_key_clear", icon='ICON_X', text="")
                                        
                                        split = layout.split()
                                        sub = split.column(align=True)
index 420b6a2..6a99748 100644 (file)
@@ -175,6 +175,7 @@ void OBJECT_OT_game_property_remove(struct wmOperatorType *ot);
 /* object_shapekey.c */
 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);
 
 /* object_group.c */
 void OBJECT_OT_group_add(struct wmOperatorType *ot);
index 1e95eca..c6baf84 100644 (file)
@@ -171,6 +171,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(LATTICE_OT_select_all_toggle);
        WM_operatortype_append(LATTICE_OT_make_regular);
index 90d1a9d..4773049 100644 (file)
@@ -95,7 +95,6 @@ void ED_base_object_select(Base *base, short mode)
 void ED_base_object_activate(bContext *C, Base *base)
 {
        Scene *scene= CTX_data_scene(C);
-       Base *tbase;
        
        /* sets scene->basact */
        BASACT= base;
index 2ec3edd..b7db3a2 100644 (file)
@@ -72,6 +72,7 @@
 #include "ED_object.h"
 
 #include "RNA_access.h"
+#include "RNA_define.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -416,7 +417,7 @@ void ED_object_shape_key_add(bContext *C, Scene *scene, Object *ob)
 
 /*********************** remove shape key ***********************/
 
-int ED_object_shape_key_remove(bContext *C, Scene *scene, Object *ob)
+int ED_object_shape_key_remove(bContext *C, Object *ob)
 {
        Main *bmain= CTX_data_main(C);
        KeyBlock *kb, *rkb;
@@ -502,6 +503,7 @@ void OBJECT_OT_shape_key_add(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Add Shape Key";
+       ot->name= "Add shape key to the object.";
        ot->idname= "OBJECT_OT_shape_key_add";
        
        /* api callbacks */
@@ -514,10 +516,9 @@ void OBJECT_OT_shape_key_add(wmOperatorType *ot)
 
 static int shape_key_remove_exec(bContext *C, wmOperator *op)
 {
-       Scene *scene= CTX_data_scene(C);
        Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
 
-       if(!ED_object_shape_key_remove(C, scene, ob))
+       if(!ED_object_shape_key_remove(C, ob))
                return OPERATOR_CANCELLED;
        
        return OPERATOR_FINISHED;
@@ -527,6 +528,7 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Remove Shape Key";
+       ot->name= "Remove shape key from the object.";
        ot->idname= "OBJECT_OT_shape_key_remove";
        
        /* api callbacks */
@@ -537,3 +539,36 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
+static int shape_key_clear_exec(bContext *C, wmOperator *op)
+{
+       Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+       Key *key= ob_get_key(ob);
+       KeyBlock *kb= ob_get_keyblock(ob);
+
+       if(!key || !kb)
+               return OPERATOR_CANCELLED;
+       
+       for(kb=key->block.first; kb; kb=kb->next)
+               kb->curval= 0.0f;
+
+       DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+       
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_shape_key_clear(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Clear Shape Keys";
+       ot->description= "Clear weights for all shape keys.";
+       ot->idname= "OBJECT_OT_shape_key_clear";
+       
+       /* api callbacks */
+       ot->poll= shape_key_poll;
+       ot->exec= shape_key_clear_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+