|
Blender
V2.93
|
#include <float.h>#include <math.h>#include <stdlib.h>#include <string.h>#include "MEM_guardedalloc.h"#include "DNA_curve_types.h"#include "DNA_curveprofile_types.h"#include "BLI_blenlib.h"#include "BLI_math.h"#include "BLI_task.h"#include "BLI_threads.h"#include "BLI_utildefines.h"#include "BKE_curve.h"#include "BKE_curveprofile.h"#include "BKE_fcurve.h"#include "BLO_read_write.h"Go to the source code of this file.
Classes | |
| struct | CurvatureSortPoint |
|
static |
Helper function for 'BKE_curveprofile_create_samples.' Calculates the angle between the handles on the inside of the edge starting at index i. A larger angle means the edge is more curved.
| i_edge | The start index of the edge to calculate the angle for. |
Definition at line 641 of file curveprofile.c.
References angle_v2v2(), sub_v2_v2v2(), and x.
Referenced by BKE_curveprofile_create_samples().
| 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().
| void BKE_curveprofile_blend_read | ( | struct BlendDataReader * | reader, |
| struct CurveProfile * | profile | ||
| ) |
Definition at line 1123 of file curveprofile.c.
References BKE_curveprofile_init(), BLO_read_data_address, NULL, CurveProfile::path, CurveProfile::path_len, CurveProfilePoint::profile, CurveProfile::segments, CurveProfile::segments_len, and CurveProfile::table.
Referenced by blendRead(), curve_blend_read_data(), and scene_blend_read_data().
| void BKE_curveprofile_blend_write | ( | struct BlendWriter * | writer, |
| const struct CurveProfile * | profile | ||
| ) |
Definition at line 1116 of file curveprofile.c.
References BLO_write_struct, BLO_write_struct_array, CurveProfile::path, and CurveProfile::path_len.
Referenced by blendWrite(), curve_blend_write(), and scene_blend_write().
| CurveProfile* BKE_curveprofile_copy | ( | const CurveProfile * | profile | ) |
Definition at line 75 of file curveprofile.c.
References BKE_curveprofile_copy_data(), MEM_dupallocN, and NULL.
| void BKE_curveprofile_copy_data | ( | CurveProfile * | target, |
| const CurveProfile * | profile | ||
| ) |
Definition at line 61 of file curveprofile.c.
References MEM_dupallocN, CurveProfile::path, CurveProfile::path_len, CurveProfilePoint::profile, CurveProfile::segments, and CurveProfile::table.
Referenced by BKE_curveprofile_copy().
| 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.
| n_segments | The 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_edges | Whether 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_samples | Return 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().
| 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.
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().
| void BKE_curveprofile_evaluate_length_portion | ( | const CurveProfile * | profile, |
| float | length_portion, | ||
| float * | x_out, | ||
| float * | y_out | ||
| ) |
Does a single evaluation along the profile's path. Travels down (length_portion * path) length and returns the position at that point.
| length_portion | The portion (0 to 1) of the path's full length to sample at. |
Definition at line 1072 of file curveprofile.c.
References BKE_curveprofile_total_length(), curveprofile_distance_to_next_table_point(), interpf(), CurveProfile::path, CurveProfile::path_len, PROF_TABLE_LEN, CurveProfile::table, CurveProfilePoint::x, and CurveProfilePoint::y.
| void BKE_curveprofile_free | ( | 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().
| void BKE_curveprofile_free_data | ( | CurveProfile * | profile | ) |
Definition at line 46 of file curveprofile.c.
References MEM_SAFE_FREE, CurveProfile::path, CurveProfile::segments, and CurveProfile::table.
Referenced by BKE_curveprofile_free(), ui_but_clipboard_free(), ui_but_copy_CurveProfile(), and ui_but_paste_CurveProfile().
| 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().
| 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.
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().
| 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.
| handle_1 | Whether to move the 1st or 2nd control point. |
| delta | The relative change in the handle's 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().
| 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.
| snap | Whether to snap the point to the grid |
| delta | The relative change of the point's location. |
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().
| 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.
| flag | CurveProfilePoint.flag. |
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().
| bool BKE_curveprofile_remove_point | ( | CurveProfile * | profile, |
| CurveProfilePoint * | point | ||
| ) |
Removes a specific point from the path of control points.
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().
| void BKE_curveprofile_reset | ( | CurveProfile * | profile | ) |
Resets the profile to the current preset.
Definition at line 451 of file curveprofile.c.
References curveprofile_build_steps(), curveprofile_build_supports(), CurveProfile::flag, HD_AUTO, HD_VECT, MEM_callocN, MEM_SAFE_FREE, NULL, CurveProfile::path, CurveProfile::path_len, point_init(), CurveProfile::preset, PROF_DIRTY_PRESET, PROF_PRESET_CORNICE, PROF_PRESET_CROWN, PROF_PRESET_LINE, PROF_PRESET_STEPS, PROF_PRESET_SUPPORTS, CurveProfilePoint::profile, CurveProfile::segments_len, and CurveProfile::table.
Referenced by BKE_curveprofile_add(), CurveProfile_buttons_reset(), CurveProfile_presets_dofunc(), and CurveProfile_tools_dofunc().
| 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().
| void BKE_curveprofile_reverse | ( | CurveProfile * | profile | ) |
Flips the profile across the diagonal so that its orientation is reversed.
Definition at line 362 of file curveprofile.c.
References BLI_assert, ELEM, CurveProfilePoint::h1, CurveProfilePoint::h1_loc, CurveProfilePoint::h2, CurveProfilePoint::h2_loc, HD_ALIGN, HD_FREE, MEM_freeN, MEM_mallocN, mirror_point(), CurveProfile::path, CurveProfile::path_len, and CurveProfilePoint::profile.
Referenced by CurveProfile_buttons_reverse().
| void BKE_curveprofile_selected_handle_set | ( | CurveProfile * | profile, |
| int | type_1, | ||
| int | type_2 | ||
| ) |
Sets the handle type of the selected control points.
| type_1,type_2 | Handle type for the first handle. HD_VECT, HD_AUTO, HD_FREE, or HD_ALIGN. |
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.
| void BKE_curveprofile_set_defaults | ( | CurveProfile * | profile | ) |
Sets the default settings and clip range for the profile widget. Does not generate either table.
Definition at line 864 of file curveprofile.c.
References BLI_rctf_init(), CurveProfile::changed_timestamp, CurveProfile::clip_rect, CurveProfile::flag, MEM_callocN, CurveProfile::path, CurveProfile::path_len, PROF_USE_CLIP, CurveProfilePoint::profile, CurveProfile::view_rect, CurveProfilePoint::x, and CurveProfilePoint::y.
Referenced by BKE_curveprofile_add().
| float BKE_curveprofile_total_length | ( | const CurveProfile * | profile | ) |
Calculates the total length of the profile from the curves sampled in the table.
Definition at line 995 of file curveprofile.c.
References len_v2v2(), CurveProfile::path_len, PROF_TABLE_LEN, CurveProfile::table, and CurveProfilePoint::x.
Referenced by BKE_curveprofile_create_samples_even_spacing(), and BKE_curveprofile_evaluate_length_portion().
| void BKE_curveprofile_update | ( | CurveProfile * | profile, |
| const int | update_flags | ||
| ) |
Should be called after the widget is changed. Does profile and remove double checks and more importantly, recreates the display / evaluation and segments tables.
| update_flags | Bitfield with fields defined in header file. Controls removing doubles and clipping. |
Definition at line 905 of file curveprofile.c.
References BKE_curveprofile_remove_point(), BLI_assert, BLI_rctf_size_x(), BLI_rctf_size_y(), CurveProfile::changed_timestamp, clamp_f(), CurveProfile::clip_rect, curveprofile_make_segments_table(), curveprofile_make_table(), CurveProfile::flag, len_squared_v2v2(), CurveProfile::path, CurveProfile::path_len, pow2f(), PROF_UPDATE_CLIP, PROF_UPDATE_REMOVE_DOUBLES, PROF_USE_CLIP, CurveProfile::segments_len, CurveProfile::view_rect, x, CurveProfilePoint::x, rctf::xmax, rctf::xmin, y, CurveProfilePoint::y, rctf::ymax, and rctf::ymin.
Referenced by BKE_curveprofile_init(), CurveProfile_buttons_delete(), CurveProfile_buttons_reset(), CurveProfile_buttons_reverse(), CurveProfile_buttons_update(), CurveProfile_clipping_toggle(), CurveProfile_presets_dofunc(), CurveProfile_tools_dofunc(), ui_do_but_CURVEPROFILE(), ui_draw_but_CURVEPROFILE(), and ui_numedit_but_CURVEPROFILE().
|
static |
Definition at line 626 of file curveprofile.c.
References NULL, and point_calculate_handle().
Referenced by BKE_curveprofile_create_samples().
|
static |
Puts the widgets control points in a step pattern. Uses vector handles for each point.
Definition at line 415 of file curveprofile.c.
References float(), HD_VECT, CurveProfile::path, CurveProfile::path_len, point_init(), x, and y.
Referenced by BKE_curveprofile_reset().
|
static |
Builds a quarter circle profile with space on each side for 'support loops.'
Definition at line 396 of file curveprofile.c.
References cosf, HD_AUTO, HD_VECT, M_PI_2, CurveProfile::path, CurveProfile::path_len, point_init(), sinf, x, and y.
Referenced by BKE_curveprofile_reset().
|
static |
Gives the distance to the next point in the widgets sampled table, in other words the length of the 'i' edge of the table.
Definition at line 983 of file curveprofile.c.
References BLI_assert, len_v2v2(), CurveProfile::path_len, PROF_TABLE_LEN, CurveProfile::table, and CurveProfilePoint::x.
Referenced by BKE_curveprofile_create_samples_even_spacing(), and BKE_curveprofile_evaluate_length_portion().
|
static |
Creates the table of points used for displaying a preview of the sampled segment locations on the widget itself.
Definition at line 838 of file curveprofile.c.
References BKE_curveprofile_create_samples(), BKE_curveprofile_create_samples_even_spacing(), CurveProfile::flag, MEM_callocN, MEM_SAFE_FREE, PROF_SAMPLE_EVEN_LENGTHS, PROF_SAMPLE_STRAIGHT_EDGES, CurveProfile::segments, and CurveProfile::segments_len.
Referenced by BKE_curveprofile_update().
|
static |
Creates a higher resolution table by sampling the curved points. This table is used for display and evenly spaced evaluation.
Definition at line 819 of file curveprofile.c.
References BKE_curveprofile_create_samples(), MEM_callocN, MEM_SAFE_FREE, CurveProfile::path_len, PROF_TABLE_LEN, CurveProfile::table, CurveProfilePoint::x, and CurveProfilePoint::y.
Referenced by BKE_curveprofile_add(), and BKE_curveprofile_update().
|
static |
Helper for 'curve_profile_create' samples. Returns whether both handles that make up the edge are vector handles.
Definition at line 546 of file curveprofile.c.
References HD_VECT.
Referenced by BKE_curveprofile_create_samples().
|
static |
Definition at line 350 of file curveprofile.c.
References CurveProfilePoint::flag, CurveProfilePoint::h1, CurveProfilePoint::h2, point_init(), CurveProfilePoint::x, and CurveProfilePoint::y.
Referenced by BKE_curveprofile_reverse().
|
static |
Used to set bezier handle locations in the sample creation process. Reduced copy of calchandleNurb_intern code in curve.c, mostly changed by removing the third dimension.
Definition at line 555 of file curveprofile.c.
References CurveProfilePoint::h1, CurveProfilePoint::h1_loc, CurveProfilePoint::h2, CurveProfilePoint::h2_loc, HD_AUTO, HD_FREE, HD_VECT, len, len_v2(), madd_v2_v2v2fl(), next, NULL, sub_v2_v2v2(), and CurveProfilePoint::x.
Referenced by calculate_path_handles().
|
static |
Shorthand helper function for setting location and interpolation of a point.
Definition at line 259 of file curveprofile.c.
References CurveProfilePoint::flag, CurveProfilePoint::h1, CurveProfilePoint::h2, x, CurveProfilePoint::x, y, and CurveProfilePoint::y.
Referenced by BKE_curveprofile_insert(), BKE_curveprofile_reset(), curveprofile_build_steps(), curveprofile_build_supports(), and mirror_point().
|
static |
Helper function for 'BKE_curveprofile_create_samples' for sorting edges based on curvature.
Definition at line 664 of file curveprofile.c.
References Freestyle::a, and CurvatureSortPoint::point_curvature.
Referenced by BKE_curveprofile_create_samples().