Added a button to clear the weights of all shape keys, useful
when editing shapes and doing blending tests.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user