Special bf-committers request; Lamp/World/Material now each have 10
authorTon Roosendaal <ton@blender.org>
Sat, 4 Dec 2004 21:49:02 +0000 (21:49 +0000)
committerTon Roosendaal <ton@blender.org>
Sat, 4 Dec 2004 21:49:02 +0000 (21:49 +0000)
channels to link texture to.

The amount of code changes seems large, but is mostly getting rind of
hardcoded values (6 and 8) for channels, replacing it with MAX_MTEX.

Further did some fixes;
- Ipo for Lamp showed too many mapping channels
- Texture MapTo buttons for lamp missed the slider to blend texture color
- Lamp texture mapping "View" only worked for Spot, now it uses lamp-
  view vector for all types. (Nice for projections!)

23 files changed:
source/blender/blenkernel/intern/ipo.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/texture.c
source/blender/blenkernel/intern/world.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/makesdna/DNA_ipo_types.h
source/blender/makesdna/DNA_lamp_types.h
source/blender/makesdna/DNA_material_types.h
source/blender/makesdna/DNA_world_types.h
source/blender/python/api2_2x/Material.c
source/blender/render/extern/include/render_types.h
source/blender/render/intern/source/texture.c
source/blender/renderconverter/intern/convertBlenderScene.c
source/blender/src/buttons_shading.c
source/blender/src/editipo.c
source/blender/src/editobject.c
source/blender/src/header_buttonswin.c
source/blender/src/header_ipo.c
source/blender/src/oops.c
source/blender/src/outliner.c
source/blender/src/previewrender.c

index 9476cd1aab7405e859101604dd2cb8097cb2bfb2..06197bc99c52575421455e878c6969458b67b247 100644 (file)
@@ -165,7 +165,7 @@ int la_ar[LA_TOTIPO]= {
        MA_MAP1+MAP_OFS_X, MA_MAP1+MAP_OFS_Y, MA_MAP1+MAP_OFS_Z, 
        MA_MAP1+MAP_SIZE_X, MA_MAP1+MAP_SIZE_Y, MA_MAP1+MAP_SIZE_Z, 
        MA_MAP1+MAP_R, MA_MAP1+MAP_G, MA_MAP1+MAP_B,
-       MA_MAP1+MAP_DVAR, MA_MAP1+MAP_COLF, MA_MAP1+MAP_NORF, MA_MAP1+MAP_VARF
+       MA_MAP1+MAP_DVAR, MA_MAP1+MAP_COLF
 };
 
 /* yafray: aperture & focal distance curves added */
@@ -1172,6 +1172,8 @@ void *get_ipo_poin(ID *id, IpoCurve *icu, int *type)
                        else if(icu->adrcode & MA_MAP6) mtex= ma->mtex[5];
                        else if(icu->adrcode & MA_MAP7) mtex= ma->mtex[6];
                        else if(icu->adrcode & MA_MAP8) mtex= ma->mtex[7];
+                       else if(icu->adrcode & MA_MAP9) mtex= ma->mtex[8];
+                       else if(icu->adrcode & MA_MAP10) mtex= ma->mtex[9];
                        
                        if(mtex) {
                                poin= give_mtex_poin(mtex, icu->adrcode & (MA_MAP1-1) );
@@ -1254,6 +1256,8 @@ void *get_ipo_poin(ID *id, IpoCurve *icu, int *type)
                        else if(icu->adrcode & MA_MAP6) mtex= wo->mtex[5];
                        else if(icu->adrcode & MA_MAP7) mtex= wo->mtex[6];
                        else if(icu->adrcode & MA_MAP8) mtex= wo->mtex[7];
+                       else if(icu->adrcode & MA_MAP9) mtex= wo->mtex[8];
+                       else if(icu->adrcode & MA_MAP10) mtex= wo->mtex[9];
                        
                        if(mtex) {
                                poin= give_mtex_poin(mtex, icu->adrcode & (MA_MAP1-1) );
@@ -1297,6 +1301,8 @@ void *get_ipo_poin(ID *id, IpoCurve *icu, int *type)
                        else if(icu->adrcode & MA_MAP6) mtex= la->mtex[5];
                        else if(icu->adrcode & MA_MAP7) mtex= la->mtex[6];
                        else if(icu->adrcode & MA_MAP8) mtex= la->mtex[7];
+                       else if(icu->adrcode & MA_MAP9) mtex= la->mtex[8];
+                       else if(icu->adrcode & MA_MAP10) mtex= la->mtex[9];
                        
                        if(mtex) {
                                poin= give_mtex_poin(mtex, icu->adrcode & (MA_MAP1-1) );
index be99b7b8d98554bf2f2630b4bffef822bff846a6..71e19c040c50d27c05e4a8a3c083bd6fb84a12f8 100644 (file)
@@ -73,7 +73,7 @@ void free_material(Material *ma)
        if(ma->ren) MEM_freeN(ma->ren);
        ma->ren= NULL;
        
-       for(a=0; a<8; a++) {
+       for(a=0; a<MAX_MTEX; a++) {
                mtex= ma->mtex[a];
                if(mtex && mtex->tex) mtex->tex->id.us--;
                if(mtex) MEM_freeN(mtex);
@@ -143,7 +143,7 @@ Material *copy_material(Material *ma)
        
        id_us_plus((ID *)man->ipo);
        
-       for(a=0; a<8; a++) {
+       for(a=0; a<MAX_MTEX; a++) {
                if(ma->mtex[a]) {
                        man->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial");
                        memcpy(man->mtex[a], ma->mtex[a], sizeof(MTex));
@@ -177,7 +177,7 @@ void make_local_material(Material *ma)
                ma->id.lib= 0;
                ma->id.flag= LIB_LOCAL;
                new_id(0, (ID *)ma, 0);
-               for(a=0; a<8; a++) {
+               for(a=0; a<MAX_MTEX; a++) {
                        if(ma->mtex[a]) id_lib_extern((ID *)ma->mtex[a]->tex);
                }
                
@@ -241,7 +241,7 @@ void make_local_material(Material *ma)
                ma->id.lib= 0;
                ma->id.flag= LIB_LOCAL;
                
-               for(a=0; a<8; a++) {
+               for(a=0; a<MAX_MTEX; a++) {
                        if(ma->mtex[a]) id_lib_extern((ID *)ma->mtex[a]->tex);
                }
                
@@ -554,7 +554,7 @@ void init_render_material(Material *ma)
        ma= ma->ren;
        ma->texco= 0;
        ma->mapto= 0;
-       for(a=0; a<8; a++) {
+       for(a=0; a<MAX_MTEX; a++) {
                mtex= ma->mtex[a];
                if(mtex && mtex->tex) {
                        
index 0d2f216e24e80f58202e0f99e183486ae1396291..2dc8b67a5409c988fc26752e42282b7fc748e182 100644 (file)
@@ -287,7 +287,7 @@ void unlink_object(Object *ob)
        mat= G.main->mat.first;
        while(mat) {
        
-               for(a=0; a<8; a++) {
+               for(a=0; a<MAX_MTEX; a++) {
                        if(mat->mtex[a] && ob==mat->mtex[a]->object) {
                                /* actually, test for lib here... to do */
                                mat->mtex[a]->object= 0;
@@ -316,7 +316,7 @@ void unlink_object(Object *ob)
        wrld= G.main->world.first;
        while(wrld) {
                if(wrld->id.lib==0) {
-                       for(a=0; a<6; a++) {
+                       for(a=0; a<MAX_MTEX; a++) {
                                if(wrld->mtex[a] && ob==wrld->mtex[a]->object)
                                        wrld->mtex[a]->object =0;
                        }
@@ -519,7 +519,7 @@ Lamp *copy_lamp(Lamp *la)
        
        lan= copy_libblock(la);
 
-       for(a=0; a<8; a++) {
+       for(a=0; a<MAX_MTEX; a++) {
                if(lan->mtex[a]) {
                        lan->mtex[a]= MEM_mallocN(sizeof(MTex), "copylamptex");
                        memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
@@ -600,7 +600,7 @@ void free_lamp(Lamp *la)
                
        BPY_free_scriptlink(&la->scriptlink);
        
-       for(a=0; a<8; a++) {
+       for(a=0; a<MAX_MTEX; a++) {
                mtex= la->mtex[a];
                if(mtex && mtex->tex) mtex->tex->id.us--;
                if(mtex) MEM_freeN(mtex);
index 95168c4c0168e40cba971423d14b7cc0ab48ddbf..a0a7c1785216fb237fa9c86b752260694b1eb8e9 100644 (file)
@@ -493,7 +493,7 @@ void make_local_texture(Tex *tex)
        
        ma= G.main->mat.first;
        while(ma) {
-               for(a=0; a<8; a++) {
+               for(a=0; a<MAX_MTEX; a++) {
                        if(ma->mtex[a] && ma->mtex[a]->tex==tex) {
                                if(ma->id.lib) lib= 1;
                                else local= 1;
@@ -503,7 +503,7 @@ void make_local_texture(Tex *tex)
        }
        la= G.main->lamp.first;
        while(la) {
-               for(a=0; a<8; a++) {
+               for(a=0; a<MAX_MTEX; a++) {
                        if(la->mtex[a] && la->mtex[a]->tex==tex) {
                                if(la->id.lib) lib= 1;
                                else local= 1;
@@ -513,7 +513,7 @@ void make_local_texture(Tex *tex)
        }
        wrld= G.main->world.first;
        while(wrld) {
-               for(a=0; a<8; a++) {
+               for(a=0; a<MAX_MTEX; a++) {
                        if(wrld->mtex[a] && wrld->mtex[a]->tex==tex) {
                                if(wrld->id.lib) lib= 1;
                                else local= 1;
@@ -533,7 +533,7 @@ void make_local_texture(Tex *tex)
                
                ma= G.main->mat.first;
                while(ma) {
-                       for(a=0; a<8; a++) {
+                       for(a=0; a<MAX_MTEX; a++) {
                                if(ma->mtex[a] && ma->mtex[a]->tex==tex) {
                                        if(ma->id.lib==0) {
                                                ma->mtex[a]->tex= texn;
@@ -546,7 +546,7 @@ void make_local_texture(Tex *tex)
                }
                la= G.main->lamp.first;
                while(la) {
-                       for(a=0; a<8; a++) {
+                       for(a=0; a<MAX_MTEX; a++) {
                                if(la->mtex[a] && la->mtex[a]->tex==tex) {
                                        if(la->id.lib==0) {
                                                la->mtex[a]->tex= texn;
@@ -559,7 +559,7 @@ void make_local_texture(Tex *tex)
                }
                wrld= G.main->world.first;
                while(wrld) {
-                       for(a=0; a<8; a++) {
+                       for(a=0; a<MAX_MTEX; a++) {
                                if(wrld->mtex[a] && wrld->mtex[a]->tex==tex) {
                                        if(wrld->id.lib==0) {
                                                wrld->mtex[a]->tex= texn;
index 2f5b440a33add043b8c47b078aeff43c8e032d0d..9676f08ee781c1ebae9e975406f0975c80204f63 100644 (file)
@@ -69,7 +69,7 @@ void free_world(World *wrld)
        
        BPY_free_scriptlink(&wrld->scriptlink);
        
-       for(a=0; a<8; a++) {
+       for(a=0; a<MAX_MTEX; a++) {
                mtex= wrld->mtex[a];
                if(mtex && mtex->tex) mtex->tex->id.us--;
                if(mtex) MEM_freeN(mtex);
@@ -110,7 +110,7 @@ World *copy_world(World *wrld)
        
        wrldn= copy_libblock(wrld);
        
-       for(a=0; a<8; a++) {
+       for(a=0; a<MAX_MTEX; a++) {
                if(wrld->mtex[a]) {
                        wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial");
                        memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex));
@@ -196,7 +196,8 @@ void init_render_world()
                Normalise(R.grvec);
                Mat3CpyMat4(R.imat, R.viewinv);
                
-               for(a=0; a<6; a++) if(R.wrld.mtex[a] && R.wrld.mtex[a]->tex) R.wrld.skytype |= WO_SKYTEX;
+               for(a=0; a<MAX_MTEX; a++) 
+                       if(R.wrld.mtex[a] && R.wrld.mtex[a]->tex) R.wrld.skytype |= WO_SKYTEX;
                
                if(G.scene->camera && G.scene->camera->type==OB_CAMERA) {
                        Camera *cam= G.scene->camera->data;
index 18c70b0586bc1e4c55822d65e48afd2b1da0cf6b..3c87de94b5f066c1c59d318812bb300fb4ff1b83 100644 (file)
@@ -1542,7 +1542,7 @@ static void lib_link_lamp(FileData *fd, Main *main)
        while(la) {
                if(la->id.flag & LIB_NEEDLINK) {
 
-                       for(a=0; a<8; a++) {
+                       for(a=0; a<MAX_MTEX; a++) {
                                mtex= la->mtex[a];
                                if(mtex) {
                                        mtex->tex= newlibadr_us(fd, la->id.lib, mtex->tex);
@@ -1566,7 +1566,7 @@ static void direct_link_lamp(FileData *fd, Lamp *la)
 
        direct_link_scriptlink(fd, &la->scriptlink);
 
-       for(a=0; a<8; a++) {
+       for(a=0; a<MAX_MTEX; a++) {
                la->mtex[a]= newdataadr(fd, la->mtex[a]);
        }
 }
@@ -1691,7 +1691,7 @@ static void lib_link_world(FileData *fd, Main *main)
 
                        wrld->ipo= newlibadr_us(fd, wrld->id.lib, wrld->ipo);
 
-                       for(a=0; a<8; a++) {
+                       for(a=0; a<MAX_MTEX; a++) {
                                mtex= wrld->mtex[a];
                                if(mtex) {
                                        mtex->tex= newlibadr_us(fd, wrld->id.lib, mtex->tex);
@@ -1713,7 +1713,7 @@ static void direct_link_world(FileData *fd, World *wrld)
 
        direct_link_scriptlink(fd, &wrld->scriptlink);
 
-       for(a=0; a<8; a++) {
+       for(a=0; a<MAX_MTEX; a++) {
                wrld->mtex[a]= newdataadr(fd, wrld->mtex[a]);
        }
 }
@@ -1985,7 +1985,7 @@ static void lib_link_material(FileData *fd, Main *main)
 
                        ma->ipo= newlibadr_us(fd, ma->id.lib, ma->ipo);
 
-                       for(a=0; a<8; a++) {
+                       for(a=0; a<MAX_MTEX; a++) {
                                mtex= ma->mtex[a];
                                if(mtex) {
                                        mtex->tex= newlibadr_us(fd, ma->id.lib, mtex->tex);
@@ -2005,7 +2005,7 @@ static void direct_link_material(FileData *fd, Material *ma)
 
        direct_link_scriptlink(fd, &ma->scriptlink);
 
-       for(a=0; a<8; a++) {
+       for(a=0; a<MAX_MTEX; a++) {
                ma->mtex[a]= newdataadr(fd, ma->mtex[a]);
        }
 
@@ -4805,7 +4805,7 @@ static void expand_material(FileData *fd, Main *mainvar, Material *ma)
 {
        int a;
 
-       for(a=0; a<8; a++) {
+       for(a=0; a<MAX_MTEX; a++) {
                if(ma->mtex[a]) {
                        expand_doit(fd, mainvar, ma->mtex[a]->tex);
                        expand_doit(fd, mainvar, ma->mtex[a]->object);
@@ -4818,7 +4818,7 @@ static void expand_lamp(FileData *fd, Main *mainvar, Lamp *la)
 {
        int a;
 
-       for(a=0; a<8; a++) {
+       for(a=0; a<MAX_MTEX; a++) {
                if(la->mtex[a]) {
                        expand_doit(fd, mainvar, la->mtex[a]->tex);
                        expand_doit(fd, mainvar, la->mtex[a]->object);
@@ -4838,7 +4838,7 @@ static void expand_world(FileData *fd, Main *mainvar, World *wrld)
 {
        int a;
 
-       for(a=0; a<8; a++) {
+       for(a=0; a<MAX_MTEX; a++) {
                if(wrld->mtex[a]) {
                        expand_doit(fd, mainvar, wrld->mtex[a]->tex);
                        expand_doit(fd, mainvar, wrld->mtex[a]->object);
index 4a2dfd4889bc70d1fc5b5df9eebe44f9d66a6c65..a325749dedec9b4f60c7e9457eb2fd3bc3375234 100644 (file)
@@ -960,7 +960,7 @@ static void write_materials(WriteData *wd, ListBase *idbase)
                        /* write LibData */
                        writestruct(wd, ID_MA, "Material", 1, ma);
 
-                       for(a=0; a<8; a++) {
+                       for(a=0; a<MAX_MTEX; a++) {
                                if(ma->mtex[a]) writestruct(wd, DATA, "MTex", 1, ma->mtex[a]);
                        }
                        
@@ -984,7 +984,7 @@ static void write_worlds(WriteData *wd, ListBase *idbase)
                        /* write LibData */
                        writestruct(wd, ID_WO, "World", 1, wrld);
 
-                       for(a=0; a<8; a++) {
+                       for(a=0; a<MAX_MTEX; a++) {
                                if(wrld->mtex[a]) writestruct(wd, DATA, "MTex", 1, wrld->mtex[a]);
                        }
 
@@ -1006,7 +1006,7 @@ static void write_lamps(WriteData *wd, ListBase *idbase)
                        writestruct(wd, ID_LA, "Lamp", 1, la);
 
                        /* direct data */
-                       for(a=0; a<8; a++) {
+                       for(a=0; a<MAX_MTEX; a++) {
                                if(la->mtex[a]) writestruct(wd, DATA, "MTex", 1, la->mtex[a]);
                        }
 
index 8363fa0481added56ed4c2d52c746f2f3e015849..206c531d77f37c849c9ce4b0ed46a14323b245c1 100644 (file)
@@ -153,6 +153,8 @@ typedef short IPO_Channel;
 #define MA_MAP6                0x400
 #define MA_MAP7                0x800
 #define MA_MAP8                0x1000
+#define MA_MAP9                0x2000
+#define MA_MAP10       0x4000
 
 #define TEX_TOTNAM     14
 
@@ -252,7 +254,7 @@ typedef short IPO_Channel;
 
 /* ******************** */
 
-#define LA_TOTIPO      23
+#define LA_TOTIPO      21
 #define LA_TOTNAM      10
 
 #define LA_ENERGY      1
index 4c8811e1d5294d3b22d0036923cfc4a97e3c83ef..96aaf66f2eb1ed4aaba528897361d0977b54ac36 100644 (file)
 #include "DNA_ID.h"
 #include "DNA_scriptlink_types.h"
 
+#ifndef MAX_MTEX
+#define MAX_MTEX       10
+#endif
+
 struct MTex;
 struct Ipo;
 
@@ -68,7 +72,7 @@ typedef struct Lamp {
        short YF_phdepth, YF_useqmc, YF_bufsize, YF_pad;
        float YF_causticblur, YF_ltradius;
        
-       struct MTex *mtex[8];
+       struct MTex *mtex[10];
        struct Ipo *ipo;
        
        ScriptLink scriptlink;
index f2c4184532040d2b4e87a0dfe3df18fef5a4849b..28f3a7551c7e01d426e27d60740182f7df06bebf 100644 (file)
 #include "DNA_ID.h"
 #include "DNA_scriptlink_types.h"
 
+#ifndef MAX_MTEX
+#define MAX_MTEX       10
+#endif
+
 struct MTex;
 struct Ipo;
 struct Material;
@@ -87,7 +91,7 @@ typedef struct Material {
        short ramp_show, pad3;
        float rampfac_col, rampfac_spec;
        
-       struct MTex *mtex[8];
+       struct MTex *mtex[10];
        struct Ipo *ipo;
        struct Material *ren;
        
index 30cb6071d782f5cc90f0bbebccffe5e436882140..8404beaf7335a280a306b80ea52c7254587a1c38 100644 (file)
 struct Ipo;
 struct MTex;
 
+#ifndef MAX_MTEX
+#define MAX_MTEX       10
+#endif
+
 
 /**
  * World defines general modelling data such as a background fill,
@@ -101,7 +105,7 @@ typedef struct World {
        int physicsEngine;
 
        struct Ipo *ipo;
-       struct MTex *mtex[8];
+       struct MTex *mtex[10];
 
        ScriptLink scriptlink;
 
index 01e91cbb0b3921f4ed34de9e0657d6cbf2e685bb..37c250b6c13cbaf2894842ed9542105e06c2f527 100644 (file)
@@ -1146,11 +1146,11 @@ static PyObject *Material_getTextures( BPy_Material * self )
 {
        int i;
        struct MTex *mtex;
-       PyObject *t[8];
+       PyObject *t[MAX_MTEX];
        PyObject *tuple;
 
        /* build a texture list */
-       for( i = 0; i < 8; ++i ) {
+       for( i = 0; i < MAX_MTEX; ++i ) {
                mtex = self->material->mtex[i];
 
                if( mtex ) {
@@ -1805,10 +1805,10 @@ static PyObject *Material_setTexture( BPy_Material * self, PyObject * args )
        if( !PyArg_ParseTuple( args, "iO!|ii", &texnum, &Texture_Type, &pytex,
                               &texco, &mapto ) )
                return EXPP_ReturnPyObjError( PyExc_TypeError,
-                                             "expected int in [0,7] and Texture" );
-       if( ( texnum < 0 ) || ( texnum >= 8 ) )
+                                             "expected int in [0,9] and Texture" );
+       if( ( texnum < 0 ) || ( texnum >= MAX_MTEX ) )
                return EXPP_ReturnPyObjError( PyExc_TypeError,
-                                             "expected int in [0,7] and Texture" );
+                                             "expected int in [0,9] and Texture" );
 
        bltex = Texture_FromPyObject( pytex );
 
@@ -1836,10 +1836,10 @@ static PyObject *Material_clearTexture( BPy_Material * self, PyObject * args )
 
        if( !PyArg_ParseTuple( args, "i", &texnum ) )
                return EXPP_ReturnPyObjError( PyExc_TypeError,
-                                             "expected int in [0,7]" );
-       if( ( texnum < 0 ) || ( texnum >= 8 ) )
+                                             "expected int in [0,9]" );
+       if( ( texnum < 0 ) || ( texnum >= MAX_MTEX ) )
                return EXPP_ReturnPyObjError( PyExc_TypeError,
-                                             "expected int in [0,7]" );
+                                             "expected int in [0,9]" );
 
        mtex = self->material->mtex[texnum];
        if( mtex ) {
index 332171e46439486f2398b00700b731036f1361f7..9f1fb9efef229671abc5753fb0b31085a076b9ad 100644 (file)
@@ -275,7 +275,7 @@ typedef struct LampRen
        VlakRen *vlr_last;
        
        struct LampRen *org;
-       struct MTex *mtex[8];
+       struct MTex *mtex[MAX_MTEX];
 } LampRen;
 
 #endif /* RENDER_TYPES_H */
index d08012cc3fdb9c910f19acf9a8f24af98c317c7d..6226cd9b4189c1c03634e2f38e717900537fb6b4 100644 (file)
@@ -1270,7 +1270,7 @@ void do_material_tex(ShadeInput *shi)
        
        mat_col=mat_colspec=mat_colmir=mat_ref=mat_spec=mat_har=mat_emit=mat_alpha=mat_ray_mirr=mat_translu=mat_amb= shi->mat;
        
-       for(tex_nr=0; tex_nr<8; tex_nr++) {
+       for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
                
                /* separate tex switching */
                if(shi->mat->septex & (1<<tex_nr)) continue;
@@ -1792,8 +1792,7 @@ void do_sky_tex(float *lo)
        
        wrld_hor= wrld_zen= G.scene->world;
 
-       /* The 6 here is the max amount of channels for a world */
-       for(tex_nr=0; tex_nr<6; tex_nr++) {
+       for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
                if(R.wrld.mtex[tex_nr]) {
                        mtex= R.wrld.mtex[tex_nr];
                        
@@ -1960,7 +1959,7 @@ void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi)
        
        tex_nr= 0;
        
-       for(; tex_nr<6; tex_nr++) {
+       for(; tex_nr<MAX_MTEX; tex_nr++) {
                
                if(la->mtex[tex_nr]) {
                        mtex= la->mtex[tex_nr];
@@ -2000,8 +1999,10 @@ void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi)
                                VECCOPY(tempvec, lavec);
                                MTC_Mat3MulVecfl(la->imat, tempvec);
                                
-                               tempvec[0]*= la->spottexfac;
-                               tempvec[1]*= la->spottexfac;
+                               if(la->type==LA_SPOT) {
+                                       tempvec[0]*= la->spottexfac;
+                                       tempvec[1]*= la->spottexfac;
+                               }
                                co= tempvec; 
                                
                                dx= dxt; dy= dyt;       
index 5727c967ff024aa46f860b42ceeda9bfaaf232f9..5acb9d280f97491dc3dbbfdfa1b2af34fd54a825 100644 (file)
@@ -1432,7 +1432,7 @@ static void init_render_mesh(Object *ob)
                        if(ma->alpha==0.0 && ma->spectra==0.0) {
                                ok= 0;
                                /* texture on transparency? */
-                               for(a=0; a<8; a++) {
+                               for(a=0; a<MAX_MTEX; a++) {
                                        if(ma->mtex[a] && ma->mtex[a]->tex) {
                                                if(ma->mtex[a]->mapto & MAP_ALPHA) ok= 1;
                                        }
@@ -1711,7 +1711,7 @@ void RE_add_render_lamp(Object *ob, int doshadbuf)
        lar->spotsi= cos( M_PI*lar->spotsi/360.0 );
        lar->spotbl= (1.0-lar->spotsi)*la->spotblend;
 
-       memcpy(lar->mtex, la->mtex, 8*4);
+       memcpy(lar->mtex, la->mtex, MAX_MTEX*sizeof(void *));
 
        lar->lay= ob->lay & 0xFFFFFF;   // higher 8 bits are localview layers
 
@@ -1756,7 +1756,7 @@ void RE_add_render_lamp(Object *ob, int doshadbuf)
                }
        }
 
-       for(c=0; c<6; c++) {
+       for(c=0; c<MAX_MTEX; c++) {
                if(la->mtex[c] && la->mtex[c]->tex) {
                        lar->mode |= LA_TEXTURE;
 
index 98ceb0a8664ad4ed7ef500578da6d2b77fd3aee7..1e5ca8c6422471c155c59a43334a73487540bac4 100644 (file)
@@ -1393,11 +1393,11 @@ static void texture_panel_texture(MTex *mtex, Material *ma, World *wrld, Lamp *l
        /* CHANNELS */
        uiBlockBeginAlign(block);
        yco= 150;
-       for(a= 0; a<8; a++) {
+       for(a= 0; a<MAX_MTEX; a++) {
                
                if(ma) mt= ma->mtex[a];
-               else if(wrld && a<6)  mt= wrld->mtex[a];
-               else if(la && a<6)  mt= la->mtex[a];
+               else if(wrld)  mt= wrld->mtex[a];
+               else if(la)  mt= la->mtex[a];
                
                if(mt && mt->tex) splitIDname(mt->tex->id.name+2, str, &loos);
                else strcpy(str, "");
@@ -1407,11 +1407,11 @@ static void texture_panel_texture(MTex *mtex, Material *ma, World *wrld, Lamp *l
                        uiDefButC(block, ROW, B_TEXCHANNEL, str,        10,yco,140,19, &(ma->texact), 0.0, (float)a, 0, 0, "Click to select texture channel");
                        yco-= 20;
                }
-               else if(wrld && a<6) {
+               else if(wrld) {
                        uiDefButS(block, ROW, B_TEXCHANNEL, str,        10,yco,140,19, &(wrld->texact), 0.0, (float)a, 0, 0, "");
                        yco-= 20;
                }
-               else if(la && a<6) {
+               else if(la) {
                        uiDefButS(block, ROW, B_TEXCHANNEL, str,        10,yco,140,19, &(la->texact), 0.0, (float)a, 0, 0, "");
                        yco-= 20;
                }
@@ -1763,12 +1763,12 @@ static void world_panel_texture(World *wrld)
        /* TEX CHANNELS */
        uiBlockSetCol(block, TH_BUT_NEUTRAL);
        uiBlockBeginAlign(block);
-       for(a= 0; a<6; a++) {
+       for(a= 0; a<MAX_MTEX; a++) {
                mtex= wrld->mtex[a];
                if(mtex && mtex->tex) splitIDname(mtex->tex->id.name+2, str, &loos);
                else strcpy(str, "");
                str[10]= 0;
-               uiDefButS(block, ROW, REDRAWBUTSSHADING, str,10, 160-20*a, 80, 20, &(wrld->texact), 3.0, (float)a, 0, 0, "Texture channel");
+               uiDefButS(block, ROW, REDRAWBUTSSHADING, str,10, 160-18*a, 80, 20, &(wrld->texact), 3.0, (float)a, 0, 0, "Texture channel");
        }
        uiBlockEndAlign(block);
 
@@ -2081,6 +2081,8 @@ static void lamp_panel_mapto(Object *ob, Lamp *la)
        uiDefButS(block, MENU, B_MATPRV, mapto_blendtype_pup(),155,125,155,19, &(mtex->blendtype), 0, 0, 0, 0, "Texture blending mode");
        uiBlockEndAlign(block);
 
+       uiDefButF(block, NUMSLI, B_MATPRV, "Col  ",                     155,100,155,19, &(mtex->colfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects colour values");
+
 }
 
 
@@ -2100,12 +2102,12 @@ static void lamp_panel_texture(Object *ob, Lamp *la)
        /* TEX CHANNELS */
        uiBlockSetCol(block, TH_BUT_NEUTRAL);
        uiBlockBeginAlign(block);
-       for(a= 0; a<6; a++) {
+       for(a= 0; a<MAX_MTEX; a++) {
                mtex= la->mtex[a];
                if(mtex && mtex->tex) splitIDname(mtex->tex->id.name+2, str, &loos);
                else strcpy(str, "");
                str[10]= 0;
-               uiDefButS(block, ROW, B_REDR, str,      10, 160-20*a, 80, 20, &(la->texact), 3.0, (float)a, 0, 0, "");
+               uiDefButS(block, ROW, B_REDR, str,      10, 160-18*a, 80, 20, &(la->texact), 3.0, (float)a, 0, 0, "");
        }
        uiBlockEndAlign(block);
        
@@ -2691,24 +2693,24 @@ static void material_panel_texture(Material *ma)
        uiBlockSetCol(block, TH_BUT_NEUTRAL);
        
        uiBlockBeginAlign(block);
-       for(a= 0; a<8; a++) {
+       for(a= 0; a<MAX_MTEX; a++) {
                mtex= ma->mtex[a];
                if(mtex && mtex->tex) splitIDname(mtex->tex->id.name+2, str, &loos);
                else strcpy(str, "");
                str[10]= 0;
-               uiDefButC(block, ROW, B_MATPRV_DRAW, str,       10, 180-20*a, 70, 20, &(ma->texact), 3.0, (float)a, 0, 0, "");
+               uiDefButC(block, ROW, B_MATPRV_DRAW, str,       10, 180-18*a, 70, 20, &(ma->texact), 3.0, (float)a, 0, 0, "");
        }
        uiBlockEndAlign(block);
        
        /* SEPTEX */
        uiBlockSetCol(block, TH_AUTO);
        
-       for(a= 0; a<8; a++) {
+       for(a= 0; a<MAX_MTEX; a++) {
                mtex= ma->mtex[a];
                if(mtex && mtex->tex) {
                        if(ma->septex & (1<<a)) 
-                               uiDefButC(block, TOG|BIT|a, B_MATPRV_DRAW, " ", -20, 180-20*a, 28, 20, &ma->septex, 0.0, 0.0, 0, 0, "Click to disable or enable this texture channel");
-                       else uiDefIconButC(block, TOG|BIT|a, B_MATPRV_DRAW, ICON_CHECKBOX_HLT,  -20, 180-20*a, 28, 20, &ma->septex, 0.0, 0.0, 0, 0, "Click to disable or enable this texture channel");
+                               uiDefButC(block, TOG|BIT|a, B_MATPRV_DRAW, " ", -20, 180-18*a, 28, 20, &ma->septex, 0.0, 0.0, 0, 0, "Click to disable or enable this texture channel");
+                       else uiDefIconButC(block, TOG|BIT|a, B_MATPRV_DRAW, ICON_CHECKBOX_HLT,  -20, 180-18*a, 28, 20, &ma->septex, 0.0, 0.0, 0, 0, "Click to disable or enable this texture channel");
                }
        }
        
index 9d7d02f80db182a6df752fdf83b1750927a7eb1e..fa3273166426a1f65b52f1846e5036ca5f510b19 100644 (file)
@@ -814,6 +814,8 @@ int texchannel_to_adrcode(int channel)
                case 5: return MA_MAP6; 
                case 6: return MA_MAP7; 
                case 7: return MA_MAP8; 
+               case 8: return MA_MAP9; 
+               case 9: return MA_MAP10; 
                default: return 0;
        }
 }
@@ -2040,7 +2042,7 @@ void add_vert_ipo()
        
        ei= get_editipo();
        if(ei==0) {
-               error("Too many EditIpos");
+               error("Too many (or no) EditIpos");
                return;
        }
        
index 961a4f2515bac312b688db70b605127d7fd10ded..225e73a6b7d00721fdb7da402db44bc73bdbf994 100644 (file)
@@ -6840,7 +6840,7 @@ void single_obdata_users(int flag)
                                case OB_LAMP:
                                        if(id && id->us>1 && id->lib==0) {
                                                ob->data= la= copy_lamp(ob->data);
-                                               for(a=0; a<8; a++) {
+                                               for(a=0; a<MAX_MTEX; a++) {
                                                        if(la->mtex[a]) {
                                                                ID_NEW(la->mtex[a]->object);
                                                        }
@@ -6981,7 +6981,7 @@ void single_mat_users(int flag)
                                                        ma->ipo->id.us--;
                                                }
                                                
-                                               for(b=0; b<8; b++) {
+                                               for(b=0; b<MAX_MTEX; b++) {
                                                        if(ma->mtex[b] && ma->mtex[b]->tex) {
                                                                tex= ma->mtex[b]->tex;
                                                                if(tex->id.us>1) {
@@ -7031,7 +7031,7 @@ void single_tex_users_expand()
        ma= G.main->mat.first;
        while(ma) {
                if(ma->id.flag & LIB_NEW) {
-                       for(b=0; b<8; b++) {
+                       for(b=0; b<MAX_MTEX; b++) {
                                if(ma->mtex[b] && ma->mtex[b]->tex) {
                                        do_single_tex_user( &(ma->mtex[b]->tex) );
                                }
@@ -7043,7 +7043,7 @@ void single_tex_users_expand()
        la= G.main->lamp.first;
        while(la) {
                if(la->id.flag & LIB_NEW) {
-                       for(b=0; b<6; b++) {
+                       for(b=0; b<MAX_MTEX; b++) {
                                if(la->mtex[b] && la->mtex[b]->tex) {
                                        do_single_tex_user( &(la->mtex[b]->tex) );
                                }
@@ -7054,7 +7054,7 @@ void single_tex_users_expand()
        wo= G.main->world.first;
        while(wo) {
                if(wo->id.flag & LIB_NEW) {
-                       for(b=0; b<6; b++) {
+                       for(b=0; b<MAX_MTEX; b++) {
                                if(wo->mtex[b] && wo->mtex[b]->tex) {
                                        do_single_tex_user( &(wo->mtex[b]->tex) );
                                }
@@ -7111,7 +7111,7 @@ void single_mat_users_expand(void)
        ma= G.main->mat.first;
        while(ma) {
                if(ma->id.flag & LIB_NEW) {
-                       for(a=0; a<8; a++) {
+                       for(a=0; a<MAX_MTEX; a++) {
                                if(ma->mtex[a]) {
                                        ID_NEW(ma->mtex[a]->object);
                                }
@@ -7270,7 +7270,7 @@ void make_local(void)
                        
                        if(ob->type==OB_LAMP) {
                                la= ob->data;
-                               for(b=0; b<8; b++) {
+                               for(b=0; b<MAX_MTEX; b++) {
                                        if(la->mtex[b] && la->mtex[b]->tex) {
                                                make_local_texture(la->mtex[b]->tex);
                                        }
@@ -7283,7 +7283,7 @@ void make_local(void)
                                        if(ma) {
                                                make_local_material(ma);
                                        
-                                               for(b=0; b<8; b++) {
+                                               for(b=0; b<MAX_MTEX; b++) {
                                                        if(ma->mtex[b] && ma->mtex[b]->tex) {
                                                                make_local_texture(ma->mtex[b]->tex);
                                                        }
@@ -7300,7 +7300,7 @@ void make_local(void)
                                        if(ma) {
                                                make_local_material(ma);
                                        
-                                               for(b=0; b<8; b++) {
+                                               for(b=0; b<MAX_MTEX; b++) {
                                                        if(ma->mtex[b] && ma->mtex[b]->tex) {
                                                                make_local_texture(ma->mtex[b]->tex);
                                                        }
@@ -7541,7 +7541,7 @@ void adduplicate(float *dtrans)
                                ma= (Material *)mao->id.newid;
                                
                                if(dupflag & USER_DUP_TEX) {
-                                       for(a=0; a<8; a++) {
+                                       for(a=0; a<MAX_MTEX; a++) {
                                                if(ma->mtex[a]) {
                                                        id= (ID *)ma->mtex[a]->tex;
                                                        if(id) {
@@ -7653,7 +7653,7 @@ void selectlinks(int nr)
                                                if(mat1==mat) base->flag |= SELECT;
                                        }
                                        else if(mat1 && nr==4) {
-                                               for(b=0; b<8; b++) {
+                                               for(b=0; b<MAX_MTEX; b++) {
                                                        if(mat1->mtex[b]) {
                                                                if(tex==mat1->mtex[b]->tex) base->flag |= SELECT;
                                                        }
@@ -7695,7 +7695,7 @@ void image_aspect(void)
                        for(a=1; a<=ob->totcol; a++) {
                                ma= give_current_material(ob, a);
                                if(ma) {
-                                       for(b=0; b<8; b++) {
+                                       for(b=0; b<MAX_MTEX; b++) {
                                                if(ma->mtex[b] && ma->mtex[b]->tex) {
                                                        tex= ma->mtex[b]->tex;
                                                        if(tex->type==TEX_IMAGE && tex->ima && tex->ima->ibuf) {
index 1f53373c31ada5d8d7025820a8677c6418e17181..d0375a0163e2bf79eb906890394e95b1f3160d59 100644 (file)
@@ -99,7 +99,7 @@ void free_matcopybuf(void)
        extern MTex mtexcopybuf;        /* buttons.c */
        int a;
 
-       for(a=0; a<8; a++) {
+       for(a=0; a<MAX_MTEX; a++) {
                if(matcopybuf.mtex[a]) {
                        MEM_freeN(matcopybuf.mtex[a]);
                        matcopybuf.mtex[a]= NULL;
@@ -153,7 +153,7 @@ void do_buts_buttons(short event)
                        if(matcopybuf.ramp_col) matcopybuf.ramp_col= MEM_dupallocN(matcopybuf.ramp_col);
                        if(matcopybuf.ramp_spec) matcopybuf.ramp_spec= MEM_dupallocN(matcopybuf.ramp_spec);
 
-                       for(a=0; a<8; a++) {
+                       for(a=0; a<MAX_MTEX; a++) {
                                mtex= matcopybuf.mtex[a];
                                if(mtex) {
                                        matcopybuf.mtex[a]= MEM_dupallocN(mtex);
@@ -168,7 +168,7 @@ void do_buts_buttons(short event)
                        /* free current mat */
                        if(ma->ramp_col) MEM_freeN(ma->ramp_col);
                        if(ma->ramp_spec) MEM_freeN(ma->ramp_spec);
-                       for(a=0; a<8; a++) {
+                       for(a=0; a<MAX_MTEX; a++) {
                                mtex= ma->mtex[a];
                                if(mtex && mtex->tex) mtex->tex->id.us--;
                                if(mtex) MEM_freeN(mtex);
@@ -181,7 +181,7 @@ void do_buts_buttons(short event)
                        if(matcopybuf.ramp_col) ma->ramp_col= MEM_dupallocN(matcopybuf.ramp_col);
                        if(matcopybuf.ramp_spec) ma->ramp_spec= MEM_dupallocN(matcopybuf.ramp_spec);
                        
-                       for(a=0; a<8; a++) {
+                       for(a=0; a<MAX_MTEX; a++) {
                                mtex= ma->mtex[a];
                                if(mtex) {
                                        ma->mtex[a]= MEM_dupallocN(mtex);
index b2e5ca3df2c3b0752777d36c555eac26a0faefc9..0b9fa56281bc442a24ec6a6df6a310a62b51c50e 100644 (file)
@@ -56,6 +56,7 @@
 #include "DNA_ID.h"
 #include "DNA_curve_types.h"
 #include "DNA_key_types.h"
+#include "DNA_material_types.h"
 #include "DNA_ipo_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
@@ -867,21 +868,21 @@ void ipo_buttons(void)
        else if(G.sipo->blocktype == ID_TE)
                icon = ICON_TEXTURE;
 
-       uiDefIconTextButS(block, MENU, B_IPOMAIN, icon, ipo_modeselect_pup(), xco,0,100,20, &(G.sipo->blocktype), 0, 0, 0, 0, "Display IPO type");
+       uiDefIconTextButS(block, MENU, B_IPOMAIN, icon, ipo_modeselect_pup(), xco,0,100,20, &(G.sipo->blocktype), 0, 0, 0, 0, "Show IPO type");
 
        xco += 85;
 
        if(G.sipo->blocktype==ID_MA) {
-               uiDefButS(block, NUM, B_IPOMAIN, "",    xco+=XIC,0,XIC-4,YIC, &G.sipo->channel, 0.0, 7.0, 0, 0, "Displays Channel Number of the active Material texture. Click to change.");
+               uiDefButS(block, NUM, B_IPOMAIN, "",    xco+=XIC,0,XIC-4,YIC, &G.sipo->channel, 0.0, MAX_MTEX-1.0, 0, 0, "Channel Number of the active Material texture.");
                xco-= 4;
        }
        if(G.sipo->blocktype==ID_WO) {
-               uiDefButS(block, NUM, B_IPOMAIN, "",    xco+=XIC,0,XIC-4,YIC, &G.sipo->channel, 0.0, 7.0, 0, 0, "Displays Channel Number of the active World texture. Click to change.");
+               uiDefButS(block, NUM, B_IPOMAIN, "",    xco+=XIC,0,XIC-4,YIC, &G.sipo->channel, 0.0, MAX_MTEX-1.0, 0, 0, "Channel Number of the active World texture.");
                xco-= 4;
        }
        
        if(G.sipo->blocktype==ID_LA) {
-               uiDefButS(block, NUM, B_IPOMAIN, "",    xco+=XIC,0,XIC-4,YIC, &G.sipo->channel, 0.0, 7.0, 0, 0, "Displays Channel Number of the active Lamp texture. Click to change.");
+               uiDefButS(block, NUM, B_IPOMAIN, "",    xco+=XIC,0,XIC-4,YIC, &G.sipo->channel, 0.0, MAX_MTEX-1.0, 0, 0, "Channel Number of the active Lamp texture. ");
                xco-= 4;
        }
        
index 8b2bee49a9f5dc4cdf0f2a103513c7947e32fb9f..ec219e32163485e685c65e09cc02daa51242e258 100644 (file)
@@ -647,12 +647,12 @@ void add_material_oopslinks(Material *ma, Oops *oops, short flag)
        int a;
        
        if(flag & OOPS_TE) {
-               for(a=0; a<8; a++) {
+               for(a=0; a<MAX_MTEX; a++) {
                        if(ma->mtex[a]) add_oopslink("tex", oops, ID_TE, &(ma->mtex[a]->tex), (float)(0.5*OOPSX), (float)OOPSY);
                }
        }
        if(flag & OOPS_OB) {
-               for(a=0; a<8; a++) {
+               for(a=0; a<MAX_MTEX; a++) {
                        if(ma->mtex[a]) add_oopslink("ob", oops, ID_OB, &(ma->mtex[a]->object), 0.0, (float)(0.2*OOPSY));
                }
        }
@@ -755,7 +755,7 @@ void add_lamp_oopslinks(Lamp *la, Oops *oops, short flag)
        int a;
        
        if(flag & OOPS_TE) {
-               for(a=0; a<6; a++) {
+               for(a=0; a<MAX_MTEX; a++) {
                        if(la->mtex[a]) {
                                add_oopslink("tex", oops, ID_TE, &(la->mtex[a]->tex), 0.0, (float)(0.5*OOPSY));
                        }
@@ -829,7 +829,7 @@ void add_texture_oops(Material *ma)
 {
        int a;
        
-       for(a=0; a<8; a++) {
+       for(a=0; a<MAX_MTEX; a++) {
                if(ma->mtex[a]) {
                        add_test_oops(ma->mtex[a]->tex);
                        if(ma->mtex[a]->tex) if(G.soops->visiflag & OOPS_IM) add_test_oops(ma->mtex[a]->tex->ima);
@@ -1047,7 +1047,7 @@ void build_oops()
                                                oops= add_test_oops(ob->data);
                                                if(G.soops->visiflag & OOPS_IP) add_test_oops(la->ipo);
                                                if(G.soops->visiflag & OOPS_TE) {
-                                                       for(a=0; a<6; a++) {
+                                                       for(a=0; a<MAX_MTEX; a++) {
                                                                if(la->mtex[a]) add_test_oops(la->mtex[a]->tex);
                                                        }
                                                }
index 7db1318d214bc5022b3e92a1fa79c2f8f098c055..5181d253d6e2693b6a985b8c26665786156c58b3 100644 (file)
@@ -519,7 +519,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                        Material *ma= (Material *)id;
                        
                        outliner_add_element(soops, &te->subtree, ma->ipo, te, 0, 0);
-                       for(a=0; a<8; a++) {
+                       for(a=0; a<MAX_MTEX; a++) {
                                if(ma->mtex[a]) outliner_add_element(soops, &te->subtree, ma->mtex[a]->tex, te, 0, a);
                        }
                }
@@ -542,7 +542,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                        {
                                Lamp *la= (Lamp *)id;
                                outliner_add_element(soops, &te->subtree, la->ipo, te, 0, 0);
-                               for(a=0; a<6; a++) {
+                               for(a=0; a<MAX_MTEX; a++) {
                                        if(la->mtex[a]) outliner_add_element(soops, &te->subtree, la->mtex[a]->tex, te, 0, a);
                                }
                        }
@@ -551,7 +551,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                        {
                                World *wrld= (World *)id;
                                outliner_add_element(soops, &te->subtree, wrld->ipo, te, 0, 0);
-                               for(a=0; a<6; a++) {
+                               for(a=0; a<MAX_MTEX; a++) {
                                        if(wrld->mtex[a]) outliner_add_element(soops, &te->subtree, wrld->mtex[a]->tex, te, 0, a);
                                }
                        }
@@ -1600,25 +1600,23 @@ static void unlink_material_cb(TreeElement *te, TreeStoreElem *tsep)
 static void unlink_texture_cb(TreeElement *te, TreeStoreElem *tsep)
 {
        MTex **mtex= NULL;
-       int tottex= 0;
        int a;
        
        if( GS(tsep->id->name)==ID_MA) {
                Material *ma= (Material *)tsep->id;
                mtex= ma->mtex;
-               tottex= 8;
        }
        else if( GS(tsep->id->name)==ID_LA) {
                Lamp *la= (Lamp *)tsep->id;
                mtex= la->mtex;
-               tottex= 6;
        }
        else if( GS(tsep->id->name)==ID_WO) {
                World *wrld= (World *)tsep->id;
                mtex= wrld->mtex;
-               tottex= 6;
        }
-       for(a=0; a<tottex; a++) {
+       else return;
+       
+       for(a=0; a<MAX_MTEX; a++) {
                if(a==te->index && mtex[a]) {
                        if(mtex[a]->tex) {
                                mtex[a]->tex->id.us--;
index 4db3f79591054b97a66b2736a2fc643a1a719148..b36483837d31cf2a0db9a805e26eb95ed66f279a 100644 (file)
@@ -1076,7 +1076,7 @@ void BIF_previewrender(SpaceButs *sbuts)
                init_render_material(mat);
                
                /* clear imats */
-               for(x=0; x<8; x++) {
+               for(x=0; x<MAX_MTEX; x++) {
                        if(mat->mtex[x]) {
                                if(mat->mtex[x]->tex) {
                                        init_render_texture(mat->mtex[x]->tex);
@@ -1279,7 +1279,7 @@ void BIF_previewrender(SpaceButs *sbuts)
        
        if(mat) {
                end_render_material(mat);
-               for(x=0; x<8; x++) {
+               for(x=0; x<MAX_MTEX; x++) {
                        if(mat->mtex[x] && mat->mtex[x]->tex) end_render_texture(mat->mtex[x]->tex);
                }       
        }