Merge branch 'TyGrze-draw-debug-point'

This commit is contained in:
2026-06-30 08:44:16 +02:00
2 changed files with 49 additions and 0 deletions
+38
View File
@@ -1526,6 +1526,44 @@ void DebugDraw::DrawCircle(const Vector3& position, const Float3& normal, float
}
}
void DebugDraw::DrawPoint(const Vector3& position, float radius, const Color& color, float duration, bool depthTest)
{
Float3 normal = (Float3)(Context->LastViewPosition - position);
if (normal.Length() < ZeroTolerance)
normal = Float3::Up;
normal.Normalize();
// Create matrix transform for unit circle points
Matrix world, scale, matrix;
Float3 right, up;
if (Float3::Dot(normal, Float3::Up) > 0.99f)
right = Float3::Right;
else if (Float3::Dot(normal, Float3::Down) > 0.99f)
right = Float3::Left;
else
Float3::Cross(normal, Float3::Up, right);
Float3::Cross(right, normal, up);
Matrix::Scaling(radius, scale);
const Float3 positionF = position - Context->Origin;
Matrix::CreateWorld(positionF, normal, up, world);
Matrix::Multiply(scale, world, matrix);
// Build a filled disc as a triangle fan from the center over the transformed unit circle points
PROFILE_MEM(EngineDebug);
auto& debugDrawData = depthTest ? Context->DebugDrawDepthTest : Context->DebugDrawDefault;
auto& debugDrawList = duration > 0 ? debugDrawData.DefaultTriangles : debugDrawData.OneFrameTriangles;
for (int32 i = 0; i < DEBUG_DRAW_CIRCLE_VERTICES; i += 2)
{
DebugTriangle t;
t.Color = Color32(color);
t.TimeLeft = duration;
t.V0 = positionF;
t.V1 = Float3::Transform(CircleCache[i], matrix);
t.V2 = Float3::Transform(CircleCache[i + 1], matrix);
debugDrawList.Add(t);
}
}
void DebugDraw::DrawWireTriangle(const Vector3& v0, const Vector3& v1, const Vector3& v2, const Color& color, float duration, bool depthTest)
{
DrawLine(v0, v1, color, duration, depthTest);
+11
View File
@@ -267,6 +267,16 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw
/// <param name="duration">The duration (in seconds). Use 0 to draw it only once.</param>
/// <param name="depthTest">If set to <c>true</c> depth test will be performed, otherwise depth will be ignored.</param>
API_FUNCTION() static void DrawCircle(const Vector3& position, const Float3& normal, float radius, const Color& color = Color::White, float duration = 0.0f, bool depthTest = true);
/// <summary>
/// Draws the point facing camera.
/// </summary>
/// <param name="position">The center position.</param>
/// <param name="radius">The radius.</param>
/// <param name="color">The color.</param>
/// <param name="duration">The duration (in seconds). Use 0 to draw it only once.</param>
/// <param name="depthTest">If set to <c>true</c> depth test will be performed, otherwise depth will be ignored.</param>
API_FUNCTION() static void DrawPoint(const Vector3& position, float radius, const Color& color = Color::White, float duration = 0.0f, bool depthTest = true);
/// <summary>
/// Draws the wireframe triangle.
@@ -780,6 +790,7 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw
#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_POINT(position, radius, color, duration, depthTest) DebugDraw::DrawPoint(position, 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)