[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21999] branches/soc-2009-yukishiro/source /blender/sh/intern/compute.c: bug fix: normal should not be translated

Jingyuan Huang jingyuan.huang at gmail.com
Tue Jul 28 23:49:21 CEST 2009


Revision: 21999
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21999
Author:   yukishiro
Date:     2009-07-28 23:49:21 +0200 (Tue, 28 Jul 2009)

Log Message:
-----------
bug fix: normal should not be translated

Modified Paths:
--------------
    branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c

Modified: branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c	2009-07-28 21:08:28 UTC (rev 21998)
+++ branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c	2009-07-28 21:49:21 UTC (rev 21999)
@@ -62,7 +62,6 @@
 #define L 4
 #define NUM_SAMPLES 100
 #define SQRT_SAMPLES 10
-#define CLAMP(val) ((val)<0.0f) ? 0 : (((val)>1.0f) ? 1.0f : (val))
 
 typedef float Vec3[3];
 typedef float** ShCoeffs;
@@ -645,7 +644,7 @@
 
 	Isect isec;
         int i, j, k, m, num_verts;
-        float no[3], N, *y_val;
+        float mat[4][4], no[3], N, *y_val;
 	int num_sh= (env->degree + 1) * (env->degree + 1);
         float weight= 4.0f/(float)NUM_SAMPLES;
 	int offset = 0, visible;
@@ -681,7 +680,8 @@
 				no[0] = verts[j].no[0] / 32767.0;
 				no[1] = verts[j].no[1] / 32767.0;
 				no[2] = verts[j].no[2] / 32767.0;
-				Mat4MulVecfl(ob->obmat, no); // XXX
+				EulToMat4(ob->rot, mat);
+				Mat4MulVecfl(mat, no);
 
                                 N = samples[k][0] * no[0] + samples[k][1] * no[1] + samples[k][2] * no[2];
 
@@ -733,7 +733,7 @@
 	LightEnv* env=scene->lightenv;
 
         int i, k, m;
-        float no[3], N, *y_val;
+        float mat[4][4], no[3], N, *y_val;
 	int num_sh= (env->degree + 1) * (env->degree + 1);
         float weight= 4.0f/(float)NUM_SAMPLES;
 
@@ -760,11 +760,14 @@
 	}
 	
 	for (i = 0; i < num_verts; i++) {
+		memset(coeffs[i].val, 0, 25 * sizeof(float));
+
 	        for (k = 0; k < NUM_SAMPLES; k++) {
 			no[0] = verts[i].no[0] / 32767.0;
 			no[1] = verts[i].no[1] / 32767.0;
 			no[2] = verts[i].no[2] / 32767.0;
-			Mat4MulVecfl(ob->obmat, no); // XXX
+			EulToMat4(ob->rot, mat);
+			Mat4MulVecfl(mat, no);
 
 	                N = samples[k][0] * no[0] + samples[k][1] * no[1] + samples[k][2] * no[2];
 	
@@ -1058,9 +1061,9 @@
                                 lval[1] += y_val[m] * env->shcoeffs[m][1];
                                 lval[2] += y_val[m] * env->shcoeffs[m][2];
                         }
-			lval[0] = CLAMP(lval[0]);
-			lval[1] = CLAMP(lval[1]);
-			lval[2] = CLAMP(lval[2]);
+			CLAMP(lval[0], 0.0, 1.0);
+			CLAMP(lval[1], 0.0, 1.0);
+			CLAMP(lval[2], 0.0, 1.0);
                         lval[3] = 1.0;
                 }
         }





More information about the Bf-blender-cvs mailing list