Fix selected spline points to be drawn relative to the view for greater readability
#2595
This commit is contained in:
@@ -741,6 +741,11 @@ void DebugDraw::SetContext(void* context)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Vector3 DebugDraw::GetViewPos()
|
||||||
|
{
|
||||||
|
return Context->LastViewPos;
|
||||||
|
}
|
||||||
|
|
||||||
void DebugDraw::Draw(RenderContext& renderContext, GPUTextureView* target, GPUTextureView* depthBuffer, bool enableDepthTest)
|
void DebugDraw::Draw(RenderContext& renderContext, GPUTextureView* target, GPUTextureView* depthBuffer, bool enableDepthTest)
|
||||||
{
|
{
|
||||||
PROFILE_GPU_CPU("Debug Draw");
|
PROFILE_GPU_CPU("Debug Draw");
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw
|
|||||||
|
|
||||||
#if USE_EDITOR
|
#if USE_EDITOR
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Allocates the context for Debug Drawing. Can be use to redirect debug shapes collecting to a separate container (instead of global state).
|
/// Allocates the context for Debug Drawing. Can be used to redirect debug shapes collecting to a separate container (instead of global state).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The context object. Release it wil FreeContext. Returns null if failed.</returns>
|
/// <returns>The context object. Release it wil FreeContext. Returns null if failed.</returns>
|
||||||
API_FUNCTION() static void* AllocateContext();
|
API_FUNCTION() static void* AllocateContext();
|
||||||
@@ -64,6 +64,9 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw
|
|||||||
API_FUNCTION() static void SetContext(void* context);
|
API_FUNCTION() static void SetContext(void* context);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Gets the last view position when rendering the current context. Can be sued for custom culling or LODing when drawing more complex shapes.
|
||||||
|
static Vector3 GetViewPos();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Draws the collected debug shapes to the output.
|
/// Draws the collected debug shapes to the output.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -717,7 +720,7 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw
|
|||||||
API_FUNCTION() static void Clear(void* context = nullptr);
|
API_FUNCTION() static void Clear(void* context = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEBUG_DRAW_AXIS_FROM_DIRECTION(origin, direction, size, duration, depthTest) DebugDraw::DrawAxisFromDirection(origin, direction, size, duration, depthTest);
|
#define DEBUG_DRAW_AXIS_FROM_DIRECTION(origin, direction, size, duration, depthTest) DebugDraw::DrawAxisFromDirection(origin, direction, size, duration, depthTest);
|
||||||
#define DEBUG_DRAW_DIRECTION(origin, direction, color, duration, depthTest) DebugDraw::DrawDirection(origin, direction, color, 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(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_RAY(ray, color, length, duration, depthTest) DebugDraw::DrawRay(ray, color, length, duration, depthTest);
|
||||||
|
|||||||
@@ -490,19 +490,26 @@ void Spline::SetKeyframes(MArray* data, int32 keySize)
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void DrawSpline(Spline* spline, const Color& color, const Transform& transform, bool depthTest)
|
FORCE_INLINE float NodeSizeByDistance(const Vector3& nodePosition, bool scaleByDistance)
|
||||||
|
{
|
||||||
|
if (scaleByDistance)
|
||||||
|
return (float)(Vector3::Distance(DebugDraw::GetViewPos(), nodePosition) / 100);
|
||||||
|
return 5.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawSpline(Spline* spline, const Color& color, const Transform& transform, bool depthTest, bool scaleByDistance = false)
|
||||||
{
|
{
|
||||||
const int32 count = spline->Curve.GetKeyframes().Count();
|
const int32 count = spline->Curve.GetKeyframes().Count();
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return;
|
return;
|
||||||
Spline::Keyframe* prev = spline->Curve.GetKeyframes().Get();
|
Spline::Keyframe* prev = spline->Curve.GetKeyframes().Get();
|
||||||
Vector3 prevPos = transform.LocalToWorld(prev->Value.Translation);
|
Vector3 prevPos = transform.LocalToWorld(prev->Value.Translation);
|
||||||
DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(prevPos, 5.0f), color, 0.0f, depthTest);
|
DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(prevPos, NodeSizeByDistance(prevPos, scaleByDistance)), color, 0.0f, depthTest);
|
||||||
for (int32 i = 1; i < count; i++)
|
for (int32 i = 1; i < count; i++)
|
||||||
{
|
{
|
||||||
Spline::Keyframe* next = prev + 1;
|
Spline::Keyframe* next = prev + 1;
|
||||||
Vector3 nextPos = transform.LocalToWorld(next->Value.Translation);
|
Vector3 nextPos = transform.LocalToWorld(next->Value.Translation);
|
||||||
DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(nextPos, 5.0f), color, 0.0f, depthTest);
|
DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(nextPos, NodeSizeByDistance(nextPos, scaleByDistance)), color, 0.0f, depthTest);
|
||||||
const float d = (next->Time - prev->Time) / 3.0f;
|
const float d = (next->Time - prev->Time) / 3.0f;
|
||||||
DEBUG_DRAW_BEZIER(prevPos, prevPos + prev->TangentOut.Translation * d, nextPos + next->TangentIn.Translation * d, nextPos, color, 0.0f, depthTest);
|
DEBUG_DRAW_BEZIER(prevPos, prevPos + prev->TangentOut.Translation * d, nextPos + next->TangentIn.Translation * d, nextPos, color, 0.0f, depthTest);
|
||||||
prev = next;
|
prev = next;
|
||||||
@@ -521,7 +528,7 @@ void Spline::OnDebugDraw()
|
|||||||
|
|
||||||
void Spline::OnDebugDrawSelected()
|
void Spline::OnDebugDrawSelected()
|
||||||
{
|
{
|
||||||
DrawSpline(this, Color::White, _transform, false);
|
DrawSpline(this, Color::White, _transform, false, true);
|
||||||
|
|
||||||
// Base
|
// Base
|
||||||
Actor::OnDebugDrawSelected();
|
Actor::OnDebugDrawSelected();
|
||||||
|
|||||||
Reference in New Issue
Block a user