[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42430] branches/bmesh/blender/source/ blender/blenlib/intern/math_geom.c: make use of axis_dominant_v3() function for is_quad_convex_v3()
Campbell Barton
ideasman42 at gmail.com
Mon Dec 5 03:57:40 CET 2011
Revision: 42430
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42430
Author: campbellbarton
Date: 2011-12-05 02:57:30 +0000 (Mon, 05 Dec 2011)
Log Message:
-----------
make use of axis_dominant_v3() function for is_quad_convex_v3()
Modified Paths:
--------------
branches/bmesh/blender/source/blender/blenlib/intern/math_geom.c
Modified: branches/bmesh/blender/source/blender/blenlib/intern/math_geom.c
===================================================================
--- branches/bmesh/blender/source/blender/blenlib/intern/math_geom.c 2011-12-05 02:12:49 UTC (rev 42429)
+++ branches/bmesh/blender/source/blender/blenlib/intern/math_geom.c 2011-12-05 02:57:30 UTC (rev 42430)
@@ -3055,34 +3055,21 @@
int is_quad_convex_v3(const float *v1, const float *v2, const float *v3, const float *v4)
{
float nor[3], nor1[3], nor2[3], vec[4][2];
+ int axis_a, axis_b;
/* define projection, do both trias apart, quad is undefined! */
- normal_tri_v3( nor1,v1, v2, v3);
- normal_tri_v3( nor2,v1, v3, v4);
- nor[0]= ABS(nor1[0]) + ABS(nor2[0]);
- nor[1]= ABS(nor1[1]) + ABS(nor2[1]);
- nor[2]= ABS(nor1[2]) + ABS(nor2[2]);
+ normal_tri_v3(nor1, v1, v2, v3);
+ normal_tri_v3(nor2, v1, v3, v4);
+ add_v3_v3v3(nor, nor1, nor2);
- if(nor[2] >= nor[0] && nor[2] >= nor[1]) {
- vec[0][0]= v1[0]; vec[0][1]= v1[1];
- vec[1][0]= v2[0]; vec[1][1]= v2[1];
- vec[2][0]= v3[0]; vec[2][1]= v3[1];
- vec[3][0]= v4[0]; vec[3][1]= v4[1];
- }
- else if(nor[1] >= nor[0] && nor[1]>= nor[2]) {
- vec[0][0]= v1[0]; vec[0][1]= v1[2];
- vec[1][0]= v2[0]; vec[1][1]= v2[2];
- vec[2][0]= v3[0]; vec[2][1]= v3[2];
- vec[3][0]= v4[0]; vec[3][1]= v4[2];
- }
- else {
- vec[0][0]= v1[1]; vec[0][1]= v1[2];
- vec[1][0]= v2[1]; vec[1][1]= v2[2];
- vec[2][0]= v3[1]; vec[2][1]= v3[2];
- vec[3][0]= v4[1]; vec[3][1]= v4[2];
- }
+ axis_dominant_v3(&axis_a, &axis_b, nor);
+
+ vec[0][0]= v1[axis_a]; vec[0][1]= v1[axis_b];
+ vec[1][0]= v2[axis_a]; vec[1][1]= v2[axis_b];
+
+ vec[2][0]= v3[axis_a]; vec[2][1]= v3[axis_b];
+ vec[3][0]= v4[axis_a]; vec[3][1]= v4[axis_b];
/* linetests, the 2 diagonals have to instersect to be convex */
- if( isect_line_line_v2(vec[0], vec[2], vec[1], vec[3]) > 0 ) return 1;
- return 0;
+ return (isect_line_line_v2(vec[0], vec[2], vec[1], vec[3]) > 0) ? 1 : 0;
}
More information about the Bf-blender-cvs
mailing list