[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14474] trunk/blender/source/blender: bugfix for [#8256] Creating proxy from linked mesh object removes materials

Campbell Barton ideasman42 at gmail.com
Sat Apr 19 13:23:50 CEST 2008


Revision: 14474
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14474
Author:   campbellbarton
Date:     2008-04-19 13:23:50 +0200 (Sat, 19 Apr 2008)

Log Message:
-----------
bugfix for [#8256] Creating proxy from linked mesh object removes materials

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/object.c
    trunk/blender/source/blender/include/blendef.h
    trunk/blender/source/blender/src/buttons_editing.c
    trunk/blender/source/blender/src/editobject.c

Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c	2008-04-19 02:19:46 UTC (rev 14473)
+++ trunk/blender/source/blender/blenkernel/intern/object.c	2008-04-19 11:23:50 UTC (rev 14474)
@@ -113,6 +113,8 @@
 
 #include "BPY_extern.h"
 
+#include "blendef.h"
+
 /* Local function protos */
 static void solve_parenting (Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul);
 
@@ -1351,11 +1353,29 @@
 	
 	/* skip constraints, constraintchannels, nla? */
 	
-	
+	/* set object type and link to data */
 	ob->type= target->type;
 	ob->data= target->data;
 	id_us_plus((ID *)ob->data);		/* ensures lib data becomes LIB_EXTERN */
 	
+	/* copy material and index information */
+	ob->actcol= ob->totcol= 0;
+	if(ob->mat) MEM_freeN(ob->mat);
+	ob->mat = NULL;
+	if ((target->totcol) && (target->mat) && OB_SUPPORT_MATERIAL(ob)) {
+		int i;
+		ob->colbits = target->colbits;
+		
+		ob->actcol= target->actcol;
+		ob->totcol= target->totcol;
+		
+		ob->mat = MEM_dupallocN(target->mat);
+		for(i=0; i<target->totcol; i++) {
+			/* dont need to run test_object_materials since we know this object is new and not used elsewhere */
+			id_us_plus(ob->mat[i]); 
+		}
+	}
+	
 	/* type conversions */
 	if(target->type == OB_ARMATURE) {
 		copy_object_pose(ob, target);	/* data copy, object pointers in constraints */

Modified: trunk/blender/source/blender/include/blendef.h
===================================================================
--- trunk/blender/source/blender/include/blendef.h	2008-04-19 02:19:46 UTC (rev 14473)
+++ trunk/blender/source/blender/include/blendef.h	2008-04-19 11:23:50 UTC (rev 14474)
@@ -101,6 +101,7 @@
 #define LASTBASE		G.scene->base.last
 #define BASACT			(G.scene->basact)
 #define OBACT			(BASACT? BASACT->object: 0)
+#define OB_SUPPORT_MATERIAL(ob) ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)
 #define ID_NEW(a)		if( (a) && (a)->id.newid ) (a)= (void *)(a)->id.newid
 #define ID_NEW_US(a)	if( (a)->id.newid) {(a)= (void *)(a)->id.newid; (a)->id.us++;}
 #define ID_NEW_US2(a)	if( ((ID *)a)->newid) {(a)= ((ID *)a)->newid; ((ID *)a)->us++;}

Modified: trunk/blender/source/blender/src/buttons_editing.c
===================================================================
--- trunk/blender/source/blender/src/buttons_editing.c	2008-04-19 02:19:46 UTC (rev 14473)
+++ trunk/blender/source/blender/src/buttons_editing.c	2008-04-19 11:23:50 UTC (rev 14474)
@@ -5414,8 +5414,7 @@
 	}
 	
 	/* now only objects that can be visible rendered */
-	if ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL);
-	else return;
+	if (!OB_SUPPORT_MATERIAL(ob)) return;
 	
 	uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
 	give_obdata_texspace(ob, &poin, NULL, NULL, NULL);

Modified: trunk/blender/source/blender/src/editobject.c
===================================================================
--- trunk/blender/source/blender/src/editobject.c	2008-04-19 02:19:46 UTC (rev 14473)
+++ trunk/blender/source/blender/src/editobject.c	2008-04-19 11:23:50 UTC (rev 14474)
@@ -3675,7 +3675,7 @@
 	strcat (str, "|Object Constraints%x22");
 	strcat (str, "|NLA Strips%x26");
 	
-	if ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL) {
+	if (OB_SUPPORT_MATERIAL(ob)) {
 		strcat(str, "|Texture Space%x17");
 	}	
 	





More information about the Bf-blender-cvs mailing list