separate material lost all materials for the new mesh

This commit is contained in:
2009-10-08 09:22:39 +00:00
parent 5a7db36b1d
commit 8f154364f2
4 changed files with 15 additions and 9 deletions

View File

@@ -62,8 +62,8 @@ void assign_matarar(struct Object *ob, struct Material ***matar, int totcol);
int find_material_index(struct Object *ob, struct Material *ma);
void object_add_material_slot(struct Object *ob);
void object_remove_material_slot(struct Object *ob);
int object_add_material_slot(struct Object *ob);
int object_remove_material_slot(struct Object *ob);
/* rendering */

View File

@@ -630,8 +630,7 @@ void assign_matarar(struct Object *ob, struct Material ***matar, int totcol)
{
int i, actcol_orig= ob->actcol;
while(ob->totcol)
object_remove_material_slot(ob);
while(object_remove_material_slot(ob)) {};
/* now we have the right number of slots */
for(i=0; i<totcol; i++)
@@ -664,17 +663,18 @@ int find_material_index(Object *ob, Material *ma)
return 0;
}
void object_add_material_slot(Object *ob)
int object_add_material_slot(Object *ob)
{
Material *ma;
if(ob==0) return;
if(ob->totcol>=MAXMAT) return;
if(ob==0) return FALSE;
if(ob->totcol>=MAXMAT) return FALSE;
ma= give_current_material(ob, ob->actcol);
assign_material(ob, ma, ob->totcol+1);
ob->actcol= ob->totcol;
return TRUE;
}
static void do_init_render_material(Material *ma, int r_mode, float *amb)
@@ -889,7 +889,7 @@ void automatname(Material *ma)
}
void object_remove_material_slot(Object *ob)
int object_remove_material_slot(Object *ob)
{
Material *mao, ***matarar;
Object *obt;
@@ -898,7 +898,7 @@ void object_remove_material_slot(Object *ob)
short *totcolp;
int a, actcol;
if(ob==NULL || ob->totcol==0) return;
if(ob==NULL || ob->totcol==0) return FALSE;
/* take a mesh/curve/mball as starting point, remove 1 index,
* AND with all objects that share the ob->data
@@ -909,6 +909,8 @@ void object_remove_material_slot(Object *ob)
totcolp= give_totcolp(ob);
matarar= give_matarar(ob);
if(*matarar==NULL) return FALSE;
/* we delete the actcol */
if(ob->totcol) {
mao= (*matarar)[ob->actcol-1];
@@ -971,6 +973,8 @@ void object_remove_material_slot(Object *ob)
}
freedisplist(&ob->disp);
}
return TRUE;
}

View File

@@ -1233,6 +1233,7 @@ Object *copy_object(Object *ob)
if(ob->totcol) {
obn->mat= MEM_dupallocN(ob->mat);
obn->matbits= MEM_dupallocN(ob->matbits);
obn->totcol= ob->totcol;
}
if(ob->bb) obn->bb= MEM_dupallocN(ob->bb);

View File

@@ -1343,6 +1343,7 @@ static int mesh_separate_selected(Scene *scene, Base *editbase)
/* 2 */
basenew->object->data= menew= add_mesh(me->id.name); /* empty */
assign_matarar(basenew->object, give_matarar(obedit), *give_totcolp(obedit)); /* new in 2.5 */
me->id.us--;
make_editMesh(scene, basenew->object);
emnew= menew->edit_mesh;