summaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-04-06 12:42:16 +0200
committerGitHub <noreply@github.com>2019-04-06 12:42:16 +0200
commit34ea708596031afb0bdd522ba0b6196078bbadde (patch)
tree806df034d0854059f5c36882a0e43c59db4cdce9 /core/math
parent506ff1f065936153efef0ace24e0d922b999b9e6 (diff)
parentdcbe55a1facc3cc2c6058dda967fcbe9fdc8c7d0 (diff)
Merge pull request #26699 from Schroedi/fix-line-circle-intersect
Fixes Geometry.segment_intersects_circle working only one way.
Diffstat (limited to 'core/math')
-rw-r--r--core/math/geometry.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/math/geometry.h b/core/math/geometry.h
index 4b478b6b16..7347cb742a 100644
--- a/core/math/geometry.h
+++ b/core/math/geometry.h
@@ -702,9 +702,11 @@ public:
/* if we can assume that the line segment starts outside the circle (e.g. for continuous time collision detection) then the following can be skipped and we can just return the equivalent of res1 */
sqrtterm = Math::sqrt(sqrtterm);
real_t res1 = (-b - sqrtterm) / (2 * a);
- //real_t res2 = ( -b + sqrtterm ) / (2 * a);
+ real_t res2 = (-b + sqrtterm) / (2 * a);
- return (res1 >= 0 && res1 <= 1) ? res1 : -1;
+ if (res1 >= 0 && res1 <= 1) return res1;
+ if (res2 >= 0 && res2 <= 1) return res2;
+ return -1;
}
static inline Vector<Vector3> clip_polygon(const Vector<Vector3> &polygon, const Plane &p_plane) {