Patch from Banlu Kemiyatorn
[blender.git] / source / blender / radiosity / intern / source / radfactors.c
index 64beea24d233aec88a997532f4c5405e64f29bce..d5b7c1caef3ab035b9c51d1b4639de6ad832bc52 100644 (file)
@@ -1,14 +1,11 @@
 /* ***************************************
  *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -26,7 +23,7 @@
  *
  * Contributor(s): none yet.
  *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
 
 
 
@@ -56,9 +53,9 @@
 #include "RE_render_ext.h"       /* for `RE_zbufferall_radio and RE_zbufferall_radio */
 
 /* locals */
-void rad_setmatrices(RadView *vw);
-void clearsubflagelem(RNode *rn);
-void setsubflagelem(RNode *rn);
+static void rad_setmatrices(RadView *vw);
+static void clearsubflagelem(RNode *rn);
+static void setsubflagelem(RNode *rn);
 
 RadView hemitop, hemiside;
 
@@ -82,20 +79,20 @@ float calcStokefactor(RPatch *shoot, RPatch *rp, RNode *rn, float *area)
                VecSubf(vec[2], shoot->cent, rn->v3);
                VecSubf(vec[3], shoot->cent, rn->v4);
 
-               Normalise(vec[0]);
-               Normalise(vec[1]);
-               Normalise(vec[2]);
-               Normalise(vec[3]);
+               Normalize(vec[0]);
+               Normalize(vec[1]);
+               Normalize(vec[2]);
+               Normalize(vec[3]);
 
                /* cross product */
                Crossf(cross[0], vec[0], vec[1]);
                Crossf(cross[1], vec[1], vec[2]);
                Crossf(cross[2], vec[2], vec[3]);
                Crossf(cross[3], vec[3], vec[0]);
-               Normalise(cross[0]);
-               Normalise(cross[1]);
-               Normalise(cross[2]);
-               Normalise(cross[3]);
+               Normalize(cross[0]);
+               Normalize(cross[1]);
+               Normalize(cross[2]);
+               Normalize(cross[3]);
 
                /* angles */
                rad[0]= vec[0][0]*vec[1][0]+ vec[0][1]*vec[1][1]+ vec[0][2]*vec[1][2];
@@ -126,17 +123,17 @@ float calcStokefactor(RPatch *shoot, RPatch *rp, RNode *rn, float *area)
                VecSubf(vec[1], shoot->cent, rn->v2);
                VecSubf(vec[2], shoot->cent, rn->v3);
 
-               Normalise(vec[0]);
-               Normalise(vec[1]);
-               Normalise(vec[2]);
+               Normalize(vec[0]);
+               Normalize(vec[1]);
+               Normalize(vec[2]);
 
                /* cross product */
                Crossf(cross[0], vec[0], vec[1]);
                Crossf(cross[1], vec[1], vec[2]);
                Crossf(cross[2], vec[2], vec[0]);
-               Normalise(cross[0]);
-               Normalise(cross[1]);
-               Normalise(cross[2]);
+               Normalize(cross[0]);
+               Normalize(cross[1]);
+               Normalize(cross[2]);
 
                /* angles */
                rad[0]= vec[0][0]*vec[1][0]+ vec[0][1]*vec[1][1]+ vec[0][2]*vec[1][2];
@@ -257,7 +254,7 @@ void rad_make_hocos(RadView *vw)
        /* } */
 }
 
-void rad_setmatrices(RadView *vw)          /* for hemi's */
+static void rad_setmatrices(RadView *vw)           /* for hemi's */
 {
        float up1[3], len, twist;
 
@@ -322,7 +319,7 @@ int makeformfactors(RPatch *shoot)
                vec[1]= (float)BLI_drand();
                vec[2]= (float)BLI_drand();
                Crossf(up, shoot->norm, vec);
-               len= Normalise(up);
+               len= Normalize(up);
                /* this safety for input normals that are zero or illegal sized */
                if(a>3) return 0;
        } while(len==0.0 || len>1.0);
@@ -538,10 +535,10 @@ void progressiverad()
 
                if(shoot->first->f & RAD_TWOSIDED) {
                        VECCOPY(unshot, shoot->unshot);
-                       VecMulf(shoot->norm, -1.0);
+                       VecNegf(shoot->norm);
                        if(makeformfactors(shoot))
                                applyformfactors(shoot);
-                       VecMulf(shoot->norm, -1.0);
+                       VecNegf(shoot->norm);
                        VECCOPY(shoot->unshot, unshot);
                }
        
@@ -631,7 +628,7 @@ void minmaxradelemfilt(RNode *rn, float *min, float *max, float *errmin, float *
        }
 }
 
-void setsubflagelem(RNode *rn)
+static void setsubflagelem(RNode *rn)
 {
        
        if(rn->down1) {
@@ -643,7 +640,7 @@ void setsubflagelem(RNode *rn)
        }
 }
 
-void clearsubflagelem(RNode *rn)
+static void clearsubflagelem(RNode *rn)
 {
        
        if(rn->down1) {
@@ -744,11 +741,9 @@ void subdivideshootElements(int it)
                                        }
                                }
                                if(rn) {
-                                       min[0]= min[1]= min[2]= 1.0e10;
-                                       max[0]= max[1]= max[2]= -1.0e10;
+                                       INIT_MINMAX(min, max);
                                        /* errmin and max are the filtered colors */
-                                       errmin[0]= errmin[1]= errmin[2]= 1.0e10;
-                                       errmax[0]= errmax[1]= errmax[2]= -1.0e10;
+                                       INIT_MINMAX(errmin, errmax);
                                        minmaxradelemfilt(rp->first, min, max, errmin, errmax);
                                        
                                        /* if small difference between colors: no subdiv */
@@ -912,8 +907,8 @@ void inithemiwindows()
        memset(vw, 0, sizeof(RadView));
        vw->rectx= RG.hemires;
        vw->recty= RG.hemires;
-       vw->rectz= MEM_mallocN(4*vw->rectx*vw->recty, "initwindows");
-       vw->rect= MEM_mallocN(4*vw->rectx*vw->recty, "initwindows");
+       vw->rectz= MEM_mallocN(sizeof(int)*vw->rectx*vw->recty, "initwindows");
+       vw->rect= MEM_mallocN(sizeof(int)*vw->rectx*vw->recty, "initwindows");
        vw->mynear= RG.maxsize/2000.0;
        vw->myfar= 2.0*RG.maxsize;
        vw->wx1= -vw->mynear;