Fixed incorrect distances for AABB raycast results
This commit is contained in:
parent
e293094b6d
commit
20fe6c4877
|
@ -155,6 +155,11 @@ namespace SHADE
|
||||||
SHRaycastResult result;
|
SHRaycastResult result;
|
||||||
|
|
||||||
result.hit = Intersects(ray.position, ray.direction, result.distance);
|
result.hit = Intersects(ray.position, ray.direction, result.distance);
|
||||||
|
|
||||||
|
// Negative distances are invalid, therefore false
|
||||||
|
if (result.distance < 0.0f)
|
||||||
|
result.hit = false;
|
||||||
|
|
||||||
if (result.hit)
|
if (result.hit)
|
||||||
{
|
{
|
||||||
result.position = ray.position + ray.direction * result.distance;
|
result.position = ray.position + ray.direction * result.distance;
|
||||||
|
|
|
@ -197,7 +197,9 @@ namespace SHADE
|
||||||
// Load start and end points into the container for debug drawing
|
// Load start and end points into the container for debug drawing
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
|
|
||||||
SHVec3 endPos = info.ray.position + info.ray.direction * SHRay::MAX_RAYCAST_DIST;
|
// Default end pos is how far the ray was casted.
|
||||||
|
const float DISTANCE = info.distance == std::numeric_limits<float>::infinity() ? SHRay::MAX_RAYCAST_DIST : info.distance;
|
||||||
|
SHVec3 endPos = info.ray.position + info.ray.direction * DISTANCE;
|
||||||
|
|
||||||
if (!results.empty())
|
if (!results.empty())
|
||||||
endPos = results.back().position;
|
endPos = results.back().position;
|
||||||
|
|
Loading…
Reference in New Issue