[Bf-blender-cvs] [a7ac594] master: Cleanup: rename line to segments, avoids confusion

Campbell Barton noreply at git.blender.org
Thu Nov 12 21:57:10 CET 2015


Commit: a7ac59414b8a9fee2fd7a9b8c39099f89239771d
Author: Campbell Barton
Date:   Fri Nov 13 07:25:36 2015 +1100
Branches: master
https://developer.blender.org/rBa7ac59414b8a9fee2fd7a9b8c39099f89239771d

Cleanup: rename line to segments, avoids confusion

Differentiate between lines and segments.

===================================================================

M	source/blender/blenkernel/intern/mask_evaluate.c
M	source/blender/blenlib/BLI_math_geom.h
M	source/blender/blenlib/intern/lasso.c
M	source/blender/blenlib/intern/math_geom.c
M	source/blender/blenlib/intern/rct.c
M	source/blender/editors/mesh/editmesh_knife.c
M	source/blender/editors/sculpt_paint/paint_image_proj.c
M	source/blender/editors/space_logic/logic_buttons.c
M	source/blender/editors/space_node/node_add.c
M	source/blender/editors/space_node/node_relationships.c

===================================================================

diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c
index 5517fc3..1b275f4 100644
--- a/source/blender/blenkernel/intern/mask_evaluate.c
+++ b/source/blender/blenkernel/intern/mask_evaluate.c
@@ -253,7 +253,7 @@ static void feather_bucket_check_intersect(
 		if (check_a >= cur_a - 1 || cur_b == check_a)
 			continue;
 
-		if (isect_seg_seg_v2(v1, v2, v3, v4)) {
+		if (isect_seg_seg_v2_simple(v1, v2, v3, v4)) {
 			int k;
 			float p[2];
 			float min_a[2], max_a[2];
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index dfc5189..d804b57 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -154,25 +154,31 @@ void limit_dist_v3(float v1[3], float v2[3], const float dist);
 #define ISECT_LINE_LINE_EXACT        1
 #define ISECT_LINE_LINE_CROSS        2
 
-int isect_line_line_v2_point(const float v0[2], const float v1[2], const float v2[2], const float v3[2], float r_vi[2]);
-int isect_line_line_v2(const float a1[2], const float a2[2], const float b1[2], const float b2[2]);
-int isect_line_line_v2_int(const int a1[2], const int a2[2], const int b1[2], const int b2[2]);
+int  isect_seg_seg_v2(const float a1[2], const float a2[2], const float b1[2], const float b2[2]);
+int  isect_seg_seg_v2_int(const int a1[2], const int a2[2], const int b1[2], const int b2[2]);
+int  isect_seg_seg_v2_point(const float v0[2], const float v1[2], const float v2[2], const float v3[2], float vi[2]);
+bool isect_seg_seg_v2_simple(const float v1[2], const float v2[2], const float v3[2], const float v4[2]);
+
 int isect_line_sphere_v3(const float l1[3], const float l2[3], const float sp[3], const float r, float r_p1[3], float r_p2[3]);
 int isect_line_sphere_v2(const float l1[2], const float l2[2], const float sp[2], const float r, float r_p1[2], float r_p2[2]);
-int isect_seg_seg_v2_point(const float v0[2], const float v1[2], const float v2[2], const float v3[2], float vi[2]);
-bool isect_seg_seg_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2]);
 
+int isect_line_line_v2_point(
+        const float v0[2], const float v1[2],
+        const float v2[2], const float v3[2],
+        float r_vi[2]);
 int isect_line_line_epsilon_v3(
         const float v1[3], const float v2[3],
-        const float v3[3], const float v4[3], float i1[3], float i2[3],
+        const float v3[3], const float v4[3],
+        float i1[3], float i2[3],
         const float epsilon);
 int isect_line_line_v3(
         const float v1[3], const float v2[3],
         const float v3[3], const float v4[3],
-        float i1[3], float i2[3]);
-bool isect_line_line_strict_v3(const float v1[3], const float v2[3],
-                               const float v3[3], const float v4[3],
-                               float vi[3], float *r_lambda);
+        float r_i1[3], float r_i2[3]);
+bool isect_line_line_strict_v3(
+        const float v1[3], const float v2[3],
+        const float v3[3], const float v4[3],
+        float vi[3], float *r_lambda);
 
 bool isect_ray_plane_v3(
         const float p1[3], const float d[3],
diff --git a/source/blender/blenlib/intern/lasso.c b/source/blender/blenlib/intern/lasso.c
index 2370453..25d43e9 100644
--- a/source/blender/blenlib/intern/lasso.c
+++ b/source/blender/blenlib/intern/lasso.c
@@ -87,9 +87,9 @@ bool BLI_lasso_is_edge_inside(const int mcords[][2], const unsigned int moves,
 
 	/* no points in lasso, so we have to intersect with lasso edge */
 
-	if (isect_line_line_v2_int(mcords[0], mcords[moves - 1], v1, v2) > 0) return true;
+	if (isect_seg_seg_v2_int(mcords[0], mcords[moves - 1], v1, v2) > 0) return true;
 	for (a = 0; a < moves - 1; a++) {
-		if (isect_line_line_v2_int(mcords[a], mcords[a + 1], v1, v2) > 0) return true;
+		if (isect_seg_seg_v2_int(mcords[a], mcords[a + 1], v1, v2) > 0) return true;
 	}
 
 	return false;
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 82da1e4..f8bcbae 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -649,7 +649,7 @@ void closest_on_tri_to_point_v3(float r[3], const float p[3],
 /******************************* Intersection ********************************/
 
 /* intersect Line-Line, shorts */
-int isect_line_line_v2_int(const int v1[2], const int v2[2], const int v3[2], const int v4[2])
+int isect_seg_seg_v2_int(const int v1[2], const int v2[2], const int v3[2], const int v4[2])
 {
 	float div, lambda, mu;
 
@@ -692,7 +692,7 @@ int isect_line_line_v2_point(const float v0[2], const float v1[2], const float v
 }
 
 /* intersect Line-Line, floats */
-int isect_line_line_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
+int isect_seg_seg_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
 {
 	float div, lambda, mu;
 
@@ -714,7 +714,10 @@ int isect_line_line_v2(const float v1[2], const float v2[2], const float v3[2],
  *  -1: collinear
  *   1: intersection
  */
-int isect_seg_seg_v2_point(const float v0[2], const float v1[2], const float v2[2], const float v3[2], float r_vi[2])
+int isect_seg_seg_v2_point(
+        const float v0[2], const float v1[2],
+        const float v2[2], const float v3[2],
+        float r_vi[2])
 {
 	float s10[2], s32[2], s30[2], d;
 	const float eps = 1e-6f;
@@ -813,7 +816,7 @@ int isect_seg_seg_v2_point(const float v0[2], const float v1[2], const float v2[
 	}
 }
 
-bool isect_seg_seg_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
+bool isect_seg_seg_v2_simple(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
 {
 #define CCW(A, B, C) \
 	((C[1] - A[1]) * (B[0] - A[0]) > \
@@ -824,17 +827,15 @@ bool isect_seg_seg_v2(const float v1[2], const float v2[2], const float v3[2], c
 #undef CCW
 }
 
+/**
+ * \param l1, l2: Coordinates (point of line).
+ * \param sp, r:  Coordinate and radius (sphere).
+ * \return r_p1, r_p2: Intersection coordinates.
+ */
 int isect_line_sphere_v3(const float l1[3], const float l2[3],
                          const float sp[3], const float r,
                          float r_p1[3], float r_p2[3])
 {
-	/* l1:         coordinates (point of line)
-	 * l2:         coordinates (point of line)
-	 * sp, r:      coordinates and radius (sphere)
-	 * r_p1, r_p2: return intersection coordinates
-	 */
-
-
 	/* adapted for use in blender by Campbell Barton - 2011
 	 *
 	 * atelier iebele abel - 2001
@@ -2011,7 +2012,8 @@ bool isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3
  */
 int isect_line_line_epsilon_v3(
         const float v1[3], const float v2[3],
-        const float v3[3], const float v4[3], float i1[3], float i2[3],
+        const float v3[3], const float v4[3],
+        float r_i1[3], float r_i2[3],
         const float epsilon)
 {
 	float a[3], b[3], c[3], ab[3], cb[3];
@@ -2035,8 +2037,8 @@ int isect_line_line_epsilon_v3(
 		cross_v3_v3v3(cb, c, b);
 
 		mul_v3_fl(a, dot_v3v3(cb, ab) / div);
-		add_v3_v3v3(i1, v1, a);
-		copy_v3_v3(i2, i1);
+		add_v3_v3v3(r_i1, v1, a);
+		copy_v3_v3(r_i2, r_i1);
 
 		return 1; /* one intersection only */
 	}
@@ -2062,10 +2064,10 @@ int isect_line_line_epsilon_v3(
 		cross_v3_v3v3(cb, c, b);
 
 		mul_v3_fl(a, dot_v3v3(cb, ab) / dot_v3v3(ab, ab));
-		add_v3_v3v3(i1, v1, a);
+		add_v3_v3v3(r_i1, v1, a);
 
 		/* for the second line, just substract the offset from the first intersection point */
-		sub_v3_v3v3(i2, i1, t);
+		sub_v3_v3v3(r_i2, r_i1, t);
 
 		return 2; /* two nearest points */
 	}
@@ -2073,10 +2075,11 @@ int isect_line_line_epsilon_v3(
 
 int isect_line_line_v3(
         const float v1[3], const float v2[3],
-        const float v3[3], const float v4[3], float i1[3], float i2[3])
+        const float v3[3], const float v4[3],
+        float r_i1[3], float r_i2[3])
 {
 	const float epsilon = 0.000001f;
-	return isect_line_line_epsilon_v3(v1, v2, v3, v4, i1, i2, epsilon);
+	return isect_line_line_epsilon_v3(v1, v2, v3, v4, r_i1, r_i2, epsilon);
 }
 
 /** Intersection point strictly between the two lines
@@ -4591,13 +4594,13 @@ bool is_quad_convex_v3(const float v1[3], const float v2[3], const float v3[3],
 	mul_v2_m3v3(vec[3], mat, v4);
 
 	/* linetests, the 2 diagonals have to instersect to be convex */
-	return (isect_line_line_v2(vec[0], vec[2], vec[1], vec[3]) > 0);
+	return (isect_seg_seg_v2(vec[0], vec[2], vec[1], vec[3]) > 0);
 }
 
 bool is_quad_convex_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
 {
 	/* linetests, the 2 diagonals have to instersect to be convex */
-	return (isect_line_line_v2(v1, v3, v2, v4) > 0);
+	return (isect_seg_seg_v2(v1, v3, v2, v4) > 0);
 }
 
 bool is_poly_convex_v2(const float verts[][2], unsigned int nr)
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index a5f7fe2..9d5a463 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -173,7 +173,7 @@ bool BLI_rcti_inside_rcti(rcti *rct_a, const rcti *rct_b)
 }
 
 
-/* based closely on 'isect_line_line_v2_int', but in modified so corner cases are treated as intersections */
+/* based closely on 'isect_seg_seg_v2_int', but in modified so corner cases are treated as intersections */
 static int isect_segments_i(const int v1[2], const int v2[2], const int v3[2], const int v4[2])
 {
 	const double div = (double)((v2[0] - v1[0]) * (v4[1] - v3[1]) - (v2[1] - v1[1]) * (v4[0] - v3[0]));
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 621155b..3c8ea19 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -1672,7 +1672,7 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
 		knife_project_v2(kcd, kfe->v2->cageco, se2);
 		isect_kind = (kfe_verts_in_cut) ? -1 : isect_seg_seg_v2_point(s1, s2, se1, se2, sint);
 		if (isect_kind == -1) {
-			/* isect_seg_seg_v2 doesn't do tolerance test around ends of s1-s2 */
+			/* isect_seg_seg_v2_simple doesn't do tolerance test around ends of s1-s2 */
 			closest_to

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list