diff options
author | Jacques Lucke <jacques@blender.org> | 2022-07-02 22:51:45 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-07-02 22:51:58 +0300 |
commit | ab444a80a280e125b3e4d002941504d56f340ced (patch) | |
tree | 7862c87f35f3d0463d3322ddb68442014ba1afdd /source/blender/editors/sculpt_paint/curves_sculpt_brush.cc | |
parent | 69ee9ca90e36aa6a74317262fccb1e3e2e9210bc (diff) |
BLI: refactor length parameterization
This refactor had two main goals:
* Simplify the sampling code by using an algorithm with fewer special cases.
* Generalize the sampling to support non-sorted samples.
The `SampleSegmentHint` optimization was inspired by `ValueAccessor` from
OpenVDB and improves performance 2x in my test cases.
Differential Revision: https://developer.blender.org/D15348
Diffstat (limited to 'source/blender/editors/sculpt_paint/curves_sculpt_brush.cc')
-rw-r--r-- | source/blender/editors/sculpt_paint/curves_sculpt_brush.cc | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc index 1c785fa6452..7d17db515fb 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc @@ -345,7 +345,7 @@ void move_last_point_and_resample(MutableSpan<float3> positions, const float3 &n { /* Find the accumulated length of each point in the original curve, * treating it as a poly curve for performance reasons and simplicity. */ - Array<float> orig_lengths(length_parameterize::lengths_num(positions.size(), false)); + Array<float> orig_lengths(length_parameterize::segments_num(positions.size(), false)); length_parameterize::accumulate_lengths<float3>(positions, false, orig_lengths); const float orig_total_length = orig_lengths.last(); @@ -363,8 +363,7 @@ void move_last_point_and_resample(MutableSpan<float3> positions, const float3 &n Array<int> indices(positions.size() - 1); Array<float> factors(positions.size() - 1); - length_parameterize::create_samples_from_sorted_lengths( - orig_lengths, new_lengths, false, indices, factors); + length_parameterize::sample_at_lengths(orig_lengths, new_lengths, indices, factors); Array<float3> new_positions(positions.size() - 1); length_parameterize::linear_interpolation<float3>(positions, indices, factors, new_positions); |