summaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2020-12-30 22:32:14 +0100
committerGitHub <noreply@github.com>2020-12-30 22:32:14 +0100
commit41e9028868e49669de83c82ba20fd9dcef0d1b8b (patch)
treeca7ec2e0a6ea9a58d99e8bafd4e45badb7ca6625 /core/math
parent6010c49424b4e5a1110b6c5a17ef2fdbfc398067 (diff)
parente455ca2f2fc81e59a9c6bbe03ba6ca11b253de5d (diff)
Merge pull request #44274 from mbrlabs/geometry2d-tests
Added Geometry2D unit tests
Diffstat (limited to 'core/math')
-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;