diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-01-13 11:06:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-13 11:06:34 +0100 |
commit | 9ddf1115bc2719c250c771187ed94d7c6ff0a28d (patch) | |
tree | 6566313d42c87bba82885143a6a6cd3e45c2a3c3 /core/math | |
parent | 1ff170e67f0044b0a9f42fc936f09847c5ec4127 (diff) |
Revert "fixed invalid implementation of Plane::intersects_segment and Plane::intersects_ray"
Diffstat (limited to 'core/math')
-rw-r--r-- | core/math/plane.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/core/math/plane.cpp b/core/math/plane.cpp index ee59a0e171..cd3cbce300 100644 --- a/core/math/plane.cpp +++ b/core/math/plane.cpp @@ -115,14 +115,15 @@ bool Plane::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 return false; } - real_t dist = (-normal.dot(p_from) - d) / den; + real_t dist = (normal.dot(p_from) - d) / den; //printf("dist is %i\n",dist); - if (dist < -CMP_EPSILON) { //this is a ray, before the emitting pos (p_from) doesn't exist + if (dist > CMP_EPSILON) { //this is a ray, before the emitting pos (p_from) doesn't exist return false; } + dist = -dist; *p_intersection = p_from + segment * dist; return true; @@ -139,7 +140,7 @@ bool Plane::intersects_segment(const Vector3 &p_begin, const Vector3 &p_end, Vec return false; } - real_t dist = (-normal.dot(p_begin) - d) / den; + real_t dist = (normal.dot(p_begin) - d) / den; //printf("dist is %i\n",dist); if (dist < -CMP_EPSILON || dist > (1.0 + CMP_EPSILON)) { @@ -147,6 +148,7 @@ bool Plane::intersects_segment(const Vector3 &p_begin, const Vector3 &p_end, Vec return false; } + dist = -dist; *p_intersection = p_begin + segment * dist; return true; |