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>2013-03-15 01:44:16 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-03-15 01:44:16 +0400
commit113f2367a089efb78ae0bc2b793d8be5e6b89183 (patch)
tree1988041ad01abb2d6e30b8a126d6f430acaf247c /source/blender/blenlib/intern/lasso.c
parenta2a594fb3686921e3225a470bc96f61bc12287a8 (diff)
move polygon intersection out of BLI_lasso into BLI_math_geom since its a generally useful function.
adds: - isect_point_poly_v2() - isect_point_poly_v2_int()
Diffstat (limited to 'source/blender/blenlib/intern/lasso.c')
-rw-r--r--source/blender/blenlib/intern/lasso.c39
1 files changed, 3 insertions, 36 deletions
diff --git a/source/blender/blenlib/intern/lasso.c b/source/blender/blenlib/intern/lasso.c
index 024c1010765..aa08a780394 100644
--- a/source/blender/blenlib/intern/lasso.c
+++ b/source/blender/blenlib/intern/lasso.c
@@ -57,46 +57,13 @@ bool BLI_lasso_is_point_inside(const int mcords[][2], const short moves,
const int sx, const int sy,
const int error_value)
{
- /* we do the angle rule, define that all added angles should be about zero or (2 * PI) */
- float angletot = 0.0, dot, ang, cross, fp1[2], fp2[2];
- int a;
- const int *p1, *p2;
-
if (sx == error_value) {
return false;
}
-
- p1 = mcords[moves - 1];
- p2 = mcords[0];
-
- /* first vector */
- fp1[0] = (float)(p1[0] - sx);
- fp1[1] = (float)(p1[1] - sy);
- normalize_v2(fp1);
-
- for (a = 0; a < moves; a++) {
- /* second vector */
- fp2[0] = (float)(p2[0] - sx);
- fp2[1] = (float)(p2[1] - sy);
- normalize_v2(fp2);
-
- /* dot and angle and cross */
- dot = fp1[0] * fp2[0] + fp1[1] * fp2[1];
- ang = fabs(saacos(dot));
-
- cross = (float)((p1[1] - p2[1]) * (p1[0] - sx) + (p2[0] - p1[0]) * (p1[1] - sy));
-
- if (cross < 0.0f) angletot -= ang;
- else angletot += ang;
-
- /* circulate */
- fp1[0] = fp2[0]; fp1[1] = fp2[1];
- p1 = p2;
- p2 = mcords[a + 1];
+ else {
+ int pt[2] = {sx, sy};
+ return isect_point_poly_v2_int(pt, mcords, moves);
}
-
- if (fabsf(angletot) > 4.0f) return true;
- return false;
}
/* edge version for lasso select. we assume boundbox check was done */