diff options
author | Hans Goudey <h.goudey@me.com> | 2022-04-15 18:14:54 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-04-15 18:15:48 +0300 |
commit | 7484f274dcdc9092dd5d85059e8d110572fe3b3c (patch) | |
tree | b35e754bfbe5d62f5be6e890de2cd957a9adcad8 /source/blender/blenlib | |
parent | cc6db8921bdc497d75c495c843b913109adb9d4a (diff) |
Curves: Port curve to mesh node to the new data-block
This commit changes the Curve to Mesh node to work with `Curves`
instead of `CurveEval`. The change ends up basically completely
rewriting the node, since the different attribute storage means that
the decisions made previously don't make much sense anymore.
The main loops are now "for each attribute: for each curve combination"
rather than the other way around, with the goal of taking advantage
of the locality of curve attributes. This improvement is quite
noticeable with many small curves; I measured a 4-5x improvement
(around 4-5s to <1s) when converting millions of curves to tens of
millions of faces. I didn't obverse any change in performance compared
to 3.1 with fewer curves though.
The changes also solve an algorithmic flaw where any interpolated
attributes would be evaluated for every curve combination instead
of just once per curve. This can be a large improvement when there
are many profile curves.
The code relies heavily on a function `foreach_curve_combination`
which calculates some basic information about each combination and
calls a templated function. I made assumptions about unnecessary reads
being removed by compiler optimizations. For further performance
improvements in the future that might be an area to investigate.
Another might be using a "for a group of curves: for each attribute:
for each curve" pattern to increase the locality of memory access.
Differential Revision: https://developer.blender.org/D14642
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_vector.hh | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_vector.hh b/source/blender/blenlib/BLI_vector.hh index da9ab9c313e..acf47f67168 100644 --- a/source/blender/blenlib/BLI_vector.hh +++ b/source/blender/blenlib/BLI_vector.hh @@ -387,6 +387,16 @@ class Vector { } /** + * Reset the size of the vector so that it contains new_size elements. + * All existing elements are destructed, and not copied if the data must be reallocated. + */ + void reinitialize(const int64_t new_size) + { + this->clear(); + this->resize(new_size); + } + + /** * Afterwards the vector has 0 elements, but will still have * memory to be refilled again. */ |