diff options
| author | Rémi Verschelde | 2018-01-03 11:15:28 +0100 |
|---|---|---|
| committer | GitHub | 2018-01-03 11:15:28 +0100 |
| commit | 459ee51338ff9ffb8248a4351eee3b558438aa50 (patch) | |
| tree | b366aad4e6ee15907af75cb659f42b5ec79b6f58 /core/math/geometry.cpp | |
| parent | 0b235a5efa9f6825e638d98d9eaadcc11423b3c3 (diff) | |
| parent | 8505871a87b59b27acc0912a6dd815231c3b78b1 (diff) | |
| download | godot-459ee51338ff9ffb8248a4351eee3b558438aa50.tar.gz godot-459ee51338ff9ffb8248a4351eee3b558438aa50.tar.zst godot-459ee51338ff9ffb8248a4351eee3b558438aa50.zip | |
Diffstat (limited to 'core/math/geometry.cpp')
| -rw-r--r-- | core/math/geometry.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp index b2145eca8..a3b48320b 100644 --- a/core/math/geometry.cpp +++ b/core/math/geometry.cpp @@ -30,6 +30,17 @@ #include "geometry.h" #include "print_string.h" +bool Geometry::is_point_in_polygon(const Vector2 &p_point, const Vector<Vector2> &p_polygon) { + + Vector<int> indices = Geometry::triangulate_polygon(p_polygon); + for (int j = 0; j + 3 <= indices.size(); j += 3) { + int i1 = indices[j], i2 = indices[j + 1], i3 = indices[j + 2]; + if (Geometry::is_point_in_triangle(p_point, p_polygon[i1], p_polygon[i2], p_polygon[i3])) + return true; + } + return false; +} + void Geometry::MeshData::optimize_vertices() { Map<int, int> vtx_remap; |
