Blender  V3.3
Classes | Functions
blender::bke::curves::bezier Namespace Reference

Classes

struct  Insertion
 

Functions

bool segment_is_vector (const HandleType left, const HandleType right)
 
bool segment_is_vector (const int8_t left, const int8_t right)
 
bool segment_is_vector (Span< int8_t > handle_types_left, Span< int8_t > handle_types_right, int segment_index)
 
bool last_cyclic_segment_is_vector (Span< int8_t > handle_types_left, Span< int8_t > handle_types_right)
 
bool point_is_sharp (Span< int8_t > handle_types_left, Span< int8_t > handle_types_right, int index)
 
void calculate_evaluated_offsets (Span< int8_t > handle_types_left, Span< int8_t > handle_types_right, bool cyclic, int resolution, MutableSpan< int > evaluated_offsets)
 
Insertion insert (const float3 &point_prev, const float3 &handle_prev, const float3 &handle_next, const float3 &point_next, float parameter)
 
float3 calculate_vector_handle (const float3 &point, const float3 &next_point)
 
void calculate_auto_handles (bool cyclic, Span< int8_t > types_left, Span< int8_t > types_right, Span< float3 > positions, MutableSpan< float3 > positions_left, MutableSpan< float3 > positions_right)
 
void set_handle_position (const float3 &position, HandleType type, HandleType type_other, const float3 &new_handle, float3 &handle, float3 &handle_other)
 
void evaluate_segment (const float3 &point_0, const float3 &point_1, const float3 &point_2, const float3 &point_3, MutableSpan< float3 > result)
 
void calculate_evaluated_positions (Span< float3 > positions, Span< float3 > handles_left, Span< float3 > handles_right, Span< int > evaluated_offsets, MutableSpan< float3 > evaluated_positions)
 
void interpolate_to_evaluated (GSpan src, Span< int > evaluated_offsets, GMutableSpan dst)
 
static float3 calculate_aligned_handle (const float3 &position, const float3 &other_handle, const float3 &aligned_handle)
 
static void calculate_point_handles (const HandleType type_left, const HandleType type_right, const float3 position, const float3 prev_position, const float3 next_position, float3 &left, float3 &right)
 
template<typename T >
static void linear_interpolation (const T &a, const T &b, MutableSpan< T > dst)
 
template<typename T >
static void interpolate_to_evaluated (const Span< T > src, const Span< int > evaluated_offsets, MutableSpan< T > dst)
 

Function Documentation

◆ calculate_aligned_handle()

static float3 blender::bke::curves::bezier::calculate_aligned_handle ( const float3 position,
const float3 other_handle,
const float3 aligned_handle 
)
static

◆ calculate_auto_handles()

void blender::bke::curves::bezier::calculate_auto_handles ( bool  cyclic,
Span< int8_t types_left,
Span< int8_t types_right,
Span< float3 positions,
MutableSpan< float3 positions_left,
MutableSpan< float3 positions_right 
)

Recalculate all auto (BEZIER_HANDLE_AUTO) and vector (BEZIER_HANDLE_VECTOR) handles with positions automatically derived from the neighboring control points, and update aligned (BEZIER_HANDLE_ALIGN) handles to line up with neighboring non-aligned handles. The choices made here are relatively arbitrary, but having standardized behavior is essential.

Definition at line 165 of file curve_bezier.cc.

References calculate_point_handles(), blender::Span< T >::first(), blender::MutableSpan< T >::first(), blender::Span< T >::last(), blender::MutableSpan< T >::last(), blender::threading::parallel_for(), and positions.

Referenced by blender::bke::CurvesGeometry::calculate_bezier_auto_handles().

◆ calculate_evaluated_offsets()

void blender::bke::curves::bezier::calculate_evaluated_offsets ( Span< int8_t handle_types_left,
Span< int8_t handle_types_right,
bool  cyclic,
int  resolution,
MutableSpan< int >  evaluated_offsets 
)

Calculate offsets into the curve's evaluated points for each control point. While most control point edges generate the number of edges specified by the resolution, vector segments only generate one edge.

The size of the offsets array must be the same as the number of points. The value at each index is the evaluated point offset including the following segment.

Definition at line 29 of file curve_bezier.cc.

References BLI_assert, blender::MutableSpan< T >::first(), blender::MutableSpan< T >::last(), last_cyclic_segment_is_vector(), offset, segment_is_vector(), blender::Span< T >::size(), blender::MutableSpan< T >::size(), and size().

◆ calculate_evaluated_positions()

void blender::bke::curves::bezier::calculate_evaluated_positions ( Span< float3 positions,
Span< float3 handles_left,
Span< float3 handles_right,
Span< int >  evaluated_offsets,
MutableSpan< float3 evaluated_positions 
)

Calculate all evaluated points for the Bezier curve.

Parameters
evaluated_offsetsThe index in the evaluated points array for each control point, including the points from the corresponding segment. Used to vary the number of evaluated points per segment, i.e. to make vector segment only have one edge. This is expected to be calculated by calculate_evaluated_offsets, and is the reason why this function doesn't need arguments like "cyclic" and "resolution".

Definition at line 233 of file curve_bezier.cc.

References BLI_assert, evaluate_segment(), blender::Span< T >::first(), blender::MutableSpan< T >::first(), blender::Span< T >::last(), blender::threading::parallel_for(), positions, blender::Span< T >::size(), blender::MutableSpan< T >::size(), and blender::MutableSpan< T >::take_front().

Referenced by blender::bke::CurvesGeometry::evaluated_positions().

◆ calculate_point_handles()

static void blender::bke::curves::bezier::calculate_point_handles ( const HandleType  type_left,
const HandleType  type_right,
const float3  position,
const float3  prev_position,
const float3  next_position,
float3 left,
float3 right 
)
static

◆ calculate_vector_handle()

float3 blender::bke::curves::bezier::calculate_vector_handle ( const float3 point,
const float3 next_point 
)
inline

Calculate the automatically defined positions for a vector handle (BEZIER_HANDLE_VECTOR). While this can be calculated automatically with calculate_auto_handles, when more context is available, it can be preferable for performance reasons to calculate it for a single segment when necessary.

Definition at line 922 of file BKE_curves.hh.

References blender::math::interpolate(), and point.

Referenced by calculate_point_handles().

◆ evaluate_segment()

void blender::bke::curves::bezier::evaluate_segment ( const float3 point_0,
const float3 point_1,
const float3 point_2,
const float3 point_3,
MutableSpan< float3 result 
)

Evaluate a cubic Bezier segment, using the "forward differencing" method. A generic Bezier curve is made up by four points, but in many cases the first and last points are referred to as the control points, and the middle points are the corresponding handles.

Definition at line 206 of file curve_bezier.cc.

References BLI_assert, q1, and result.

Referenced by calculate_evaluated_positions().

◆ insert()

Insertion blender::bke::curves::bezier::insert ( const float3 point_prev,
const float3 handle_prev,
const float3 handle_next,
const float3 point_next,
float  parameter 
)

Compute the Bezier segment insertion for the given parameter on the segment, returning the position and handles of the new point and the updated existing handle positions.

          handle_prev         handle_next
               x-----------------x
              /                   \
             /      x---O---x      \
            /        result         \
           /                         \
          O                           O
      point_prev                   point_next

Definition at line 61 of file curve_bezier.cc.

References BLI_assert, blender::math::interpolate(), and result.

Referenced by AUD_addSet(), bvhtree_from_editmesh_looptri_create_tree(), ED_gpencil_select_stroke_segment(), blender::gpu::GPUSource::material_functions_parse(), blender::ed::space_node::node_link_insert_offset_ntree(), and blender::geometry::subdivide_bezier_segment().

◆ interpolate_to_evaluated() [1/2]

template<typename T >
static void blender::bke::curves::bezier::interpolate_to_evaluated ( const Span< T src,
const Span< int >  evaluated_offsets,
MutableSpan< T dst 
)
static

◆ interpolate_to_evaluated() [2/2]

void blender::bke::curves::bezier::interpolate_to_evaluated ( GSpan  src,
Span< int >  evaluated_offsets,
GMutableSpan  dst 
)

Evaluate generic data to the evaluated points, with counts for each segment described by #evaluated_offsets. Unlike other curve types, for Bezier curves generic data and positions are treated separately, since attribute values aren't stored for the handle control points.

Definition at line 325 of file curve_bezier.cc.

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

Referenced by blender::bke::CurvesGeometry::evaluated_normals(), blender::bke::CurvesGeometry::evaluated_positions(), and blender::bke::CurvesGeometry::interpolate_to_evaluated().

◆ last_cyclic_segment_is_vector()

bool blender::bke::curves::bezier::last_cyclic_segment_is_vector ( Span< int8_t handle_types_left,
Span< int8_t handle_types_right 
)

Return true if the curve's last cyclic segment has a vector type. This only makes a difference in the shape of cyclic curves.

Definition at line 23 of file curve_bezier.cc.

References blender::Span< T >::first(), blender::Span< T >::last(), and segment_is_vector().

Referenced by calculate_evaluated_offsets().

◆ linear_interpolation()

template<typename T >
static void blender::bke::curves::bezier::linear_interpolation ( const T a,
const T b,
MutableSpan< T dst 
)
inlinestatic

◆ point_is_sharp()

bool blender::bke::curves::bezier::point_is_sharp ( Span< int8_t handle_types_left,
Span< int8_t handle_types_right,
int  index 
)
inline

Return true if the handle types at the index are free (BEZIER_HANDLE_FREE) or vector (BEZIER_HANDLE_VECTOR). In these cases, directional continuities from the previous and next evaluated segments is assumed not to be desired.

Definition at line 904 of file BKE_curves.hh.

References BEZIER_HANDLE_FREE, BEZIER_HANDLE_VECTOR, and ELEM.

Referenced by blender::bke::mark_bezier_vector_edges_sharp().

◆ segment_is_vector() [1/3]

bool blender::bke::curves::bezier::segment_is_vector ( const HandleType  left,
const HandleType  right 
)
inline

Return true if the handles that make up a segment both have a vector type. Vector segments for Bezier curves have special behavior because they aren't divided into many evaluated points.

Definition at line 912 of file BKE_curves.hh.

References BEZIER_HANDLE_VECTOR, left, and right.

Referenced by calculate_evaluated_offsets(), last_cyclic_segment_is_vector(), segment_is_vector(), and blender::geometry::subdivide_bezier_segment().

◆ segment_is_vector() [2/3]

bool blender::bke::curves::bezier::segment_is_vector ( const int8_t  left,
const int8_t  right 
)
inline

Definition at line 917 of file BKE_curves.hh.

References left, right, and segment_is_vector().

◆ segment_is_vector() [3/3]

bool blender::bke::curves::bezier::segment_is_vector ( Span< int8_t handle_types_left,
Span< int8_t handle_types_right,
int  segment_index 
)

◆ set_handle_position()

void blender::bke::curves::bezier::set_handle_position ( const float3 position,
HandleType  type,
HandleType  type_other,
const float3 new_handle,
float3 handle,
float3 handle_other 
)

Change the handles of a single control point, aligning any aligned (BEZIER_HANDLE_ALIGN) handles on the other side of the control point.

Note
This ignores the inputs if the handle types are automatically calculated, so the types should be updated before-hand to be editable.

Definition at line 147 of file curve_bezier.cc.

References BEZIER_HANDLE_ALIGN, BEZIER_HANDLE_AUTO, BEZIER_HANDLE_VECTOR, calculate_aligned_handle(), ELEM, and type.