changes for materials to treat them as shorts not int/chars (since they are stored as shorts intermally)
- converting nurbs to mesh was casting the material to unsigned char. - subsurf was casting to char, then int -> short in a loop. - have material functions take & return shorts.
This commit is contained in:
		@@ -58,6 +58,10 @@ CHECKER_ARGS = [
 | 
			
		||||
    # re-definitions, rna causes most of these
 | 
			
		||||
    "-redef",
 | 
			
		||||
    "-syntax",
 | 
			
		||||
    
 | 
			
		||||
    # dummy, witjout this splint complains with:
 | 
			
		||||
    #  /usr/include/bits/confname.h:31:27: *** Internal Bug at cscannerHelp.c:2428: Unexpanded macro not function or constant: int _PC_MAX_CANON 
 | 
			
		||||
    "-D_PC_MAX_CANON=0",
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -69,19 +69,19 @@ short *give_totcolp(struct Object *ob);
 | 
			
		||||
struct Material ***give_matarar_id(struct ID *id); /* same but for ID's */
 | 
			
		||||
short *give_totcolp_id(struct ID *id);
 | 
			
		||||
 | 
			
		||||
struct Material *give_current_material(struct Object *ob, int act);
 | 
			
		||||
struct ID *material_from(struct Object *ob, int act);
 | 
			
		||||
void assign_material(struct Object *ob, struct Material *ma, int act);
 | 
			
		||||
void assign_matarar(struct Object *ob, struct Material ***matar, int totcol);
 | 
			
		||||
struct Material *give_current_material(struct Object *ob, short act);
 | 
			
		||||
struct ID *material_from(struct Object *ob, short act);
 | 
			
		||||
void assign_material(struct Object *ob, struct Material *ma, short act);
 | 
			
		||||
void assign_matarar(struct Object *ob, struct Material ***matar, short totcol);
 | 
			
		||||
 | 
			
		||||
int find_material_index(struct Object *ob, struct Material *ma);
 | 
			
		||||
short find_material_index(struct Object *ob, struct Material *ma);
 | 
			
		||||
 | 
			
		||||
int object_add_material_slot(struct Object *ob);
 | 
			
		||||
int object_remove_material_slot(struct Object *ob);
 | 
			
		||||
 | 
			
		||||
/* rna api */
 | 
			
		||||
void material_append_id(struct ID *id, struct Material *ma);
 | 
			
		||||
struct Material *material_pop_id(struct ID *id, int index, int remove_material_slot);
 | 
			
		||||
struct Material *material_pop_id(struct ID *id, int index, int remove_material_slot); /* index is an int because of RNA */
 | 
			
		||||
 | 
			
		||||
/* rendering */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -84,7 +84,7 @@ void nurbs_to_mesh(struct Object *ob);
 | 
			
		||||
void mesh_to_curve(struct Scene *scene, struct Object *ob);
 | 
			
		||||
void free_dverts(struct MDeformVert *dvert, int totvert);
 | 
			
		||||
void copy_dverts(struct MDeformVert *dst, struct MDeformVert *src, int totvert); /* __NLA */
 | 
			
		||||
void mesh_delete_material_index(struct Mesh *me, int index);
 | 
			
		||||
void mesh_delete_material_index(struct Mesh *me, short index);
 | 
			
		||||
void mesh_set_smooth_flag(struct Object *meshOb, int enableSmooth);
 | 
			
		||||
 | 
			
		||||
struct BoundBox *mesh_get_bb(struct Object *ob);
 | 
			
		||||
 
 | 
			
		||||
@@ -524,7 +524,7 @@ short *give_totcolp_id(ID *id)
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void data_delete_material_index_id(ID *id, int index)
 | 
			
		||||
static void data_delete_material_index_id(ID *id, short index)
 | 
			
		||||
{
 | 
			
		||||
	switch(GS(id->name)) {
 | 
			
		||||
	case ID_ME:
 | 
			
		||||
@@ -556,8 +556,9 @@ void material_append_id(ID *id, Material *ma)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Material *material_pop_id(ID *id, int index, int remove_material_slot)
 | 
			
		||||
Material *material_pop_id(ID *id, int index_i, int remove_material_slot)
 | 
			
		||||
{
 | 
			
		||||
	short index= (short)index_i;
 | 
			
		||||
	Material *ret= NULL;
 | 
			
		||||
	Material ***matar;
 | 
			
		||||
	if((matar= give_matarar_id(id))) {
 | 
			
		||||
@@ -600,7 +601,7 @@ Material *material_pop_id(ID *id, int index, int remove_material_slot)
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Material *give_current_material(Object *ob, int act)
 | 
			
		||||
Material *give_current_material(Object *ob, short act)
 | 
			
		||||
{
 | 
			
		||||
	Material ***matarar, *ma;
 | 
			
		||||
	short *totcolp;
 | 
			
		||||
@@ -638,7 +639,7 @@ Material *give_current_material(Object *ob, int act)
 | 
			
		||||
	return ma;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ID *material_from(Object *ob, int act)
 | 
			
		||||
ID *material_from(Object *ob, short act)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	if(ob==NULL) return NULL;
 | 
			
		||||
@@ -722,7 +723,7 @@ void test_object_materials(ID *id)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void assign_material(Object *ob, Material *ma, int act)
 | 
			
		||||
void assign_material(Object *ob, Material *ma, short act)
 | 
			
		||||
{
 | 
			
		||||
	Material *mao, **matar, ***matarar;
 | 
			
		||||
	char *matbits;
 | 
			
		||||
@@ -793,9 +794,10 @@ void assign_material(Object *ob, Material *ma, int act)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* XXX - this calls many more update calls per object then are needed, could be optimized */
 | 
			
		||||
void assign_matarar(struct Object *ob, struct Material ***matar, int totcol)
 | 
			
		||||
void assign_matarar(struct Object *ob, struct Material ***matar, short totcol)
 | 
			
		||||
{
 | 
			
		||||
	int i, actcol_orig= ob->actcol;
 | 
			
		||||
	int actcol_orig= ob->actcol;
 | 
			
		||||
	short i;
 | 
			
		||||
 | 
			
		||||
	while(object_remove_material_slot(ob)) {};
 | 
			
		||||
 | 
			
		||||
@@ -810,7 +812,7 @@ void assign_matarar(struct Object *ob, struct Material ***matar, int totcol)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int find_material_index(Object *ob, Material *ma)
 | 
			
		||||
short find_material_index(Object *ob, Material *ma)
 | 
			
		||||
{
 | 
			
		||||
	Material ***matarar;
 | 
			
		||||
	short a, *totcolp;
 | 
			
		||||
@@ -1062,7 +1064,7 @@ int object_remove_material_slot(Object *ob)
 | 
			
		||||
	Material *mao, ***matarar;
 | 
			
		||||
	Object *obt;
 | 
			
		||||
	short *totcolp;
 | 
			
		||||
	int a, actcol;
 | 
			
		||||
	short a, actcol;
 | 
			
		||||
	
 | 
			
		||||
	if(ob==NULL || ob->totcol==0) return FALSE;
 | 
			
		||||
	
 | 
			
		||||
@@ -1600,18 +1602,21 @@ static void calculate_tface_materialname(char *matname, char *newname, int flag)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* returns -1 if no match */
 | 
			
		||||
static int mesh_getmaterialnumber(Mesh *me, Material *ma) {
 | 
			
		||||
	int a;
 | 
			
		||||
static short mesh_getmaterialnumber(Mesh *me, Material *ma)
 | 
			
		||||
{
 | 
			
		||||
	short a;
 | 
			
		||||
 | 
			
		||||
	for (a=0; a<me->totcol; a++)
 | 
			
		||||
		if (me->mat[a] == ma)
 | 
			
		||||
	for (a=0; a<me->totcol; a++) {
 | 
			
		||||
		if (me->mat[a] == ma) {
 | 
			
		||||
			return a;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* append material */
 | 
			
		||||
static int mesh_addmaterial(Mesh *me, Material *ma)
 | 
			
		||||
static short mesh_addmaterial(Mesh *me, Material *ma)
 | 
			
		||||
{
 | 
			
		||||
	material_append_id(&me->id, NULL);
 | 
			
		||||
	me->mat[me->totcol-1]= ma;
 | 
			
		||||
@@ -1633,11 +1638,11 @@ static void set_facetexture_flags(Material *ma, Image *image)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* returns material number */
 | 
			
		||||
static int convert_tfacenomaterial(Main *main, Mesh *me, MTFace *tf, int flag)
 | 
			
		||||
static short convert_tfacenomaterial(Main *main, Mesh *me, MTFace *tf, int flag)
 | 
			
		||||
{
 | 
			
		||||
	Material *ma;
 | 
			
		||||
	char idname[MAX_ID_NAME];
 | 
			
		||||
	int mat_nr= -1;
 | 
			
		||||
	short mat_nr= -1;
 | 
			
		||||
	
 | 
			
		||||
	/* new material, the name uses the flag*/
 | 
			
		||||
	sprintf(idname, "MAMaterial.TF.%0*d", integer_getdigits(flag), flag);
 | 
			
		||||
@@ -1684,7 +1689,8 @@ static void convert_tfacematerial(Main *main, Material *ma)
 | 
			
		||||
	MFace *mf;
 | 
			
		||||
	MTFace *tf;
 | 
			
		||||
	int flag, index;
 | 
			
		||||
	int a, mat_nr;
 | 
			
		||||
	int a;
 | 
			
		||||
	short mat_nr;
 | 
			
		||||
	CustomDataLayer *cdl;
 | 
			
		||||
	char idname[MAX_ID_NAME];
 | 
			
		||||
 | 
			
		||||
@@ -1703,7 +1709,7 @@ static void convert_tfacematerial(Main *main, Material *ma)
 | 
			
		||||
 | 
			
		||||
		/* loop over all the faces and stop at the ones that use the material*/
 | 
			
		||||
		for(a=0, mf=me->mface; a<me->totface; a++, mf++) {
 | 
			
		||||
			if(me->mat[(int)mf->mat_nr] != ma) continue;
 | 
			
		||||
			if(me->mat[mf->mat_nr] != ma) continue;
 | 
			
		||||
 | 
			
		||||
			/* texface data for this face */
 | 
			
		||||
			tf = ((MTFace*)cdl->data) + a;
 | 
			
		||||
@@ -1752,6 +1758,9 @@ static void convert_tfacematerial(Main *main, Material *ma)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define MAT_BGE_DISPUTED -99999
 | 
			
		||||
 | 
			
		||||
int do_version_tface(Main *main, int fileload)
 | 
			
		||||
{
 | 
			
		||||
	Mesh *me;
 | 
			
		||||
@@ -1807,15 +1816,16 @@ int do_version_tface(Main *main, int fileload)
 | 
			
		||||
				flag = encode_tfaceflag(tf, 1);
 | 
			
		||||
				
 | 
			
		||||
				/* create/find a new material and assign to the face */
 | 
			
		||||
				if (check_tfaceneedmaterial(flag))
 | 
			
		||||
				if (check_tfaceneedmaterial(flag)) {
 | 
			
		||||
					mf->mat_nr= convert_tfacenomaterial(main, me, tf, flag);
 | 
			
		||||
					
 | 
			
		||||
			/* else mark them as no-material to be reverted to 0 later */
 | 
			
		||||
				else
 | 
			
		||||
				}
 | 
			
		||||
				/* else mark them as no-material to be reverted to 0 later */
 | 
			
		||||
				else {
 | 
			
		||||
					mf->mat_nr = -1;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			else if(mf->mat_nr < me->totcol) {
 | 
			
		||||
				ma= me->mat[(int)mf->mat_nr];
 | 
			
		||||
				ma= me->mat[mf->mat_nr];
 | 
			
		||||
				
 | 
			
		||||
				/* no material create one if necessary */
 | 
			
		||||
				if(!ma) {
 | 
			
		||||
@@ -1837,7 +1847,7 @@ int do_version_tface(Main *main, int fileload)
 | 
			
		||||
					continue;
 | 
			
		||||
				
 | 
			
		||||
				/* material already marked as disputed */
 | 
			
		||||
				else if(ma->game.flag == -99999)
 | 
			
		||||
				else if(ma->game.flag == MAT_BGE_DISPUTED)
 | 
			
		||||
					continue;
 | 
			
		||||
 | 
			
		||||
				/* found a material */
 | 
			
		||||
@@ -1850,7 +1860,7 @@ int do_version_tface(Main *main, int fileload)
 | 
			
		||||
			
 | 
			
		||||
					/* mark material as disputed */
 | 
			
		||||
					else if (ma->game.flag != -flag) {
 | 
			
		||||
						ma->game.flag = -99999;
 | 
			
		||||
						ma->game.flag = MAT_BGE_DISPUTED;
 | 
			
		||||
						continue;
 | 
			
		||||
					}
 | 
			
		||||
			
 | 
			
		||||
@@ -1882,9 +1892,11 @@ int do_version_tface(Main *main, int fileload)
 | 
			
		||||
						mf->mat_nr= convert_tfacenomaterial(main, me, tf, encode_tfaceflag(tf, 1));
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				for(a=0, mf=me->mface; a<me->totface; a++, mf++)
 | 
			
		||||
			}
 | 
			
		||||
			else {
 | 
			
		||||
				for(a=0, mf=me->mface; a<me->totface; a++, mf++) {
 | 
			
		||||
					mf->mat_nr=0;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@@ -1898,7 +1910,7 @@ int do_version_tface(Main *main, int fileload)
 | 
			
		||||
		if (ma->id.lib) continue;
 | 
			
		||||
 | 
			
		||||
		/* disputed material */
 | 
			
		||||
		if (ma->game.flag == -99999) {
 | 
			
		||||
		if (ma->game.flag == MAT_BGE_DISPUTED) {
 | 
			
		||||
			ma->game.flag = 0;
 | 
			
		||||
			if (fileload) {
 | 
			
		||||
				printf("Warning: material \"%s\" skipped - to convert old game texface to material go to the Help menu.\n", ma->id.name+2);
 | 
			
		||||
@@ -1911,7 +1923,7 @@ int do_version_tface(Main *main, int fileload)
 | 
			
		||||
	
 | 
			
		||||
		/* no conflicts in this material - 90% of cases
 | 
			
		||||
		 * convert from tface system to material */
 | 
			
		||||
		else if (ma->game.flag < 0){
 | 
			
		||||
		else if (ma->game.flag < 0) {
 | 
			
		||||
			decode_tfaceflag(ma, -(ma->game.flag), 1);
 | 
			
		||||
 | 
			
		||||
			/* material is good make sure all faces using
 | 
			
		||||
@@ -1932,8 +1944,7 @@ int do_version_tface(Main *main, int fileload)
 | 
			
		||||
			
 | 
			
		||||
					/* loop over all the faces and stop at the ones that use the material*/
 | 
			
		||||
					for (a=0, mf=me->mface; a<me->totface; a++, mf++) {
 | 
			
		||||
						if (me->mat[(int)mf->mat_nr] != ma) continue;
 | 
			
		||||
						else {
 | 
			
		||||
						if (me->mat[mf->mat_nr] == ma) {
 | 
			
		||||
							/* texface data for this face */
 | 
			
		||||
							tf = ((MTFace*)cdl->data) + a;
 | 
			
		||||
							tf->mode |= TF_CONVERTED;
 | 
			
		||||
 
 | 
			
		||||
@@ -917,7 +917,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
 | 
			
		||||
				mface->v2= startvert+index[2];
 | 
			
		||||
				mface->v3= startvert+index[1];
 | 
			
		||||
				mface->v4= 0;
 | 
			
		||||
				mface->mat_nr= (unsigned char)dl->col;
 | 
			
		||||
				mface->mat_nr= dl->col;
 | 
			
		||||
				test_index_face(mface, NULL, 0, 3);
 | 
			
		||||
 | 
			
		||||
				if(smooth) mface->flag |= ME_SMOOTH;
 | 
			
		||||
@@ -966,7 +966,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
 | 
			
		||||
					mface->v2= p3;
 | 
			
		||||
					mface->v3= p4;
 | 
			
		||||
					mface->v4= p2;
 | 
			
		||||
					mface->mat_nr= (unsigned char)dl->col;
 | 
			
		||||
					mface->mat_nr= dl->col;
 | 
			
		||||
					test_index_face(mface, NULL, 0, 4);
 | 
			
		||||
 | 
			
		||||
					if(smooth) mface->flag |= ME_SMOOTH;
 | 
			
		||||
@@ -1252,7 +1252,7 @@ void mesh_to_curve(Scene *scene, Object *ob)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void mesh_delete_material_index(Mesh *me, int index)
 | 
			
		||||
void mesh_delete_material_index(Mesh *me, short index)
 | 
			
		||||
{
 | 
			
		||||
	MFace *mf;
 | 
			
		||||
	int i;
 | 
			
		||||
 
 | 
			
		||||
@@ -968,8 +968,9 @@ static void ccgDM_copyFinalFaceArray(DerivedMesh *dm, MFace *mface)
 | 
			
		||||
	for(index = 0; index < totface; index++) {
 | 
			
		||||
		CCGFace *f = ccgdm->faceMap[index].face;
 | 
			
		||||
		int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
 | 
			
		||||
		int flag = (faceFlags)? faceFlags[index*2]: ME_SMOOTH;
 | 
			
		||||
		int mat_nr = (faceFlags)? faceFlags[index*2+1]: 0;
 | 
			
		||||
		/* keep types in sync with MFace, avoid many conversions */
 | 
			
		||||
		char flag = (faceFlags)? faceFlags[index*2]: ME_SMOOTH;
 | 
			
		||||
		short mat_nr = (faceFlags)? faceFlags[index*2+1]: 0;
 | 
			
		||||
 | 
			
		||||
		for(S = 0; S < numVerts; S++) {
 | 
			
		||||
			for(y = 0; y < gridSize - 1; y++) {
 | 
			
		||||
 
 | 
			
		||||
@@ -6362,7 +6362,7 @@ static void alphasort_version_246(FileData *fd, Library *lib, Mesh *me)
 | 
			
		||||
	/* if we do, set alpha sort if the game engine did it before */
 | 
			
		||||
	for(a=0, mf=me->mface; a<me->totface; a++, mf++) {
 | 
			
		||||
		if(mf->mat_nr < me->totcol) {
 | 
			
		||||
			ma= newlibadr(fd, lib, me->mat[(int)mf->mat_nr]);
 | 
			
		||||
			ma= newlibadr(fd, lib, me->mat[mf->mat_nr]);
 | 
			
		||||
			texalpha = 0;
 | 
			
		||||
 | 
			
		||||
			/* we can't read from this if it comes from a library,
 | 
			
		||||
 
 | 
			
		||||
@@ -129,7 +129,7 @@ void GeometryExporter::operator()(Object *ob)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// powerful because it handles both cases when there is material and when there's not
 | 
			
		||||
void GeometryExporter::createPolylist(int material_index,
 | 
			
		||||
void GeometryExporter::createPolylist(short material_index,
 | 
			
		||||
					bool has_uvs,
 | 
			
		||||
					bool has_color,
 | 
			
		||||
					Object *ob,
 | 
			
		||||
 
 | 
			
		||||
@@ -67,7 +67,7 @@ public:
 | 
			
		||||
	void operator()(Object *ob);
 | 
			
		||||
 | 
			
		||||
	// powerful because it handles both cases when there is material and when there's not
 | 
			
		||||
	void createPolylist(int material_index,
 | 
			
		||||
	void createPolylist(short material_index,
 | 
			
		||||
						bool has_uvs,
 | 
			
		||||
						bool has_color,
 | 
			
		||||
						Object *ob,
 | 
			
		||||
 
 | 
			
		||||
@@ -778,7 +778,7 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
 | 
			
		||||
								std::map<COLLADAFW::UniqueId, Material*>& uid_material_map,
 | 
			
		||||
								Object *ob, const COLLADAFW::UniqueId *geom_uid, 
 | 
			
		||||
								MTex **color_texture, char *layername, MTFace *texture_face,
 | 
			
		||||
								std::map<Material*, TexIndexTextureArrayMap>& material_texture_mapping_map, int mat_index)
 | 
			
		||||
								std::map<Material*, TexIndexTextureArrayMap>& material_texture_mapping_map, short mat_index)
 | 
			
		||||
{
 | 
			
		||||
	Mesh *me = (Mesh*)ob->data;
 | 
			
		||||
	const COLLADAFW::UniqueId& ma_uid = cmaterial.getReferencedMaterial();
 | 
			
		||||
 
 | 
			
		||||
@@ -141,7 +141,7 @@ public:
 | 
			
		||||
									std::map<COLLADAFW::UniqueId, Material*>& uid_material_map,
 | 
			
		||||
									Object *ob, const COLLADAFW::UniqueId *geom_uid, 
 | 
			
		||||
									MTex **color_texture, char *layername, MTFace *texture_face,
 | 
			
		||||
									std::map<Material*, TexIndexTextureArrayMap>& material_texture_mapping_map, int mat_index);
 | 
			
		||||
									std::map<Material*, TexIndexTextureArrayMap>& material_texture_mapping_map, short mat_index);
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	Object *create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom,
 | 
			
		||||
 
 | 
			
		||||
@@ -217,7 +217,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
 | 
			
		||||
			
 | 
			
		||||
			if(me->totvert) {
 | 
			
		||||
				/* Add this object's materials to the base one's if they don't exist already (but only if limits not exceeded yet) */
 | 
			
		||||
				if(totcol < MAXMAT-1) {
 | 
			
		||||
				if(totcol < MAXMAT) {
 | 
			
		||||
					for(a=1; a<=base->object->totcol; a++) {
 | 
			
		||||
						ma= give_current_material(base->object, a);
 | 
			
		||||
 | 
			
		||||
@@ -231,7 +231,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
 | 
			
		||||
							}
 | 
			
		||||
							totcol++;
 | 
			
		||||
						}
 | 
			
		||||
						if(totcol>=MAXMAT-1) 
 | 
			
		||||
						if(totcol >= MAXMAT)
 | 
			
		||||
							break;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
 
 | 
			
		||||
@@ -557,7 +557,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
 | 
			
		||||
	ddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
 | 
			
		||||
 | 
			
		||||
	for(a=0, mf=mface; a<totface; a++, tface++, mf++) {
 | 
			
		||||
		int matnr= mf->mat_nr;
 | 
			
		||||
		short matnr= mf->mat_nr;
 | 
			
		||||
		int mf_smooth= mf->flag & ME_SMOOTH;
 | 
			
		||||
		Material *mat = me->mat[matnr];
 | 
			
		||||
		int mode= mat->game.flag;
 | 
			
		||||
 
 | 
			
		||||
@@ -205,8 +205,9 @@ typedef struct Material {
 | 
			
		||||
 | 
			
		||||
/* maximum number of materials per material array.
 | 
			
		||||
 * (on object, mesh, lamp, etc.). limited by
 | 
			
		||||
 * short mat_nr in verts, faces. */
 | 
			
		||||
#define MAXMAT			32767
 | 
			
		||||
 * short mat_nr in verts, faces.
 | 
			
		||||
 * -1 becayse for active material we store the index + 1 */
 | 
			
		||||
#define MAXMAT			(32767-1)
 | 
			
		||||
 | 
			
		||||
/* material_type */
 | 
			
		||||
#define MA_TYPE_SURFACE	0
 | 
			
		||||
 
 | 
			
		||||
@@ -296,7 +296,8 @@ static EnumPropertyItem *rna_Curve_fill_mode_itemf(bContext *UNUSED(C), PointerR
 | 
			
		||||
{
 | 
			
		||||
	Curve *cu= (Curve*)ptr->id.data;
 | 
			
		||||
 | 
			
		||||
	return (cu->flag&CU_3D)  ? curve3d_fill_mode_items : curve2d_fill_mode_items;
 | 
			
		||||
	/* cast to quiet warning it IS a const still */
 | 
			
		||||
	return (EnumPropertyItem *)((cu->flag & CU_3D) ? curve3d_fill_mode_items : curve2d_fill_mode_items);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int rna_Nurb_length(PointerRNA *ptr)
 | 
			
		||||
 
 | 
			
		||||
@@ -981,7 +981,7 @@ static void flag_render_node_material(Render *re, bNodeTree *ntree)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Material *give_render_material(Render *re, Object *ob, int nr)
 | 
			
		||||
static Material *give_render_material(Render *re, Object *ob, short nr)
 | 
			
		||||
{
 | 
			
		||||
	extern Material defmaterial;	/* material.c */
 | 
			
		||||
	Material *ma;
 | 
			
		||||
@@ -2688,7 +2688,8 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr,
 | 
			
		||||
	int timeoffset, float *orco, float mat[4][4])
 | 
			
		||||
{
 | 
			
		||||
	Object *ob= obr->ob;
 | 
			
		||||
	int a, a1, end, totvert, vertofs;
 | 
			
		||||
	int a, end, totvert, vertofs;
 | 
			
		||||
	short mat_iter;
 | 
			
		||||
	VertRen *ver;
 | 
			
		||||
	VlakRen *vlr;
 | 
			
		||||
	MVert *mvert = NULL;
 | 
			
		||||
@@ -2718,16 +2719,16 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr,
 | 
			
		||||
 | 
			
		||||
		/* faces in order of color blocks */
 | 
			
		||||
		vertofs= obr->totvert - totvert;
 | 
			
		||||
		for(a1=0; (a1<ob->totcol || (a1==0 && ob->totcol==0)); a1++) {
 | 
			
		||||
		for(mat_iter= 0; (mat_iter < ob->totcol || (mat_iter==0 && ob->totcol==0)); mat_iter++) {
 | 
			
		||||
 | 
			
		||||
			ma= give_render_material(re, ob, a1+1);
 | 
			
		||||
			ma= give_render_material(re, ob, mat_iter+1);
 | 
			
		||||
			end= dm->getNumFaces(dm);
 | 
			
		||||
			mface= dm->getFaceArray(dm);
 | 
			
		||||
 | 
			
		||||
			for(a=0; a<end; a++, mface++) {
 | 
			
		||||
				int v1, v2, v3, v4, flag;
 | 
			
		||||
 | 
			
		||||
				if( mface->mat_nr==a1 ) {
 | 
			
		||||
				if(mface->mat_nr == mat_iter) {
 | 
			
		||||
					float len;
 | 
			
		||||
 | 
			
		||||
					v1= mface->v1;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user