Cleanup: Slightly generalize attribute gather function
Move implementation to array_utils namespace, use function to gather all attributes at once.
This commit is contained in:
parent
cf1b3eee99
commit
f3ba4115f2
|
@ -942,18 +942,6 @@ void gather_attributes(const AttributeAccessor src_attributes,
|
|||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static void gather_group_to_group(const OffsetIndices<int> src_offsets,
|
||||
const OffsetIndices<int> dst_offsets,
|
||||
const IndexMask &selection,
|
||||
const Span<T> src,
|
||||
MutableSpan<T> dst)
|
||||
{
|
||||
selection.foreach_index(GrainSize(512), [&](const int64_t src_i, const int64_t dst_i) {
|
||||
dst.slice(dst_offsets[dst_i]).copy_from(src.slice(src_offsets[src_i]));
|
||||
});
|
||||
}
|
||||
|
||||
static void gather_group_to_group(const OffsetIndices<int> src_offsets,
|
||||
const OffsetIndices<int> dst_offsets,
|
||||
const IndexMask &selection,
|
||||
|
@ -962,7 +950,8 @@ static void gather_group_to_group(const OffsetIndices<int> src_offsets,
|
|||
{
|
||||
attribute_math::convert_to_static_type(src.type(), [&](auto dummy) {
|
||||
using T = decltype(dummy);
|
||||
gather_group_to_group(src_offsets, dst_offsets, selection, src.typed<T>(), dst.typed<T>());
|
||||
array_utils::gather_group_to_group(
|
||||
src_offsets, dst_offsets, selection, src.typed<T>(), dst.typed<T>());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -165,6 +165,18 @@ inline void gather(const VArray<T> &src,
|
|||
});
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void gather_group_to_group(const OffsetIndices<int> src_offsets,
|
||||
const OffsetIndices<int> dst_offsets,
|
||||
const IndexMask &selection,
|
||||
const Span<T> src,
|
||||
MutableSpan<T> dst)
|
||||
{
|
||||
selection.foreach_index(GrainSize(512), [&](const int64_t src_i, const int64_t dst_i) {
|
||||
dst.slice(dst_offsets[dst_i]).copy_from(src.slice(src_offsets[src_i]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the \a src data from the groups defined by \a src_offsets to the groups in \a dst defined
|
||||
* by \a dst_offsets. Groups to use are masked by \a selection, and it is assumed that the
|
||||
|
|
|
@ -532,12 +532,12 @@ struct EraseOperationExecutor {
|
|||
const bke::AnonymousAttributePropagationInfo propagation_info{};
|
||||
|
||||
/* Copy curves attributes. */
|
||||
for (bke::AttributeTransferData &attribute : bke::retrieve_attributes_for_transfer(
|
||||
src_attributes, dst_attributes, ATTR_DOMAIN_MASK_CURVE, propagation_info, {"cyclic"}))
|
||||
{
|
||||
bke::attribute_math::gather(attribute.src, dst_to_src_curve.as_span(), attribute.dst.span);
|
||||
attribute.dst.finish();
|
||||
}
|
||||
bke::gather_attributes(src_attributes,
|
||||
ATTR_DOMAIN_CURVE,
|
||||
propagation_info,
|
||||
{"cyclic"},
|
||||
dst_to_src_curve,
|
||||
dst_attributes);
|
||||
array_utils::gather(
|
||||
src_now_cyclic.as_span(), dst_to_src_curve.as_span(), dst.cyclic_for_write());
|
||||
|
||||
|
|
Loading…
Reference in New Issue