Blender
V3.3
|
#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 |
#define COORD_FITTING_INFLUENCE 20.0f |
Definition at line 43 of file gpencil_curve.c.
#define POINT_DIM 9 |
void BKE_gpencil_convert_curve | ( | struct Main * | bmain, |
struct Scene * | scene, | ||
struct Object * | ob_gp, | ||
struct Object * | ob_cu, | ||
bool | use_collections, | ||
float | scale_thickness, | ||
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 464 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(), RenderData::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, Scene::r, sample, scene, Object::totcol, and Object::type.
Referenced by object_convert_exec().
void BKE_gpencil_editcurve_recalculate_handles | ( | struct bGPDstroke * | gps | ) |
Recalculate the handles of the edit curve of a grease pencil stroke.
Definition at line 1103 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 | ||
) |
Definition at line 748 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 1229 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, is_cyclic(), MEM_callocN, MEM_freeN, NULL, and bGPDcurve::tot_curve_points.
Referenced by gpencil_stroke_subdivide_exec().
bGPDcurve* BKE_gpencil_stroke_editcurve_generate | ( | struct bGPDstroke * | gps, |
float | error_threshold, | ||
float | corner_angle, | ||
float | stroke_radius | ||
) |
Creates a bGPDcurve by doing a cubic curve fitting on the grease pencil stroke points.
Definition at line 615 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 | ( | struct bGPdata * | gpd, |
struct bGPDstroke * | gps, | ||
struct bGPDcurve * | gpc | ||
) |
Sync the selection from edit-curve to stroke.
Definition at line 774 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, point_index, 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 | ( | struct bGPdata * | gpd, |
struct bGPDlayer * | gpl, | ||
struct bGPDstroke * | gps | ||
) |
Updates the edit-curve for a stroke. Frees the old curve if one exists and generates a new one.
Definition at line 726 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 | ( | struct bGPDstroke * | gps, |
uint | resolution, | ||
bool | is_adaptive | ||
) |
Recalculate stroke points with the edit-curve of the stroke.
Definition at line 1019 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(), is_cyclic(), 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().
Definition at line 1349 of file gpencil_curve.c.
References BKE_gpencil_layer_is_editable(), BKE_gpencil_stroke_editcurve_sync_selection(), bool, GP_FRAME_SELECT, GPENCIL_MULTIEDIT_SESSIONS_ON, bGPdata::layers, LISTBASE_FOREACH, bGPDframe::next, and NULL.
Definition at line 1310 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(), bool, 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 135 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 168 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 866 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 880 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 50 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 287 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, sample, bGPDspoint::strength, bGPDframe::strokes, Nurb::type, BPoint::vec, and bGPDspoint::x.
Referenced by BKE_gpencil_convert_curve().
Definition at line 1172 of file gpencil_curve.c.
References count, bGPDcurve::curve_points, bGPDcurve_point::flag, GP_CURVE_POINT_SELECT, is_cyclic(), and bGPDcurve::tot_curve_points.
Referenced by BKE_gpencil_editcurve_subdivide().
|
static |
Definition at line 1196 of file gpencil_curve.c.
References usdtokens::b(), 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().
Definition at line 453 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 202 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 216 of file gpencil_curve.c.
References Object::data, and NULL.
Referenced by gpencil_convert_spline().
|
static |
Definition at line 840 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 853 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 542 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(), blender::math::length(), normalize_v3_length(), NULL, offset, 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 912 of file gpencil_curve.c.
References CLAMP_MIN, float(), floorf, gpencil_approximate_curve_segment_arclength(), gpencil_calculate_stroke_points_curve_segment(), is_cyclic(), MEM_callocN, MEM_freeN, point_index, 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 981 of file gpencil_curve.c.
References BKE_curve_calc_coords_axis_len(), float(), gpencil_calculate_stroke_points_curve_segment(), is_cyclic(), MEM_callocN, bGPDcurve_point::point_index, POINTER_OFFSET, and stride.
Referenced by BKE_gpencil_stroke_update_geometry_from_editcurve().