Copy Shape Verts

In mesh editmode, while editing a shape, select some verts, W Key, "Copy Shape Verts". You will be presented with a list of shapes and once chosen, the selected verts will be moved to the position of the verts from the chosen shape. Most handy use would be reverting part of a shape back to basis e.g.

Making eyebrow shapes, add a key and model the eyebrow shape symetrically with the x-mirror tool
Go out of editmode, copy that shape
Go into each shape and revert 1 side to basis

If the mesh has had verts added/removed since last entering editmode, you need to TAB-TAB first before copying
This commit is contained in:
2005-12-21 21:37:11 +00:00
parent dabd52f89d
commit 15766e1612
3 changed files with 87 additions and 1 deletions

View File

@@ -54,6 +54,7 @@ editmesh_tool.c: UI called tools for editmesh, geometry changes here, otherwise
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_view3d_types.h"
#include "DNA_key_types.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
@@ -5348,3 +5349,83 @@ void mesh_rip(void)
Transform();
}
void shape_copy_from(KeyBlock* fromKey)
{
EditMesh *em = G.editMesh;
EditVert *ev = NULL;
for(ev = em->verts.first; ev ; ev = ev->next){
if(ev->f & SELECT){
float *data;
//Check that index is valid in fromKey
//Copy co from fromKey->data
data = fromKey->data;
VECCOPY(ev->co, data+(ev->keyindex*3));
}
}
BIF_undo_push("Copy Blendshape Verts");
return;
}
void shape_copy_select_from()
{
Mesh* me = (Mesh*)G.obedit->data;
EditMesh *em = G.editMesh;
EditVert *ev = NULL;
int totverts = 0;
Key* ky = NULL;
KeyBlock* kb = NULL;
int maxlen=32, nr=0, a=0;
char *menu;
if(me->key){
ky = me->key;
} else {
error("Object Has No Key");
return;
}
if(ky->block.first){
for(kb=ky->block.first;kb;kb = kb->next){
maxlen += 40; // Size of a block name
}
menu = MEM_callocN(maxlen, "Copy Shape Menu Text");
strcpy(menu, "Copy Vert Positions from Shape %t|");
for(kb=ky->block.first;kb;kb = kb->next){
sprintf(menu,"%s %s %cx%d|",menu,kb->name,'%',a);
a++;
}
nr = pupmenu(menu);
MEM_freeN(menu);
} else {
error("Object Has No Blendshapes");
return;
}
a = 0;
for(kb=ky->block.first;kb;kb = kb->next){
if(a == nr){
for(ev = em->verts.first;ev;ev = ev->next){
totverts++;
}
if(me->totvert != totverts){
error("Shape Has had Verts Added/Removed, please cycle editmode before copying");
return;
}
shape_copy_from(kb);
return;
}
a++;
}
return;
}