Before implementing curve evaluation for the new Curves
type, I did a review of available curve libraries, with the hope of avoiding reimplenting evaluation and other tools in case an existing library already provided the functionality. In addition to providing necessary features, a library should be actively maintained, have a focus on performance, interface with C/C++, have a “pleasant” API, and a GPL compatible license.
We’re aiming on supporting four curve types: poly curves, Bezier curves, Catmull Rom curves, and NURBS, like the existing Blender curve object, with the addition of Catmull Rom, which is a standard for hair-like use cases. As a reminder, NURBS (Non-Uniform (knots vector can be adjusted manually), Rational (every control point has a weight), B-spline) is a generalization of the other curve types. The generality comes with a performance and UI cost.
Storing attributes on curves and interpolating those to the resulting evaluated points seems to be a use case that isn’t often considered. Ideally, interpolating attributes besides positions would not require a complete re-evaluation of a complex curve.
I found quite a few suggestions online, but in the end, I don’t think I found a library that met our needs and followed the other criteria. The following is a description of the options and my reasoning, in a rough order of how compelling I thought they were.
I’m sharing this here in case anyone finds it interesting, and since I think it’s better than keeping it as a note locally.
-
Open CASCADE
- The geometry kernel behind FreeCAD. I’m sure this has all of the relevant features (though it’s hard to tell exactly, since the library does quite a lot).
- Also being looked into for work on surfaces (Better curve surface support). Though that’s not what I’m interested in at the moment, supporting proper solids in Blender in the longer term would be wonderful, especially in a procedural context.
- The focus on geometry is definitely a plus, compared so some other libraries that focus on splines in the context of image manipulation, for example.
- It looks like quite a bit of learning would be required just for our simple use case.
- It’s not clear if it has a focus on performance. In fact, its large scope may be a downside in this case.
- Conclusion: I’m not sure yet. It strikes me as complicated, but well documented from what I’ve seen so far. The scope is just way bigger than what we need at the moment.
-
tinynurbs
- A small header-only library.
- Actively in development.
- The curves seem to own their control points arrays, weights, etc, meaning we will have extra copies if using this.
- Code looks well written and self-explanatory.
- Conclusion: It’s not clear this is worth using, but if not, it looks like it would serve as a great point of reference.
-
vspline
- A “modern C++” approach, with a focus on performance with SIMD and multi-threading.
- Well documented.
- It’s not clear that this is a downside, but the library seems focussed on image processing use cases.
- No support for non-uniform & rational B-splines (NURBS).
- Rather complicated, using plenty of seemingly unique terminology (though maybe it just looks that way because it provides proper documentation).
- Conclusion: Tempting, because of the focus on performance and the apparent abundance of features, but in the end the lack of support for NURBS and its complexity are turn-offs.
-
tinyspline
- Supports general NURBS, Bezier curves, B-splines.
- Written in C89 with C++ bindings.
- Latest commits are fairly recent.
- Documentation is a bit lacking, and the examples don’t seem that compelling honestly.
- Conclusion: No real benefit over using our own implementation.
-
Boost
- Provides a straightforward implemenation of Bezier and Catmull-Rom evaluation (not NURBS).
- Seems to focus on performance.
- Conclusion: Not worth using a library for these relatively simple curve types.
-
Ayam
- A general modeling application with support for NURBS.
- Development looks active.
- Doesn’t look like it’s meant to be used as a library.
- Conclusion: Not applicable.
-
SplineLibrary
- Provides implementations of Catmull-Rom splines, generric B-splines, and others.
- No support for non-uniform & rational B-splines (NURBS).
- Last commit in 2018
- Conclusion: No real benefit over using our own implementation.
-
SISL
- A general NURBS curve and surface library.
- C rather than C++ (not templated on float type).
- Not “modern” code (seems to use public function names like
s1012
for some reason), unamed parameters in headers - I don’t think AGPL is compatible with Blender’s GPL license.
- Conclusion: It looks interesting and full-featured, but even disragarding the license issue, I’m not sure using it would be helpful.
-
GNU Scientific Library
- The scope of the provided features isn’t clear.
- Part of a much larger library.
- Conclusion: Not clear enough that this would be helpful.
-
Einspline
- Doesn’t look actively maintained.
- Only B-splines supported, not more general NURBS.
- Conclusion: Not applicable.
-
Eigen
- The “unsupported” status makes this not a compelling choice to me.
- The documentation isn’t very clear on the purpose of the module.
- Conclusion: Not applicable.
-
Scyllarus C++ API NURBS
- Licensing isn’t clear, focus is image processing anyway.
- Conclusion: Not applicable.
-
openNURBS
- Misleading naming and marketing-- this is just an implementation of I/O for Rhino’s proprietary 3DM format, not an “open” implementation of NURBS.
- Conclusion: Not applicable.
-
libnurbs
- A “planned” extension of the openNURBS project, to improve the documentation apparently.
- Not updated for 9 years.
- Conclusion: Not applicable.