Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-11-12 23:25:36 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-11-12 23:48:05 +0300
commita7ac59414b8a9fee2fd7a9b8c39099f89239771d (patch)
tree70289cd6d50009e6930962d48c55777a87951276
parent930771d0cf6bf296b42849b675a1e0c52d04c003 (diff)
Cleanup: rename line to segments, avoids confusion
Differentiate between lines and segments.
-rw-r--r--source/blender/blenkernel/intern/mask_evaluate.c2
-rw-r--r--source/blender/blenlib/BLI_math_geom.h26
-rw-r--r--source/blender/blenlib/intern/lasso.c4
-rw-r--r--source/blender/blenlib/intern/math_geom.c43
-rw-r--r--source/blender/blenlib/intern/rct.c2
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c8
-rw-r--r--source/blender/editors/space_logic/logic_buttons.c2
-rw-r--r--source/blender/editors/space_node/node_add.c2
-rw-r--r--source/blender/editors/space_node/node_relationships.c2
10 files changed, 53 insertions, 44 deletions
diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c
index 5517fc36bc1..1b275f455f4 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 dfc51895c77..d804b57ffe1 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 23704538413..25d43e9d002 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 82da1e4ef58..f8bcbae00b0 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 a5f7fe2a008..9d5a4630f68 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 621155bc696..3c8ea19180e 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_line_segment_v2(sint, s1, se1, se2);
if (len_squared_v2v2(sint, s1) <= line_tol_sq)
isect_kind = 1;
@@ -2480,7 +2480,7 @@ static bool find_hole_chains(KnifeTool_OpData *kcd, ListBase *hole, BMFace *f, L
for (k = 0; k < nh && ok; k++) {
if (k == i || (k + 1) % nh == i)
continue;
- if (isect_line_line_v2(hco[i], fco[j], hco[k], hco[(k + 1) % nh]))
+ if (isect_seg_seg_v2(hco[i], fco[j], hco[k], hco[(k + 1) % nh]))
ok = false;
}
if (!ok)
@@ -2488,7 +2488,7 @@ static bool find_hole_chains(KnifeTool_OpData *kcd, ListBase *hole, BMFace *f, L
for (k = 0; k < nf && ok; k++) {
if (k == j || (k + 1) % nf == j)
continue;
- if (isect_line_line_v2(hco[i], fco[j], fco[k], fco[(k + 1) % nf]))
+ if (isect_seg_seg_v2(hco[i], fco[j], fco[k], fco[(k + 1) % nf]))
ok = false;
}
if (ok) {
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 6ebf965b215..64fefa38341 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -2989,10 +2989,10 @@ static bool project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int buck
isect_point_tri_v2(p3, v1, v2, v3) ||
isect_point_tri_v2(p4, v1, v2, v3) ||
/* we can avoid testing v3,v1 because another intersection MUST exist if this intersects */
- (isect_line_line_v2(p1, p2, v1, v2) || isect_line_line_v2(p1, p2, v2, v3)) ||
- (isect_line_line_v2(p2, p3, v1, v2) || isect_line_line_v2(p2, p3, v2, v3)) ||
- (isect_line_line_v2(p3, p4, v1, v2) || isect_line_line_v2(p3, p4, v2, v3)) ||
- (isect_line_line_v2(p4, p1, v1, v2) || isect_line_line_v2(p4, p1, v2, v3)))
+ (isect_seg_seg_v2(p1, p2, v1, v2) || isect_seg_seg_v2(p1, p2, v2, v3)) ||
+ (isect_seg_seg_v2(p2, p3, v1, v2) || isect_seg_seg_v2(p2, p3, v2, v3)) ||
+ (isect_seg_seg_v2(p3, p4, v1, v2) || isect_seg_seg_v2(p3, p4, v2, v3)) ||
+ (isect_seg_seg_v2(p4, p1, v1, v2) || isect_seg_seg_v2(p4, p1, v2, v3)))
{
return 1;
}
diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c
index e0cbc1c9539..12c7ef3d3ec 100644
--- a/source/blender/editors/space_logic/logic_buttons.c
+++ b/source/blender/editors/space_logic/logic_buttons.c
@@ -91,7 +91,7 @@ static int cut_links_intersect(uiLinkLine *line, float mcoords[][2], int tot)
if (ui_link_bezier_points(&rectlink, coord_array, LINK_RESOL)) {
for (i=0; i<tot-1; i++)
for (b=0; b<LINK_RESOL-1; b++)
- if (isect_line_line_v2(mcoords[i], mcoords[i+1], coord_array[b], coord_array[b+1]) > 0)
+ if (isect_seg_seg_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0)
return 1;
}
return 0;
diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c
index aef1116b0b8..07dc654b735 100644
--- a/source/blender/editors/space_node/node_add.c
+++ b/source/blender/editors/space_node/node_add.c
@@ -107,7 +107,7 @@ static bool add_reroute_intersect_check(bNodeLink *link, float mcoords[][2], int
for (i = 0; i < tot - 1; i++)
for (b = 0; b < NODE_LINK_RESOL; b++)
- if (isect_line_line_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) {
+ if (isect_seg_seg_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) {
result[0] = (mcoords[i][0] + mcoords[i + 1][0]) / 2.0f;
result[1] = (mcoords[i][1] + mcoords[i + 1][1]) / 2.0f;
return 1;
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index 3bd72370f5f..8a808b2ae9d 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -858,7 +858,7 @@ static bool cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot)
for (i = 0; i < tot - 1; i++)
for (b = 0; b < NODE_LINK_RESOL; b++)
- if (isect_line_line_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0)
+ if (isect_seg_seg_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0)
return 1;
}
return 0;