[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23708] trunk/blender/source/blender: separate material lost all materials for the new mesh

Campbell Barton ideasman42 at gmail.com
Thu Oct 8 11:22:39 CEST 2009


Revision: 23708
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23708
Author:   campbellbarton
Date:     2009-10-08 11:22:39 +0200 (Thu, 08 Oct 2009)

Log Message:
-----------
separate material lost all materials for the new mesh

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_material.h
    trunk/blender/source/blender/blenkernel/intern/material.c
    trunk/blender/source/blender/blenkernel/intern/object.c
    trunk/blender/source/blender/editors/mesh/editmesh.c

Modified: trunk/blender/source/blender/blenkernel/BKE_material.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_material.h	2009-10-08 08:01:51 UTC (rev 23707)
+++ trunk/blender/source/blender/blenkernel/BKE_material.h	2009-10-08 09:22:39 UTC (rev 23708)
@@ -62,8 +62,8 @@
 
 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 */
 

Modified: trunk/blender/source/blender/blenkernel/intern/material.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/material.c	2009-10-08 08:01:51 UTC (rev 23707)
+++ trunk/blender/source/blender/blenkernel/intern/material.c	2009-10-08 09:22:39 UTC (rev 23708)
@@ -630,8 +630,7 @@
 {
 	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 @@
 	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 object_remove_material_slot(Object *ob)
+int object_remove_material_slot(Object *ob)
 {
 	Material *mao, ***matarar;
 	Object *obt;
@@ -898,7 +898,7 @@
 	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 @@
 	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 @@
 		}
 		freedisplist(&ob->disp);
 	}
+
+	return TRUE;
 }
 
 

Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c	2009-10-08 08:01:51 UTC (rev 23707)
+++ trunk/blender/source/blender/blenkernel/intern/object.c	2009-10-08 09:22:39 UTC (rev 23708)
@@ -1233,6 +1233,7 @@
 	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);

Modified: trunk/blender/source/blender/editors/mesh/editmesh.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh.c	2009-10-08 08:01:51 UTC (rev 23707)
+++ trunk/blender/source/blender/editors/mesh/editmesh.c	2009-10-08 09:22:39 UTC (rev 23708)
@@ -1343,6 +1343,7 @@
 	
 	/* 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;





More information about the Bf-blender-cvs mailing list