From 809b9e3a7ae5aef0d4a196a482cec3e641429836 Mon Sep 17 00:00:00 2001 From: NoriteSC <53096989+NoriteSC@users.noreply.github.com> Date: Sun, 1 Oct 2023 16:47:33 +0200 Subject: [PATCH] added safeguards --- Source/Engine/Debug/DebugDraw.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/Engine/Debug/DebugDraw.cpp b/Source/Engine/Debug/DebugDraw.cpp index 733c4a643..1e50a74be 100644 --- a/Source/Engine/Debug/DebugDraw.cpp +++ b/Source/Engine/Debug/DebugDraw.cpp @@ -934,15 +934,22 @@ void DebugDraw::DrawAxisFromDirection(const Vector3& origin, const Vector3& dire void DebugDraw::DrawDirection(const Vector3& origin, const Vector3& direction, const Color& color, float duration, bool depthTest) { + auto dir = origin + direction; + if (dir.IsNanOrInfinity()) + return; DrawLine(origin, origin + direction, color, duration, depthTest); } void DebugDraw::DrawRay(const Vector3& origin, const Vector3& direction,const Color& color, float length, float duration, bool depthTest) { + if (isnan(length) || isinf(length)) + return; DrawLine(origin, origin + (direction.GetNormalized() * length), color, duration, depthTest); } void DebugDraw::DrawRay(const Ray& ray,const Color& color, float length, float duration, bool depthTest) { + if (isnan(length) || isinf(length)) + return; DrawLine(ray.Position, ray.Position + (ray.Direction.GetNormalized() * length), color, duration, depthTest); }