use inline BLI_math functions for dot product and length calculation.
[blender.git] / source / blender / render / intern / source / shadeinput.c
index 928139659d1a8a463032ff9aae98d4a8b44729ac..e0b5da817cb33fd26ec88421aff4180262f61bd9 100644 (file)
@@ -127,8 +127,8 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr)
                if(shi->passflag & SCE_PASS_SHADOW)
                        VECADDISFAC(shr->shad, shr_t.shad, fac);
 
-               VECMUL(shi->vn, -1.0f);
-               VECMUL(shi->facenor, -1.0f);
+               negate_v3(shi->vn);
+               negate_v3(shi->facenor);
        }
        
        /* depth >= 1 when ray-shading */
@@ -608,7 +608,7 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v
                if(shi->obi->flag & R_TRANSFORMED)
                        mul_m4_v3(shi->obi->mat, v1);
                
-               dface= v1[0]*shi->facenor[0]+v1[1]*shi->facenor[1]+v1[2]*shi->facenor[2];
+               dface = dot_v3v3(v1, shi->facenor);
                
                /* ortho viewplane cannot intersect using view vector originating in (0,0,0) */
                if(R.r.mode & R_ORTHO) {
@@ -650,7 +650,7 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v
                else {
                        float div;
                        
-                       div= shi->facenor[0]*view[0] + shi->facenor[1]*view[1] + shi->facenor[2]*view[2];
+                       div = dot_v3v3(shi->facenor, view);
                        if (div!=0.0f) fac= dface/div;
                        else fac= 0.0f;
                        
@@ -756,17 +756,11 @@ void shade_input_set_uv(ShadeInput *shi)
                }
                else {
                        /* most of this could become re-used for faces */
-                       float detsh, t00, t10, t01, t11, xn, yn, zn;
+                       float detsh, t00, t10, t01, t11;
                        int axis1, axis2;
 
                        /* find most stable axis to project */
-                       xn= fabs(shi->facenor[0]);
-                       yn= fabs(shi->facenor[1]);
-                       zn= fabs(shi->facenor[2]);
-
-                       if(zn>=xn && zn>=yn) { axis1= 0; axis2= 1; }
-                       else if(yn>=xn && yn>=zn) { axis1= 0; axis2= 2; }
-                       else { axis1= 1; axis2= 2; }
+                       axis_dominant_v3(&axis1, &axis2, shi->facenor);
 
                        /* compute u,v and derivatives */
                        t00= v3[axis1]-v1[axis1]; t01= v3[axis2]-v1[axis2];
@@ -1274,7 +1268,7 @@ void shade_input_set_shade_texco(ShadeInput *shi)
 
                                zbuf_make_winmat(&R, winmat);
                                if(shi->obi->flag & R_TRANSFORMED)
-                                       mul_m4_m4m4(obwinmat, obi->mat, winmat);
+                                       mult_m4_m4m4(obwinmat, winmat, obi->mat);
                                else
                                        copy_m4_m4(obwinmat, winmat);