- 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.
# 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",
]
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 */
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);
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:
}
}
-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))) {
return ret;
}
-Material *give_current_material(Object *ob, int act)
+Material *give_current_material(Object *ob, short act)
{
Material ***matarar, *ma;
short *totcolp;
return ma;
}
-ID *material_from(Object *ob, int act)
+ID *material_from(Object *ob, short act)
{
if(ob==NULL) return NULL;
}
}
-void assign_material(Object *ob, Material *ma, int act)
+void assign_material(Object *ob, Material *ma, short act)
{
Material *mao, **matar, ***matarar;
char *matbits;
}
/* 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)) {};
}
-int find_material_index(Object *ob, Material *ma)
+short find_material_index(Object *ob, Material *ma)
{
Material ***matarar;
short a, *totcolp;
Material *mao, ***matarar;
Object *obt;
short *totcolp;
- int a, actcol;
+ short a, actcol;
if(ob==NULL || ob->totcol==0) return FALSE;
}
/* 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;
}
/* 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);
MFace *mf;
MTFace *tf;
int flag, index;
- int a, mat_nr;
+ int a;
+ short mat_nr;
CustomDataLayer *cdl;
char idname[MAX_ID_NAME];
/* 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;
}
}
+
+#define MAT_BGE_DISPUTED -99999
+
int do_version_tface(Main *main, int fileload)
{
Mesh *me;
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) {
continue;
/* material already marked as disputed */
- else if(ma->game.flag == -99999)
+ else if(ma->game.flag == MAT_BGE_DISPUTED)
continue;
/* found a material */
/* mark material as disputed */
else if (ma->game.flag != -flag) {
- ma->game.flag = -99999;
+ ma->game.flag = MAT_BGE_DISPUTED;
continue;
}
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;
+ }
}
}
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);
/* 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
/* 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;
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;
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;
}
}
-void mesh_delete_material_index(Mesh *me, int index)
+void mesh_delete_material_index(Mesh *me, short index)
{
MFace *mf;
int i;
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++) {
/* 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,
}
// 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,
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,
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();
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,
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);
}
totcol++;
}
- if(totcol>=MAXMAT-1)
+ if(totcol >= MAXMAT)
break;
}
}
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;
/* 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
{
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)
}
}
-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;
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;
/* 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;