aboutsummaryrefslogtreecommitdiffstats
path: root/legacy/evas/src/lib/canvas/evas_object_polygon.c
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2011-06-27 05:31:07 +0000
committerTom Hacohen <tom@stosb.com>2011-06-27 05:31:07 +0000
commitfa78e73f6ba67ea48af58d9335d9cca5ed9cd02e (patch)
treee3b9c38643da4173c3acc641100d29f74f4165fd /legacy/evas/src/lib/canvas/evas_object_polygon.c
parentRevert "bla" - Wasn't supposed to go in yet. (diff)
downloadefl-fa78e73f6ba67ea48af58d9335d9cca5ed9cd02e.tar.gz
Evas polygon: Fix polygon is_inside calculation.
SVN revision: 60721
Diffstat (limited to 'legacy/evas/src/lib/canvas/evas_object_polygon.c')
-rw-r--r--legacy/evas/src/lib/canvas/evas_object_polygon.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/legacy/evas/src/lib/canvas/evas_object_polygon.c b/legacy/evas/src/lib/canvas/evas_object_polygon.c
index d4798afd46..4fe6030366 100644
--- a/legacy/evas/src/lib/canvas/evas_object_polygon.c
+++ b/legacy/evas/src/lib/canvas/evas_object_polygon.c
@@ -525,13 +525,18 @@ evas_object_polygon_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
p_next = eina_list_data_get(o->points);
}
- line_y = ((double) (p->y - p_next->y) / (double) (p->x - p_next->x)) *
- (x - p_next->x) + p_next->y;
- /* We crossed that edge if the line is directly above us */
- if ((line_y < y) &&
- (((p->x < p_next->x) && (p->x <= x) && (x <= p_next->x)) ||
- ((p->x > p_next->x) && (p_next->x <= x) && (x <= p->x))))
- num_edges++;
+ /* This only works if this condition is true */
+ if ((x != p_next->x) && (p->x != p_next->x))
+ {
+ line_y = ((double) (p->y - p_next->y) /
+ (double) (p->x - p_next->x)) *
+ (x - p_next->x) + p_next->y;
+ /* We crossed that edge if the line is directly above us */
+ if ((line_y < y) &&
+ (((p->x < p_next->x) && (p->x <= x) && (x <= p_next->x)) ||
+ ((p->x > p_next->x) && (p_next->x <= x) && (x <= p->x))))
+ num_edges++;
+ }
}
/* Return true if num_edges is odd */