Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/material.c')
-rw-r--r--source/blender/blenkernel/intern/material.c58
1 files changed, 51 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index f5df6efd622..ed9be989dbd 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -1,7 +1,4 @@
-
-/* material.c
- *
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -193,7 +190,7 @@ void init_material(Material *ma)
ma->vol.ms_diff = 1.f;
ma->vol.ms_intensity = 1.f;
- ma->game.flag=0;
+ ma->game.flag = GEMAT_BACKCULL;
ma->game.alpha_blend=0;
ma->game.face_orientation=0;
@@ -723,6 +720,48 @@ void test_object_materials(ID *id)
}
}
+void assign_material_id(ID *id, Material *ma, short act)
+{
+ Material *mao, **matar, ***matarar;
+ short *totcolp;
+
+ if(act>MAXMAT) return;
+ if(act<1) act= 1;
+
+ /* prevent crashing when using accidentally */
+ BLI_assert(id->lib == NULL);
+ if(id->lib) return;
+
+ /* test arraylens */
+
+ totcolp= give_totcolp_id(id);
+ matarar= give_matarar_id(id);
+
+ if(totcolp==NULL || matarar==NULL) return;
+
+ if(act > *totcolp) {
+ matar= MEM_callocN(sizeof(void *)*act, "matarray1");
+
+ if(*totcolp) {
+ memcpy(matar, *matarar, sizeof(void *)*(*totcolp));
+ MEM_freeN(*matarar);
+ }
+
+ *matarar= matar;
+ *totcolp= act;
+ }
+
+ /* in data */
+ mao= (*matarar)[act-1];
+ if(mao) mao->id.us--;
+ (*matarar)[act-1]= ma;
+
+ if(ma)
+ id_us_plus((ID *)ma);
+
+ test_object_materials(id);
+}
+
void assign_material(Object *ob, Material *ma, short act)
{
Material *mao, **matar, ***matarar;
@@ -1283,7 +1322,7 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, const float c
*g=1.0f;
else
*g = tmp;
-
+
tmp = facm + fac*col[2];
if(tmp <= 0.0f)
*b = 0.0f;
@@ -1772,7 +1811,7 @@ int do_version_tface(Main *main, int fileload)
int flag;
int index;
- /* sometimes mesh has no materials but will need a new one. In those
+ /* sometimes mesh has no materials but will need a new one. In those
* cases we need to ignore the mf->mat_nr and only look at the face
* mode because it can be zero as uninitialized or the 1st created material
*/
@@ -1953,6 +1992,11 @@ int do_version_tface(Main *main, int fileload)
}
}
}
+ /* material is not used by faces with texface
+ * set the default flag - do it only once */
+ else
+ if (fileload)
+ ma->game.flag = GEMAT_BACKCULL;
}
return nowarning;