summaryrefslogtreecommitdiffstats
path: root/core/math/geometry.h
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-03-03 14:41:36 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-03-03 14:41:36 -0300
commit2c2894ceb674927a35d2798b3e63adabdb020077 (patch)
tree9e8950e0acc8fb7531fa60ce8c0321a5b60c335a /core/math/geometry.h
parent4d2198110b4af7f203eeef95697255569e49bce7 (diff)
parenta0ee5cc3531786a652ee43d3a57cb69dff34bd70 (diff)
downloadredot-engine-2c2894ceb674927a35d2798b3e63adabdb020077.tar.gz
Merge branch 'master' of https://github.com/okamstudio/godot
Conflicts: modules/gdscript/gd_tokenizer.cpp scene/resources/shader_graph.h
Diffstat (limited to 'core/math/geometry.h')
-rw-r--r--core/math/geometry.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/math/geometry.h b/core/math/geometry.h
index 81530e30c0..7e0cc01a22 100644
--- a/core/math/geometry.h
+++ b/core/math/geometry.h
@@ -511,6 +511,20 @@ public:
else
return p_segment[0]+n*d; // inside
}
+
+ static bool is_point_in_triangle(const Vector2& s, const Vector2& a, const Vector2& b, const Vector2& c)
+ {
+ int as_x = s.x-a.x;
+ int as_y = s.y-a.y;
+
+ bool s_ab = (b.x-a.x)*as_y-(b.y-a.y)*as_x > 0;
+
+ if((c.x-a.x)*as_y-(c.y-a.y)*as_x > 0 == s_ab) return false;
+
+ if((c.x-b.x)*(s.y-b.y)-(c.y-b.y)*(s.x-b.x) > 0 != s_ab) return false;
+
+ return true;
+ }
static Vector2 get_closest_point_to_segment_uncapped_2d(const Vector2& p_point, const Vector2 *p_segment) {
Vector2 p=p_point-p_segment[0];