forked from bartvdbraak/blender
Shape Keys
Active shape key can now be changed while in edit mode. This is based on exit/enter editmode again in the background, which is not ideal, as that loses the undo history. But that already happened anyway when you did exit/change-active/enter manually.
This commit is contained in:
parent
3ffb695b10
commit
e2b74dc736
@ -154,6 +154,7 @@ class DATA_PT_shape_keys(DataButtonsPanel):
|
||||
sub.alignment = 'RIGHT'
|
||||
|
||||
subrow = sub.row(align=True)
|
||||
subrow.active= enable_edit_value
|
||||
subrow.itemR(ob, "shape_key_lock", icon='ICON_UNPINNED', text="")
|
||||
subrow.itemR(kb, "mute", icon='ICON_MUTE_IPO_OFF', text="")
|
||||
subrow.itemO("object.shape_key_clear", icon='ICON_X', text="")
|
||||
@ -163,31 +164,30 @@ class DATA_PT_shape_keys(DataButtonsPanel):
|
||||
sub.itemR(ob, "shape_key_edit_mode", text="")
|
||||
|
||||
row = layout.row()
|
||||
row.enabled = enable_edit_value
|
||||
row.itemR(kb, "name")
|
||||
|
||||
if key.relative:
|
||||
if ob.active_shape_key_index != 0:
|
||||
row = layout.row()
|
||||
row.enabled = enable_edit_value
|
||||
row.active = enable_edit_value
|
||||
row.itemR(kb, "value")
|
||||
|
||||
split = layout.split()
|
||||
sub = split.column(align=True)
|
||||
sub.enabled = enable_edit_value
|
||||
sub.active = enable_edit_value
|
||||
sub.itemL(text="Range:")
|
||||
sub.itemR(kb, "slider_min", text="Min")
|
||||
sub.itemR(kb, "slider_max", text="Max")
|
||||
|
||||
sub = split.column(align=True)
|
||||
sub.enabled = enable_edit_value
|
||||
sub.active = enable_edit_value
|
||||
sub.itemL(text="Blend:")
|
||||
sub.item_pointerR(kb, "vertex_group", ob, "vertex_groups", text="")
|
||||
sub.item_pointerR(kb, "relative_key", key, "keys", text="")
|
||||
|
||||
else:
|
||||
row = layout.row()
|
||||
row.enabled = enable_edit
|
||||
row.active = enable_edit_value
|
||||
row.itemR(key, "slurph")
|
||||
|
||||
class DATA_PT_uv_texture(DataButtonsPanel):
|
||||
|
@ -173,6 +173,8 @@ typedef struct EditMesh
|
||||
short mat_nr;
|
||||
/* stats */
|
||||
int totvert, totedge, totface, totvertsel, totedgesel, totfacesel;
|
||||
/* shape key being edited */
|
||||
int shapenr;
|
||||
|
||||
struct DerivedMesh *derivedCage, *derivedFinal;
|
||||
/* the custom data layer mask that was last used to calculate
|
||||
|
@ -1960,7 +1960,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
|
||||
Object *ob;
|
||||
uiBlock *block= uiLayoutGetBlock(layout);
|
||||
uiBut *but;
|
||||
uiLayout *split, *overlap, *sub;
|
||||
uiLayout *split, *overlap, *sub, *row;
|
||||
char *name, *namebuf;
|
||||
int icon;
|
||||
|
||||
@ -1971,7 +1971,8 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
|
||||
|
||||
if(itemptr->type == &RNA_ShapeKey) {
|
||||
ob= (Object*)activeptr->data;
|
||||
uiLayoutSetEnabled(sub, ob->mode != OB_MODE_EDIT);
|
||||
if(ob->mode == OB_MODE_EDIT && !(ob->type == OB_MESH))
|
||||
uiLayoutSetEnabled(sub, 0);
|
||||
}
|
||||
|
||||
but= uiDefButR(block, LISTROW, 0, "", 0,0, UI_UNIT_X*10,UI_UNIT_Y, activeptr, activepropname, 0, 0, i, 0, 0, "");
|
||||
@ -2005,11 +2006,13 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
|
||||
|
||||
uiItemL(split, name, icon);
|
||||
|
||||
if(i == 0) uiItemL(split, "", 0);
|
||||
else uiItemR(split, "", 0, itemptr, "value", 0);
|
||||
if(ob->mode == OB_MODE_EDIT && !(ob->shapeflag & OB_SHAPE_EDIT_MODE))
|
||||
uiLayoutSetEnabled(split, 0);
|
||||
//uiItemR(split, "", ICON_MUTE_IPO_OFF, itemptr, "mute", 0);
|
||||
row= uiLayoutRow(split, 1);
|
||||
if(i == 0) uiItemL(row, "", 0);
|
||||
else uiItemR(row, "", 0, itemptr, "value", 0);
|
||||
|
||||
if(ob->mode == OB_MODE_EDIT && !((ob->shapeflag & OB_SHAPE_EDIT_MODE) && ob->type == OB_MESH))
|
||||
uiLayoutSetActive(row, 0);
|
||||
//uiItemR(row, "", ICON_MUTE_IPO_OFF, itemptr, "mute", 0);
|
||||
}
|
||||
else
|
||||
uiItemL(sub, name, icon);
|
||||
|
@ -785,6 +785,7 @@ void make_editMesh(Scene *scene, Object *ob)
|
||||
/* undo-ing in past for previous editmode sessions gives corrupt 'keyindex' values */
|
||||
undo_editmode_clear();
|
||||
keyco= actkey->data;
|
||||
em->shapenr= ob->shapenr;
|
||||
}
|
||||
|
||||
/* make editverts */
|
||||
@ -1184,7 +1185,8 @@ void load_editMesh(Scene *scene, Object *ob)
|
||||
|
||||
/* are there keys? */
|
||||
if(me->key) {
|
||||
KeyBlock *currkey, *actkey = ob_get_keyblock(ob);
|
||||
KeyBlock *currkey;
|
||||
KeyBlock *actkey= BLI_findlink(&me->key->block, em->shapenr-1);
|
||||
|
||||
/* Lets reorder the key data so that things line up roughly
|
||||
* with the way things were before editmode */
|
||||
|
@ -480,7 +480,6 @@ void ED_object_enter_editmode(bContext *C, int flag)
|
||||
|
||||
static int editmode_toggle_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
|
||||
if(!CTX_data_edit_object(C))
|
||||
ED_object_enter_editmode(C, EM_WAITCURSOR);
|
||||
else
|
||||
|
@ -121,6 +121,21 @@ void rna_Object_update_data(bContext *C, PointerRNA *ptr)
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ptr->id.data);
|
||||
}
|
||||
|
||||
void rna_Object_active_shape_update(bContext *C, PointerRNA *ptr)
|
||||
{
|
||||
Object *ob= ptr->id.data;
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
int editmode= (scene->obedit == ob && ob->type == OB_MESH);
|
||||
|
||||
if(editmode) {
|
||||
/* exit/enter editmode to get new shape */
|
||||
ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO);
|
||||
ED_object_enter_editmode(C, EM_WAITCURSOR);
|
||||
}
|
||||
|
||||
rna_Object_update_data(C, ptr);
|
||||
}
|
||||
|
||||
static void rna_Object_dependency_update(bContext *C, PointerRNA *ptr)
|
||||
{
|
||||
DAG_id_flush_update(ptr->id.data, OB_RECALC_OB);
|
||||
@ -1657,7 +1672,7 @@ static void rna_def_object(BlenderRNA *brna)
|
||||
RNA_def_property_int_sdna(prop, NULL, "shapenr");
|
||||
RNA_def_property_int_funcs(prop, "rna_Object_active_shape_key_index_get", "rna_Object_active_shape_key_index_set", "rna_Object_active_shape_key_index_range");
|
||||
RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index.");
|
||||
RNA_def_property_update(prop, 0, "rna_Object_update_data");
|
||||
RNA_def_property_update(prop, 0, "rna_Object_active_shape_update");
|
||||
|
||||
RNA_api_object(srna);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user