Curves: Add simplify_curve_attribute function #118560

Merged
Falk David merged 17 commits from filedescriptor/blender:curves-resample-adaptive into main 2024-03-26 15:28:22 +01:00
1 changed files with 10 additions and 10 deletions
Showing only changes of commit 0fbf054734 - Show all commits

View File

@ -91,11 +91,11 @@ static void ramer_douglas_peucker(const IndexRange range,
}
template<typename T>
static void curve_simplifiy(const Span<float3> positions,
const bool cyclic,
const float epsilon,
const Span<T> attribute_data,
MutableSpan<bool> points_to_delete)
static void curve_simplify(const Span<float3> positions,
const bool cyclic,
const float epsilon,
const Span<T> attribute_data,
MutableSpan<bool> points_to_delete)
{
const Vector<IndexRange> selection_ranges = array_utils::find_all_ranges(
points_to_delete.as_span(), true);
@ -138,11 +138,11 @@ IndexMask simplify_curve_attribute(const Span<float3> positions,
if constexpr (std::is_same_v<T, float> || std::is_same_v<T, float2> ||
std::is_same_v<T, float3>)
{
curve_simplifiy(positions.slice(points),
cyclic[curve_i],
epsilon,
attribute_data.typed<T>().slice(points),
points_to_delete.as_mutable_span().slice(points));
curve_simplify(positions.slice(points),
filedescriptor marked this conversation as resolved Outdated

Can you return early at the beginning of this function in this case rather than checking inside the loop?

Can you return early at the beginning of this function in this case rather than checking inside the loop?
cyclic[curve_i],
epsilon,
attribute_data.typed<T>().slice(points),
points_to_delete.as_mutable_span().slice(points));
}
});
filedescriptor marked this conversation as resolved Outdated

It seems clearer to slice all the input data so it's all local to the curve in curve_simplifiy

It seems clearer to slice all the input data so it's all local to the curve in `curve_simplifiy`
});