From 3bfa37019e2be364d5eff59ba891135832ca8726 Mon Sep 17 00:00:00 2001
From: NoriteSC <53096989+NoriteSC@users.noreply.github.com>
Date: Tue, 12 Sep 2023 10:59:07 +0200
Subject: [PATCH] DebugDraw extra
fixes
ray direction was dictating the length of ray
now ray is normalized and multiplied by length
added default vaule for
Color& color to be Color::White
[info] c# because
Color color = Color.White
is not valid think to do on c# side the default value is not genereted
[to do] generate extra overload binding in c#
---
Source/Engine/Debug/DebugDraw.cpp | 9 +++++++--
Source/Engine/Debug/DebugDraw.h | 13 ++++++++++++-
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/Source/Engine/Debug/DebugDraw.cpp b/Source/Engine/Debug/DebugDraw.cpp
index e8489f5b5..ccd247674 100644
--- a/Source/Engine/Debug/DebugDraw.cpp
+++ b/Source/Engine/Debug/DebugDraw.cpp
@@ -920,9 +920,14 @@ void DebugDraw::DrawActors(Actor** selectedActors, int32 selectedActorsCount, bo
}
}
-void DebugDraw::DrawRay(const Vector3& origin, const Vector3& direction, const Color& color, float duration, bool depthTest)
+void DebugDraw::DrawRay(const Vector3& origin, const Vector3& direction, Color& color, float length, float duration, bool depthTest)
{
- DrawLine(origin, origin + direction, color, duration, depthTest);
+ DrawLine(origin, origin + (direction.GetNormalized() * length), color, duration, depthTest);
+}
+
+void DebugDraw::DrawRay(const Ray& ray, Color& color, float length, float duration, bool depthTest)
+{
+ DrawLine(ray.Position, ray.Position + (ray.Direction.GetNormalized() * length), color, duration, depthTest);
}
void DebugDraw::DrawLine(const Vector3& start, const Vector3& end, const Color& color, float duration, bool depthTest)
diff --git a/Source/Engine/Debug/DebugDraw.h b/Source/Engine/Debug/DebugDraw.h
index a4f69678a..5a811be7e 100644
--- a/Source/Engine/Debug/DebugDraw.h
+++ b/Source/Engine/Debug/DebugDraw.h
@@ -75,9 +75,20 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw
/// The origin of the line.
/// The direction of the line.
/// The color.
+ /// The length of the ray.
/// The duration (in seconds). Use 0 to draw it only once.
/// If set to true depth test will be performed, otherwise depth will be ignored.
- API_FUNCTION() static void DrawRay(const Vector3& origin, const Vector3& direction, const Color& color, float duration = 0.0f, bool depthTest = true);
+ API_FUNCTION() static void DrawRay(const Vector3& origin, const Vector3& direction, Color& color = Color::White, float length = 3.402823466e+38f, float duration = 0.0f, bool depthTest = true);
+
+ ///
+ /// Draws the line in a direction.
+ ///
+ /// The ray.
+ /// The color.
+ /// The length of the ray.
+ /// The duration (in seconds). Use 0 to draw it only once.
+ /// If set to true depth test will be performed, otherwise depth will be ignored.
+ API_FUNCTION() static void DrawRay(const Ray& ray, Color& color = Color::White, float length = 3.402823466e+38f, float duration = 0.0f, bool depthTest = true);
///
/// Draws the line.