22using bke::CurvesGeometry;
29 const std::array<int, CURVE_TYPES_NUM> &type_counts)
34 if (
ELEM(attribute_id,
"handle_type_left",
"handle_type_right",
"handle_left",
"handle_right")) {
37 if (
ELEM(attribute_id,
"nurbs_weight")) {
55 return !no_interpolation.
contains(attribute_id);
82 const GVArray src_from_attribute = *src_from_attributes.
lookup(ids[i], domain);
83 if (src_from_attribute) {
86 const GVArray src_to_attribute = *src_to_attributes.
lookup(ids[i], domain, data_type);
88 result.src_from.append(src_from_attribute);
92 const GVArray src_to_attribute = *src_to_attributes.
lookup(ids[i], domain);
99 result.src_to.append(src_to_attribute);
103 ids[i], domain, data_type);
104 result.dst.append(std::move(dst_attribute));
132 if (iter.name ==
"position") {
163 if (iter.name ==
"curve_type") {
180 const GSpan src_data,
194 const int dst_points_num = dst_data.
size();
200 using T =
decltype(dummy);
206 const int i_src_curve = src_curve_indices[
pos];
207 const IndexRange src_points = src_points_by_curve[i_src_curve];
208 const IndexRange dst_points = dst_points_by_curve[i_dst_curve];
212 dst_sample_indices.
slice(dst_points),
213 dst_sample_factors.
slice(dst_points),
214 dst.
slice(dst_points));
217 const IndexRange src_evaluated_points = src_evaluated_points_by_curve[i_src_curve];
218 evaluated_data.reinitialize(src_evaluated_points.
size());
220 i_src_curve, src.
slice(src_points), evaluated_data.as_mutable_span());
222 dst_sample_indices.
slice(dst_points),
223 dst_sample_factors.
slice(dst_points),
224 dst.
slice(dst_points));
233 const float mix_factor,
243 const float mix_factor,
248 using T = decltype(dummy);
249 const Span<T> from = src_from.typed<T>();
250 const Span<T> to = src_to.typed<T>();
251 const MutableSpan<T> dst_typed = dst.typed<T>();
252 selection.foreach_index(GrainSize(512), [&](const int curve) {
253 dst_typed[curve] = math::interpolate(from[curve], to[curve], mix_factor);
260 const float mix_factor,
268 using T = decltype(dummy);
269 const Span<T> from = src_from.typed<T>();
270 const Span<T> to = src_to.typed<T>();
271 const MutableSpan<T> dst_typed = dst.typed<T>();
272 mix_arrays(from.slice(range), to.slice(range), mix_factor, dst_typed.slice(range));
283 const float mix_factor,
304 from_curves, to_curves, dst_curves);
306 from_curves, to_curves, dst_curves);
325 const int i_from_curve = from_curve_indices[
pos];
326 const int i_to_curve = to_curve_indices[
pos];
327 const IndexRange dst_points = dst_points_by_curve[i_dst_curve];
329 i_from_curve, from_curves_cyclic[i_from_curve]);
331 i_to_curve, to_curves_cyclic[i_to_curve]);
340 !from_curves_cyclic[i_from_curve],
350 if (dst_curve_flip_direction[i_dst_curve]) {
353 !to_curves_cyclic[i_to_curve],
359 !to_curves_cyclic[i_to_curve],
368 for (
const int i_attribute : point_attributes.
dst.index_range()) {
370 if (!point_attributes.
dst[i_attribute]) {
374 const GSpan src_from = point_attributes.
src_from[i_attribute];
375 const GSpan src_to = point_attributes.
src_to[i_attribute];
399 mix_arrays(from_samples, to_samples, mix_factor, dst_curve_mask, dst_points_by_curve, dst);
431 from_evaluated_positions,
439 to_evaluated_positions,
453 for (
const int i_attribute : curve_attributes.
dst.index_range()) {
455 if (!curve_attributes.
dst[i_attribute]) {
459 const GSpan src_from = curve_attributes.
src_from[i_attribute];
460 const GSpan src_to = curve_attributes.
src_to[i_attribute];
474 mix_arrays(from_samples, to_samples, mix_factor, dst_curve_mask, dst);
Low-level operations for curves.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its and value channels Color Retrieve a color attribute
Span< T > as_span() const
MutableSpan< T > as_mutable_span()
const CPPType & type() const
MutableSpan< T > typed() const
const CPPType & type() const
const CPPType & type() const
static GVArray ForSpan(GSpan span)
constexpr int64_t size() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
bool contains(const Key &key) const
constexpr Span slice(int64_t start, int64_t size) const
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr bool is_empty() const
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
GAttributeReader lookup(const StringRef attribute_id) const
MutableSpan< float3 > positions_for_write()
OffsetIndices< int > points_by_curve() const
const std::array< int, CURVE_TYPES_NUM > & curve_type_counts() const
MutableAttributeAccessor attributes_for_write()
Span< float > evaluated_lengths_for_curve(int curve_index, bool cyclic) const
void interpolate_to_evaluated(int curve_index, GSpan src, GMutableSpan dst) const
OffsetIndices< int > evaluated_points_by_curve() const
void fill_curve_types(CurveType type)
AttributeAccessor attributes() const
void ensure_evaluated_lengths() const
Span< float3 > evaluated_positions() const
VArray< int8_t > curve_types() const
VArray< bool > cyclic() const
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef attribute_id, AttrDomain domain, eCustomDataType data_type)
void foreach_index(Fn &&fn) const
void copy(const GVArray &src, GMutableSpan dst, int64_t grain_size=4096)
void convert_to_static_type(const CPPType &cpp_type, const Func &func)
bool attribute_name_is_anonymous(const StringRef name)
eCustomDataType cpp_type_to_custom_data_type(const CPPType &type)
static AttributesForInterpolation gather_curve_attributes_to_interpolate(const CurvesGeometry &from_curves, const CurvesGeometry &to_curves, CurvesGeometry &dst_curves)
static void mix_arrays(const Span< T > from, const Span< T > to, const float mix_factor, const MutableSpan< T > dst)
static AttributesForInterpolation retrieve_attribute_spans(const Span< StringRef > ids, const CurvesGeometry &src_from_curves, const CurvesGeometry &src_to_curves, const bke::AttrDomain domain, CurvesGeometry &dst_curves)
void interpolate_curves(const bke::CurvesGeometry &from_curves, const bke::CurvesGeometry &to_curves, Span< int > from_curve_indices, Span< int > to_curve_indices, const IndexMask &dst_curve_mask, Span< bool > dst_curve_flip_direction, const float mix_factor, bke::CurvesGeometry &dst_curves)
static void sample_curve_attribute(const bke::CurvesGeometry &src_curves, const Span< int > src_curve_indices, const OffsetIndices< int > dst_points_by_curve, const GSpan src_data, const IndexMask &dst_curve_mask, const Span< int > dst_sample_indices, const Span< float > dst_sample_factors, GMutableSpan dst_data)
static bool interpolate_attribute_to_poly_curve(const StringRef attribute_id)
static bool interpolate_attribute_to_curves(const StringRef attribute_id, const std::array< int, CURVE_TYPES_NUM > &type_counts)
static AttributesForInterpolation gather_point_attributes_to_interpolate(const CurvesGeometry &from_curves, const CurvesGeometry &to_curves, CurvesGeometry &dst_curves)
void sample_uniform_reverse(Span< float > accumulated_segment_lengths, bool include_first_point, MutableSpan< int > r_segment_indices, MutableSpan< float > r_factors)
void interpolate(const Span< T > src, const Span< int > indices, const Span< float > factors, MutableSpan< T > dst)
void sample_uniform(Span< float > accumulated_segment_lengths, bool include_last_point, MutableSpan< int > r_segment_indices, MutableSpan< float > r_factors)
T interpolate(const T &a, const T &b, const FactorT &t)
GPU_SHADER_INTERFACE_INFO(overlay_edit_curve_handle_iface, "vert").flat(Type pos vertex_in(1, Type::UINT, "data") .vertex_out(overlay_edit_curve_handle_iface) .geometry_layout(PrimitiveIn Frequency::GEOMETRY storage_buf(1, Qualifier::READ, "uint", "data[]", Frequency::GEOMETRY) .push_constant(Type Frequency::GEOMETRY selection[]
Vector< bke::GSpanAttributeWriter > dst
Vector< GVArraySpan > src_from
Vector< GVArraySpan > src_to