Fix selected spline points to be drawn relative to the view for greater readability
#2595
This commit is contained in:
@@ -490,19 +490,26 @@ void Spline::SetKeyframes(MArray* data, int32 keySize)
|
||||
|
||||
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();
|
||||
if (count == 0)
|
||||
return;
|
||||
Spline::Keyframe* prev = spline->Curve.GetKeyframes().Get();
|
||||
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++)
|
||||
{
|
||||
Spline::Keyframe* next = prev + 1;
|
||||
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;
|
||||
DEBUG_DRAW_BEZIER(prevPos, prevPos + prev->TangentOut.Translation * d, nextPos + next->TangentIn.Translation * d, nextPos, color, 0.0f, depthTest);
|
||||
prev = next;
|
||||
@@ -521,7 +528,7 @@ void Spline::OnDebugDraw()
|
||||
|
||||
void Spline::OnDebugDrawSelected()
|
||||
{
|
||||
DrawSpline(this, Color::White, _transform, false);
|
||||
DrawSpline(this, Color::White, _transform, false, true);
|
||||
|
||||
// Base
|
||||
Actor::OnDebugDrawSelected();
|
||||
|
||||
Reference in New Issue
Block a user