[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24965] trunk/blender/source/blender/ blenlib: Math Lib: merging over some changes from the sculpt branch:

Brecht Van Lommel brecht at blender.org
Sat Nov 28 14:11:41 CET 2009


Revision: 24965
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24965
Author:   blendix
Date:     2009-11-28 14:11:41 +0100 (Sat, 28 Nov 2009)

Log Message:
-----------
Math Lib: merging over some changes from the sculpt branch:

* swap v2/v3
* multiply-and-add (madd) v3
* inline v3 short/float conversion
* mul_v3_m3v3

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_math_matrix.h
    trunk/blender/source/blender/blenlib/BLI_math_vector.h
    trunk/blender/source/blender/blenlib/intern/math_geom.c
    trunk/blender/source/blender/blenlib/intern/math_matrix.c
    trunk/blender/source/blender/blenlib/intern/math_vector.c
    trunk/blender/source/blender/blenlib/intern/math_vector_inline.c

Modified: trunk/blender/source/blender/blenlib/BLI_math_matrix.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_matrix.h	2009-11-28 11:34:04 UTC (rev 24964)
+++ trunk/blender/source/blender/blenlib/BLI_math_matrix.h	2009-11-28 13:11:41 UTC (rev 24965)
@@ -82,6 +82,7 @@
 void mul_project_m4_v4(float M[4][4], float r[3]);
 
 void mul_m3_v3(float M[3][3], float r[3]);
+void mul_v3_m3v3(float r[3], float M[3][3], float a[3]);
 void mul_transposed_m3_v3(float M[3][3], float r[3]);
 void mul_m3_v3_double(float M[3][3], double r[3]);
 

Modified: trunk/blender/source/blender/blenlib/BLI_math_vector.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_vector.h	2009-11-28 11:34:04 UTC (rev 24964)
+++ trunk/blender/source/blender/blenlib/BLI_math_vector.h	2009-11-28 13:11:41 UTC (rev 24965)
@@ -54,6 +54,9 @@
 MINLINE void copy_v2_v2(float r[2], float a[2]);
 MINLINE void copy_v3_v3(float r[3], float a[3]);
 
+MINLINE void swap_v2_v2(float a[2], float b[2]);
+MINLINE void swap_v3_v3(float a[3], float b[3]);
+
 /********************************* Arithmetic ********************************/
 
 MINLINE void add_v2_v2(float r[2], float a[2]);
@@ -72,6 +75,11 @@
 MINLINE void mul_v3_v3(float r[3], float a[3]);
 MINLINE void mul_v3_v3v3(float r[3], float a[3], float b[3]);
 
+MINLINE void madd_v3_v3fl(float r[3], float a[3], float f);
+MINLINE void madd_v3_v3v3(float r[3], float a[3], float b[3]);
+MINLINE void madd_v3_v3v3fl(float r[3], float a[3], float b[3], float f);
+MINLINE void madd_v3_v3v3v3(float r[3], float a[3], float b[3], float c[3]);
+
 MINLINE void negate_v3(float r[3]);
 MINLINE void negate_v3_v3(float r[3], float a[3]);
 
@@ -137,8 +145,8 @@
 void print_v3(char *str, float a[3]);
 void print_v4(char *str, float a[4]);
 
-void normal_short_to_float_v3(float r[3], short n[3]);
-void normal_float_to_short_v3(short r[3], float n[3]);
+MINLINE void normal_short_to_float_v3(float r[3], short n[3]);
+MINLINE void normal_float_to_short_v3(short r[3], float n[3]);
 
 void minmax_v3_v3v3(float r[3], float min[3], float max[3]);
 

Modified: trunk/blender/source/blender/blenlib/intern/math_geom.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_geom.c	2009-11-28 11:34:04 UTC (rev 24964)
+++ trunk/blender/source/blender/blenlib/intern/math_geom.c	2009-11-28 13:11:41 UTC (rev 24965)
@@ -1602,7 +1602,7 @@
 /* vector clouds */
 /* void vcloud_estimate_transform(int list_size, float (*pos)[3], float *weight,float (*rpos)[3], float *rweight,
   							   float lloc[3],float rloc[3],float lrot[3][3],float lscale[3][3])
-/*
+
 input
 (
 int list_size

Modified: trunk/blender/source/blender/blenlib/intern/math_matrix.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_matrix.c	2009-11-28 11:34:04 UTC (rev 24964)
+++ trunk/blender/source/blender/blenlib/intern/math_matrix.c	2009-11-28 13:11:41 UTC (rev 24965)
@@ -338,15 +338,19 @@
 	vec[3]=x*mat[0][3] + y*mat[1][3] + z*mat[2][3] + mat[3][3]*vec[3];
 }
 
-void mul_m3_v3(float mat[][3], float *vec)
+void mul_v3_m3v3(float r[3], float M[3][3], float a[3])
 {
-	float x,y;
+	r[0]= M[0][0]*a[0] + M[1][0]*a[1] + M[2][0]*a[2];
+	r[1]= M[0][1]*a[0] + M[1][1]*a[1] + M[2][1]*a[2];
+	r[2]= M[0][2]*a[0] + M[1][2]*a[1] + M[2][2]*a[2];
+}
 
-	x=vec[0]; 
-	y=vec[1];
-	vec[0]= x*mat[0][0] + y*mat[1][0] + mat[2][0]*vec[2];
-	vec[1]= x*mat[0][1] + y*mat[1][1] + mat[2][1]*vec[2];
-	vec[2]= x*mat[0][2] + y*mat[1][2] + mat[2][2]*vec[2];
+void mul_m3_v3(float M[3][3], float r[3])
+{
+	float tmp[3];
+
+	mul_v3_m3v3(tmp, M, r);
+	copy_v3_v3(r, tmp);
 }
 
 void mul_transposed_m3_v3(float mat[][3], float *vec)

Modified: trunk/blender/source/blender/blenlib/intern/math_vector.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_vector.c	2009-11-28 11:34:04 UTC (rev 24964)
+++ trunk/blender/source/blender/blenlib/intern/math_vector.c	2009-11-28 13:11:41 UTC (rev 24965)
@@ -292,20 +292,6 @@
 	printf("%s: %.3f %.3f %.3f %.3f\n", str, v[0], v[1], v[2], v[3]);
 }
 
-void normal_short_to_float_v3(float *out, short *in)
-{
-	out[0] = in[0]*(1.0f/32767.0f);
-	out[1] = in[1]*(1.0f/32767.0f);
-	out[2] = in[2]*(1.0f/32767.0f);
-}
-
-void normal_float_to_short_v3(short *out, float *in)
-{
-	out[0] = (short)(in[0]*32767.0f);
-	out[1] = (short)(in[1]*32767.0f);
-	out[2] = (short)(in[2]*32767.0f);
-}
-
 void minmax_v3_v3v3(float *min, float *max, float *vec)
 {
 	if(min[0]>vec[0]) min[0]= vec[0];

Modified: trunk/blender/source/blender/blenlib/intern/math_vector_inline.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_vector_inline.c	2009-11-28 11:34:04 UTC (rev 24964)
+++ trunk/blender/source/blender/blenlib/intern/math_vector_inline.c	2009-11-28 13:11:41 UTC (rev 24965)
@@ -58,6 +58,19 @@
 	r[2]= a[2];
 }
 
+MINLINE void swap_v2_v2(float a[2], float b[2])
+{
+	SWAP(float, a[0], b[0]);
+	SWAP(float, a[1], b[1]);
+}
+
+MINLINE void swap_v3_v3(float a[3], float b[3])
+{
+	SWAP(float, a[0], b[0]);
+	SWAP(float, a[1], b[1]);
+	SWAP(float, a[2], b[2]);
+}
+
 /********************************* Arithmetic ********************************/
 
 MINLINE void add_v2_v2(float *r, float *a)
@@ -76,7 +89,7 @@
 {
 	r[0] += a[0];
 	r[1] += a[1];
-	r[1] += a[1];
+	r[2] += a[2];
 }
 
 MINLINE void add_v3_v3v3(float *r, float *a, float *b)
@@ -102,7 +115,7 @@
 {
 	r[0] -= a[0];
 	r[1] -= a[1];
-	r[1] -= a[1];
+	r[2] -= a[2];
 }
 
 MINLINE void sub_v3_v3v3(float *r, float *a, float *b)
@@ -139,6 +152,34 @@
 	r[2] *= a[2];
 }
 
+MINLINE void madd_v3_v3fl(float r[3], float a[3], float f)
+{
+	r[0] += a[0]*f;
+	r[1] += a[1]*f;
+	r[2] += a[2]*f;
+}
+
+MINLINE void madd_v3_v3v3(float r[3], float a[3], float b[3])
+{
+	r[0] += a[0]*b[0];
+	r[1] += a[1]*b[1];
+	r[2] += a[2]*b[2];
+}
+
+MINLINE void madd_v3_v3v3fl(float r[3], float a[3], float b[3], float f)
+{
+	r[0] = a[0] + b[0]*f;
+	r[1] = a[1] + b[1]*f;
+	r[2] = a[2] + b[2]*f;
+}
+
+MINLINE void madd_v3_v3v3v3(float r[3], float a[3], float b[3], float c[3])
+{
+	r[0] = a[0] + b[0]*c[0];
+	r[1] = a[1] + b[1]*c[1];
+	r[2] = a[2] + b[2]*c[2];
+}
+
 MINLINE void mul_v3_v3v3(float *v, float *v1, float *v2)
 {
 	v[0] = v1[0] * v2[0];
@@ -254,5 +295,19 @@
 	return d;
 }
 
+MINLINE void normal_short_to_float_v3(float *out, short *in)
+{
+	out[0] = in[0]*(1.0f/32767.0f);
+	out[1] = in[1]*(1.0f/32767.0f);
+	out[2] = in[2]*(1.0f/32767.0f);
+}
+
+MINLINE void normal_float_to_short_v3(short *out, float *in)
+{
+	out[0] = (short)(in[0]*32767.0f);
+	out[1] = (short)(in[1]*32767.0f);
+	out[2] = (short)(in[2]*32767.0f);
+}
+
 #endif /* BLI_MATH_VECTOR_INLINE */
 





More information about the Bf-blender-cvs mailing list