MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / DrawSpline

Function DrawSpline

Source/Engine/Level/Actors/Spline.cpp:503–538  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

501 }
502
503 void DrawSpline(Spline* spline, const Color& color, const Transform& transform, bool depthTest, bool scaleByDistance = false)
504 {
505 const int32 count = spline->Curve.GetKeyframes().Count();
506 if (count == 0)
507 return;
508 Spline::Keyframe* prev = spline->Curve.GetKeyframes().Get();
509 Vector3 prevPos = transform.LocalToWorld(prev->Value.Translation);
510 Real distance = Vector3::Distance(prevPos, DebugDraw::GetViewPos());
511 if (distance < METERS_TO_UNITS(800)) // 800m
512 {
513 // Bezier curve
514 DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(prevPos, NodeSizeByDistance(prevPos, scaleByDistance)), color, 0.0f, depthTest);
515 for (int32 i = 1; i < count; i++)
516 {
517 Spline::Keyframe* next = prev + 1;
518 Vector3 nextPos = transform.LocalToWorld(next->Value.Translation);
519 DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(nextPos, NodeSizeByDistance(nextPos, scaleByDistance)), color, 0.0f, depthTest);
520 const float d = (next->Time - prev->Time) / 3.0f;
521 DEBUG_DRAW_BEZIER(prevPos, transform.LocalToWorld(prev->Value.Translation + prev->TangentOut.Translation * d), transform.LocalToWorld(next->Value.Translation + next->TangentIn.Translation * d), nextPos, color, 0.0f, depthTest);
522 prev = next;
523 prevPos = nextPos;
524 }
525 }
526 else
527 {
528 // Simplified
529 for (int32 i = 1; i < count; i++)
530 {
531 Spline::Keyframe* next = prev + 1;
532 Vector3 nextPos = transform.LocalToWorld(next->Value.Translation);
533 DEBUG_DRAW_LINE(prevPos, nextPos, color, 0.0f, depthTest);
534 prev = next;
535 prevPos = nextPos;
536 }
537 }
538 }
539}
540
541void Spline::OnDebugDraw()

Callers 2

OnDebugDrawMethod · 0.85
OnDebugDrawSelectedMethod · 0.85

Calls 7

DistanceFunction · 0.85
NodeSizeByDistanceFunction · 0.85
BoundingSphereClass · 0.50
CountMethod · 0.45
GetKeyframesMethod · 0.45
GetMethod · 0.45
LocalToWorldMethod · 0.45

Tested by

no test coverage detected