summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorMarcus Brummer <mbrlabs7@gmail.com>2020-12-10 10:39:49 +0100
committerMarcus Brummer <mbrlabs7@gmail.com>2020-12-30 21:11:09 +0100
commite455ca2f2fc81e59a9c6bbe03ba6ca11b253de5d (patch)
tree49ab8a8e28484910dc61f25635e532d2ede86998 /core
parentb24f9f2d8f060533f2dff16c73bf93c94f23fbdf (diff)
Added Geometry2D unit tests
Diffstat (limited to 'core')
-rw-r--r--core/math/geometry_2d.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/core/math/geometry_2d.h b/core/math/geometry_2d.h
index 12bad5768e..de580ea639 100644
--- a/core/math/geometry_2d.h
+++ b/core/math/geometry_2d.h
@@ -145,6 +145,12 @@ public:
return p_segment[0] + n * d; // Inside.
}
+// Disable False Positives in MSVC compiler; we correctly check for 0 here to prevent a division by 0.
+// See: https://github.com/godotengine/godot/pull/44274
+#ifdef _MSC_VER
+#pragma warning(disable : 4723)
+#endif
+
static bool line_intersects_line(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b, Vector2 &r_result) {
// See http://paulbourke.net/geometry/pointlineplane/
@@ -159,6 +165,11 @@ public:
return true;
}
+// Re-enable division by 0 warning
+#ifdef _MSC_VER
+#pragma warning(default : 4723)
+#endif
+
static bool segment_intersects_segment(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b, Vector2 *r_result) {
Vector2 B = p_to_a - p_from_a;
Vector2 C = p_from_b - p_from_a;