diff --git a/src/collision/shapes/CylinderShape.cpp b/src/collision/shapes/CylinderShape.cpp index da0a9f49..abaa04b2 100644 --- a/src/collision/shapes/CylinderShape.cpp +++ b/src/collision/shapes/CylinderShape.cpp @@ -175,10 +175,8 @@ bool CylinderShape::raycast(const Ray& ray, ProxyShape* proxyShape) const { (mDotN - nDotD) + t) <= decimal(0.0)); } - t = t0; - // If the intersection is behind the origin of the ray, we return no hit - return (t >= decimal(0.0)); + return (t0 >= decimal(0.0)); } // Raycast method with feedback information diff --git a/src/collision/shapes/SphereShape.cpp b/src/collision/shapes/SphereShape.cpp index d8eefaf8..b5c9b694 100644 --- a/src/collision/shapes/SphereShape.cpp +++ b/src/collision/shapes/SphereShape.cpp @@ -69,10 +69,7 @@ bool SphereShape::raycast(const Ray& ray, ProxyShape* proxyShape) const { decimal discriminant = b*b - c; // If the discriminant is negative, there is no intersection - if (discriminant < decimal(0.0)) return false; - - // There is an intersection - return true; + return (discriminant >= decimal(0.0)); } // Raycast method with feedback information