[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60544] trunk/blender/source/blender: fix for lasso selection (in non-zbuf mode) when the line intersected its self.

Campbell Barton ideasman42 at gmail.com
Fri Oct 4 12:48:25 CEST 2013


Revision: 60544
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60544
Author:   campbellbarton
Date:     2013-10-04 10:48:24 +0000 (Fri, 04 Oct 2013)
Log Message:
-----------
fix for lasso selection (in non-zbuf mode) when the line intersected its self.
isect_point_poly_v2() - add argument to check overlapping areas.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_math_geom.h
    trunk/blender/source/blender/blenlib/intern/lasso.c
    trunk/blender/source/blender/blenlib/intern/math_geom.c
    trunk/blender/source/blender/bmesh/tools/bmesh_bisect_plane.c
    trunk/blender/source/blender/editors/mesh/editmesh_knife.c

Modified: trunk/blender/source/blender/blenlib/BLI_math_geom.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_geom.h	2013-10-04 10:07:32 UTC (rev 60543)
+++ trunk/blender/source/blender/blenlib/BLI_math_geom.h	2013-10-04 10:48:24 UTC (rev 60544)
@@ -155,8 +155,8 @@
                               const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2], const float epsilon);
 
 /* point in polygon */
-bool isect_point_poly_v2(const float pt[2], const float verts[][2], const unsigned int nr);
-bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], const unsigned int nr);
+bool isect_point_poly_v2(const float pt[2], const float verts[][2], const unsigned int nr, const bool use_overlap);
+bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], const unsigned int nr, const bool use_overlap);
 
 int isect_point_quad_v2(const float p[2], const float a[2], const float b[2], const float c[2], const float d[2]);
 

Modified: trunk/blender/source/blender/blenlib/intern/lasso.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/lasso.c	2013-10-04 10:07:32 UTC (rev 60543)
+++ trunk/blender/source/blender/blenlib/intern/lasso.c	2013-10-04 10:48:24 UTC (rev 60544)
@@ -63,7 +63,7 @@
 	}
 	else {
 		int pt[2] = {sx, sy};
-		return isect_point_poly_v2_int(pt, mcords, moves);
+		return isect_point_poly_v2_int(pt, mcords, moves, true);
 	}
 }
 

Modified: trunk/blender/source/blender/blenlib/intern/math_geom.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_geom.c	2013-10-04 10:07:32 UTC (rev 60543)
+++ trunk/blender/source/blender/blenlib/intern/math_geom.c	2013-10-04 10:48:24 UTC (rev 60544)
@@ -712,7 +712,8 @@
 }
 
 /* point in polygon (keep float and int versions in sync) */
-bool isect_point_poly_v2(const float pt[2], const float verts[][2], const unsigned int nr)
+bool isect_point_poly_v2(const float pt[2], const float verts[][2], const unsigned int nr,
+                         const bool use_overlap)
 {
 	/* we do the angle rule, define that all added angles should be about zero or (2 * PI) */
 	float angletot = 0.0;
@@ -749,9 +750,18 @@
 		p1 = p2;
 	}
 
-	return (fabsf(angletot) > 4.0f);
+	angletot = fabsf(angletot);
+	if (use_overlap) {
+		const int nested = floorf((angletot / (float)(M_PI * 2.0)) + 0.00001f);
+		angletot -= nested * (float)(M_PI * 2.0);
+		return (angletot > 4.0f) != (nested % 2);
+	}
+	else {
+		return (angletot > 4.0f);
+	}
 }
-bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], const unsigned int nr)
+bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], const unsigned int nr,
+                             const bool use_overlap)
 {
 	/* we do the angle rule, define that all added angles should be about zero or (2 * PI) */
 	float angletot = 0.0;
@@ -788,7 +798,15 @@
 		p1 = p2;
 	}
 
-	return (fabsf(angletot) > 4.0f);
+	angletot = fabsf(angletot);
+	if (use_overlap) {
+		const int nested = floorf((angletot / (float)(M_PI * 2.0)) + 0.00001f);
+		angletot -= nested * (float)(M_PI * 2.0);
+		return (angletot > 4.0f) != (nested % 2);
+	}
+	else {
+		return (angletot > 4.0f);
+	}
 }
 
 /* point in tri */

Modified: trunk/blender/source/blender/bmesh/tools/bmesh_bisect_plane.c
===================================================================
--- trunk/blender/source/blender/bmesh/tools/bmesh_bisect_plane.c	2013-10-04 10:07:32 UTC (rev 60543)
+++ trunk/blender/source/blender/bmesh/tools/bmesh_bisect_plane.c	2013-10-04 10:48:24 UTC (rev 60544)
@@ -237,7 +237,7 @@
 				            face_verts_proj_2d[BM_VERT_LOOPINDEX(v_a)],
 				            face_verts_proj_2d[BM_VERT_LOOPINDEX(v_b)]);
 
-				if (isect_point_poly_v2(co_mid, (const float (*)[2])face_verts_proj_2d, f_len_orig)) {
+				if (isect_point_poly_v2(co_mid, (const float (*)[2])face_verts_proj_2d, f_len_orig, false)) {
 					BMLoop *l_a, *l_b;
 					bool found = false;
 					unsigned int j;

Modified: trunk/blender/source/blender/editors/mesh/editmesh_knife.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_knife.c	2013-10-04 10:07:32 UTC (rev 60543)
+++ trunk/blender/source/blender/editors/mesh/editmesh_knife.c	2013-10-04 10:48:24 UTC (rev 60544)
@@ -3525,7 +3525,7 @@
 		while (p) {
 			const float (*mval_fl)[2] = p->link;
 			const int mval_tot = MEM_allocN_len(mval_fl) / sizeof(*mval_fl);
-			isect += (int)isect_point_poly_v2(cent_ss, mval_fl, mval_tot - 1);
+			isect += (int)isect_point_poly_v2(cent_ss, mval_fl, mval_tot - 1, false);
 			p = p->next;
 		}
 




More information about the Bf-blender-cvs mailing list