Preview
Asset is in development, documentation is a draft
5.Performance Guidelines
Spline Mesher 2 is built on a foundation of the C# Job System and Burst Compiler. Which results in highly optimized native code running in parallel on multiple CPU cores. Functionality has been built on top of Unity’s native Splines framework to use it with this technology, which greatly enhances its use beyond Unity’s original scope. There is no asset on the store comparable, which is ready to take advantage of!
Mesh generation as a whole is up to 500 times faster than in Spline Mesher 1
Splines
Sampling splines is slow, even through Unity’s provided job-friendly method. Therefor this asset employs a custom caching solution to fork up the sampling cost just once. After which, sampling the cached data is extremely fast in comparison (up to 26 times).
Spline alterations
Whenever a Spline changes, it’s required to cache it by reading it out over it’s entire length and convert the data into a format usable by the Job System (eg. native arrays). Once this process has completed, the spline data will be used extremely efficiently for mesh generation.
But, the process itself is relatively costly. This means: rebuilding that happens based on spline changes is slower than just rebuilding by calling the Rebuild() function or changing parameters in the inspector.
Procedural splines
If you are creating one or more splines through script it is highly inefficient to call SplineContainer.Spline = newSpline (overwrite). This is because it will first trigger the removal of a Spline (causing its related mesh/cap objects to be destroyed) before it is added again (objects/arrays being recreated from scratch).
Instead use SplineContainer.Spline.Copy(newSpline). This will count as a spline change, which is far more efficient. You will find that the performance difference is significant.
Garbage collection
In the Editor and in Development builds the mesh generation as a whole yields some garbage collection. This is related to some QoL processes.
For example, all the created meshes are neatly given a name, rather than appearing blank. This is to make it possible to identify them in something like a build report or the memory profiler.
In a regular build this would not be the case and peak performance is maintained.
Realtime mesh generation
By large this asset is designed to be a level design and world building tool.
Can you make a snake-like mesh deform in realtime? Absolutely, just alter the knot positions through script! But the CPU performance won’t nearly be as great as using a rigged mesh or GPU-based deformation system. You can easily spent 10-20% of your target framerate on deforming the spline/mesh alone.
This has a lot to do with the Spline framework and this asset being design for flexibilty and expanded functionality, which comes at the cost of bare bones performance. Practically speaking, moving tentacles or a physics enabled bridge are all possible. But these are always done using skeletal animations if you’ve seen them in games.
