[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27110] branches/render25/source/blender/ blenlib: Render Branch: math functions
Brecht Van Lommel
brecht at blender.org
Tue Feb 23 20:27:36 CET 2010
Revision: 27110
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27110
Author: blendix
Date: 2010-02-23 20:27:36 +0100 (Tue, 23 Feb 2010)
Log Message:
-----------
Render Branch: math functions
* add len_squared_v3v3
* add mul_v4_m4v4
* add box_minmax_bounds_m4
* rename disc_to_sh to vec_fac_to_sh
Modified Paths:
--------------
branches/render25/source/blender/blenlib/BLI_math_geom.h
branches/render25/source/blender/blenlib/BLI_math_matrix.h
branches/render25/source/blender/blenlib/BLI_math_vector.h
branches/render25/source/blender/blenlib/BLI_rand.h
branches/render25/source/blender/blenlib/intern/math_geom.c
branches/render25/source/blender/blenlib/intern/math_geom_inline.c
branches/render25/source/blender/blenlib/intern/math_matrix.c
branches/render25/source/blender/blenlib/intern/math_vector_inline.c
Modified: branches/render25/source/blender/blenlib/BLI_math_geom.h
===================================================================
--- branches/render25/source/blender/blenlib/BLI_math_geom.h 2010-02-23 19:24:59 UTC (rev 27109)
+++ branches/render25/source/blender/blenlib/BLI_math_geom.h 2010-02-23 19:27:36 UTC (rev 27110)
@@ -152,6 +152,8 @@
int box_clip_bounds_m4(float boundbox[2][3],
float bounds[4], float winmat[4][4]);
+void box_minmax_bounds_m4(float min[3], float max[3],
+ float boundbox[2][3], float mat[4][4]);
/********************************** Mapping **********************************/
@@ -189,7 +191,7 @@
MINLINE void add_sh_shsh(float r[9], float a[9], float b[9]);
MINLINE float eval_shv3(float r[9], float v[3]);
-MINLINE void disc_to_sh(float r[9], float n[3], float area);
+MINLINE void vec_fac_to_sh(float r[9], float v[3], float fac);
#ifdef __cplusplus
}
Modified: branches/render25/source/blender/blenlib/BLI_math_matrix.h
===================================================================
--- branches/render25/source/blender/blenlib/BLI_math_matrix.h 2010-02-23 19:24:59 UTC (rev 27109)
+++ branches/render25/source/blender/blenlib/BLI_math_matrix.h 2010-02-23 19:27:36 UTC (rev 27110)
@@ -78,7 +78,8 @@
void mul_m4_v3(float M[4][4], float r[3]);
void mul_v3_m4v3(float r[3], float M[4][4], float v[3]);
void mul_mat3_m4_v3(float M[4][4], float r[3]);
-void mul_m4_v4(float M[4][4], float r[3]);
+void mul_m4_v4(float M[4][4], float r[4]);
+void mul_v4_m4v4(float r[4], float M[4][4], float v[4]);
void mul_project_m4_v4(float M[4][4], float r[3]);
void mul_m3_v3(float M[3][3], float r[3]);
Modified: branches/render25/source/blender/blenlib/BLI_math_vector.h
===================================================================
--- branches/render25/source/blender/blenlib/BLI_math_vector.h 2010-02-23 19:24:59 UTC (rev 27109)
+++ branches/render25/source/blender/blenlib/BLI_math_vector.h 2010-02-23 19:27:36 UTC (rev 27110)
@@ -95,6 +95,7 @@
MINLINE float len_v2v2(const float a[2], const float b[2]);
MINLINE float len_v3(const float a[3]);
MINLINE float len_v3v3(const float a[3], const float b[3]);
+MINLINE float len_squared_v3v3(const float a[3], const float b[3]);
MINLINE float normalize_v2(float r[2]);
MINLINE float normalize_v2_v2(float r[2], const float a[2]);
Modified: branches/render25/source/blender/blenlib/BLI_rand.h
===================================================================
--- branches/render25/source/blender/blenlib/BLI_rand.h 2010-02-23 19:24:59 UTC (rev 27109)
+++ branches/render25/source/blender/blenlib/BLI_rand.h 2010-02-23 19:27:36 UTC (rev 27110)
@@ -83,15 +83,15 @@
/** Better seed for the random number generator, using noise.c hash[] */
- /** Allows up to 16 threads to address */
+ /** Allows up to BLENDER_MAX_THREADS threads to address */
void BLI_thread_srandom (int thread, unsigned int seed);
/** Return a pseudo-random number N where 0<=N<(2^31) */
- /** Allows up to 16 threads to address */
+ /** Allows up to BLENDER_MAX_THREADS threads to address */
int BLI_thread_rand (int thread);
/** Return a pseudo-random number N where 0.0f<=N<1.0f */
- /** Allows up to 16 threads to address */
+ /** Allows up to BLENDER_MAX_THREADS threads to address */
float BLI_thread_frand (int thread);
Modified: branches/render25/source/blender/blenlib/intern/math_geom.c
===================================================================
--- branches/render25/source/blender/blenlib/intern/math_geom.c 2010-02-23 19:24:59 UTC (rev 27109)
+++ branches/render25/source/blender/blenlib/intern/math_geom.c 2010-02-23 19:27:36 UTC (rev 27110)
@@ -30,10 +30,13 @@
#include <stdlib.h>
#include <string.h>
+#include "MEM_guardedalloc.h"
+
#include "BLI_math.h"
#include "BLI_memarena.h"
-#include "MEM_guardedalloc.h"
+#include "BKE_utildefines.h"
+
/********************************** Polygons *********************************/
void cent_tri_v3(float *cent, float *v1, float *v2, float *v3)
@@ -125,10 +128,6 @@
return (len/2.0f);
}
-#define MAX2(x,y) ((x)>(y) ? (x) : (y))
-#define MAX3(x,y,z) MAX2(MAX2((x),(y)) , (z))
-
-
float area_poly_v3(int nr, float verts[][3], float *normal)
{
float x, y, z, area, max;
@@ -1767,6 +1766,27 @@
return flag;
}
+void box_minmax_bounds_m4(float min[3], float max[3], float boundbox[2][3], float mat[4][4])
+{
+ float mn[3], mx[3], vec[3];
+ int a;
+
+ copy_v3_v3(mn, min);
+ copy_v3_v3(mx, max);
+
+ for(a=0; a<8; a++) {
+ vec[0]= (a & 1)? boundbox[0][0]: boundbox[1][0];
+ vec[1]= (a & 2)? boundbox[0][1]: boundbox[1][1];
+ vec[2]= (a & 4)? boundbox[0][2]: boundbox[1][2];
+
+ mul_m4_v3(mat, vec);
+ DO_MINMAX(vec, mn, mx);
+ }
+
+ copy_v3_v3(min, mn);
+ copy_v3_v3(max, mx);
+}
+
/********************************** Mapping **********************************/
void map_to_tube(float *u, float *v,float x, float y, float z)
Modified: branches/render25/source/blender/blenlib/intern/math_geom_inline.c
===================================================================
--- branches/render25/source/blender/blenlib/intern/math_geom_inline.c 2010-02-23 19:24:59 UTC (rev 27109)
+++ branches/render25/source/blender/blenlib/intern/math_geom_inline.c 2010-02-23 19:27:36 UTC (rev 27110)
@@ -76,15 +76,15 @@
return sum;
}
-MINLINE void disc_to_sh(float r[9], float n[3], float area)
+MINLINE void vec_fac_to_sh(float r[9], float v[3], float fac)
{
/* See formula (3) in:
"An Efficient Representation for Irradiance Environment Maps" */
float sh[9], x, y, z;
- x= n[0];
- y= n[1];
- z= n[2];
+ x= v[0];
+ y= v[1];
+ z= v[2];
sh[0]= 0.282095f;
@@ -98,7 +98,7 @@
sh[7]= 1.092548f*x*z;
sh[8]= 0.546274f*(x*x - y*y);
- mul_sh_fl(sh, area);
+ mul_sh_fl(sh, fac);
copy_sh_sh(r, sh);
}
Modified: branches/render25/source/blender/blenlib/intern/math_matrix.c
===================================================================
--- branches/render25/source/blender/blenlib/intern/math_matrix.c 2010-02-23 19:24:59 UTC (rev 27109)
+++ branches/render25/source/blender/blenlib/intern/math_matrix.c 2010-02-23 19:27:36 UTC (rev 27110)
@@ -325,19 +325,25 @@
vec[2] /= w;
}
-void mul_m4_v4(float mat[][4], float *vec)
+void mul_v4_m4v4(float r[4], float mat[4][4], float v[4])
{
- float x,y,z;
+ float x, y, z;
- x=vec[0];
- y=vec[1];
- z= vec[2];
- vec[0]=x*mat[0][0] + y*mat[1][0] + z*mat[2][0] + mat[3][0]*vec[3];
- vec[1]=x*mat[0][1] + y*mat[1][1] + z*mat[2][1] + mat[3][1]*vec[3];
- vec[2]=x*mat[0][2] + y*mat[1][2] + z*mat[2][2] + mat[3][2]*vec[3];
- vec[3]=x*mat[0][3] + y*mat[1][3] + z*mat[2][3] + mat[3][3]*vec[3];
+ x= v[0];
+ y= v[1];
+ z= v[2];
+
+ r[0]= x*mat[0][0] + y*mat[1][0] + z*mat[2][0] + mat[3][0]*v[3];
+ r[1]= x*mat[0][1] + y*mat[1][1] + z*mat[2][1] + mat[3][1]*v[3];
+ r[2]= x*mat[0][2] + y*mat[1][2] + z*mat[2][2] + mat[3][2]*v[3];
+ r[3]= x*mat[0][3] + y*mat[1][3] + z*mat[2][3] + mat[3][3]*v[3];
}
+void mul_m4_v4(float mat[4][4], float r[4])
+{
+ mul_v4_m4v4(r, mat, r);
+}
+
void mul_v3_m3v3(float r[3], float M[3][3], float a[3])
{
r[0]= M[0][0]*a[0] + M[1][0]*a[1] + M[2][0]*a[2];
Modified: branches/render25/source/blender/blenlib/intern/math_vector_inline.c
===================================================================
--- branches/render25/source/blender/blenlib/intern/math_vector_inline.c 2010-02-23 19:24:59 UTC (rev 27109)
+++ branches/render25/source/blender/blenlib/intern/math_vector_inline.c 2010-02-23 19:27:36 UTC (rev 27110)
@@ -305,6 +305,14 @@
return len_v3(d);
}
+MINLINE float len_squared_v3v3(const float a[3], const float b[3])
+{
+ float d[3];
+
+ sub_v3_v3v3(d, b, a);
+ return dot_v3v3(d, d);
+}
+
MINLINE float normalize_v2_v2(float r[2], const float a[2])
{
float d= dot_v2v2(a, a);
More information about the Bf-blender-cvs
mailing list