|
Blender
V2.93
|
#include <math.h>#include <stddef.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "CLG_log.h"#include "MEM_guardedalloc.h"#include "BLI_blenlib.h"#include "BLI_math_vector.h"#include "BLT_translation.h"#include "DNA_collection_types.h"#include "DNA_gpencil_types.h"#include "DNA_material_types.h"#include "DNA_meshdata_types.h"#include "DNA_scene_types.h"#include "BKE_collection.h"#include "BKE_context.h"#include "BKE_curve.h"#include "BKE_gpencil.h"#include "BKE_gpencil_curve.h"#include "BKE_gpencil_geom.h"#include "BKE_main.h"#include "BKE_material.h"#include "BKE_object.h"#include "curve_fit_nd.h"#include "DEG_depsgraph_query.h"Go to the source code of this file.
Macros | |
| #define | COORD_FITTING_INFLUENCE 20.0f |
| #define | POINT_DIM 9 |
Functions | |
Convert to curve object | |
| static int | gpencil_check_same_material_color (Object *ob_gp, const float color_stroke[4], const float color_fill[4], const bool do_fill, const bool do_stroke, Material **r_mat) |
| static Material * | gpencil_add_from_curve_material (Main *bmain, Object *ob_gp, const float stroke_color[4], const float fill_color[4], const bool stroke, const bool fill, int *r_idx) |
| static void | gpencil_add_new_points (bGPDstroke *gps, const float *coord_array, const float pressure_start, const float pressure_end, const int init, const int totpoints, const float init_co[3], const bool last) |
| static Collection * | gpencil_get_parent_collection (Scene *scene, Object *ob) |
| static int | gpencil_get_stroke_material_fromcurve (Main *bmain, Object *ob_gp, Object *ob_cu, bool *do_stroke, bool *do_fill) |
| static void | gpencil_convert_spline (Main *bmain, Object *ob_gp, Object *ob_cu, const float scale_thickness, const float sample, bGPDframe *gpf, Nurb *nu) |
| static void | gpencil_editstroke_deselect_all (bGPDcurve *gpc) |
| void | BKE_gpencil_convert_curve (Main *bmain, Scene *scene, Object *ob_gp, Object *ob_cu, const bool use_collections, const float scale_thickness, const float sample) |
Edit-Curve Kernel Functions | |
| static bGPDcurve * | gpencil_stroke_editcurve_generate_edgecases (bGPDstroke *gps, const float stroke_radius) |
| bGPDcurve * | BKE_gpencil_stroke_editcurve_generate (bGPDstroke *gps, const float error_threshold, const float corner_angle, const float stroke_radius) |
| void | BKE_gpencil_stroke_editcurve_update (bGPdata *gpd, bGPDlayer *gpl, bGPDstroke *gps) |
| void | BKE_gpencil_editcurve_stroke_sync_selection (bGPdata *UNUSED(gpd), bGPDstroke *gps, bGPDcurve *gpc) |
| void | BKE_gpencil_stroke_editcurve_sync_selection (bGPdata *gpd, bGPDstroke *gps, bGPDcurve *gpc) |
| static void | gpencil_interpolate_fl_from_to (float from, float to, float *point_offset, int it, int stride) |
| static void | gpencil_interpolate_v4_from_to (float from[4], float to[4], float *point_offset, int it, int stride) |
| static float | gpencil_approximate_curve_segment_arclength (bGPDcurve_point *cpt_start, bGPDcurve_point *cpt_end) |
| static void | gpencil_calculate_stroke_points_curve_segment (bGPDcurve_point *cpt, bGPDcurve_point *cpt_next, float *points_offset, int resolu, int stride) |
| static float * | gpencil_stroke_points_from_editcurve_adaptive_resolu (bGPDcurve_point *curve_point_array, int curve_point_array_len, int resolution, bool is_cyclic, int *r_points_len) |
| static float * | gpencil_stroke_points_from_editcurve_fixed_resolu (bGPDcurve_point *curve_point_array, int curve_point_array_len, int resolution, bool is_cyclic, int *r_points_len) |
| void | BKE_gpencil_stroke_update_geometry_from_editcurve (bGPDstroke *gps, const uint resolution, const bool adaptive) |
| void | BKE_gpencil_editcurve_recalculate_handles (bGPDstroke *gps) |
| static int | gpencil_editcurve_subdivide_count (bGPDcurve *gpc, bool is_cyclic) |
| static void | gpencil_editcurve_subdivide_curve_segment (bGPDcurve_point *cpt_start, bGPDcurve_point *cpt_end, bGPDcurve_point *cpt_new) |
| void | BKE_gpencil_editcurve_subdivide (bGPDstroke *gps, const int cuts) |
| void | BKE_gpencil_strokes_selected_update_editcurve (bGPdata *gpd) |
| void | BKE_gpencil_strokes_selected_sync_selection_editcurve (bGPdata *gpd) |
| #define COORD_FITTING_INFLUENCE 20.0f |
Definition at line 59 of file gpencil_curve.c.
| #define POINT_DIM 9 |
| void BKE_gpencil_convert_curve | ( | Main * | bmain, |
| Scene * | scene, | ||
| Object * | ob_gp, | ||
| Object * | ob_cu, | ||
| const bool | use_collections, | ||
| const float | scale_thickness, | ||
| const float | sample | ||
| ) |
Convert a curve object to grease pencil stroke.
| bmain | Main thread pointer |
| scene | Original scene. |
| ob_gp | Grease pencil object to add strokes. |
| ob_cu | Curve to convert. |
| use_collections | Create layers using collection names. |
| scale_thickness | Scale thickness factor. |
| sample | Sample distance, zero to disable. |
Definition at line 491 of file gpencil_curve.c.
References Object::actcol, BKE_gpencil_layer_active_get(), BKE_gpencil_layer_addnew(), BKE_gpencil_layer_frame_get(), BKE_gpencil_layer_named_get(), BKE_gpencil_merge_materials(), BKE_object_material_slot_remove(), BKE_object_material_slot_used(), CFRA, Object::data, DATA_, DEG_id_tag_update(), ELEM, ListBase::first, GP_GETFRAME_ADD_COPY, gpencil_convert_spline(), gpencil_get_parent_collection(), Collection::id, Object::id, ID_RECALC_COPY_ON_WRITE, ID_RECALC_GEOMETRY, LISTBASE_FOREACH, ID::name, NULL, Curve::nurb, OB_GPENCIL, blender::compositor::sample(), scene, Object::totcol, and Object::type.
Referenced by object_convert_exec().
| void BKE_gpencil_editcurve_recalculate_handles | ( | bGPDstroke * | gps | ) |
Recalculate the handles of the edit curve of a grease pencil stroke
Definition at line 1148 of file gpencil_curve.c.
References bGPDcurve_point::bezt, BKE_nurb_handle_calc(), bGPDcurve::curve_points, bGPDstroke::editcurve, bGPDcurve_point::flag, bGPDstroke::flag, GP_CURVE_POINT_SELECT, GP_STROKE_CYCLIC, GP_STROKE_NEEDS_CURVE_UPDATE, NULL, and bGPDcurve::tot_curve_points.
Referenced by BKE_gpencil_curve_delete_tagged_points(), createTransGPencil_curves(), gpencil_dissolve_selected_curve_points(), gpencil_editcurve_set_handle_type_exec(), gpencil_snap_to_grid(), gpencil_stroke_cyclical_set_exec(), gpencil_stroke_subdivide_exec(), and recalcData_gpencil_strokes().
| void BKE_gpencil_editcurve_stroke_sync_selection | ( | bGPdata * | UNUSEDgpd, |
| bGPDstroke * | gps, | ||
| bGPDcurve * | gpc | ||
| ) |
Sync the selection from stroke to editcurve
Definition at line 784 of file gpencil_curve.c.
References bGPDcurve_point::bezt, BEZT_DESEL_ALL, BEZT_SEL_ALL, bGPDcurve::curve_points, bGPDspoint::flag, bGPDcurve_point::flag, bGPDcurve::flag, bGPDstroke::flag, GP_CURVE_POINT_SELECT, GP_CURVE_SELECT, GP_SPOINT_SELECT, GP_STROKE_SELECT, gpencil_editstroke_deselect_all(), bGPDcurve_point::point_index, bGPDstroke::points, and bGPDcurve::tot_curve_points.
Referenced by BKE_gpencil_strokes_selected_update_editcurve().
| void BKE_gpencil_editcurve_subdivide | ( | bGPDstroke * | gps, |
| const int | cuts | ||
| ) |
Definition at line 1274 of file gpencil_curve.c.
References bGPDcurve_point::bezt, BEZT_SEL_ALL, bGPDcurve::curve_points, bGPDstroke::editcurve, bGPDcurve_point::flag, bGPDstroke::flag, GP_CURVE_POINT_SELECT, GP_STROKE_CYCLIC, gpencil_editcurve_subdivide_count(), gpencil_editcurve_subdivide_curve_segment(), BezTriple::h1, BezTriple::h2, HD_ALIGN, MEM_callocN, MEM_freeN, NULL, and bGPDcurve::tot_curve_points.
Referenced by gpencil_stroke_subdivide_exec().
| bGPDcurve* BKE_gpencil_stroke_editcurve_generate | ( | bGPDstroke * | gps, |
| const float | error_threshold, | ||
| const float | corner_angle, | ||
| const float | stroke_radius | ||
| ) |
Creates a bGPDcurve by doing a cubic curve fitting on the grease pencil stroke points.
Definition at line 645 of file gpencil_curve.c.
References bGPDcurve_point::bezt, BKE_gpencil_stroke_editcurve_new(), bGPDstroke::boundbox_max, bGPDstroke::boundbox_min, COORD_FITTING_INFLUENCE, bGPDcurve::curve_points, bGPDstroke::flag, free(), GP_STROKE_CYCLIC, gpencil_stroke_editcurve_generate_edgecases(), BezTriple::h1, BezTriple::h2, HD_ALIGN, HD_FREE, len_v3v3(), madd_v3_v3v3fl(), MEM_callocN, MEM_freeN, mul_v3_v3fl(), mul_v4_v4fl(), NULL, POINT_DIM, bGPDcurve_point::point_index, bGPDstroke::points, bGPDspoint::pressure, bGPDcurve_point::pressure, r, bGPDspoint::strength, bGPDcurve_point::strength, sub_v3_v3v3(), bGPDstroke::totpoints, BezTriple::vec, bGPDspoint::vert_color, bGPDcurve_point::vert_color, and bGPDspoint::x.
Referenced by BKE_gpencil_stroke_editcurve_update().
| void BKE_gpencil_stroke_editcurve_sync_selection | ( | bGPdata * | gpd, |
| bGPDstroke * | gps, | ||
| bGPDcurve * | gpc | ||
| ) |
Sync the selection from editcurve to stroke
Definition at line 813 of file gpencil_curve.c.
References BKE_gpencil_stroke_select_index_reset(), BKE_gpencil_stroke_select_index_set(), bGPDcurve::curve_points, bGPDspoint::flag, bGPDcurve_point::flag, bGPDcurve::flag, bGPDstroke::flag, GP_CURVE_POINT_SELECT, GP_CURVE_SELECT, GP_SPOINT_SELECT, GP_STROKE_CYCLIC, GP_STROKE_SELECT, bGPDcurve_point::point_index, bGPDstroke::points, bGPDcurve::tot_curve_points, and bGPDstroke::totpoints.
Referenced by BKE_gpencil_strokes_selected_sync_selection_editcurve().
| void BKE_gpencil_stroke_editcurve_update | ( | bGPdata * | gpd, |
| bGPDlayer * | gpl, | ||
| bGPDstroke * | gps | ||
| ) |
Updates the editcurve for a stroke. Frees the old curve if one exists and generates a new one.
Definition at line 759 of file gpencil_curve.c.
References BKE_gpencil_free_stroke_editcurve(), BKE_gpencil_stroke_editcurve_generate(), bGPdata::curve_edit_corner_angle, bGPdata::curve_edit_threshold, bGPDstroke::editcurve, bGPDlayer::line_change, NULL, bGPdata::pixfactor, bGPDstroke::thickness, and bGPDstroke::totpoints.
Referenced by BKE_gpencil_strokes_selected_update_editcurve(), ED_gpencil_select_curve_toggle_all(), gpencil_editmode_toggle_exec(), gpencil_generic_stroke_select(), gpencil_select_exec(), gpencil_stroke_do_circle_sel(), gpencil_stroke_enter_editcurve_mode_exec(), and gpencil_strokes_reproject_exec().
| void BKE_gpencil_stroke_update_geometry_from_editcurve | ( | bGPDstroke * | gps, |
| const uint | resolution, | ||
| const bool | adaptive | ||
| ) |
Recalculate stroke points with the editcurve of the stroke.
Definition at line 1061 of file gpencil_curve.c.
References bGPDcurve_point::bezt, BKE_gpencil_stroke_select_index_reset(), copy_v3_v3(), copy_v4_v4(), bGPDcurve::curve_points, bGPDstroke::dvert, bGPDstroke::editcurve, bGPDspoint::flag, bGPDstroke::flag, float(), GP_SPOINT_SELECT, GP_STROKE_CYCLIC, GP_STROKE_SELECT, gpencil_stroke_points_from_editcurve_adaptive_resolu(), gpencil_stroke_points_from_editcurve_fixed_resolu(), MEM_freeN, MEM_recallocN, NULL, bGPDstroke::points, bGPDspoint::pressure, bGPDcurve_point::pressure, bGPDspoint::strength, bGPDcurve_point::strength, bGPDcurve::tot_curve_points, bGPDstroke::totpoints, BezTriple::vec, bGPDspoint::vert_color, bGPDcurve_point::vert_color, and bGPDspoint::x.
Referenced by BKE_gpencil_stroke_geometry_update().
| void BKE_gpencil_strokes_selected_sync_selection_editcurve | ( | bGPdata * | gpd | ) |
Definition at line 1394 of file gpencil_curve.c.
References BKE_gpencil_layer_is_editable(), BKE_gpencil_stroke_editcurve_sync_selection(), GP_FRAME_SELECT, GPENCIL_MULTIEDIT_SESSIONS_ON, bGPdata::layers, LISTBASE_FOREACH, bGPDframe::next, and NULL.
| void BKE_gpencil_strokes_selected_update_editcurve | ( | bGPdata * | gpd | ) |
Definition at line 1355 of file gpencil_curve.c.
References BKE_gpencil_editcurve_stroke_sync_selection(), BKE_gpencil_layer_is_editable(), BKE_gpencil_stroke_editcurve_update(), BKE_gpencil_stroke_geometry_update(), GP_CURVE_NEEDS_STROKE_UPDATE, GP_FRAME_SELECT, GP_STROKE_NEEDS_CURVE_UPDATE, GP_STROKE_SELECT, GPENCIL_MULTIEDIT_SESSIONS_ON, bGPdata::layers, LISTBASE_FOREACH, bGPDframe::next, and NULL.
|
static |
Definition at line 151 of file gpencil_curve.c.
References BKE_gpencil_object_material_new(), copy_v4_v4(), MaterialGPencilStyle::fill_rgba, MaterialGPencilStyle::flag, GP_MATERIAL_FILL_SHOW, GP_MATERIAL_STROKE_SHOW, Material::gp_style, and MaterialGPencilStyle::stroke_rgba.
|
static |
Definition at line 184 of file gpencil_curve.c.
References BLI_assert, copy_v3_v3(), float(), init, interp_v3_v3v3(), interpf(), len_v3v3(), bGPDstroke::points, bGPDspoint::pressure, bGPDspoint::strength, and bGPDspoint::x.
Referenced by gpencil_convert_spline().
|
static |
Definition at line 905 of file gpencil_curve.c.
References bGPDcurve_point::bezt, len_v3v3(), and BezTriple::vec.
Referenced by gpencil_stroke_points_from_editcurve_adaptive_resolu().
|
static |
Definition at line 919 of file gpencil_curve.c.
References bGPDcurve_point::bezt, BKE_curve_forward_diff_bezier(), gpencil_interpolate_fl_from_to(), gpencil_interpolate_v4_from_to(), POINTER_OFFSET, bGPDcurve_point::pressure, bGPDcurve_point::strength, stride, BezTriple::vec, and bGPDcurve_point::vert_color.
Referenced by gpencil_stroke_points_from_editcurve_adaptive_resolu(), and gpencil_stroke_points_from_editcurve_fixed_resolu().
|
static |
Definition at line 66 of file gpencil_curve.c.
References BKE_object_material_get(), compare_v4v4(), copy_v4_v4(), MaterialGPencilStyle::fill_rgba, MaterialGPencilStyle::fill_style, GP_MATERIAL_FILL_STYLE_SOLID, GP_MATERIAL_STROKE_STYLE_SOLID, Material::gp_style, NULL, rgb_to_hsv_v(), MaterialGPencilStyle::stroke_rgba, Object::totcol, and zero_v3().
|
static |
Definition at line 303 of file gpencil_curve.c.
References ARRAY_SET_ITEMS, Nurb::bezt, BKE_curve_forward_diff_bezier(), BKE_gpencil_stroke_close(), BKE_gpencil_stroke_geometry_update(), BKE_gpencil_stroke_sample(), BKE_nurb_makeCurve(), BLI_addtail(), Nurb::bp, CLAMP_MIN, copy_v3_v3(), CU_BEZIER, CU_NURB_CYCLIC, CU_NURBS, CU_POLY, Object::data, Nurb::flagu, GP_STROKE_3DSPACE, GP_STROKE_CAP_ROUND, GP_STROKE_SELECT, gpencil_add_new_points(), gpencil_get_stroke_material_fromcurve(), init, MEM_callocN, MEM_SAFE_FREE, NULL, Nurb::pntsu, Nurb::pntsv, bGPDspoint::pressure, BPoint::radius, Nurb::resolu, blender::compositor::sample(), bGPDspoint::strength, bGPDframe::strokes, Nurb::type, BPoint::vec, and bGPDspoint::x.
Referenced by BKE_gpencil_convert_curve().
|
static |
Definition at line 1217 of file gpencil_curve.c.
References count, bGPDcurve::curve_points, bGPDcurve_point::flag, GP_CURVE_POINT_SELECT, and bGPDcurve::tot_curve_points.
Referenced by BKE_gpencil_editcurve_subdivide().
|
static |
Definition at line 1241 of file gpencil_curve.c.
References bGPDcurve_point::bezt, interp_v4_v4v4(), interpf(), bGPDcurve_point::pressure, q1, bGPDcurve_point::strength, BezTriple::vec, and bGPDcurve_point::vert_color.
Referenced by BKE_gpencil_editcurve_subdivide().
|
static |
Definition at line 469 of file gpencil_curve.c.
References bGPDcurve_point::bezt, BEZT_DESEL_ALL, bGPDcurve::curve_points, bGPDcurve_point::flag, bGPDcurve::flag, GP_CURVE_POINT_SELECT, GP_CURVE_SELECT, and bGPDcurve::tot_curve_points.
Referenced by BKE_gpencil_editcurve_stroke_sync_selection().
|
static |
Definition at line 218 of file gpencil_curve.c.
References FOREACH_SCENE_COLLECTION_BEGIN, FOREACH_SCENE_COLLECTION_END, LISTBASE_FOREACH, NULL, and scene.
Referenced by BKE_gpencil_convert_curve().
|
static |
Definition at line 232 of file gpencil_curve.c.
References Object::data, and NULL.
Referenced by gpencil_convert_spline().
|
static |
Definition at line 879 of file gpencil_curve.c.
References float(), from, interpf(), POINTER_OFFSET, r, and stride.
Referenced by gpencil_calculate_stroke_points_curve_segment().
|
static |
Definition at line 892 of file gpencil_curve.c.
References float(), from, interp_v4_v4v4(), POINTER_OFFSET, r, and stride.
Referenced by gpencil_calculate_stroke_points_curve_segment().
|
static |
Definition at line 569 of file gpencil_curve.c.
References add_v3_v3v3(), bGPDcurve_point::bezt, BKE_gpencil_stroke_editcurve_new(), BLI_assert, copy_v3_v3(), copy_v4_v4(), bGPDcurve::curve_points, float(), BezTriple::h1, BezTriple::h2, HD_FREE, HD_VECT, len_v3v3(), length(), normalize_v3_length(), NULL, bGPDcurve_point::point_index, bGPDstroke::points, bGPDspoint::pressure, bGPDcurve_point::pressure, bGPDspoint::strength, bGPDcurve_point::strength, sub_v3_v3v3(), bGPDstroke::totpoints, BezTriple::vec, bGPDspoint::vert_color, bGPDcurve_point::vert_color, and bGPDspoint::x.
Referenced by BKE_gpencil_stroke_editcurve_generate().
|
static |
Definition at line 951 of file gpencil_curve.c.
References CLAMP_MIN, float(), floorf, gpencil_approximate_curve_segment_arclength(), gpencil_calculate_stroke_points_curve_segment(), MEM_callocN, MEM_freeN, bGPDcurve_point::point_index, POINTER_OFFSET, and stride.
Referenced by BKE_gpencil_stroke_update_geometry_from_editcurve().
|
static |
Helper: calculate the points on a curve with a fixed resolution.
Definition at line 1020 of file gpencil_curve.c.
References BKE_curve_calc_coords_axis_len(), float(), gpencil_calculate_stroke_points_curve_segment(), MEM_callocN, bGPDcurve_point::point_index, POINTER_OFFSET, and stride.
Referenced by BKE_gpencil_stroke_update_geometry_from_editcurve().