diff options
author | Hans Goudey <h.goudey@me.com> | 2022-06-08 19:40:08 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-06-08 19:40:14 +0300 |
commit | fe4e646405eb3a8e38617411a2f9b1b8f6b8a8cb (patch) | |
tree | 1212e0a0b62d78e972eaf95f3af53211fbf45750 /source/blender/blenlib/BLI_bounds.hh | |
parent | a3e7280bd896f4e3755bb0ededfd83031e2734ea (diff) |
Fix: Incorrect curves and pointcloud bounding boxes
The generic bounds utility used an incorrect initial value. The value
cannot be zero-initialized, because that breaks the case where all
values are greater than zero.
Diffstat (limited to 'source/blender/blenlib/BLI_bounds.hh')
-rw-r--r-- | source/blender/blenlib/BLI_bounds.hh | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/source/blender/blenlib/BLI_bounds.hh b/source/blender/blenlib/BLI_bounds.hh index d20382ed500..f5a18a0ea48 100644 --- a/source/blender/blenlib/BLI_bounds.hh +++ b/source/blender/blenlib/BLI_bounds.hh @@ -28,10 +28,11 @@ template<typename T> static std::optional<MinMaxResult<T>> min_max(Span<T> value if (values.is_empty()) { return std::nullopt; } + const MinMaxResult<T> init{values.first(), values.first()}; return threading::parallel_reduce( values.index_range(), 1024, - MinMaxResult<T>(), + init, [&](IndexRange range, const MinMaxResult<T> &init) { MinMaxResult<T> result = init; for (const int i : range) { @@ -55,10 +56,11 @@ static std::optional<MinMaxResult<T>> min_max_with_radii(Span<T> values, Span<Ra if (values.is_empty()) { return std::nullopt; } + const MinMaxResult<T> init{values.first(), values.first()}; return threading::parallel_reduce( values.index_range(), 1024, - MinMaxResult<T>(), + init, [&](IndexRange range, const MinMaxResult<T> &init) { MinMaxResult<T> result = init; for (const int i : range) { |