About this mod
For CET developers. This is an implementation of bezier (single and multiple bezier segments)
- Requirements
- Permissions and credits
There's enough here that I figured a small demo mod would be better than a zip file in the cet-snippets channel
------------------------------------------------------------------------------------------------------------
The log viewer is here
------------------------------------------------------------------------------------------------------------
The implementation of bezier is really simple, but gets more complex if you want to chain multiple bezier segments together
For a single bezier, you have two endpoints and N control points (usually one or two). The line will pass through the endpoints, but never touch the control points (unless everything is colinear, but then what would be the point)
If you have two bezier segments, you can make the path smooth through the middle endpoint if the control points are colinear with that middle endpoint
So one of the helper functions is to return an array of bezier segments based on an array of endpoints and a percent (for curviness)
There are also helper functions that return an array of sample points at regular percent intervals along the path (path could be open or closed)
------------------------------------------------------------------------------------------------------------
v5:
There was an edge case that finally executed, and it was using variable names from the c# version instead of lua version's names
v4:
Params were swapped in a function call (count, segments). This call normally doesn't happen, one of those edge case cleanups
v3:
There is a function Quaternion_FromAxisRadians that is a wrapper to the game's implementation. Turns out, axis needs to be a unit vector
Ran into an exception where a tiny segment relative to others caused no sample points for that segment (now skipping it properly)
Went ahead and added AnimationCurve class (was working on it in my other mod)
v2:
When porting from c#, there was a [0] that should have been [1]
In GetSegments, it compares segment lengths and angles and adjusts the along percent a bit better
Made two versions of GetBezierPoints_Segments
- The uniform version has the points uniformly spread, which looks good for sweeping curves, but bad for pinched curves
- Standard adjusts counts better based on relative segment lengths