[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24457] trunk/blender/source/blender/ blenlib: Math Lib

Brecht Van Lommel brecht at blender.org
Tue Nov 10 20:13:05 CET 2009


Revision: 24457
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24457
Author:   blendix
Date:     2009-11-10 20:13:05 +0100 (Tue, 10 Nov 2009)

Log Message:
-----------
Math Lib

* Fix remaining issues before conversion.
* Inline various vector functions, currently enabled for all platforms.
  I expect this to work in GCC/MSVC at least, if other platforms don't
  support it, #ifdef's can be added.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_math_geom.h
    trunk/blender/source/blender/blenlib/BLI_math_matrix.h
    trunk/blender/source/blender/blenlib/BLI_math_rotation.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_rotation.c
    trunk/blender/source/blender/blenlib/intern/math_vector.c

Added Paths:
-----------
    trunk/blender/source/blender/blenlib/intern/math_vector_inline.c

Modified: trunk/blender/source/blender/blenlib/BLI_math_geom.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_geom.h	2009-11-10 17:13:21 UTC (rev 24456)
+++ trunk/blender/source/blender/blenlib/BLI_math_geom.h	2009-11-10 19:13:05 UTC (rev 24457)
@@ -43,7 +43,7 @@
 float area_tri_v2(float a[2], float b[2], float c[2]);
 float area_tri_v3(float a[3], float b[3], float c[3]);
 float area_quad_v3(float a[3], float b[3], float c[3], float d[3]);
-float area_poly_v3(int nr, float *verts, float normal[3]); // TODO float verts[][3]
+float area_poly_v3(int nr, float verts[][3], float normal[3]);
 
 /********************************* Distance **********************************/
 
@@ -56,7 +56,6 @@
 
 /******************************* Intersection ********************************/
 
-/* TODO return values are not always first yet */
 /* TODO int return value consistency */
 
 /* line-line */
@@ -65,8 +64,8 @@
 #define ISECT_LINE_LINE_EXACT		 1
 #define ISECT_LINE_LINE_CROSS		 2
 
-short isect_line_line_v2(float a1[2], float a2[2], float b1[2], float b2[2]); // TODO return int
-short isect_line_line_v2_short(short a1[2], short a2[2], short b1[2], short b2[2]); // TODO return int
+int isect_line_line_v2(float a1[2], float a2[2], float b1[2], float b2[2]);
+int isect_line_line_v2_short(short a1[2], short a2[2], short b1[2], short b2[2]);
 
 /* Returns the number of point of interests
  * 0 - lines are colinear

Modified: trunk/blender/source/blender/blenlib/BLI_math_matrix.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_matrix.h	2009-11-10 17:13:21 UTC (rev 24456)
+++ trunk/blender/source/blender/blenlib/BLI_math_matrix.h	2009-11-10 19:13:05 UTC (rev 24457)
@@ -43,8 +43,8 @@
 					{ 0.0, 1.0, 0.0},\
 					{ 0.0, 0.0, 1.0}}
 
-void zero_m3(float *R); // TODO R[3][3]);
-void zero_m4(float *R); // TODO R[4][4]);
+void zero_m3(float R[3][3]);
+void zero_m4(float R[4][4]);
 
 void unit_m3(float R[3][3]);
 void unit_m4(float R[4][4]);
@@ -62,8 +62,6 @@
 void add_m3_m3m3(float R[3][3], float A[3][3], float B[3][3]);
 void add_m4_m4m4(float R[4][4], float A[4][4], float B[4][4]);
 
-// TODO review mul order
-
 void mul_m3_m3m3(float R[3][3], float A[3][3], float B[3][3]);
 void mul_m4_m4m4(float R[4][4], float A[4][4], float B[4][4]);
 void mul_m4_m3m4(float R[4][4], float A[3][3], float B[4][4]);
@@ -77,24 +75,24 @@
 	float M1[4][4], float M2[4][4], float M3[4][4], float M4[4][4],
 	float M5[4][4], float M6[4][4], float M7[4][4], float M8[4][4]);
 
-void mul_m4_v3(float M[4][4], float r[3]); // TODO order
+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_no_transl_m4v3(float M[4][4], float r[3]);
-void mul_m4_v4(float M[4][4], float r[3]); // TODO order
-void mul_project_m4_v4(float M[4][4], float r[3]); // TODO order
+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_project_m4_v4(float M[4][4], float r[3]);
 
-void mul_m3_v3(float M[3][3], float r[3]); // TODO order
-void mul_transposed_m3_v3(float M[3][3], float r[3]); // TODO order
+void mul_m3_v3(float M[3][3], float r[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]);
 
-void mul_m3_fl(float *R, float f); // TODO R[3][3], float f);
-void mul_m4_fl(float *R, float f); // TODO R[4][4], float f);
-void mul_no_transl_m4_fl(float *R, float f); // TODO R[4][4], float f);
+void mul_m3_fl(float R[3][3], float f);
+void mul_m4_fl(float R[4][4], float f);
+void mul_mat3_m4_fl(float R[4][4], float f);
 
-void invert_m3(float R[3][3]);
-void invert_m3_m3(float R[3][3], float A[3][3]);
-void invert_m4(float R[4][4]); // TODO does not exist
-int invert_m4_m4(float R[4][4], float A[4][4]); // TODO return int
+int invert_m3(float R[3][3]);
+int invert_m3_m3(float R[3][3], float A[3][3]);
+int invert_m4(float R[4][4]);
+int invert_m4_m4(float R[4][4], float A[4][4]);
 
 /****************************** Linear Algebra *******************************/
 
@@ -113,9 +111,6 @@
 void adjoint_m3_m3(float R[3][3], float A[3][3]);
 void adjoint_m4_m4(float R[4][4], float A[4][4]);
 
-//float determinant_m2(float A[2][2]); // TODO params
-//float determinant_m3(float A[3][3]); // TODO params
-
 float determinant_m2(
 	float a, float b,
 	float c, float d);

Modified: trunk/blender/source/blender/blenlib/BLI_math_rotation.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_rotation.h	2009-11-10 17:13:21 UTC (rev 24456)
+++ trunk/blender/source/blender/blenlib/BLI_math_rotation.h	2009-11-10 19:13:05 UTC (rev 24457)
@@ -44,7 +44,7 @@
 
 /* arithmetic */
 void mul_qt_qtqt(float q[4], float a[4], float b[4]);
-void mul_qt_v3(float q[4], float r[3]); // TODO order
+void mul_qt_v3(float q[4], float r[3]);
 void mul_qt_fl(float q[4], float f);
 void mul_fac_qt_fl(float q[4], float f);
 
@@ -60,7 +60,7 @@
 
 /* interpolation */
 void interp_qt_qtqt(float q[4], float a[4], float b[4], float t);
-void add_qt_qtqt(float q[4], float a[4], float b[4], float t); // TODO name
+void add_qt_qtqt(float q[4], float a[4], float b[4], float t);
 
 /* conversion */
 void quat_to_mat3(float mat[3][3], float q[4]);
@@ -72,8 +72,6 @@
 void vec_to_quat(float q[4], float vec[3], short axis, short upflag);
 void rotation_between_vecs_to_quat(float q[4], float v1[3], float v2[3]);
 
-void Mat3ToQuat_is_ok(float wmat[][3], float *q); // TODO what is this?
-
 /* other */
 void print_qt(char *str, float q[4]);
 
@@ -96,7 +94,7 @@
 void mat3_to_vec_rot(float vec[3], float *phi, float mat[3][3]);
 void mat4_to_vec_rot(float vec[3], float *phi, float mat[4][4]);
 
-void vec_rot_to_quat(float quat[4], float vec[3], float phi); // TODO
+void vec_rot_to_quat(float quat[4], float vec[3], float phi);
 void vec_rot_to_mat3(float mat[3][3], float vec[3], float phi);
 void vec_rot_to_mat4(float mat[4][4], float vec[3], float phi);
 

Modified: trunk/blender/source/blender/blenlib/BLI_math_vector.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_vector.h	2009-11-10 17:13:21 UTC (rev 24456)
+++ trunk/blender/source/blender/blenlib/BLI_math_vector.h	2009-11-10 19:13:05 UTC (rev 24457)
@@ -32,64 +32,73 @@
 extern "C" {
 #endif
 
+/* add platform/compiler checks here if it is not supported */
+#define BLI_MATH_INLINE
+
+#ifdef BLI_MATH_INLINE
+#ifdef _MSC_VER
+#define MINLINE static __inline
+#else
+#define MINLINE static inline
+#endif
+#include "intern/math_vector_inline.c"
+#else
 #define MINLINE
+#endif
 
-//#define static inline
-//#include "intern/math_vector_inline.h"
-
 /************************************* Init ***********************************/
 
-void zero_v2(float r[2]);
-void zero_v3(float r[3]);
+MINLINE void zero_v2(float r[2]);
+MINLINE void zero_v3(float r[3]);
 
-void copy_v2_v2(float r[2], float a[2]);
-void copy_v3_v3(float r[3], float a[3]);
+MINLINE void copy_v2_v2(float r[2], float a[2]);
+MINLINE void copy_v3_v3(float r[3], float a[3]);
 
 /********************************* Arithmetic ********************************/
 
-void add_v2_v2(float r[2], float a[2]);
-void add_v2_v2v2(float r[2], float a[2], float b[2]);
-void add_v3_v3(float r[3], float a[3]);
-void add_v3_v3v3(float r[3], float a[3], float b[3]);
+MINLINE void add_v2_v2(float r[2], float a[2]);
+MINLINE void add_v2_v2v2(float r[2], float a[2], float b[2]);
+MINLINE void add_v3_v3(float r[3], float a[3]);
+MINLINE void add_v3_v3v3(float r[3], float a[3], float b[3]);
 
-void sub_v2_v2(float r[2], float a[2]);
-void sub_v2_v2v2(float r[2], float a[2], float b[2]);
-void sub_v3_v3(float r[3], float a[3]);
-void sub_v3_v3v3(float r[3], float a[3], float b[3]);
+MINLINE void sub_v2_v2(float r[2], float a[2]);
+MINLINE void sub_v2_v2v2(float r[2], float a[2], float b[2]);
+MINLINE void sub_v3_v3(float r[3], float a[3]);
+MINLINE void sub_v3_v3v3(float r[3], float a[3], float b[3]);
 
-void mul_v2_fl(float r[2], float f);
-void mul_v3_fl(float r[3], float f);
-void mul_v3_v3fl(float r[3], float a[3], float f);
-void mul_v3_v3(float r[3], float a[3]);
-void mul_v3_v3v3(float r[3], float a[3], float b[3]);
+MINLINE void mul_v2_fl(float r[2], float f);
+MINLINE void mul_v3_fl(float r[3], float f);
+MINLINE void mul_v3_v3fl(float r[3], float a[3], float f);
+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]);
 
-void negate_v3(float r[3]);
-void negate_v3_v3(float r[3], float a[3]);
+MINLINE void negate_v3(float r[3]);
+MINLINE void negate_v3_v3(float r[3], float a[3]);
 
-float dot_v2v2(float a[2], float b[2]); 
-float dot_v3v3(float a[3], float b[3]);
+MINLINE float dot_v2v2(float a[2], float b[2]); 
+MINLINE float dot_v3v3(float a[3], float b[3]);
 
-float cross_v2v2(float a[2], float b[2]);
-void cross_v3_v3v3(float r[3], float a[3], float b[3]);
+MINLINE float cross_v2v2(float a[2], float b[2]);
+MINLINE void cross_v3_v3v3(float r[3], float a[3], float b[3]);
 
-void star_m3_v3(float R[3][3],float a[3]);
+MINLINE void star_m3_v3(float R[3][3],float a[3]);
 
 /*********************************** Length **********************************/
 
-float len_v2(float a[2]);
-float len_v2v2(float a[2], float b[2]);
-float len_v3(float a[3]);
-float len_v3v3(float a[3], float b[3]);
+MINLINE float len_v2(float a[2]);
+MINLINE float len_v2v2(float a[2], float b[2]);
+MINLINE float len_v3(float a[3]);
+MINLINE float len_v3v3(float a[3], float b[3]);
 
-float normalize_v2(float r[2]);
-float normalize_v3(float r[3]);
+MINLINE float normalize_v2(float r[2]);
+MINLINE float normalize_v3(float r[3]);
 
 /******************************* Interpolation *******************************/
 
-void interp_v2_v2v2(float r[2], const float a[2], const float b[2], const float t); // TODO const
-void interp_v2_v2v2v2(float r[2], const float a[2], const float b[2], const float c[3], const float t[3]); // TODO const
-void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t); // TODO const
-void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3]); // TODO const
+void interp_v2_v2v2(float r[2], float a[2], float b[2], float t);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list