From 3bf5cf782b7f8d488e20ed82ab22c1b1b00aefbd Mon Sep 17 00:00:00 2001 From: Kearwood Gilbert Date: Tue, 18 Feb 2014 01:51:09 -0800 Subject: [PATCH] More sphereCast bug fixes --HG-- branch : nfb --- KREngine/kraken/KRTriangle3.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/KREngine/kraken/KRTriangle3.cpp b/KREngine/kraken/KRTriangle3.cpp index b140802..c60c764 100644 --- a/KREngine/kraken/KRTriangle3.cpp +++ b/KREngine/kraken/KRTriangle3.cpp @@ -214,7 +214,7 @@ KRVector3 KRTriangle3::closestPointOnTriangle(const KRVector3 &p) const bool KRTriangle3::sphereCast(const KRVector3 &start, const KRVector3 &dir, float radius, KRVector3 &hit_point, float &hit_distance) const { // Dir must be normalized - const float SMALL_NUM = 0.00000001f; // anything that avoids division overflow + const float SMALL_NUM = 0.001f; // anything that avoids division overflow KRVector3 tri_normal = calculateNormal(); @@ -242,7 +242,7 @@ bool KRTriangle3::sphereCast(const KRVector3 &start, const KRVector3 &dir, float // Determine the first point hit by the swept sphere on the triangle's plane plane_intersect_distance = -(cotangent_distance / denom); - plane_intersect = start + dir * plane_intersect_distance; + plane_intersect = start + dir * plane_intersect_distance - tri_normal * radius; } if(plane_intersect_distance < 0.0f) {