summaryrefslogtreecommitdiff
path: root/core/math/plane.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-01-11 22:56:03 +0100
committerGitHub <noreply@github.com>2019-01-11 22:56:03 +0100
commit3652442a923575890d1ca0c3719a6c80039dcf59 (patch)
tree68a47eefbd7aa8e4775f3e0d43c95f070ccf3843 /core/math/plane.cpp
parentd8bb3d7fed36d8268330d9375d782749c7aa02dc (diff)
parent2c36078be43f5008c1baa05ea507bb24809055d4 (diff)
Merge pull request #24897 from GlaDos28/master
fixed invalid implementation of Plane::intersects_segment and Plane::intersects_ray
Diffstat (limited to 'core/math/plane.cpp')
-rw-r--r--core/math/plane.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/core/math/plane.cpp b/core/math/plane.cpp
index cd3cbce300..ee59a0e171 100644
--- a/core/math/plane.cpp
+++ b/core/math/plane.cpp
@@ -115,15 +115,14 @@ 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;
@@ -140,7 +139,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)) {
@@ -148,7 +147,6 @@ 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;