summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGilles Roudière <gilles.roudiere@gmail.com>2021-06-09 20:01:08 +0200
committerGilles Roudière <gilles.roudiere@gmail.com>2021-06-29 11:07:46 +0200
commit30a615dd94f2dc990466f3953ad26a0e3f79a170 (patch)
tree6c56164465c1a6e45babc05560e016e2335e7b53 /core
parenteb318d3e04ac6d3bb01b0f2a8311d06ba55c3a2b (diff)
Implement painting properties over TileSets
Diffstat (limited to 'core')
-rw-r--r--core/math/geometry_2d.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/core/math/geometry_2d.h b/core/math/geometry_2d.h
index 4958b5ac6a..a2894bc1d3 100644
--- a/core/math/geometry_2d.h
+++ b/core/math/geometry_2d.h
@@ -362,6 +362,19 @@ public:
return (intersections & 1);
}
+ static bool is_segment_intersecting_polygon(const Vector2 &p_from, const Vector2 &p_to, const Vector<Vector2> &p_polygon) {
+ int c = p_polygon.size();
+ const Vector2 *p = p_polygon.ptr();
+ for (int i = 0; i < c; i++) {
+ const Vector2 &v1 = p[i];
+ const Vector2 &v2 = p[(i + 1) % c];
+ if (segment_intersects_segment(p_from, p_to, v1, v2, nullptr)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
static real_t vec2_cross(const Point2 &O, const Point2 &A, const Point2 &B) {
return (real_t)(A.x - O.x) * (B.y - O.y) - (real_t)(A.y - O.y) * (B.x - O.x);
}