Blender
V3.3
|
#include <BKE_spline.hh>
Classes | |
struct | LookupResult |
Static Public Member Functions | |
static void | copy_base_settings (const Spline &src, Spline &dst) |
Public Attributes | |
NormalMode | normal_mode = NORMAL_MODE_MINIMUM_TWIST |
blender::bke::CustomDataAttributes | attributes |
Protected Member Functions | |
virtual void | correct_end_tangents () const =0 |
virtual void | copy_settings (Spline &dst) const =0 |
virtual void | copy_data (Spline &dst) const =0 |
virtual void | reverse_impl ()=0 |
A spline is an abstraction of a single branch-less curve section, its evaluation methods, and data. The spline data itself is just control points and a set of attributes by the set of "evaluated" data is often used instead. Conceptually, the derived vs. original data is an essential distinction. Derived data is usually calculated lazily and cached on the spline.
Any derived class of Spline has to manage two things:
Beyond that, everything is the base class's responsibility, with minor exceptions. Further evaluation happens in a layer on top of the evaluated points generated by the derived types.
There are a few methods to evaluate a spline:
Commonly used evaluated data is stored in caches on the spline itself so that operations on splines don't need to worry about taking ownership of evaluated data when they don't need to.
Definition at line 52 of file BKE_spline.hh.
|
virtualdefault |
|
inline |
Definition at line 79 of file BKE_spline.hh.
|
inline |
Definition at line 82 of file BKE_spline.hh.
References copy_base_settings().
void Spline::bounds_min_max | ( | blender::float3 & | min, |
blender::float3 & | max, | ||
bool | use_evaluated | ||
) | const |
Definition at line 490 of file spline_base.cc.
References evaluated_positions(), max, min, minmax_v3v3_v3(), and positions().
SplinePtr Spline::copy | ( | ) | const |
Return a new spline with the same data, settings, and attributes.
Definition at line 53 of file spline_base.cc.
References attributes, and copy_without_attributes().
Definition at line 30 of file spline_base.cc.
References is_cyclic_, normal_mode, and src.
Referenced by copy_only_settings(), and Spline().
Implemented in PolySpline, and NURBSpline.
Referenced by copy_without_attributes().
SplinePtr Spline::copy_only_settings | ( | ) | const |
Return a new spline with the same type and settings like "cyclic", but without any data.
Definition at line 60 of file spline_base.cc.
References copy_base_settings(), copy_settings(), create_spline(), and type_.
Referenced by copy_without_attributes().
Implemented in PolySpline, and NURBSpline.
Referenced by copy_only_settings().
SplinePtr Spline::copy_without_attributes | ( | ) | const |
The same as copy, but skips copying dynamic attributes to the new spline.
Definition at line 68 of file spline_base.cc.
References copy_data(), and copy_only_settings().
Referenced by copy().
|
protectedpure virtual |
Implemented in PolySpline, and NURBSpline.
Referenced by evaluated_tangents().
int Spline::evaluated_edges_num | ( | ) | const |
Definition at line 119 of file spline_base.cc.
References evaluated_points_num(), and is_cyclic_.
Referenced by NURBSpline::calculate_basis_cache(), evaluated_lengths(), and sample_uniform_index_factors().
Return non-owning access to the cache of accumulated lengths along the spline. Each item is the length of the subsequent segment, i.e. the first value is the length of the first segment rather than 0. This calculation is rather trivial, and only depends on the evaluated positions. However, the results are used often, and it is necessarily single threaded, so it is cached.
Definition at line 169 of file spline_base.cc.
References accumulate_lengths(), evaluated_edges_num(), evaluated_lengths_cache_, evaluated_positions(), is_cyclic_, length_cache_dirty_, length_cache_mutex_, lock, positions(), and blender::Vector< T, InlineBufferCapacity, Allocator >::resize().
Referenced by length(), lookup_evaluated_length(), and sample_uniform_index_factors().
Return non-owning access to the direction vectors perpendicular to the tangents at every evaluated point. The method used to generate the normal vectors depends on Spline.normal_mode.
Definition at line 361 of file spline_base.cc.
References calculate_normals_minimum(), calculate_normals_z_up(), evaluated_normals_cache_, evaluated_points_num(), evaluated_tangents(), interpolate_to_evaluated(), is_cyclic_, lock, normal_cache_dirty_, normal_cache_mutex_, normal_mode, NORMAL_MODE_MINIMUM_TWIST, NORMAL_MODE_Z_UP, normals, rotate_direction_around_axis(), tangents, and tilts().
|
pure virtual |
Implemented in PolySpline, NURBSpline, and BezierSpline.
Referenced by evaluated_edges_num(), evaluated_normals(), evaluated_tangents(), lookup_data_from_index_factor(), and lookup_evaluated_length().
|
pure virtual |
Return non-owning access to the direction of the curve at each evaluated point.
Definition at line 234 of file spline_base.cc.
References calculate_tangents(), correct_end_tangents(), evaluated_points_num(), evaluated_positions(), evaluated_tangents_cache_, is_cyclic_, lock, positions(), tangent_cache_dirty_, and tangent_cache_mutex_.
Referenced by evaluated_normals().
GVArray Spline::interpolate_to_evaluated | ( | blender::GSpan | data | ) | const |
Definition at line 498 of file spline_base.cc.
References data, and interpolate_to_evaluated().
|
inline |
Definition at line 228 of file BKE_spline.hh.
References data, interpolate_to_evaluated(), T, and blender::GVArray::typed().
|
pure virtual |
Interpolate a virtual array of data with the size of the number of control points to the evaluated points. For poly splines, the lifetime of the returned virtual array must not exceed the lifetime of the input data.
Implemented in BezierSpline, PolySpline, and NURBSpline.
Referenced by evaluated_normals(), NURBSpline::evaluated_positions(), interpolate_to_evaluated(), blender::nodes::node_geo_curve_trim_cc::to_single_point_nurbs(), and blender::nodes::node_geo_curve_trim_cc::trim_nurbs_spline().
bool Spline::is_cyclic | ( | ) | const |
Definition at line 143 of file spline_base.cc.
References is_cyclic_.
Referenced by calculate_mappings_linear_resolution().
float Spline::length | ( | ) | const |
Definition at line 130 of file spline_base.cc.
References evaluated_lengths(), blender::Span< T >::is_empty(), and blender::Span< T >::last().
Referenced by lookup_evaluated_factor(), lookup_evaluated_length(), sample_uniform_index_factors(), and set_handle_position().
Spline::LookupResult Spline::lookup_data_from_index_factor | ( | float | index_factor | ) | const |
Definition at line 469 of file spline_base.cc.
References evaluated_points_num(), blender::math::floor(), and is_cyclic_.
Spline::LookupResult Spline::lookup_evaluated_factor | ( | float | factor | ) | const |
Find the position on the evaluated spline at the given portion of the total length. The return value is the indices of the two neighboring points at that location and the factor between them, which can be used to look up any attribute on the evaluated points.
Definition at line 400 of file spline_base.cc.
References length(), and lookup_evaluated_length().
Spline::LookupResult Spline::lookup_evaluated_length | ( | float | length | ) | const |
The same as lookup_evaluated_factor, but looks up a length directly instead of a portion of the total.
Definition at line 405 of file spline_base.cc.
References blender::Span< T >::begin(), BLI_assert, blender::Span< T >::end(), evaluated_lengths(), evaluated_points_num(), length(), and offset.
Referenced by lookup_evaluated_factor().
|
pure virtual |
Mark all caches for re-computation. This must be called after any operation that would change the generated positions, tangents, normals, mapping, etc. of the evaluated points.
Implemented in PolySpline, NURBSpline, and BezierSpline.
Referenced by blender::bke::create_attribute_providers_for_curve(), reverse(), transform(), and translate().
|
pure virtual |
Implemented in PolySpline, NURBSpline, and BezierSpline.
|
pure virtual |
Implemented in PolySpline, NURBSpline, and BezierSpline.
Referenced by bounds_min_max(), evaluated_lengths(), evaluated_tangents(), reverse(), blender::bke::VArrayImpl_For_SplinePosition::set(), blender::bke::VArrayImpl_For_SplinePosition::set_all(), blender::nodes::node_geo_curve_trim_cc::to_single_point_poly(), transform(), translate(), and blender::nodes::node_geo_curve_trim_cc::trim_poly_spline().
|
pure virtual |
Implemented in PolySpline, NURBSpline, and BezierSpline.
|
pure virtual |
Implemented in PolySpline, NURBSpline, and BezierSpline.
Referenced by blender::bke::create_attribute_providers_for_curve(), reverse(), blender::nodes::node_geo_curve_trim_cc::to_single_point_nurbs(), blender::nodes::node_geo_curve_trim_cc::to_single_point_poly(), blender::nodes::node_geo_curve_trim_cc::trim_nurbs_spline(), and blender::nodes::node_geo_curve_trim_cc::trim_poly_spline().
|
pure virtual |
void Spline::reverse | ( | ) |
Change the direction of the spline (switch the start and end) without changing its shape.
Definition at line 94 of file spline_base.cc.
References ATTR_DOMAIN_POINT, attribute, attributes, BLI_assert_unreachable, blender::attribute_math::convert_to_static_type(), blender::bke::AttributeMetaData::data_type, blender::bke::CustomDataAttributes::foreach_attribute(), blender::bke::CustomDataAttributes::get_for_write(), mark_cache_invalid(), positions(), radii(), reverse_impl(), and tilts().
|
protectedpure virtual |
Implemented in PolySpline, NURBSpline, and BezierSpline.
Referenced by reverse().
Return an array of evenly spaced samples along the length of the spline. The samples are indices and factors to the next index encoded in floats. The logic for converting from the float values to interpolation data is in lookup_data_from_index_factor.
Definition at line 423 of file spline_base.cc.
References BLI_assert, evaluated_edges_num(), evaluated_lengths(), float(), is_cyclic_, blender::Array< T, InlineBufferCapacity, Allocator >::last(), length(), and blender::Span< T >::size().
|
inline |
Definition at line 214 of file BKE_spline.hh.
References sample_with_index_factors(), and src.
void Spline::sample_with_index_factors | ( | const blender::GVArray & | src, |
blender::Span< float > | index_factors, | ||
blender::GMutableSpan | dst | ||
) | const |
Sample any input data with a value for each evaluated point (already interpolated to evaluated points) to arbitrary parameters in between the evaluated points. The interpolation is quite simple, but this handles the cyclic and end point special cases.
Definition at line 503 of file spline_base.cc.
References BLI_assert, blender::attribute_math::convert_to_static_type(), blender::threading::parallel_for(), and src.
Referenced by sample_with_index_factors().
|
inline |
Definition at line 206 of file BKE_spline.hh.
References sample_with_index_factors(), and src.
int Spline::segments_num | ( | ) | const |
Definition at line 136 of file spline_base.cc.
References is_cyclic_, and size().
Referenced by NURBSpline::evaluated_points_num().
Definition at line 148 of file spline_base.cc.
References is_cyclic_.
|
pure virtual |
Return the number of control points.
Implemented in PolySpline, NURBSpline, and BezierSpline.
Referenced by segments_num().
|
pure virtual |
Implemented in PolySpline, NURBSpline, and BezierSpline.
|
pure virtual |
Implemented in PolySpline, NURBSpline, and BezierSpline.
Referenced by blender::bke::create_attribute_providers_for_curve(), evaluated_normals(), reverse(), blender::nodes::node_geo_curve_trim_cc::to_single_point_nurbs(), blender::nodes::node_geo_curve_trim_cc::to_single_point_poly(), blender::nodes::node_geo_curve_trim_cc::trim_nurbs_spline(), and blender::nodes::node_geo_curve_trim_cc::trim_poly_spline().
|
virtual |
Reimplemented in BezierSpline.
Definition at line 86 of file spline_base.cc.
References mark_cache_invalid(), and positions().
|
virtual |
Reimplemented in BezierSpline.
Definition at line 78 of file spline_base.cc.
References mark_cache_invalid(), and positions().
CurveType Spline::type | ( | ) | const |
Definition at line 25 of file spline_base.cc.
References type_.
Referenced by curve_eval_to_curves(), blender::bke::VArrayImpl_For_BezierHandles::get(), blender::bke::VArrayImpl_For_BezierHandles::set(), blender::bke::VArrayImpl_For_BezierHandles::set_all(), and set_handle_position().
blender::bke::CustomDataAttributes Spline::attributes |
Definition at line 56 of file BKE_spline.hh.
Referenced by copy(), blender::bke::create_attribute_providers_for_curve(), BezierSpline::resize(), NURBSpline::resize(), PolySpline::resize(), reverse(), blender::nodes::node_geo_curve_trim_cc::to_single_point_bezier(), blender::nodes::node_geo_curve_trim_cc::to_single_point_nurbs(), blender::nodes::node_geo_curve_trim_cc::to_single_point_poly(), blender::nodes::node_geo_curve_trim_cc::trim_bezier_spline(), blender::nodes::node_geo_curve_trim_cc::trim_nurbs_spline(), and blender::nodes::node_geo_curve_trim_cc::trim_poly_spline().
|
mutableprotected |
Accumulated lengths along the evaluated points.
Definition at line 73 of file BKE_spline.hh.
Referenced by evaluated_lengths().
|
mutableprotected |
Normal direction vectors for each evaluated point.
Definition at line 68 of file BKE_spline.hh.
Referenced by evaluated_normals().
|
mutableprotected |
Direction of the spline at each evaluated point.
Definition at line 63 of file BKE_spline.hh.
Referenced by evaluated_tangents().
|
protected |
Definition at line 60 of file BKE_spline.hh.
Referenced by NURBSpline::calculate_basis_cache(), NURBSpline::calculate_knots(), NURBSpline::check_valid_num_and_order(), copy_base_settings(), BezierSpline::ensure_auto_handles(), evaluated_edges_num(), evaluated_lengths(), BezierSpline::evaluated_mappings(), evaluated_normals(), BezierSpline::evaluated_positions(), evaluated_tangents(), BezierSpline::interpolation_data_from_index_factor(), is_cyclic(), NURBSpline::knots_num(), lookup_data_from_index_factor(), sample_uniform_index_factors(), BezierSpline::segment_is_vector(), segments_num(), and set_cyclic().
|
mutableprotected |
Definition at line 75 of file BKE_spline.hh.
Referenced by evaluated_lengths(), BezierSpline::mark_cache_invalid(), NURBSpline::mark_cache_invalid(), and PolySpline::mark_cache_invalid().
|
mutableprotected |
Definition at line 74 of file BKE_spline.hh.
Referenced by evaluated_lengths().
|
mutableprotected |
Definition at line 70 of file BKE_spline.hh.
Referenced by evaluated_normals(), BezierSpline::mark_cache_invalid(), NURBSpline::mark_cache_invalid(), and PolySpline::mark_cache_invalid().
|
mutableprotected |
Definition at line 69 of file BKE_spline.hh.
Referenced by evaluated_normals().
NormalMode Spline::normal_mode = NORMAL_MODE_MINIMUM_TWIST |
Definition at line 54 of file BKE_spline.hh.
Referenced by copy_base_settings(), and evaluated_normals().
|
mutableprotected |
Definition at line 65 of file BKE_spline.hh.
Referenced by evaluated_tangents(), BezierSpline::mark_cache_invalid(), NURBSpline::mark_cache_invalid(), and PolySpline::mark_cache_invalid().
|
mutableprotected |
Definition at line 64 of file BKE_spline.hh.
Referenced by evaluated_tangents().
|
protected |
Definition at line 59 of file BKE_spline.hh.
Referenced by copy_only_settings(), and type().