[Question to developers] Which algorithm is used for spline components in UE4?

I hope that one of the developers would be able to share information on how current implementation of spline components works under the hood.
More specifically what kind of class of curves is used - is it one of the Bézier, Cubic Hermite or maybe Catmull-Rom?
What is the mathematical relationship between tangents of control points - how they affect curve? Answer to this can be obvious from class of curve but maybe tangents are derived from some other parameters, just to make them easier to manipulate visually.

I could solve my problem by implementing my own splines, but there are so much functionality behind them already that it would be like re-inventing the bicycle.

The reason why I’m asking is that I need to develop (or find) an algorithm to manipulate looped spline with length constraint.
To illustrate this:
Spline Animation.jpg
When control points at the bottom change their position, total length of the spline becomes longer or shorter, which is undesirable.
The purpose of the algorithm is to re-calculate positions and tangents of control points to conform to length constraint.
The idea is to have a several classes of control points:

  • Static, which are locked into specific place with fixed tangents
  • Static Position Scalable Tangents, locked into position but tangents can be scaled
  • Restricted Position Scalable Tangent, this control points are allowed to move only in specific axis and their tangents can be scaled.

Right now I have an idea how to solve this iteratively but if I knew the math behind the current implementation of splines I could do it analytically.

They’re Cubic Bezier by default, found out by checking out in Engine source :slight_smile:

Hi Jamsh,
I’ve visualized tangents that are assigned to control points and see that they are actually symmetrical handles. Already found some paper on length constraint Bezier, there are no analytical solution to this, so I’ll go with iterative algorithm. Thank you for your help!

Are you certain about that?
When you put control points p0-p1-p2-p3 in a square, the middle point S(1/2) should end up at 75% height of the square (simple DeCasteljau algorith with pen and paper gives you that).
In the engine you have tangents t0 and t3 given instead. I assume that t0 = p1-p0 and t3 = p3-p2.
In the game the spline is however much shorter than what I expected!

What I espected:

Heck, even Paint built-in spline tool does it right :slight_smile:

In UE4 I get this instead:

Don’t use attachments for pics, they never work. Host them on or somewhere.

It’s been a long time since I checked, but I’m fairly certain. You can always look in SplineComponent.cpp and check for yourself just to make sure. I seem to remember looking when I wanted to plot orbits using splines, but because they can’t be perfect mathematical ellipses it never really worked.