code cleanup: function naming, use BKE_*type* prefix.
[blender.git] / source / blender / render / intern / source / render_texture.c
index 453bb0aeeb6091271ef756ed75f7d5559b9dd658..0c090e7e9841ea9de0db91a660b09145594be710 100644 (file)
@@ -227,7 +227,7 @@ static int blend(Tex *tex, float *texvec, TexResult *texres)
                texres->tin= (2.0f+x+y)/4.0f;
        }
        else if (tex->stype==TEX_RAD) { /* radial */
-               texres->tin= (atan2(y,x) / (2*M_PI) + 0.5);
+               texres->tin= (atan2(y, x) / (2*M_PI) + 0.5);
        }
        else {  /* sphere TEX_SPHERE */
                texres->tin= 1.0-sqrt(x*x+      y*y+texvec[2]*texvec[2]);
@@ -870,7 +870,7 @@ static int cubemap(MTex *mtex, VlakRen *vlr, float *n, float x, float y, float z
                        /* test for v1, vlr can be faked for baking */
                        if (vlr->v1 && vlr->v1->orco) {
                                float nor[3];
-                               normal_tri_v3( nor,vlr->v1->orco, vlr->v2->orco, vlr->v3->orco);
+                               normal_tri_v3(nor, vlr->v1->orco, vlr->v2->orco, vlr->v3->orco);
                                
                                if ( fabs(nor[0])<fabs(nor[2]) && fabs(nor[1])<fabs(nor[2]) ) vlr->puno |= ME_PROJXY;
                                else if ( fabs(nor[0])<fabs(nor[1]) && fabs(nor[2])<fabs(nor[1]) ) vlr->puno |= ME_PROJXZ;
@@ -969,8 +969,8 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d
                        fx = (t[0] + 1.0f) / 2.0f;
                        fy = (t[1] + 1.0f) / 2.0f;
                }
-               else if (wrap==MTEX_TUBE) map_to_tube( &fx, &fy,t[0], t[1], t[2]);
-               else if (wrap==MTEX_SPHERE) map_to_sphere( &fx, &fy,t[0], t[1], t[2]);
+               else if (wrap==MTEX_TUBE) map_to_tube( &fx, &fy, t[0], t[1], t[2]);
+               else if (wrap==MTEX_SPHERE) map_to_sphere(&fx, &fy, t[0], t[1], t[2]);
                else {
                        if (texco==TEXCO_OBJECT) cubemap_ob(ob, n, t[0], t[1], t[2], &fx, &fy);
                        else if (texco==TEXCO_GLOB) cubemap_glob(n, t[0], t[1], t[2], &fx, &fy);
@@ -1041,20 +1041,20 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d
                        }
                        if (ok) {
                                if (wrap==MTEX_TUBE) {
-                                       map_to_tube( area, area+1,t[0], t[1], t[2]);
-                                       map_to_tube( area+2, area+3,t[0]+dxt[0], t[1]+dxt[1], t[2]+dxt[2]);
-                                       map_to_tube( area+4, area+5,t[0]+dyt[0], t[1]+dyt[1], t[2]+dyt[2]);
+                                       map_to_tube(area, area+1, t[0], t[1], t[2]);
+                                       map_to_tube(area + 2, area + 3, t[0] + dxt[0], t[1] + dxt[1], t[2] + dxt[2]);
+                                       map_to_tube(area + 4, area + 5, t[0] + dyt[0], t[1] + dyt[1], t[2] + dyt[2]);
                                }
                                else { 
-                                       map_to_sphere(area,area+1,t[0], t[1], t[2]);
-                                       map_to_sphere( area+2, area+3,t[0]+dxt[0], t[1]+dxt[1], t[2]+dxt[2]);
-                                       map_to_sphere( area+4, area+5,t[0]+dyt[0], t[1]+dyt[1], t[2]+dyt[2]);
+                                       map_to_sphere(area, area+1, t[0], t[1], t[2]);
+                                       map_to_sphere(area + 2, area + 3, t[0] + dxt[0], t[1] + dxt[1], t[2] + dxt[2]);
+                                       map_to_sphere(area + 4, area + 5, t[0] + dyt[0], t[1] + dyt[1], t[2] + dyt[2]);
                                }
                                areaflag= 1;
                        }
                        else {
-                               if (wrap==MTEX_TUBE) map_to_tube( &fx, &fy,t[0], t[1], t[2]);
-                               else map_to_sphere( &fx, &fy,t[0], t[1], t[2]);
+                               if (wrap==MTEX_TUBE) map_to_tube( &fx, &fy, t[0], t[1], t[2]);
+                               else map_to_sphere(&fx, &fy, t[0], t[1], t[2]);
                                dxt[0]/= 2.0f;
                                dxt[1]/= 2.0f;
                                dyt[0]/= 2.0f;
@@ -1185,7 +1185,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex,
                        tex, which_output, R.r.cfra, (R.r.scemode & R_TEXNODE_PREVIEW) != 0, NULL, NULL);
        }
        else
-       switch(tex->type) {
+       switch (tex->type) {
        
        case 0:
                texres->tin= 0.0f;
@@ -1231,7 +1231,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex,
                copy_v3_v3(tmpvec, texvec);
                mul_v3_fl(tmpvec, 1.0f/tex->noisesize);
                
-               switch(tex->stype) {
+               switch (tex->stype) {
                case TEX_MFRACTAL:
                case TEX_FBM:
                        retval= mg_mFractalOrfBmTex(tex, tmpvec, texres);
@@ -1389,7 +1389,7 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa
 {
        float facm, col;
        
-       switch(blendtype) {
+       switch (blendtype) {
        case MTEX_BLEND:
                fact*= facg;
                facm= 1.0f-fact;
@@ -1530,7 +1530,7 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
        facm= 1.0f-fact;
        if (flip) SWAP(float, fact, facm);
 
-       switch(blendtype) {
+       switch (blendtype) {
        case MTEX_BLEND:
                in= fact*tex + facm*out;
                break;
@@ -1647,7 +1647,7 @@ static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, floa
                        }
                }
                if (tex->extend == TEX_REPEAT && (tex->flag & TEX_REPEAT_YMIR)) {
-                       if  (tex->texfilter == TXF_BOX)
+                       if (tex->texfilter == TXF_BOX)
                                texvec[1] -= floorf(texvec[1]);
                        else if (texvec[1] < 0.f || texvec[1] > 1.f) {
                                const float ty = 0.5f*texvec[1];
@@ -2102,9 +2102,9 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
                
                        // generate the surface derivatives in object space
                        mul_m3_v3(view2obj, dPdx);
-                       mul_m3_v3( view2obj, dPdy );
+                       mul_m3_v3(view2obj, dPdy);
                        // generate the unit normal in object space
-                       mul_transposed_m3_v3( obj2view, vN );
+                       mul_transposed_m3_v3(obj2view, vN);
                        normalize_v3(vN);
                }
                
@@ -2126,9 +2126,9 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
                fMagnitude = abs_fDet;
                if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) {
                        // pre do transform of texres->nor by the inverse transposed of obj2view
-                       mul_transposed_m3_v3( view2obj, vN );
-                       mul_transposed_m3_v3( view2obj, ntap_bump->vR1 );
-                       mul_transposed_m3_v3( view2obj, ntap_bump->vR2 );
+                       mul_transposed_m3_v3(view2obj, vN);
+                       mul_transposed_m3_v3(view2obj, ntap_bump->vR1);
+                       mul_transposed_m3_v3(view2obj, ntap_bump->vR2);
                        
                        fMagnitude *= len_v3(vN);
                }
@@ -3054,7 +3054,7 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h
                        }
                        
                        /* Grab the mapping settings for this texture */
-                       switch(mtex->texco) {
+                       switch (mtex->texco) {
                        case TEXCO_ANGMAP:
                                /* only works with texture being "real" */
                                /* use saacos(), fixes bug [#22398], float precision caused lo[2] to be slightly less then -1.0 */
@@ -3077,8 +3077,8 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h
                        case TEXCO_H_SPHEREMAP:
                        case TEXCO_H_TUBEMAP:
                                if (skyflag & WO_ZENUP) {
-                                       if (mtex->texco==TEXCO_H_TUBEMAP) map_to_tube( tempvec, tempvec+1,lo[0], lo[2], lo[1]);
-                                       else map_to_sphere( tempvec, tempvec+1,lo[0], lo[2], lo[1]);
+                                       if (mtex->texco==TEXCO_H_TUBEMAP) map_to_tube( tempvec, tempvec+1, lo[0], lo[2], lo[1]);
+                                       else map_to_sphere(tempvec, tempvec+1, lo[0], lo[2], lo[1]);
                                        /* tube/spheremap maps for outside view, not inside */
                                        tempvec[0]= 1.0f-tempvec[0];
                                        /* only top half */
@@ -3644,14 +3644,14 @@ void RE_free_sample_material(Material *mat)
                        MTex *mtex= mat->mtex[tex_nr];
        
                        if (mtex->tex) {
-                               free_texture(mtex->tex);
+                               BKE_texture_free(mtex->tex);
                                MEM_freeN(mtex->tex);
                                mtex->tex = NULL;
                        }
                }
        }
 
-       free_material(mat);
+       BKE_material_free(mat);
        MEM_freeN(mat);
 }
 
@@ -3683,7 +3683,7 @@ void RE_sample_material_color(Material *mat, float color[3], float *alpha, const
        if (!mvert || !mface || !mat) return;
        v1=mface[face_index].v1, v2=mface[face_index].v2, v3=mface[face_index].v3;
        if (hit_quad) {v2=mface[face_index].v3; v3=mface[face_index].v4;}
-       normal_tri_v3( normal, mvert[v1].co, mvert[v2].co, mvert[v3].co);
+       normal_tri_v3(normal, mvert[v1].co, mvert[v2].co, mvert[v3].co);
 
        /* generate shadeinput with data required */
        shi.mat = mat;
@@ -3737,7 +3737,7 @@ void RE_sample_material_color(Material *mat, float color[3], float *alpha, const
                                }
                        }
                        /* active uv map */
-                       shi.actuv = CustomData_get_active_layer_index(&orcoDm->faceData,CD_MTFACE) - layer_index;
+                       shi.actuv = CustomData_get_active_layer_index(&orcoDm->faceData, CD_MTFACE) - layer_index;
                        shi.totuv = layers;
                }