diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-10-22 20:35:51 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-10-22 20:35:51 +0400 |
commit | 3ffb695b10bd85f7cd431f6144dbc2c427a365ee (patch) | |
tree | 008509058f8da92056c567e50951d48438a35c82 /source/blender/editors | |
parent | b06640c583ed9900223855004d8e9cd6947adf21 (diff) |
Shape Keys
Blended shape keys can now be displayed & edited in edit mode. This
is much like showing an armature modifier in edit mode, and shape keys
now are a applied as a virtual modifier (for mesh & lattice only, curve
doesn't fit in the stack well due to tilt).
The main thing missing still is being able to switch between the active
shape key in edit mode, that's more complicated.. but the weights of
other shapes can be edited while in edit mode.
One thing to be careful about is that this does automatic crazyspace
correction, which means that if you edit a shape key with a low value,
the actual vertices will be moved to correct for that and actually move
a (potentially much) longer distance.
Also includes some UI tweaks, mainly placing some buttons horizontally
since the vertical list was getting too long.
Diffstat (limited to 'source/blender/editors')
4 files changed, 46 insertions, 26 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 10449a1133e..41a0ad7d4b0 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1503,11 +1503,11 @@ static void ui_litem_layout_row(uiLayout *litem) /* align right/center */ offset= 0; if(litem->alignment == UI_LAYOUT_ALIGN_RIGHT) { - if(fixedw == 0 && freew < w-fixedw) + if(freew > 0 && freew < w-fixedw) offset= (w - fixedw) - freew; } else if(litem->alignment == UI_LAYOUT_ALIGN_CENTER) { - if(fixedw == 0 && freew < w-fixedw) + if(freew > 0 && freew < w-fixedw) offset= ((w - fixedw) - freew)/2; } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 960574ae8a9..75ae475435a 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -506,7 +506,7 @@ static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v) { Object *ob = ob_v; ModifierData *md= md_v; - int i, cageIndex = modifiers_getCageIndex(ob, NULL ); + int i, cageIndex = modifiers_getCageIndex(ob, NULL, 0); /* undo button operation */ md->mode ^= eModifierMode_OnCage; @@ -715,7 +715,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, PointerRNA *ptr) uiBlockSetButLock(uiLayoutGetBlock(layout), (ob && ob->id.lib), ERROR_LIBDATA_MESSAGE); /* find modifier and draw it */ - cageIndex = modifiers_getCageIndex(ob, &lastCageIndex); + cageIndex = modifiers_getCageIndex(ob, &lastCageIndex, 0); // XXX virtual modifiers are not accesible for python vmd = modifiers_getVirtualModifierList(ob); @@ -1955,13 +1955,30 @@ static int list_item_icon_get(bContext *C, PointerRNA *itemptr, int rnaicon) return rnaicon; } -static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *itemptr, int i, int rnaicon) +static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *itemptr, int i, int rnaicon, PointerRNA *activeptr, char *activepropname) { + Object *ob; uiBlock *block= uiLayoutGetBlock(layout); - uiLayout *split; + uiBut *but; + uiLayout *split, *overlap, *sub; char *name, *namebuf; int icon; + overlap= uiLayoutOverlap(layout); + + /* list item behind label & other buttons */ + sub= uiLayoutRow(overlap, 0); + + if(itemptr->type == &RNA_ShapeKey) { + ob= (Object*)activeptr->data; + uiLayoutSetEnabled(sub, ob->mode != OB_MODE_EDIT); + } + + but= uiDefButR(block, LISTROW, 0, "", 0,0, UI_UNIT_X*10,UI_UNIT_Y, activeptr, activepropname, 0, 0, i, 0, 0, ""); + uiButSetFlag(but, UI_BUT_NO_TOOLTIP); + + sub= uiLayoutRow(overlap, 0); + /* retrieve icon and name */ icon= list_item_icon_get(C, itemptr, rnaicon); if(!icon || icon == ICON_DOT) @@ -1974,24 +1991,28 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe uiBlockSetEmboss(block, UI_EMBOSSN); if(itemptr->type == &RNA_MeshTextureFaceLayer || itemptr->type == &RNA_MeshColorLayer) { - uiItemL(layout, name, icon); + uiItemL(sub, name, icon); uiDefIconButR(block, TOG, 0, ICON_SCENE, 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "active_render", 0, 0, 0, 0, 0, NULL); } else if(itemptr->type == &RNA_MaterialTextureSlot) { - uiItemL(layout, name, icon); + uiItemL(sub, name, icon); uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, ptr, "use_textures", i, 0, 0, 0, 0, NULL); } else if(itemptr->type == &RNA_ShapeKey) { - split= uiLayoutSplit(layout, 0.75f); + ob= (Object*)activeptr->data; + + split= uiLayoutSplit(sub, 0.75f); 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); } else - uiItemL(layout, name, icon); + uiItemL(sub, name, icon); uiBlockSetEmboss(block, UI_EMBOSS); @@ -2006,7 +2027,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propna PropertyRNA *prop= NULL, *activeprop; PropertyType type, activetype; StructRNA *ptype; - uiLayout *box, *row, *col, *subrow, *overlap; + uiLayout *box, *row, *col; uiBlock *block; uiBut *but; Panel *pa; @@ -2151,16 +2172,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propna if(ptr->data && prop) { /* create list items */ RNA_PROP_BEGIN(ptr, itemptr, prop) { - if(i >= pa->list_scroll && i<pa->list_scroll+items) { - overlap= uiLayoutOverlap(col); - - subrow= uiLayoutRow(overlap, 0); - but= uiDefButR(block, LISTROW, 0, "", 0,0, UI_UNIT_X*10,UI_UNIT_Y, activeptr, activepropname, 0, 0, i, 0, 0, ""); - uiButSetFlag(but, UI_BUT_NO_TOOLTIP); - - subrow= uiLayoutRow(overlap, 0); - list_item_row(C, subrow, ptr, &itemptr, i, rnaicon); - } + if(i >= pa->list_scroll && i<pa->list_scroll+items) + list_item_row(C, col, ptr, &itemptr, i, rnaicon, activeptr, activepropname); i++; } diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 5f3d73ec348..4d4dd7a0738 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -544,6 +544,13 @@ static int ED_object_shape_key_mirror(bContext *C, Scene *scene, Object *ob) /********************** shape key operators *********************/ +static int shape_key_mode_poll(bContext *C) +{ + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + ID *data= (ob)? ob->data: NULL; + return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT); +} + static int shape_key_poll(bContext *C) { Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; @@ -569,7 +576,7 @@ void OBJECT_OT_shape_key_add(wmOperatorType *ot) ot->idname= "OBJECT_OT_shape_key_add"; /* api callbacks */ - ot->poll= shape_key_poll; + ot->poll= shape_key_mode_poll; ot->exec= shape_key_add_exec; /* flags */ @@ -594,7 +601,7 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot) ot->idname= "OBJECT_OT_shape_key_remove"; /* api callbacks */ - ot->poll= shape_key_poll; + ot->poll= shape_key_mode_poll; ot->exec= shape_key_remove_exec; /* flags */ @@ -652,7 +659,7 @@ void OBJECT_OT_shape_key_mirror(wmOperatorType *ot) ot->idname= "OBJECT_OT_shape_key_mirror"; /* api callbacks */ - ot->poll= shape_key_poll; + ot->poll= shape_key_mode_poll; ot->exec= shape_key_mirror_exec; /* flags */ @@ -710,7 +717,7 @@ void OBJECT_OT_shape_key_move(wmOperatorType *ot) ot->idname= "OBJECT_OT_shape_key_move"; /* api callbacks */ - ot->poll= shape_key_poll; + ot->poll= shape_key_mode_poll; ot->exec= shape_key_move_exec; /* flags */ diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index cdfdcaffb0d..cefb7741658 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2199,7 +2199,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t) /* detect CrazySpace [tm] */ if(propmode==0) { - if(modifiers_getCageIndex(t->obedit, NULL)>=0) { + if(modifiers_getCageIndex(t->obedit, NULL, 1)>=0) { if(modifiers_isDeformed(t->scene, t->obedit)) { /* check if we can use deform matrices for modifier from the start up to stack, they are more accurate than quats */ |