Blender  V3.3
Classes | Public Member Functions | Protected Member Functions | List of all members
BezierSpline Class Referencefinal

#include <BKE_spline.hh>

Inheritance diagram for BezierSpline:
Spline

Classes

struct  InsertResult
 
struct  InterpolationData
 

Public Member Functions

 BezierSpline ()
 
 BezierSpline (const BezierSpline &other)
 
int size () const final
 
int resolution () const
 
void set_resolution (int value)
 
void resize (int size) final
 
blender::MutableSpan< blender::float3positions () final
 
blender::Span< blender::float3positions () const final
 
blender::MutableSpan< floatradii () final
 
blender::Span< floatradii () const final
 
blender::MutableSpan< floattilts () final
 
blender::Span< floattilts () const final
 
blender::Span< int8_thandle_types_left () const
 
blender::MutableSpan< int8_thandle_types_left ()
 
blender::Span< blender::float3handle_positions_left () const
 
blender::MutableSpan< blender::float3handle_positions_left (bool write_only=false)
 
blender::Span< int8_thandle_types_right () const
 
blender::MutableSpan< int8_thandle_types_right ()
 
blender::Span< blender::float3handle_positions_right () const
 
blender::MutableSpan< blender::float3handle_positions_right (bool write_only=false)
 
void ensure_auto_handles () const
 
void translate (const blender::float3 &translation) override
 
void transform (const blender::float4x4 &matrix) override
 
void set_handle_position_right (int index, const blender::float3 &value)
 
void set_handle_position_left (int index, const blender::float3 &value)
 
bool point_is_sharp (int index) const
 
void mark_cache_invalid () final
 
int evaluated_points_num () const final
 
blender::Span< int > control_point_offsets () const
 
blender::Span< floatevaluated_mappings () const
 
blender::Span< blender::float3evaluated_positions () const final
 
InterpolationData interpolation_data_from_index_factor (float index_factor) const
 
virtual blender::GVArray interpolate_to_evaluated (const blender::GVArray &src) const override
 
void evaluate_segment (int index, int next_index, blender::MutableSpan< blender::float3 > positions) const
 
bool segment_is_vector (int start_index) const
 
InsertResult calculate_segment_insertion (int index, int next_index, float parameter)
 
- Public Member Functions inherited from Spline
virtual ~Spline ()=default
 
 Spline (const CurveType type)
 
 Spline (Spline &other)
 
SplinePtr copy () const
 
SplinePtr copy_only_settings () const
 
SplinePtr copy_without_attributes () const
 
CurveType type () const
 
int segments_num () const
 
bool is_cyclic () const
 
void set_cyclic (bool value)
 
void reverse ()
 
int evaluated_edges_num () const
 
float length () const
 
blender::Span< floatevaluated_lengths () const
 
blender::Span< blender::float3evaluated_tangents () const
 
blender::Span< blender::float3evaluated_normals () const
 
void bounds_min_max (blender::float3 &min, blender::float3 &max, bool use_evaluated) const
 
LookupResult lookup_evaluated_factor (float factor) const
 
LookupResult lookup_evaluated_length (float length) const
 
blender::Array< floatsample_uniform_index_factors (int samples_num) const
 
LookupResult lookup_data_from_index_factor (float index_factor) const
 
void sample_with_index_factors (const blender::GVArray &src, blender::Span< float > index_factors, blender::GMutableSpan dst) const
 
template<typename T >
void sample_with_index_factors (const blender::VArray< T > &src, blender::Span< float > index_factors, blender::MutableSpan< T > dst) const
 
template<typename T >
void sample_with_index_factors (blender::Span< T > src, blender::Span< float > index_factors, blender::MutableSpan< T > dst) const
 
blender::GVArray interpolate_to_evaluated (blender::GSpan data) const
 
template<typename T >
blender::VArray< Tinterpolate_to_evaluated (blender::Span< T > data) const
 

Protected Member Functions

void reverse_impl () override
 

Additional Inherited Members

- Static Public Member Functions inherited from Spline
static void copy_base_settings (const Spline &src, Spline &dst)
 
- Public Attributes inherited from Spline
NormalMode normal_mode = NORMAL_MODE_MINIMUM_TWIST
 
blender::bke::CustomDataAttributes attributes
 
- Protected Attributes inherited from Spline
CurveType type_
 
bool is_cyclic_ = false
 
blender::Vector< blender::float3evaluated_tangents_cache_
 
std::mutex tangent_cache_mutex_
 
bool tangent_cache_dirty_ = true
 
blender::Vector< blender::float3evaluated_normals_cache_
 
std::mutex normal_cache_mutex_
 
bool normal_cache_dirty_ = true
 
blender::Vector< floatevaluated_lengths_cache_
 
std::mutex length_cache_mutex_
 
bool length_cache_dirty_ = true
 

Detailed Description

A Bezier spline is made up of a many curve segments, possibly achieving continuity of curvature by constraining the alignment of curve handles. Evaluation stores the positions and a map of factors and indices in a list of floats, which is then used to interpolate any other data.

Definition at line 245 of file BKE_spline.hh.

Constructor & Destructor Documentation

◆ BezierSpline() [1/2]

BezierSpline::BezierSpline ( )
inline

Definition at line 277 of file BKE_spline.hh.

◆ BezierSpline() [2/2]

BezierSpline::BezierSpline ( const BezierSpline other)
inline

Definition at line 280 of file BKE_spline.hh.

Member Function Documentation

◆ calculate_segment_insertion()

BezierSpline::InsertResult BezierSpline::calculate_segment_insertion ( int  index,
int  next_index,
float  parameter 
)

De Casteljau Bezier subdivision.

Parameters
indexThe index of the segment's start control point.
next_indexThe index of the control point at the end of the segment. Could be 0, if the spline is cyclic.
parameterThe factor along the segment, between 0 and 1. Note that this is used directly by the calculation, it doesn't correspond to a portion of the evaluated length.
          handle_prev         handle_next
               x----------------x
              /                  \
             /      x---O---x     \
            /        result        \
           /                        \
          O                          O
      point_prev                  point_next

Definition at line 361 of file spline_bezier.cc.

References BLI_assert, ELEM, blender::length_parameterize::interpolate(), and result.

Referenced by blender::nodes::node_geo_curve_trim_cc::to_single_point_bezier(), and blender::nodes::node_geo_curve_trim_cc::trim_bezier_spline().

◆ control_point_offsets()

Span< int > BezierSpline::control_point_offsets ( ) const

Returns access to a cache of offsets into the evaluated point array for each control point. While most control point edges generate the number of edges specified by the resolution, vector segments only generate one edge.

Note
The length of the result is one greater than the number of points, so that the last item is the total number of evaluated points. This is useful to avoid recalculating the size of the last segment everywhere.

Definition at line 428 of file spline_bezier.cc.

References blender::MutableSpan< T >::first(), blender::MutableSpan< T >::last(), lock, offset, blender::Vector< T, InlineBufferCapacity, Allocator >::resize(), segment_is_vector(), and size().

Referenced by evaluated_mappings(), evaluated_points_num(), evaluated_positions(), blender::nodes::node_geo_curve_trim_cc::lookup_control_point_position(), and blender::nodes::node_geo_curve_trim_cc::trim_bezier_spline().

◆ ensure_auto_handles()

void BezierSpline::ensure_auto_handles ( ) const

Recalculate all #Auto and #Vector handles with positions automatically derived from the neighboring control points.

Definition at line 171 of file spline_bezier.cc.

References BEZIER_HANDLE_AUTO, BEZIER_HANDLE_VECTOR, ELEM, blender::length_parameterize::interpolate(), Spline::is_cyclic_, len, blender::math::length(), lock, min, next, next_position(), blender::meshintersect::prev(), previous_position(), and size().

Referenced by evaluated_positions(), handle_positions_left(), and handle_positions_right().

◆ evaluate_segment()

void BezierSpline::evaluate_segment ( int  index,
int  next_index,
blender::MutableSpan< blender::float3 positions 
) const

◆ evaluated_mappings()

Span< float > BezierSpline::evaluated_mappings ( ) const

Returns non-owning access to an array of values containing the information necessary to interpolate values from the original control points to evaluated points. The control point index is the integer part of each value, and the factor used for interpolating to the next control point is the remaining factional part.

Definition at line 494 of file spline_bezier.cc.

References calculate_mappings_linear_resolution(), control_point_offsets(), evaluated_points_num(), blender::MutableSpan< T >::first(), Spline::is_cyclic_, blender::threading::isolate_task(), lock, blender::Vector< T, InlineBufferCapacity, Allocator >::resize(), and size().

Referenced by interpolate_to_evaluated_impl().

◆ evaluated_points_num()

int BezierSpline::evaluated_points_num ( ) const
finalvirtual

◆ evaluated_positions()

Span< float3 > BezierSpline::evaluated_positions ( ) const
finalvirtual

◆ handle_positions_left() [1/2]

Span< float3 > BezierSpline::handle_positions_left ( ) const

◆ handle_positions_left() [2/2]

MutableSpan< float3 > BezierSpline::handle_positions_left ( bool  write_only = false)

Get writable access to the handle position.

Parameters
write_onlypass true for an uninitialized spline, this prevents accessing uninitialized memory while auto-generating handles.

Definition at line 109 of file spline_bezier.cc.

References ensure_auto_handles().

◆ handle_positions_right() [1/2]

Span< float3 > BezierSpline::handle_positions_right ( ) const

◆ handle_positions_right() [2/2]

MutableSpan< float3 > BezierSpline::handle_positions_right ( bool  write_only = false)

Get writable access to the handle position.

Parameters
write_onlypass true for an uninitialized spline, this prevents accessing uninitialized memory while auto-generating handles.

Definition at line 130 of file spline_bezier.cc.

References ensure_auto_handles().

◆ handle_types_left() [1/2]

MutableSpan< int8_t > BezierSpline::handle_types_left ( )

Definition at line 100 of file spline_bezier.cc.

◆ handle_types_left() [2/2]

Span< int8_t > BezierSpline::handle_types_left ( ) const

◆ handle_types_right() [1/2]

MutableSpan< int8_t > BezierSpline::handle_types_right ( )

Definition at line 121 of file spline_bezier.cc.

◆ handle_types_right() [2/2]

Span< int8_t > BezierSpline::handle_types_right ( ) const

◆ interpolate_to_evaluated()

GVArray BezierSpline::interpolate_to_evaluated ( const blender::GVArray src) const
overridevirtual

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.

Implements Spline.

Definition at line 622 of file spline_bezier.cc.

References BLI_assert, blender::attribute_math::convert_to_static_type(), evaluated_points_num(), and src.

◆ interpolation_data_from_index_factor()

BezierSpline::InterpolationData BezierSpline::interpolation_data_from_index_factor ( float  index_factor) const

Convert the data encoded in #evaulated_mappings into its parts– the information necessary to interpolate data from control points to evaluated points between them. The next control point index result will not overflow the size of the control point vectors.

Definition at line 579 of file spline_bezier.cc.

References blender::math::floor(), Spline::is_cyclic_, and size().

Referenced by interpolate_to_evaluated_impl().

◆ mark_cache_invalid()

void BezierSpline::mark_cache_invalid ( )
finalvirtual

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.

Implements Spline.

Definition at line 327 of file spline_bezier.cc.

References Spline::length_cache_dirty_, Spline::normal_cache_dirty_, and Spline::tangent_cache_dirty_.

Referenced by resize(), blender::bke::VArrayImpl_For_BezierHandles::set(), blender::bke::VArrayImpl_For_BezierHandles::set_all(), set_resolution(), transform(), and translate().

◆ point_is_sharp()

bool BezierSpline::point_is_sharp ( int  index) const

Definition at line 303 of file spline_bezier.cc.

References BEZIER_HANDLE_FREE, BEZIER_HANDLE_VECTOR, and ELEM.

◆ positions() [1/2]

Span< float3 > BezierSpline::positions ( ) const
finalvirtual

Implements Spline.

Definition at line 76 of file spline_bezier.cc.

◆ positions() [2/2]

MutableSpan< float3 > BezierSpline::positions ( )
finalvirtual

◆ radii() [1/2]

Span< float > BezierSpline::radii ( ) const
finalvirtual

Implements Spline.

Definition at line 84 of file spline_bezier.cc.

◆ radii() [2/2]

MutableSpan< float > BezierSpline::radii ( )
finalvirtual

◆ resize()

void BezierSpline::resize ( int  size)
finalvirtual

◆ resolution()

int BezierSpline::resolution ( ) const

Definition at line 47 of file spline_bezier.cc.

Referenced by calculate_mappings_linear_resolution().

◆ reverse_impl()

void BezierSpline::reverse_impl ( )
overrideprotectedvirtual

◆ segment_is_vector()

bool BezierSpline::segment_is_vector ( int  start_index) const

◆ set_handle_position_left()

void BezierSpline::set_handle_position_left ( int  index,
const blender::float3 value 
)

Set positions for the left handle of the control point, ensuring that aligned handles stay aligned. Has no effect for auto and vector type handles.

Definition at line 293 of file spline_bezier.cc.

References set_handle_position().

◆ set_handle_position_right()

void BezierSpline::set_handle_position_right ( int  index,
const blender::float3 value 
)

Set positions for the right handle of the control point, ensuring that aligned handles stay aligned. Has no effect for auto and vector type handles.

Definition at line 283 of file spline_bezier.cc.

References set_handle_position().

◆ set_resolution()

void BezierSpline::set_resolution ( int  value)

Definition at line 52 of file spline_bezier.cc.

References BLI_assert, and mark_cache_invalid().

◆ size()

int BezierSpline::size ( ) const
finalvirtual

◆ tilts() [1/2]

Span< float > BezierSpline::tilts ( ) const
finalvirtual

Implements Spline.

Definition at line 92 of file spline_bezier.cc.

◆ tilts() [2/2]

MutableSpan< float > BezierSpline::tilts ( )
finalvirtual

◆ transform()

void BezierSpline::transform ( const blender::float4x4 matrix)
overridevirtual

Reimplemented from Spline.

Definition at line 245 of file spline_bezier.cc.

References handle_positions_left(), handle_positions_right(), mark_cache_invalid(), and positions().

◆ translate()

void BezierSpline::translate ( const blender::float3 translation)
overridevirtual

Reimplemented from Spline.

Definition at line 231 of file spline_bezier.cc.

References handle_positions_left(), handle_positions_right(), mark_cache_invalid(), and positions().


The documentation for this class was generated from the following files: