From f71f214f36c0960a820c2be35d0e547ed9a52d54 Mon Sep 17 00:00:00 2001
From: NoriteSC <53096989+NoriteSC@users.noreply.github.com>
Date: Wed, 13 Sep 2023 02:53:20 +0200
Subject: [PATCH] bug fix macro added extra macros
---
Source/Engine/Debug/DebugDraw.cpp | 16 ++++
Source/Engine/Debug/DebugDraw.cs | 36 +++++++-
Source/Engine/Debug/DebugDraw.h | 135 ++++++++++++++++++------------
3 files changed, 132 insertions(+), 55 deletions(-)
diff --git a/Source/Engine/Debug/DebugDraw.cpp b/Source/Engine/Debug/DebugDraw.cpp
index 2afc9d047..733c4a643 100644
--- a/Source/Engine/Debug/DebugDraw.cpp
+++ b/Source/Engine/Debug/DebugDraw.cpp
@@ -920,6 +920,22 @@ void DebugDraw::DrawActors(Actor** selectedActors, int32 selectedActorsCount, bo
}
}
+void DebugDraw::DrawAxisFromDirection(const Vector3& origin, const Vector3& direction, const Color& color , float Size, float duration, bool depthTest)
+{
+ auto rot = Quaternion::FromDirection(direction.GetNormalized());
+ Vector3 Up = (rot * Vector3::Up );
+ Vector3 Forward = (rot * Vector3::Forward);
+ Vector3 Right = (rot * Vector3::Right );
+
+ DrawLine(origin, origin + (Up * (Size * 0.5f)) + Up , Color::Green ,duration, depthTest);
+ DrawLine(origin, origin + (Forward * (Size * 0.5f)) + Forward, Color::Blue ,duration, depthTest);
+ DrawLine(origin, origin + (Right * (Size * 0.5f)) + Right , Color::Red ,duration, depthTest);
+}
+
+void DebugDraw::DrawDirection(const Vector3& origin, const Vector3& direction, const Color& color, float duration, bool depthTest)
+{
+ 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)
{
DrawLine(origin, origin + (direction.GetNormalized() * length), color, duration, depthTest);
diff --git a/Source/Engine/Debug/DebugDraw.cs b/Source/Engine/Debug/DebugDraw.cs
index bc000e03d..f6a8a19f4 100644
--- a/Source/Engine/Debug/DebugDraw.cs
+++ b/Source/Engine/Debug/DebugDraw.cs
@@ -31,6 +31,17 @@ namespace FlaxEngine
{
}
+ ///
+ /// Draws the lines axis from direction.
+ ///
+ /// The origin of the line.
+ /// The direction of the line.
+ /// The color.
+ /// The size of the axis.
+ /// 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.
+ static void DrawAxisFromDirection(Vector3 origin, Vector3 direction, Color color ,float Size = 100.0f, float duration = 0.0f, bool depthTest = true);
+
///
/// Draws the line in a direction.
///
@@ -39,9 +50,28 @@ namespace FlaxEngine
/// The color.
/// 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.
- public static void DrawRay(Vector3 origin, Vector3 direction, Color color, float duration = 0.0f, bool depthTest = true)
- {
- }
+ static void DrawDirection(Vector3 origin, Vector3 direction, Color color, float duration = 0.0f, bool depthTest = true);
+
+ ///
+ /// Draws the line in a direction.
+ ///
+ /// 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.
+ static void DrawRay(Vector3 origin, Vector3 direction, Color color, 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.
+ static void DrawRay(Ray ray,Color color, float length = 3.402823466e+38f, float duration = 0.0f, bool depthTest = true);
///
/// Draws the line.
diff --git a/Source/Engine/Debug/DebugDraw.h b/Source/Engine/Debug/DebugDraw.h
index b5af321c7..5df31d831 100644
--- a/Source/Engine/Debug/DebugDraw.h
+++ b/Source/Engine/Debug/DebugDraw.h
@@ -69,6 +69,27 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw
/// True if draw all debug shapes from scenes too or false if draw just from specified actor list.
API_FUNCTION() static void DrawActors(Actor** selectedActors, int32 selectedActorsCount, bool drawScenes);
+ ///
+ /// Draws the lines axis from direction.
+ ///
+ /// The origin of the line.
+ /// The direction of the line.
+ /// The color.
+ /// The size of the axis.
+ /// 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 DrawAxisFromDirection(const Vector3& origin, const Vector3& direction, const Color& color = Color::White ,float Size = 100.0f, float duration = 0.0f, bool depthTest = true);
+
+ ///
+ /// Draws the line in a direction.
+ ///
+ /// The origin of the line.
+ /// The direction of the line.
+ /// The color.
+ /// 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 DrawDirection(const Vector3& origin, const Vector3& direction, const Color& color = Color::White, float duration = 0.0f, bool depthTest = true);
+
///
/// Draws the line in a direction.
///
@@ -625,61 +646,71 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw
API_FUNCTION() static void DrawText(const StringView& text, const Transform& transform, const Color& color = Color::White, int32 size = 32, float duration = 0.0f);
};
-#define DEBUG_DRAW_RAY(origin, direction, color, duration, depthTest) DebugDraw::DrawRay(origin, direction, color, duration, depthTest)
-#define DEBUG_DRAW_LINE(start, end, color, duration, depthTest) DebugDraw::DrawLine(start, end, color, duration, depthTest)
-#define DEBUG_DRAW_LINES(lines, transform, color, duration, depthTest) DebugDraw::DrawLines(lines, transform, color, duration, depthTest)
-#define DEBUG_DRAW_BEZIER(p1, p2, p3, p4, color, duration, depthTest) DebugDraw::DrawBezier(p1, p2, p3, p4, color, duration, depthTest)
-#define DEBUG_DRAW_CIRCLE(position, normal, radius, color, duration, depthTest) DebugDraw::DrawCircle(position, normal, radius, color, duration, depthTest)
-#define DEBUG_DRAW_TRIANGLE(v0, v1, v2, color, duration, depthTest) DebugDraw::DrawTriangle(v0, v1, v2, color, duration, depthTest)
-#define DEBUG_DRAW_TRIANGLES(vertices, color, duration, depthTest) DebugDraw::DrawTriangles(vertices, color, duration, depthTest)
-#define DEBUG_DRAW_TRIANGLES_EX(vertices, indices, color, duration, depthTest) DebugDraw::DrawTriangles(vertices, indices, color, duration, depthTest)
-#define DEBUG_DRAW_TRIANGLES_EX2(vertices, indices, transform, color, duration, depthTest) DebugDraw::DrawTriangles(vertices, indices, transform, color, duration, depthTest)
-#define DEBUG_DRAW_SPHERE(sphere, color, duration, depthTest) DebugDraw::DrawSphere(sphere, color, duration, depthTest)
-#define DEBUG_DRAW_TUBE(position, orientation, radius, length, color, duration, depthTest) DebugDraw::DrawTube(position, orientation, radius, length, color, duration, depthTest)
-#define DEBUG_DRAW_BOX(box, color, duration, depthTest) DebugDraw::DrawBox(box, color, duration, depthTest)
-#define DEBUG_DRAW_CYLINDER(position, orientation, radius, height, color, duration, depthTest) DebugDraw::DrawCylinder(position, orientation, radius, height, color, duration, depthTest)
-#define DEBUG_DRAW_CONE(position, orientation, radius, angleXY, angleXZ, color, duration, depthTest) DebugDraw::DrawCone(position, orientation, radius, angleXY, angleXZ, color, duration, depthTest)
-#define DEBUG_DRAW_ARC(position, orientation, radius, angle, color, duration, depthTest) DebugDraw::DrawArc(position, orientation, radius, angle, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_TRIANGLE(v0, v1, v2, color, duration, depthTest) DebugDraw::DrawWireTriangle(v0, v1, v2, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_TRIANGLES(vertices, color, duration, depthTest) DebugDraw::DrawWireTriangles(vertices, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_TRIANGLES_EX(vertices, indices, color, duration, depthTest) DebugDraw::DrawWireTriangles(vertices, indices, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_BOX(box, color, duration, depthTest) DebugDraw::DrawWireBox(box, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_FRUSTUM(frustum, color, duration, depthTest) DebugDraw::DrawWireFrustum(frustum, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_SPHERE(sphere, color, duration, depthTest) DebugDraw::DrawWireSphere(sphere, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_TUBE(position, orientation, radius, length, color, duration, depthTest) DebugDraw::DrawWireTube(position, orientation, radius, length, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_CYLINDER(position, orientation, radius, height, color, duration, depthTest) DebugDraw::DrawWireCylinder(position, orientation, radius, height, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_CONE(position, orientation, radius, angleXY, angleXZ, color, duration, depthTest) DebugDraw::DrawWireCone(position, orientation, radius, angleXY, angleXZ, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_ARC(position, orientation, radius, angle, color, duration, depthTest) DebugDraw::DrawWireArc(position, orientation, radius, angle, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_ARROW(position, orientation, scale, color, duration, depthTest) DebugDraw::DrawWireArrow(position, orientation, scale, color, duration, depthTest)
-#define DEBUG_DRAW_TEXT(text, position, color, size, duration) DebugDraw::DrawText(text, position, color, size, duration)
+
+#define DEBUG_DRAW_AXIS_FROM_DIRECTION(origin,direction,color,Size,duration,depthTest) DebugDraw::DrawAxisFromDirection(origin,direction,color,Size,duration,depthTest);
+#define DEBUG_DRAW_DIRECTION (origin,direction,color,duration,depthTest) DebugDraw::DrawDirection(origin,direction,color,duration,depthTest);
+#define DEBUG_DRAW_RAY (origin,direction,color,length,duration,depthTest) DebugDraw::DrawRay(origin,direction,color,length,duration,depthTest);
+#define DEBUG_DRAW_RAY (ray,color,length,duration,depthTest) DebugDraw::DrawRay(ray,color,length,duration,depthTest);
+
+#define DEBUG_DRAW_LINE(start, end, color, duration, depthTest) DebugDraw::DrawLine(start, end, color, duration, depthTest)
+#define DEBUG_DRAW_LINES(lines, transform, color, duration, depthTest) DebugDraw::DrawLines(lines, transform, color, duration, depthTest)
+#define DEBUG_DRAW_BEZIER(p1, p2, p3, p4, color, duration, depthTest) DebugDraw::DrawBezier(p1, p2, p3, p4, color, duration, depthTest)
+#define DEBUG_DRAW_CIRCLE(position, normal, radius, color, duration, depthTest) DebugDraw::DrawCircle(position, normal, radius, color, duration, depthTest)
+#define DEBUG_DRAW_TRIANGLE(v0, v1, v2, color, duration, depthTest) DebugDraw::DrawTriangle(v0, v1, v2, color, duration, depthTest)
+#define DEBUG_DRAW_TRIANGLES(vertices, color, duration, depthTest) DebugDraw::DrawTriangles(vertices, color, duration, depthTest)
+#define DEBUG_DRAW_TRIANGLES_EX(vertices, indices, color, duration, depthTest) DebugDraw::DrawTriangles(vertices, indices, color, duration, depthTest)
+#define DEBUG_DRAW_TRIANGLES_EX2(vertices, indices, transform, color, duration, depthTest) DebugDraw::DrawTriangles(vertices, indices, transform, color, duration, depthTest)
+#define DEBUG_DRAW_SPHERE(sphere, color, duration, depthTest) DebugDraw::DrawSphere(sphere, color, duration, depthTest)
+#define DEBUG_DRAW_TUBE(position, orientation, radius, length, color, duration, depthTest) DebugDraw::DrawTube(position, orientation, radius, length, color, duration, depthTest)
+#define DEBUG_DRAW_BOX(box, color, duration, depthTest) DebugDraw::DrawBox(box, color, duration, depthTest)
+#define DEBUG_DRAW_CYLINDER(position, orientation, radius, height, color, duration, depthTest) DebugDraw::DrawCylinder(position, orientation, radius, height, color, duration, depthTest)
+#define DEBUG_DRAW_CONE(position, orientation, radius, angleXY, angleXZ, color, duration, depthTest) DebugDraw::DrawCone(position, orientation, radius, angleXY, angleXZ, color, duration, depthTest)
+#define DEBUG_DRAW_ARC(position, orientation, radius, angle, color, duration, depthTest) DebugDraw::DrawArc(position, orientation, radius, angle, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_TRIANGLE(v0, v1, v2, color, duration, depthTest) DebugDraw::DrawWireTriangle(v0, v1, v2, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_TRIANGLES(vertices, color, duration, depthTest) DebugDraw::DrawWireTriangles(vertices, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_TRIANGLES_EX(vertices, indices, color, duration, depthTest) DebugDraw::DrawWireTriangles(vertices, indices, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_BOX(box, color, duration, depthTest) DebugDraw::DrawWireBox(box, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_FRUSTUM(frustum, color, duration, depthTest) DebugDraw::DrawWireFrustum(frustum, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_SPHERE(sphere, color, duration, depthTest) DebugDraw::DrawWireSphere(sphere, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_TUBE(position, orientation, radius, length, color, duration, depthTest) DebugDraw::DrawWireTube(position, orientation, radius, length, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_CYLINDER(position, orientation, radius, height, color, duration, depthTest) DebugDraw::DrawWireCylinder(position, orientation, radius, height, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_CONE(position, orientation, radius, angleXY, angleXZ, color, duration, depthTest) DebugDraw::DrawWireCone(position, orientation, radius, angleXY, angleXZ, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_ARC(position, orientation, radius, angle, color, duration, depthTest) DebugDraw::DrawWireArc(position, orientation, radius, angle, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_ARROW(position, orientation, scale, color, duration, depthTest) DebugDraw::DrawWireArrow(position, orientation, scale, color, duration, depthTest)
+#define DEBUG_DRAW_TEXT(text, position, color, size, duration) DebugDraw::DrawText(text, position, color, size, duration)
#else
+#define DEBUG_DRAW_AXIS_FROM_DIRECTION(origin,direction,color,Size,duration,depthTest)
+#define DEBUG_DRAW_DIRECTION (origin,direction,color,duration,depthTest)
+#define DEBUG_DRAW_RAY (origin,direction,color,length,duration,depthTest)
+#define DEBUG_DRAW_RAY (ray,color,length,duration,depthTest)
-#define DEBUG_DRAW_LINE(start, end, color, duration, depthTest)
-#define DEBUG_DRAW_LINES(lines, transform, color, duration, depthTest)
-#define DEBUG_DRAW_BEZIER(p1, p2, p3, p4, color, duration, depthTest)
-#define DEBUG_DRAW_CIRCLE(position, normal, radius, color, duration, depthTest)
-#define DEBUG_DRAW_TRIANGLE(v0, v1, v2, color, duration, depthTest)
-#define DEBUG_DRAW_TRIANGLES(vertices, color, duration, depthTest)
-#define DEBUG_DRAW_TRIANGLES_EX(vertices, indices, color, duration, depthTest)
-#define DEBUG_DRAW_TRIANGLES_EX2(vertices, indices, transform, color, duration, depthTest)
-#define DEBUG_DRAW_SPHERE(sphere, color, duration, depthTest)
-#define DEBUG_DRAW_TUBE(position, orientation, radius, length, color, duration, depthTest)
-#define DEBUG_DRAW_BOX(box, color, duration, depthTest)
-#define DEBUG_DRAW_CYLINDER(position, orientation, radius, height, color, duration, depthTest)
-#define DEBUG_DRAW_CONE(position, orientation, radius, angleXY, angleXZ, color, duration, depthTest)
-#define DEBUG_DRAW_ARC(position, orientation, radius, angle, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_TRIANGLE(v0, v1, v2, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_TRIANGLES(vertices, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_TRIANGLES_EX(vertices, indices, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_BOX(box, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_FRUSTUM(frustum, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_SPHERE(sphere, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_TUBE(position, orientation, radius, length, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_CYLINDER(position, orientation, radius, height, color, duration, depthTest)
+#define DEBUG_DRAW_RAY(origin, direction, color, duration, depthTest)
+#define DEBUG_DRAW_LINE(start, end, color, duration, depthTest)
+#define DEBUG_DRAW_LINES(lines, transform, color, duration, depthTest)
+#define DEBUG_DRAW_BEZIER(p1, p2, p3, p4, color, duration, depthTest)
+#define DEBUG_DRAW_CIRCLE(position, normal, radius, color, duration, depthTest)
+#define DEBUG_DRAW_TRIANGLE(v0, v1, v2, color, duration, depthTest)
+#define DEBUG_DRAW_TRIANGLES(vertices, color, duration, depthTest)
+#define DEBUG_DRAW_TRIANGLES_EX(vertices, indices, color, duration, depthTest)
+#define DEBUG_DRAW_TRIANGLES_EX2(vertices, indices, transform, color, duration, depthTest)
+#define DEBUG_DRAW_SPHERE(sphere, color, duration, depthTest)
+#define DEBUG_DRAW_TUBE(position, orientation, radius, length, color, duration, depthTest)
+#define DEBUG_DRAW_BOX(box, color, duration, depthTest)
+#define DEBUG_DRAW_CYLINDER(position, orientation, radius, height, color, duration, depthTest)
+#define DEBUG_DRAW_CONE(position, orientation, radius, angleXY, angleXZ, color, duration, depthTest)
+#define DEBUG_DRAW_ARC(position, orientation, radius, angle, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_TRIANGLE(v0, v1, v2, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_TRIANGLES(vertices, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_TRIANGLES_EX(vertices, indices, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_BOX(box, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_FRUSTUM(frustum, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_SPHERE(sphere, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_TUBE(position, orientation, radius, length, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_CYLINDER(position, orientation, radius, height, color, duration, depthTest)
#define DEBUG_DRAW_WIRE_CONE(position, orientation, radius, angleXY, angleXZ, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_ARC(position, orientation, radius, angle, color, duration, depthTest)
-#define DEBUG_DRAW_WIRE_ARROW(position, orientation, scale, color, duration, depthTest)
-#define DEBUG_DRAW_TEXT(text, position, color, size, duration)
+#define DEBUG_DRAW_WIRE_ARC(position, orientation, radius, angle, color, duration, depthTest)
+#define DEBUG_DRAW_WIRE_ARROW(position, orientation, scale, color, duration, depthTest)
+#define DEBUG_DRAW_TEXT(text, position, color, size, duration)
#endif