diff --git a/Source/Editor/SceneGraph/Actors/SplineNode.cs b/Source/Editor/SceneGraph/Actors/SplineNode.cs index fe96ad4e8..24ea60f21 100644 --- a/Source/Editor/SceneGraph/Actors/SplineNode.cs +++ b/Source/Editor/SceneGraph/Actors/SplineNode.cs @@ -415,6 +415,35 @@ namespace FlaxEditor.SceneGraph.Actors return distance * nodeSize; } + public override void OnDebugDraw(ViewportDebugDrawData data) + { + DrawSpline((Spline)Actor, Color.White, Actor.Transform, false); + } + + private void DrawSpline(Spline spline, Color color, Transform transform, bool depthTest) + { + var count = spline.SplineKeyframes.Length; + if (count == 0) + return; + var keyframes = spline.SplineKeyframes; + var pointIndex = 0; + var prev = spline.GetSplineKeyframe(0); + + Vector3 prevPos = transform.LocalToWorld(prev.Value.Translation); + DebugDraw.DrawWireSphere(new BoundingSphere(prevPos, 5.0f), color, 0.0f, depthTest); + for (int i = 1; i < count; i++) + { + var next = keyframes[pointIndex]; + Vector3 nextPos = transform.LocalToWorld(next.Value.Translation); + DebugDraw.DrawWireSphere(new BoundingSphere(nextPos, 5.0f), color, 0.0f, depthTest); + var d = (next.Time - prev.Time) / 3.0f; + DebugDraw.DrawBezier(prevPos, prevPos + prev.TangentOut.Translation * d, nextPos + next.TangentIn.Translation * d, nextPos, color, 0.0f, depthTest); + prev = next; + prevPos = nextPos; + pointIndex++; + } + } + /// public override bool RayCastSelf(ref RayCastData ray, out Real distance, out Vector3 normal) { diff --git a/Source/Engine/Level/Actors/Spline.cpp b/Source/Engine/Level/Actors/Spline.cpp index dbd7ef045..2923463b0 100644 --- a/Source/Engine/Level/Actors/Spline.cpp +++ b/Source/Engine/Level/Actors/Spline.cpp @@ -455,53 +455,6 @@ void Spline::SetKeyframes(MArray* data) #endif -#if USE_EDITOR - -#include "Engine/Debug/DebugDraw.h" - -namespace -{ - void DrawSpline(Spline* spline, const Color& color, const Transform& transform, bool depthTest) - { - 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); - 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); - 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; - prevPos = nextPos; - } - } -} - -void Spline::OnDebugDraw() -{ - const Color color = GetSplineColor(); - DrawSpline(this, color.AlphaMultiplied(0.7f), _transform, true); - - // Base - Actor::OnDebugDraw(); -} - -void Spline::OnDebugDrawSelected() -{ - const Color color = GetSplineColor(); - DrawSpline(this, color.AlphaMultiplied(0.3f), _transform, false); - - // Base - Actor::OnDebugDrawSelected(); -} - -#endif - void Spline::OnTransformChanged() { // Base diff --git a/Source/Engine/Level/Actors/Spline.h b/Source/Engine/Level/Actors/Spline.h index ea3cf8569..426304fb9 100644 --- a/Source/Engine/Level/Actors/Spline.h +++ b/Source/Engine/Level/Actors/Spline.h @@ -369,10 +369,6 @@ private: public: // [Actor] -#if USE_EDITOR - void OnDebugDraw() override; - void OnDebugDrawSelected() override; -#endif void OnTransformChanged() override; void Initialize() override; void Serialize(SerializeStream& stream, const void* otherObj) override;