->Commit of patch #5132: Separate by material

This patch adds a new option to the separate menu in editmode, 'By Material'.
It simply loops through all materials in the mesh selects the faces associated
with them and calls separate().

Thanks to Andrea Weikert for the patch!
This commit is contained in:
Geoffrey Bantle 2006-11-07 00:34:48 +00:00
parent 2ef6c48a65
commit e144a05114
2 changed files with 35 additions and 1 deletions

@ -63,6 +63,7 @@ extern void undo_push_mesh(char *name);
extern void separatemenu(void);
extern void separate_mesh(void);
extern void separate_mesh_loose(void);
extern void separate_material(void);
/* ******************* editmesh_add.c */
extern void make_prim(int type, float imat[3][3], short tot, short seg,

@ -1382,7 +1382,7 @@ void separatemenu(void)
if(G.editMesh->verts.first==NULL) return;
event = pupmenu("Separate %t|Selected%x1|All Loose Parts%x2");
event = pupmenu("Separate %t|Selected%x1|All Loose Parts%x2|By Material%x3");
if (event==0) return;
waitcursor(1);
@ -1394,10 +1394,43 @@ void separatemenu(void)
case 2:
separate_mesh_loose();
break;
case 3:
separate_material();
break;
}
waitcursor(0);
}
void separate_material(void)
{
EditMesh *em = G.editMesh;
unsigned char curr_mat;
Mesh *me;
me= get_mesh(G.obedit);
if(me->key) {
error("Can't separate with vertex keys");
return;
}
if(G.obedit && em) {
if(G.obedit->type == OB_MESH) {
for (curr_mat = 1; curr_mat < G.obedit->totcol; ++curr_mat) {
/* clear selection, we're going to use that to select material group */
EM_clear_flag_all(SELECT);
/* select the material */
editmesh_select_by_material(curr_mat);
/* and now separate */
separate_mesh();
}
}
}
countall();
allqueue(REDRAWVIEW3D, 0);
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
}
void separate_mesh(void)
{