Blender  V2.93
Enumerations | Functions
BKE_curveprofile.h File Reference
#include "DNA_curveprofile_types.h"

Go to the source code of this file.

Enumerations

enum  { PROF_UPDATE_NONE = 0 , PROF_UPDATE_REMOVE_DOUBLES = (1 << 0) , PROF_UPDATE_CLIP = (1 << 1) }
 

Functions

void BKE_curveprofile_set_defaults (struct CurveProfile *profile)
 
struct CurveProfileBKE_curveprofile_add (eCurveProfilePresets preset)
 
void BKE_curveprofile_free_data (struct CurveProfile *profile)
 
void BKE_curveprofile_free (struct CurveProfile *profile)
 
void BKE_curveprofile_copy_data (struct CurveProfile *target, const struct CurveProfile *profile)
 
struct CurveProfileBKE_curveprofile_copy (const struct CurveProfile *profile)
 
bool BKE_curveprofile_move_handle (struct CurveProfilePoint *point, const bool handle_1, const bool snap, const float delta[2])
 
bool BKE_curveprofile_move_point (struct CurveProfile *profile, struct CurveProfilePoint *point, const bool snap, const float delta[2])
 
bool BKE_curveprofile_remove_point (struct CurveProfile *profile, struct CurveProfilePoint *point)
 
void BKE_curveprofile_remove_by_flag (struct CurveProfile *profile, const short flag)
 
struct CurveProfilePointBKE_curveprofile_insert (struct CurveProfile *profile, float x, float y)
 
void BKE_curveprofile_selected_handle_set (struct CurveProfile *profile, int type_1, int type_2)
 
void BKE_curveprofile_reverse (struct CurveProfile *profile)
 
void BKE_curveprofile_reset_view (struct CurveProfile *profile)
 
void BKE_curveprofile_reset (struct CurveProfile *profile)
 
void BKE_curveprofile_create_samples (struct CurveProfile *profile, int n_segments, bool sample_straight_edges, struct CurveProfilePoint *r_samples)
 
void BKE_curveprofile_init (struct CurveProfile *profile, short segments_len)
 
void BKE_curveprofile_update (struct CurveProfile *profile, const int update_flags)
 
float BKE_curveprofile_total_length (const struct CurveProfile *profile)
 
void BKE_curveprofile_create_samples_even_spacing (struct CurveProfile *profile, int n_segments, struct CurveProfilePoint *r_samples)
 
void BKE_curveprofile_evaluate_length_portion (const struct CurveProfile *profile, float length_portion, float *x_out, float *y_out)
 
void BKE_curveprofile_blend_write (struct BlendWriter *writer, const struct CurveProfile *profile)
 
void BKE_curveprofile_blend_read (struct BlendDataReader *reader, struct CurveProfile *profile)
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PROF_UPDATE_NONE 
PROF_UPDATE_REMOVE_DOUBLES 
PROF_UPDATE_CLIP 

Definition at line 81 of file BKE_curveprofile.h.

Function Documentation

◆ BKE_curveprofile_add()

struct CurveProfile* BKE_curveprofile_add ( eCurveProfilePresets  preset)

Returns a pointer to a newly allocated curve profile, using the given preset.

Definition at line 887 of file curveprofile.c.

References BKE_curveprofile_reset(), BKE_curveprofile_set_defaults(), curveprofile_make_table(), MEM_callocN, and CurveProfile::preset.

Referenced by blo_do_versions_280(), blo_update_defaults_scene(), initData(), and scene_init_data().

◆ BKE_curveprofile_blend_read()

void BKE_curveprofile_blend_read ( struct BlendDataReader reader,
struct CurveProfile profile 
)

◆ BKE_curveprofile_blend_write()

void BKE_curveprofile_blend_write ( struct BlendWriter writer,
const struct CurveProfile profile 
)

◆ BKE_curveprofile_copy()

struct CurveProfile* BKE_curveprofile_copy ( const struct CurveProfile profile)

◆ BKE_curveprofile_copy_data()

void BKE_curveprofile_copy_data ( struct CurveProfile target,
const struct CurveProfile profile 
)

◆ BKE_curveprofile_create_samples()

void BKE_curveprofile_create_samples ( CurveProfile profile,
int  n_segments,
bool  sample_straight_edges,
CurveProfilePoint r_samples 
)

Used for sampling curves along the profile's path. Any points more than the number of user-defined points will be evenly distributed among the curved edges. Then the remainders will be distributed to the most curved edges.

Parameters
n_segmentsThe number of segments to sample along the path. Ideally it is higher than the number of points used to define the profile (profile->path_len).
sample_straight_edgesWhether to sample points between vector handle control points. If this is true and there are only vector edges the straight edges will still be sampled.
r_samplesReturn array of points to put the sampled positions. Must have length n_segments. Fill the array with the sampled locations and if the point corresponds to a control point, its handle type.

Definition at line 689 of file curveprofile.c.

References bezt_edge_handle_angle(), BKE_curve_forward_diff_bezier(), BLI_assert, calculate_path_handles(), CurveProfilePoint::flag, CurveProfilePoint::h1, CurveProfilePoint::h2, HD_AUTO, INT16_MAX, is_curved_edge(), MEM_callocN, MEM_freeN, CurveProfile::path, CurveProfile::path_len, CurvatureSortPoint::point_curvature, CurvatureSortPoint::point_index, sort_points_curvature(), x, and y.

Referenced by curveprofile_make_segments_table(), and curveprofile_make_table().

◆ BKE_curveprofile_create_samples_even_spacing()

void BKE_curveprofile_create_samples_even_spacing ( CurveProfile profile,
int  n_segments,
CurveProfilePoint r_samples 
)

Samples evenly spaced positions along the curve profile's table (generated from path). Fills an entire table at once for a speedup if all of the results are going to be used anyway.

Note
Requires BKE_curveprofile_init or BKE_curveprofile_update call before to fill table.
Working, but would conflict with "Sample Straight Edges" option, so this is unused for now.

Definition at line 1012 of file curveprofile.c.

References BKE_curveprofile_total_length(), BLI_assert, curveprofile_distance_to_next_table_point(), interpf(), CurveProfile::table, CurveProfilePoint::x, and CurveProfilePoint::y.

Referenced by curveprofile_make_segments_table().

◆ BKE_curveprofile_evaluate_length_portion()

void BKE_curveprofile_evaluate_length_portion ( const struct CurveProfile profile,
float  length_portion,
float x_out,
float y_out 
)

◆ BKE_curveprofile_free()

void BKE_curveprofile_free ( struct CurveProfile profile)

Definition at line 53 of file curveprofile.c.

References BKE_curveprofile_free_data(), and MEM_freeN.

Referenced by BKE_toolsettings_free(), curve_free_data(), and freeData().

◆ BKE_curveprofile_free_data()

void BKE_curveprofile_free_data ( struct CurveProfile profile)

◆ BKE_curveprofile_init()

void BKE_curveprofile_init ( CurveProfile profile,
short  segments_len 
)

Refreshes the higher resolution table sampled from the input points. A call to this or BKE_curveprofile_update is needed before evaluation functions that use the table. Also sets the number of segments used for the display preview of the locations of the sampled points.

Definition at line 966 of file curveprofile.c.

References BKE_curveprofile_update(), CurveProfile::flag, PROF_DIRTY_PRESET, PROF_UPDATE_NONE, and CurveProfile::segments_len.

Referenced by BKE_curveprofile_blend_read(), and set_profile_spacing().

◆ BKE_curveprofile_insert()

struct CurveProfilePoint* BKE_curveprofile_insert ( CurveProfile profile,
float  x,
float  y 
)

Adds a new point at the specified location. The choice for which points to place the new vertex between is made by checking which control point line segment is closest to the new point and placing the new vertex in between that segment's points.

Note
Requires BKE_curveprofile_update call after.

Definition at line 275 of file curveprofile.c.

References dist_squared_to_line_segment_v2(), distance(), CurveProfilePoint::flag, CurveProfilePoint::h1, CurveProfilePoint::h2, HD_AUTO, HD_VECT, MEM_freeN, MEM_mallocN, NULL, CurveProfile::path, CurveProfile::path_len, point_init(), PROF_SELECT, PROF_TABLE_MAX, CurveProfilePoint::profile, x, CurveProfilePoint::x, y, and CurveProfilePoint::y.

Referenced by ui_do_but_CURVEPROFILE().

◆ BKE_curveprofile_move_handle()

bool BKE_curveprofile_move_handle ( struct CurveProfilePoint point,
const bool  handle_1,
const bool  snap,
const float  delta[2] 
)

Move a point's handle, accounting for the alignment of handles with the HD_ALIGN type.

Parameters
handle_1Whether to move the 1st or 2nd control point.
deltaThe relative change in the handle's position.
Note
Requires BKE_curveprofile_update call after.
Returns
Whether the handle moved from its start position.

Definition at line 93 of file curveprofile.c.

References copy_v2_v2(), ELEM, equals_v2v2(), CurveProfilePoint::h1, CurveProfilePoint::h1_loc, CurveProfilePoint::h2, CurveProfilePoint::h2_loc, HD_ALIGN, HD_FREE, if(), snap(), CurveProfilePoint::x, and CurveProfilePoint::y.

Referenced by BKE_curveprofile_selected_handle_set(), and ui_numedit_but_CURVEPROFILE().

◆ BKE_curveprofile_move_point()

bool BKE_curveprofile_move_point ( struct CurveProfile profile,
struct CurveProfilePoint point,
const bool  snap,
const float  delta[2] 
)

Moves a control point, accounting for clipping and snapping, and moving free handles.

Parameters
snapWhether to snap the point to the grid
deltaThe relative change of the point's location.
Returns
Whether the point moved from its start position.
Note
Requires BKE_curveprofile_update call after.

Definition at line 141 of file curveprofile.c.

References CurveProfile::clip_rect, ELEM, CurveProfile::flag, CurveProfilePoint::h1, CurveProfilePoint::h1_loc, CurveProfilePoint::h2, CurveProfilePoint::h2_loc, HD_ALIGN, HD_FREE, max_ff(), min_ff(), CurveProfile::path, CurveProfile::path_len, PROF_USE_CLIP, snap(), CurveProfilePoint::x, rctf::xmax, rctf::xmin, CurveProfilePoint::y, rctf::ymax, and rctf::ymin.

Referenced by ui_numedit_but_CURVEPROFILE().

◆ BKE_curveprofile_remove_by_flag()

void BKE_curveprofile_remove_by_flag ( CurveProfile profile,
const short  flag 
)

Removes every point in the widget with the supplied flag set, except for the first and last.

Parameters
flagCurveProfilePoint.flag.
Note
Requires BKE_curveprofile_update call after.

Definition at line 229 of file curveprofile.c.

References CurveProfilePoint::flag, MEM_freeN, MEM_mallocN, CurveProfile::path, and CurveProfile::path_len.

Referenced by CurveProfile_buttons_delete(), and ui_do_but_CURVEPROFILE().

◆ BKE_curveprofile_remove_point()

bool BKE_curveprofile_remove_point ( CurveProfile profile,
CurveProfilePoint point 
)

Removes a specific point from the path of control points.

Note
Requires BKE_curveprofile_update call after.

Definition at line 192 of file curveprofile.c.

References BLI_assert, MEM_freeN, MEM_mallocN, CurveProfile::path, and CurveProfile::path_len.

Referenced by BKE_curveprofile_update().

◆ BKE_curveprofile_reset()

void BKE_curveprofile_reset ( CurveProfile profile)

◆ BKE_curveprofile_reset_view()

void BKE_curveprofile_reset_view ( CurveProfile profile)

Reset the view to the clipping rectangle.

Definition at line 441 of file curveprofile.c.

References CurveProfile::clip_rect, and CurveProfile::view_rect.

Referenced by CurveProfile_tools_dofunc().

◆ BKE_curveprofile_reverse()

void BKE_curveprofile_reverse ( CurveProfile profile)

◆ BKE_curveprofile_selected_handle_set()

void BKE_curveprofile_selected_handle_set ( CurveProfile profile,
int  type_1,
int  type_2 
)

Sets the handle type of the selected control points.

Parameters
type_1,type_2Handle type for the first handle. HD_VECT, HD_AUTO, HD_FREE, or HD_ALIGN.
Note
Requires BKE_curveprofile_update call after.

Definition at line 335 of file curveprofile.c.

References BKE_curveprofile_move_handle(), ELEM, CurveProfilePoint::flag, CurveProfilePoint::h1, CurveProfilePoint::h2, HD_ALIGN, NULL, CurveProfile::path, CurveProfile::path_len, PROF_H1_SELECT, PROF_H2_SELECT, and PROF_SELECT.

◆ BKE_curveprofile_set_defaults()

void BKE_curveprofile_set_defaults ( CurveProfile profile)

◆ BKE_curveprofile_total_length()

float BKE_curveprofile_total_length ( const struct CurveProfile profile)

◆ BKE_curveprofile_update()

void BKE_curveprofile_update ( CurveProfile profile,
const int  update_flags 
)