[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44840] trunk/blender/source/blender/ blenlib: better fix for [#30529], find the right axis rather then checking for folded quads.

Campbell Barton ideasman42 at gmail.com
Mon Mar 12 22:38:25 CET 2012


Revision: 44840
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44840
Author:   campbellbarton
Date:     2012-03-12 21:38:13 +0000 (Mon, 12 Mar 2012)
Log Message:
-----------
better fix for [#30529], find the right axis rather then checking for folded quads.

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

Modified: trunk/blender/source/blender/blenlib/BLI_math_geom.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_geom.h	2012-03-12 21:18:28 UTC (rev 44839)
+++ trunk/blender/source/blender/blenlib/BLI_math_geom.h	2012-03-12 21:38:13 UTC (rev 44840)
@@ -54,7 +54,7 @@
 float area_quad_v3(const float a[3], const float b[3], const float c[3], const float d[3]);
 float area_poly_v3(int nr, float verts[][3], const float normal[3]);
 
-int is_quad_convex_v3(const float *v1, const float *v2, const float *v3, const float *v4);
+int is_quad_convex_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3]);
 
 /********************************* Distance **********************************/
 

Modified: trunk/blender/source/blender/blenlib/intern/math_geom.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_geom.c	2012-03-12 21:18:28 UTC (rev 44839)
+++ trunk/blender/source/blender/blenlib/intern/math_geom.c	2012-03-12 21:38:13 UTC (rev 44840)
@@ -3054,25 +3054,23 @@
 }
 
 /* evaluate if entire quad is a proper convex quad */
- int is_quad_convex_v3(const float *v1, const float *v2, const float *v3, const float *v4)
+ int is_quad_convex_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
  {
 	float nor[3], nor1[3], nor2[3], vec[4][2];
 	int axis_a, axis_b;
 
 	/* define projection, do both trias apart, quad is undefined! */
 
-	/* strictly speaking this isn't necessarily convex,
-	 * but when try normals point away from eachother
-	 * we don't wan't to make that face */
-	normal_tri_v3(nor1, v2, v3, v4);
-	normal_tri_v3(nor2, v1, v2, v4);
-	if (UNLIKELY(dot_v3v3(nor1, nor2) < 0.0f)) {
-		return FALSE;
-	}
 	normal_tri_v3(nor1, v1, v2, v3);
 	normal_tri_v3(nor2, v1, v3, v4);
+
+	/* when the face is folded over as 2 tris we probably don't want to create
+	 * a quad from it, but go ahead with the intersection test since this
+	 * isn't a function for degenerate faces */
 	if (UNLIKELY(dot_v3v3(nor1, nor2) < 0.0f)) {
-		return FALSE;
+		/* flip so adding normals in the opposite direction
+		 * doesnt give a zero length vector */
+		negate_v3(nor2);
 	}
 
 	add_v3_v3v3(nor, nor1, nor2);




More information about the Bf-blender-cvs mailing list