[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56218] trunk/blender/source/blender/ blenlib/intern/math_geom.c: code cleanup: remove duplicate function _det_m3 (), clip_line_plane was copying a vector for no reason.

Campbell Barton ideasman42 at gmail.com
Mon Apr 22 20:32:11 CEST 2013


Revision: 56218
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56218
Author:   campbellbarton
Date:     2013-04-22 18:32:06 +0000 (Mon, 22 Apr 2013)
Log Message:
-----------
code cleanup: remove duplicate function _det_m3(), clip_line_plane was copying a vector for no reason.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/math_geom.c

Modified: trunk/blender/source/blender/blenlib/intern/math_geom.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_geom.c	2013-04-22 17:51:08 UTC (rev 56217)
+++ trunk/blender/source/blender/blenlib/intern/math_geom.c	2013-04-22 18:32:06 UTC (rev 56218)
@@ -1965,16 +1965,15 @@
 
 int clip_line_plane(float p1[3], float p2[3], const float plane[4])
 {
-	float dp[3], n[3], div, t, pc[3];
+	float dp[3], div, t, pc[3];
 
-	copy_v3_v3(n, plane);
 	sub_v3_v3v3(dp, p2, p1);
-	div = dot_v3v3(dp, n);
+	div = dot_v3v3(dp, plane);
 
 	if (div == 0.0f) /* parallel */
 		return 1;
 
-	t = -(dot_v3v3(p1, n) + plane[3]) / div;
+	t = -(dot_v3v3(p1, plane) + plane[3]) / div;
 
 	if (div > 0.0f) {
 		/* behind plane, completely clipped */
@@ -3135,18 +3134,6 @@
  * )
  */
 
-/* can't believe there is none in math utils */
-static float _det_m3(float m2[3][3])
-{
-	float det = 0.f;
-	if (m2) {
-		det = (m2[0][0] * (m2[1][1] * m2[2][2] - m2[1][2] * m2[2][1]) -
-		       m2[1][0] * (m2[0][1] * m2[2][2] - m2[0][2] * m2[2][1]) +
-		       m2[2][0] * (m2[0][1] * m2[1][2] - m2[0][2] * m2[1][1]));
-	}
-	return det;
-}
-
 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])
 {
@@ -3246,14 +3233,14 @@
 			/* this is pretty much Polardecompose 'inline' the algo based on Higham's thesis */
 			/* without the far case ... but seems to work here pretty neat                   */
 			odet = 0.f;
-			ndet = _det_m3(q);
+			ndet = determinant_m3_array(q);
 			while ((odet - ndet) * (odet - ndet) > eps && i < imax) {
 				invert_m3_m3(qi, q);
 				transpose_m3(qi);
 				add_m3_m3m3(q, q, qi);
 				mul_m3_fl(q, 0.5f);
 				odet = ndet;
-				ndet = _det_m3(q);
+				ndet = determinant_m3_array(q);
 				i++;
 			}
 




More information about the Bf-blender-cvs mailing list