37 const float3 ray_dir = positions[last_index] - positions[first_index];
40 lambda =
math::dot(ray_dir, positions[
index] - positions[first_index]) /
43 const T &from = attribute_data[first_index];
44 const T &to = attribute_data[last_index];
45 const T &value = attribute_data[
index];
61 points_to_delete.
slice(range).
fill(
false);
68 if (sub_range.
size() < 3) {
73 float max_dist = -1.0f;
77 positions, attribute_data, sub_range.
first(), sub_range.
last(),
index);
78 if (dist > max_dist) {
84 if (max_dist > epsilon) {
87 stack.
push(sub_range.
slice(0, max_index + 1));
88 stack.
push(sub_range.
slice(max_index, sub_range.
size() - max_index));
92 points_to_delete.
slice(inside_range).
fill(
true);
105 points_to_delete.
as_span(),
true);
108 for (const IndexRange range : selection_ranges.as_span().slice(range_of_ranges)) {
109 ramer_douglas_peucker(range, positions, epsilon, attribute_data, points_to_delete);
114 const int points_num = positions.size();
115 if (cyclic && points_num > 2) {
117 positions, attribute_data, points_num - 2, 0, points_num - 1);
118 if (dist <= epsilon) {
119 points_to_delete[points_num - 1] =
true;
127 const GSpan attribute_data,
141 const GSpan attribute_data,
145 if (epsilon <= 0.0f) {
149 points_by_curve, curves_selection,
true, points_to_delete.
as_mutable_span());
152 const IndexRange points = points_by_curve[curve_i];
157 attribute_data.
typed<
T>().slice(points),
Low-level operations for curves.
MutableSpan< T > as_mutable_span()
void to_static_type(Fn &&fn) const
const CPPType & type() const
static IndexMask from_bools(Span< bool > bools, LinearAllocator<> &memory)
constexpr int64_t first() const
constexpr IndexRange drop_back(int64_t n) const
constexpr int64_t last(const int64_t n=0) const
constexpr int64_t size() const
constexpr IndexRange slice(int64_t start, int64_t size) const
constexpr IndexRange drop_front(int64_t n) const
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
constexpr void fill(const T &value) const
constexpr Span< T > as_span() const
constexpr Span slice(int64_t start, int64_t size) const
constexpr int64_t size() const
void push(const T &value)
IndexRange index_range() const
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
Vector< IndexRange > find_all_ranges(const Span< T > span, const T &value)
void fill_points(OffsetIndices< int > points_by_curve, const IndexMask &curve_selection, GPointer value, GMutableSpan dst)
constexpr ParallelGrainSize grain_size(int grain_size)
float perpendicular_distance(const Span< float3 > positions, const Span< T > attribute_data, const int64_t first_index, const int64_t last_index, const int64_t index)
static void ramer_douglas_peucker(const IndexRange range, const Span< float3 > positions, const float epsilon, const Span< T > attribute_data, MutableSpan< bool > points_to_delete)
IndexMask simplify_curve_attribute(const Span< float3 > positions, const IndexMask &curves_selection, const OffsetIndices< int > points_by_curve, const VArray< bool > &cyclic, float epsilon, GSpan attribute_data, IndexMaskMemory &memory)
void curve_simplify(const Span< float3 > positions, const bool cyclic, const float epsilon, const GSpan attribute_data, MutableSpan< bool > points_to_delete)
T distance(const T &a, const T &b)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
T interpolate(const T &a, const T &b, const FactorT &t)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
VecBase< float, 2 > float2
VecBase< float, 3 > float3
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float