Blender  V3.3
Classes | Typedefs | Functions
BKE_gpencil_geom.h File Reference

Go to the source code of this file.

Classes

struct  GPencilPointCoordinates
 

Typedefs

typedef struct GPencilPointCoordinates GPencilPointCoordinates
 

Functions

bool BKE_gpencil_data_minmax (const struct bGPdata *gpd, float r_min[3], float r_max[3])
 
bool BKE_gpencil_stroke_minmax (const struct bGPDstroke *gps, bool use_select, float r_min[3], float r_max[3])
 
struct BoundBoxBKE_gpencil_boundbox_get (struct Object *ob)
 
void BKE_gpencil_centroid_3d (struct bGPdata *gpd, float r_centroid[3])
 
void BKE_gpencil_stroke_boundingbox_calc (struct bGPDstroke *gps)
 
void BKE_gpencil_stroke_normal (const struct bGPDstroke *gps, float r_normal[3])
 
void BKE_gpencil_stroke_simplify_adaptive (struct bGPdata *gpd, struct bGPDstroke *gps, float epsilon)
 
void BKE_gpencil_stroke_simplify_fixed (struct bGPdata *gpd, struct bGPDstroke *gps)
 
void BKE_gpencil_stroke_subdivide (struct bGPdata *gpd, struct bGPDstroke *gps, int level, int type)
 
bool BKE_gpencil_stroke_trim (struct bGPdata *gpd, struct bGPDstroke *gps)
 
void BKE_gpencil_stroke_merge_distance (struct bGPdata *gpd, struct bGPDframe *gpf, struct bGPDstroke *gps, float threshold, bool use_unselected)
 
void BKE_gpencil_stroke_2d_flat (const struct bGPDspoint *points, int totpoints, float(*points2d)[2], int *r_direction)
 
void BKE_gpencil_stroke_2d_flat_ref (const struct bGPDspoint *ref_points, int ref_totpoints, const struct bGPDspoint *points, int totpoints, float(*points2d)[2], float scale, int *r_direction)
 
void BKE_gpencil_stroke_fill_triangulate (struct bGPDstroke *gps)
 
void BKE_gpencil_stroke_geometry_update (struct bGPdata *gpd, struct bGPDstroke *gps)
 
void BKE_gpencil_stroke_uv_update (struct bGPDstroke *gps)
 
void BKE_gpencil_transform (struct bGPdata *gpd, const float mat[4][4])
 
int BKE_gpencil_stroke_point_count (const struct bGPdata *gpd)
 
void BKE_gpencil_point_coords_get (struct bGPdata *gpd, GPencilPointCoordinates *elem_data)
 
void BKE_gpencil_point_coords_apply (struct bGPdata *gpd, const GPencilPointCoordinates *elem_data)
 
void BKE_gpencil_point_coords_apply_with_mat4 (struct bGPdata *gpd, const GPencilPointCoordinates *elem_data, const float mat[4][4])
 
bool BKE_gpencil_stroke_sample (struct bGPdata *gpd, struct bGPDstroke *gps, const float dist, const bool select, const float sharp_threshold)
 
bool BKE_gpencil_stroke_smooth_point (struct bGPDstroke *gps, int point_index, float influence, int iterations, bool smooth_caps, bool keep_shape, struct bGPDstroke *r_gps)
 
bool BKE_gpencil_stroke_smooth_strength (struct bGPDstroke *gps, int point_index, float influence, int iterations, struct bGPDstroke *r_gps)
 
bool BKE_gpencil_stroke_smooth_thickness (struct bGPDstroke *gps, int point_index, float influence, int iterations, struct bGPDstroke *r_gps)
 
bool BKE_gpencil_stroke_smooth_uv (struct bGPDstroke *gps, int point_index, float influence, int iterations, struct bGPDstroke *r_gps)
 
void BKE_gpencil_stroke_smooth (struct bGPDstroke *gps, const float influence, const int iterations, const bool smooth_position, const bool smooth_strength, const bool smooth_thickness, const bool smooth_uv, const bool keep_shape, const float *weights)
 
bool BKE_gpencil_stroke_close (struct bGPDstroke *gps)
 
void BKE_gpencil_dissolve_points (struct bGPdata *gpd, struct bGPDframe *gpf, struct bGPDstroke *gps, short tag)
 
bool BKE_gpencil_stroke_stretch (struct bGPDstroke *gps, float dist, float overshoot_fac, short mode, bool follow_curvature, int extra_point_count, float segment_influence, float max_angle, bool invert_curvature)
 
bool BKE_gpencil_stroke_trim_points (struct bGPDstroke *gps, int index_from, int index_to)
 
struct bGPDstrokeBKE_gpencil_stroke_delete_tagged_points (struct bGPdata *gpd, struct bGPDframe *gpf, struct bGPDstroke *gps, struct bGPDstroke *next_stroke, int tag_flags, bool select, bool flat_cap, int limit)
 
void BKE_gpencil_curve_delete_tagged_points (struct bGPdata *gpd, struct bGPDframe *gpf, struct bGPDstroke *gps, struct bGPDstroke *next_stroke, struct bGPDcurve *gpc, int tag_flags)
 
void BKE_gpencil_stroke_flip (struct bGPDstroke *gps)
 
bool BKE_gpencil_stroke_split (struct bGPdata *gpd, struct bGPDframe *gpf, struct bGPDstroke *gps, int before_index, struct bGPDstroke **remaining_gps)
 
bool BKE_gpencil_stroke_shrink (struct bGPDstroke *gps, float dist, short mode)
 
float BKE_gpencil_stroke_length (const struct bGPDstroke *gps, bool use_3d)
 
float BKE_gpencil_stroke_segment_length (const struct bGPDstroke *gps, int start_index, int end_index, bool use_3d)
 
void BKE_gpencil_stroke_set_random_color (struct bGPDstroke *gps)
 
void BKE_gpencil_stroke_join (struct bGPDstroke *gps_a, struct bGPDstroke *gps_b, bool leave_gaps, bool fit_thickness, bool smooth)
 
void BKE_gpencil_stroke_copy_to_keyframes (struct bGPdata *gpd, struct bGPDlayer *gpl, struct bGPDframe *gpf, struct bGPDstroke *gps, bool tail)
 
bool BKE_gpencil_convert_mesh (struct Main *bmain, struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob_gp, struct Object *ob_mesh, float angle, int thickness, float offset, const float matrix[4][4], int frame_offset, bool use_seams, bool use_faces, bool use_vgroups)
 
void BKE_gpencil_stroke_uniform_subdivide (struct bGPdata *gpd, struct bGPDstroke *gps, uint32_t target_number, bool select)
 
void BKE_gpencil_stroke_to_view_space (struct RegionView3D *rv3d, struct bGPDstroke *gps, const float diff_mat[4][4])
 
void BKE_gpencil_stroke_from_view_space (struct RegionView3D *rv3d, struct bGPDstroke *gps, const float diff_mat[4][4])
 
struct bGPDstrokeBKE_gpencil_stroke_perimeter_from_view (struct RegionView3D *rv3d, struct bGPdata *gpd, const struct bGPDlayer *gpl, struct bGPDstroke *gps, int subdivisions, const float diff_mat[4][4])
 
float BKE_gpencil_stroke_average_pressure_get (struct bGPDstroke *gps)
 
bool BKE_gpencil_stroke_is_pressure_constant (struct bGPDstroke *gps)
 

Typedef Documentation

◆ GPencilPointCoordinates

Function Documentation

◆ BKE_gpencil_boundbox_get()

struct BoundBox* BKE_gpencil_boundbox_get ( struct Object ob)

Get grease pencil object bounding box.

Parameters
obGrease pencil object
Returns
Bounding box

Definition at line 149 of file gpencil_geom.cc.

References Object_Runtime::bb, boundbox_gpencil(), copy_v3_v3(), Object::data, DEG_get_original_id(), ELEM, bGPdata::flag, GP_DATA_CACHE_IS_DIRTY, Object::id, if(), Object::runtime, and BoundBox::vec.

Referenced by BKE_object_boundbox_get(), and BKE_object_minmax().

◆ BKE_gpencil_centroid_3d()

void BKE_gpencil_centroid_3d ( struct bGPdata gpd,
float  r_centroid[3] 
)

Compute center of bounding box.

Parameters
gpdGrease pencil data-block
r_centroidLocation of the center

Definition at line 108 of file gpencil_geom.cc.

References BKE_gpencil_data_minmax(), max, min, and mul_v3_v3fl().

Referenced by object_origin_set_exec(), and blender::io::gpencil::GpencilImporterSVG::read().

◆ BKE_gpencil_convert_mesh()

bool BKE_gpencil_convert_mesh ( struct Main bmain,
struct Depsgraph depsgraph,
struct Scene scene,
struct Object ob_gp,
struct Object ob_mesh,
float  angle,
int  thickness,
float  offset,
const float  matrix[4][4],
int  frame_offset,
bool  use_seams,
bool  use_faces,
bool  use_vgroups 
)

Convert a mesh object to grease pencil stroke.

Parameters
bmainMain thread pointer.
depsgraphOriginal depsgraph.
sceneOriginal scene.
ob_gpGrease pencil object to add strokes.
ob_meshMesh to convert.
angleLimit angle to consider a edge-loop ends.
thicknessThickness of the strokes.
offsetOffset along the normals.
matrixTransformation matrix.
frame_offsetDestination frame number offset.
use_seamsOnly export seam edges.
use_facesExport faces as filled strokes.

Definition at line 2682 of file gpencil_geom.cc.

References angle(), BKE_defgroup_copy_list(), BKE_gpencil_layer_addnew(), BKE_gpencil_layer_frame_get(), BKE_gpencil_layer_named_get(), BKE_gpencil_material_find_index_by_name_prefix(), BKE_gpencil_stroke_add(), BKE_gpencil_stroke_geometry_update(), BKE_gpencil_stroke_subdivide(), BKE_object_get_evaluated_mesh(), BKE_object_material_get(), RenderData::cfra, color, copy_v3_v3(), copy_v4_v4(), Object::data, MDeformWeight::def_nr, DEG_get_evaluated_object(), DEG_id_tag_update(), depsgraph, bGPDstroke::dvert, Mesh::dvert, MDeformVert::dw, ELEM, bGPDstroke::flag, GP_GETFRAME_ADD_NEW, GP_STROKE_CYCLIC, GP_SUBDIV_SIMPLE, gpencil_add_material(), gpencil_generate_edgeloops(), gpencil_material_find_index_by_name(), bGPdata::id, Material::id, Object::id, ID_RECALC_COPY_ON_WRITE, ID_RECALC_GEOMETRY, MPoly::loopstart, make_element_name(), MPoly::mat_nr, MEM_callocN, Mesh::mloop, Mesh::mpoly, mul_m4_v3(), Mesh::mvert, ID::name, OB_GPENCIL, offset, bGPDstroke::points, bGPDspoint::pressure, Material::r, Scene::r, scene, bGPDspoint::strength, Mesh::totedge, MPoly::totloop, Mesh::totpoly, MDeformVert::totweight, Object::type, MLoop::v, bGPdata::vertex_group_active_index, Mesh::vertex_group_active_index, bGPdata::vertex_group_names, Mesh::vertex_group_names, MDeformWeight::weight, and bGPDspoint::x.

Referenced by object_convert_exec().

◆ BKE_gpencil_curve_delete_tagged_points()

void BKE_gpencil_curve_delete_tagged_points ( struct bGPdata gpd,
struct bGPDframe gpf,
struct bGPDstroke gps,
struct bGPDstroke next_stroke,
struct bGPDcurve gpc,
int  tag_flags 
)

◆ BKE_gpencil_data_minmax()

bool BKE_gpencil_data_minmax ( const struct bGPdata gpd,
float  r_min[3],
float  r_max[3] 
)

Get min/max bounds of all strokes in grease pencil data-block.

Parameters
gpdGrease pencil data-block
r_minResult minimum coordinates
r_maxResult maximum coordinates
Returns
True if it was possible to calculate

◆ BKE_gpencil_dissolve_points()

void BKE_gpencil_dissolve_points ( struct bGPdata gpd,
struct bGPDframe gpf,
struct bGPDstroke gps,
short  tag 
)

Dissolve points in stroke.

Parameters
gpdGrease pencil data-block
gpfGrease pencil frame
gpsGrease pencil stroke
tagType of tag for point

Definition at line 1915 of file gpencil_geom.cc.

References BKE_gpencil_free_stroke_weights(), BKE_gpencil_stroke_geometry_update(), BLI_freelinkN(), bGPDstroke::dvert, MDeformVert::dw, bGPDspoint::flag, MEM_callocN, MEM_dupallocN, MEM_freeN, bGPDstroke::points, bGPDframe::strokes, bGPDstroke::totpoints, and bGPDstroke::triangles.

Referenced by BKE_gpencil_stroke_merge_distance().

◆ BKE_gpencil_point_coords_apply()

void BKE_gpencil_point_coords_apply ( struct bGPdata gpd,
const GPencilPointCoordinates elem_data 
)

◆ BKE_gpencil_point_coords_apply_with_mat4()

void BKE_gpencil_point_coords_apply_with_mat4 ( struct bGPdata gpd,
const GPencilPointCoordinates elem_data,
const float  mat[4][4] 
)

◆ BKE_gpencil_point_coords_get()

void BKE_gpencil_point_coords_get ( struct bGPdata gpd,
GPencilPointCoordinates elem_data 
)

◆ BKE_gpencil_stroke_2d_flat()

void BKE_gpencil_stroke_2d_flat ( const struct bGPDspoint points,
int  totpoints,
float(*)  points2d[2],
int *  r_direction 
)

Get points of stroke always flat to view not affected by camera view or view position.

Parameters
pointsArray of grease pencil points (3D)
totpointsTotal of points
points2dResult array of 2D points
r_directionReturn Concave (-1), Convex (1), or Auto-detect (0)

Referenced by gpencil_calc_points_factor().

◆ BKE_gpencil_stroke_2d_flat_ref()

void BKE_gpencil_stroke_2d_flat_ref ( const struct bGPDspoint ref_points,
int  ref_totpoints,
const struct bGPDspoint points,
int  totpoints,
float(*)  points2d[2],
float  scale,
int *  r_direction 
)

Get points of stroke always flat to view not affected by camera view or view position using another stroke as reference.

Parameters
ref_pointsArray of reference points (3D)
ref_totpointsTotal reference points
pointsArray of points to flat (3D)
totpointsTotal points
points2dResult array of 2D points
scaleScale factor
r_directionReturn Concave (-1), Convex (1), or Auto-detect (0)

Referenced by ED_gpencil_select_stroke_segment().

◆ BKE_gpencil_stroke_average_pressure_get()

float BKE_gpencil_stroke_average_pressure_get ( struct bGPDstroke gps)

Get average pressure.

Definition at line 4304 of file gpencil_geom.cc.

References float(), bGPDstroke::points, bGPDspoint::pressure, and bGPDstroke::totpoints.

◆ BKE_gpencil_stroke_boundingbox_calc()

void BKE_gpencil_stroke_boundingbox_calc ( struct bGPDstroke gps)

◆ BKE_gpencil_stroke_close()

bool BKE_gpencil_stroke_close ( struct bGPDstroke gps)

◆ BKE_gpencil_stroke_copy_to_keyframes()

void BKE_gpencil_stroke_copy_to_keyframes ( struct bGPdata gpd,
struct bGPDlayer gpl,
struct bGPDframe gpf,
struct bGPDstroke gps,
bool  tail 
)

◆ BKE_gpencil_stroke_delete_tagged_points()

struct bGPDstroke* BKE_gpencil_stroke_delete_tagged_points ( struct bGPdata gpd,
struct bGPDframe gpf,
struct bGPDstroke gps,
struct bGPDstroke next_stroke,
int  tag_flags,
bool  select,
bool  flat_cap,
int  limit 
)

◆ BKE_gpencil_stroke_fill_triangulate()

void BKE_gpencil_stroke_fill_triangulate ( struct bGPDstroke gps)

◆ BKE_gpencil_stroke_flip()

void BKE_gpencil_stroke_flip ( struct bGPDstroke gps)

◆ BKE_gpencil_stroke_from_view_space()

void BKE_gpencil_stroke_from_view_space ( struct RegionView3D rv3d,
struct bGPDstroke gps,
const float  diff_mat[4][4] 
)

Stroke from view space Transforms a stroke from view space back to world space. Inverse of BKE_gpencil_stroke_to_view_space

Note
also takes care of parent space transform.

Definition at line 3808 of file gpencil_geom.cc.

References invert_m4_m4(), mul_m4_v3(), mul_v3_m4v3(), bGPDstroke::points, bGPDstroke::totpoints, RegionView3D::viewinv, and bGPDspoint::x.

Referenced by BKE_gpencil_stroke_perimeter_from_view().

◆ BKE_gpencil_stroke_geometry_update()

void BKE_gpencil_stroke_geometry_update ( struct bGPdata gpd,
struct bGPDstroke gps 
)

Recalc all internal geometry data for the stroke

Parameters
gpdGrease pencil data-block
gpsGrease pencil stroke

Definition at line 1644 of file gpencil_geom.cc.

References BKE_gpencil_stroke_boundingbox_calc(), BKE_gpencil_stroke_fill_triangulate(), BKE_gpencil_stroke_update_geometry_from_editcurve(), BKE_gpencil_stroke_uv_update(), bGPdata::curve_edit_resolution, bGPDstroke::editcurve, bGPDcurve::flag, bGPDstroke::flag, bGPdata::flag, GP_CURVE_NEEDS_STROKE_UPDATE, GP_DATA_CURVE_ADAPTIVE_RESOLUTION, GP_STROKE_NEEDS_CURVE_UPDATE, GPENCIL_CURVE_EDIT_SESSIONS_ON, blender::opensubdiv::is_adaptive(), MEM_SAFE_FREE, bGPDstroke::tot_triangles, bGPDstroke::totpoints, and bGPDstroke::triangles.

Referenced by add_stroke(), add_stroke_cyclic(), add_stroke_simple(), apply_dash_for_frame(), applyLength(), BKE_gpencil_convert_mesh(), BKE_gpencil_curve_delete_tagged_points(), BKE_gpencil_dissolve_points(), BKE_gpencil_from_image(), BKE_gpencil_point_coords_apply(), BKE_gpencil_point_coords_apply_with_mat4(), BKE_gpencil_stroke_delete_tagged_points(), BKE_gpencil_stroke_merge_distance(), BKE_gpencil_stroke_perimeter_from_view(), BKE_gpencil_stroke_sample(), BKE_gpencil_stroke_simplify_adaptive(), BKE_gpencil_stroke_simplify_fixed(), BKE_gpencil_stroke_split(), BKE_gpencil_stroke_subdivide(), BKE_gpencil_stroke_trim(), BKE_gpencil_stroke_uniform_subdivide(), BKE_gpencil_strokes_selected_update_editcurve(), BKE_gpencil_transform(), blo_do_versions_280(), build_sequential(), deformStroke(), duplicateStroke(), ED_gpencil_create_monkey(), ED_gpencil_create_stroke(), ED_gpencil_select_curve_toggle_all(), ED_gpencil_trace_data_to_strokes(), generate_geometry(), gpencil_add_move_points(), gpencil_bake_grease_pencil_animation_exec(), gpencil_convert_spline(), gpencil_curve_extrude_points(), gpencil_dissolve_selected_curve_points(), gpencil_dissolve_selected_stroke_points(), gpencil_duplicate_exec(), gpencil_duplicate_points(), gpencil_editcurve_set_handle_type_exec(), gpencil_editmode_toggle_exec(), gpencil_generate_edgeloops(), gpencil_generic_stroke_select(), gpencil_insert_point(), gpencil_interpolate_modal(), gpencil_interpolate_seq_exec(), gpencil_interpolate_set_points(), gpencil_interpolate_update_strokes(), gpencil_primitive_interaction_end(), gpencil_primitive_update_strokes(), gpencil_recalc_geometry_exec(), gpencil_reset_transform_fill_exec(), gpencil_sculpt_brush_do_frame(), gpencil_select_exec(), gpencil_smooth_stroke(), gpencil_snap_to_grid(), gpencil_stroke_cyclical_set_exec(), gpencil_stroke_do_circle_sel(), gpencil_stroke_enter_editcurve_mode_exec(), gpencil_stroke_from_buffer(), gpencil_stroke_join_exec(), gpencil_stroke_join_islands(), gpencil_stroke_merge_exec(), gpencil_stroke_newfrombuffer(), gpencil_stroke_normalize_exec(), gpencil_stroke_subdivide_exec(), gpencil_strokes_copy_exec(), gpencil_strokes_paste_exec(), gpencil_strokes_reproject_exec(), gpencil_subdivide_stroke(), gpencil_update_geometry(), gpencil_uv_transform_calc(), lineart_gpencil_generate(), object_origin_set_exec(), recalcData_gpencil_strokes(), and reduce_stroke_points().

◆ BKE_gpencil_stroke_is_pressure_constant()

bool BKE_gpencil_stroke_is_pressure_constant ( struct bGPDstroke gps)

Check if the thickness of the stroke is constant.

Definition at line 4320 of file gpencil_geom.cc.

References bGPDstroke::points, bGPDspoint::pressure, and bGPDstroke::totpoints.

◆ BKE_gpencil_stroke_join()

void BKE_gpencil_stroke_join ( struct bGPDstroke gps_a,
struct bGPDstroke gps_b,
bool  leave_gaps,
bool  fit_thickness,
bool  smooth 
)

◆ BKE_gpencil_stroke_length()

float BKE_gpencil_stroke_length ( const struct bGPDstroke gps,
bool  use_3d 
)

Calculate grease pencil stroke length.

Parameters
gpsGrease pencil stroke.
use_3dSet to true to use 3D points.
Returns
Length of the stroke.

Referenced by applyLength(), and ED_gpencil_trace_data_to_strokes().

◆ BKE_gpencil_stroke_merge_distance()

void BKE_gpencil_stroke_merge_distance ( struct bGPdata gpd,
struct bGPDframe gpf,
struct bGPDstroke gps,
float  threshold,
bool  use_unselected 
)

Reduce a series of points when the distance is below a threshold. Special case for first and last points (both are kept) for other points, the merge point always is at first point.

Parameters
gpdGrease pencil data-block.
gpfGrease Pencil frame.
gpsGrease Pencil stroke.
thresholdDistance between points.
use_unselectedSet to true to analyze all stroke and not only selected points.

Definition at line 2324 of file gpencil_geom.cc.

References BKE_gpencil_dissolve_points(), BKE_gpencil_stroke_geometry_update(), bGPDspoint::flag, GP_SPOINT_SELECT, GP_SPOINT_TAG, len_squared_v3v3(), bGPDstroke::points, threshold, bGPDstroke::totpoints, and bGPDspoint::x.

Referenced by deformStroke(), ED_gpencil_stroke_join_and_trim(), and gpencil_merge_by_distance_exec().

◆ BKE_gpencil_stroke_minmax()

bool BKE_gpencil_stroke_minmax ( const struct bGPDstroke gps,
bool  use_select,
float  r_min[3],
float  r_max[3] 
)

Get min/max coordinate bounds for single stroke.

Parameters
gpsGrease pencil stroke
use_selectInclude only selected points
r_minResult minimum coordinates
r_maxResult maximum coordinates
Returns
True if it was possible to calculate

Referenced by gpencil_data_selected_minmax(), and viewselected_exec().

◆ BKE_gpencil_stroke_normal()

void BKE_gpencil_stroke_normal ( const struct bGPDstroke gps,
float  r_normal[3] 
)

Calculate stroke normals.

Parameters
gpsGrease pencil stroke
r_normalReturn Normal vector normalized

Referenced by deformStroke(), and duplicateStroke().

◆ BKE_gpencil_stroke_perimeter_from_view()

struct bGPDstroke* BKE_gpencil_stroke_perimeter_from_view ( struct RegionView3D rv3d,
struct bGPdata gpd,
const struct bGPDlayer gpl,
struct bGPDstroke gps,
int  subdivisions,
const float  diff_mat[4][4] 
)

Calculates the perimeter of a stroke projected from the view and returns it as a new stroke.

Parameters
subdivisionsNumber of subdivisions for the start and end caps.
Returns
: bGPDstroke pointer to stroke perimeter.

Referenced by blender::io::gpencil::GpencilIO::stroke_point_radius_get().

◆ BKE_gpencil_stroke_point_count()

int BKE_gpencil_stroke_point_count ( const struct bGPdata gpd)
Note
Used for "move only origins" in object_data_transform.c.

Referenced by ED_object_data_xform_create_ex().

◆ BKE_gpencil_stroke_sample()

bool BKE_gpencil_stroke_sample ( struct bGPdata gpd,
struct bGPDstroke gps,
const float  dist,
const bool  select,
const float  sharp_threshold 
)

◆ BKE_gpencil_stroke_segment_length()

float BKE_gpencil_stroke_segment_length ( const struct bGPDstroke gps,
int  start_index,
int  end_index,
bool  use_3d 
)

Calculate grease pencil stroke length between points.

Definition at line 1701 of file gpencil_geom.cc.

References len_v2v2(), len_v3v3(), MAX2, MIN2, bGPDstroke::points, bGPDstroke::totpoints, and bGPDspoint::x.

Referenced by ED_gpencil_stroke_join_and_trim().

◆ BKE_gpencil_stroke_set_random_color()

void BKE_gpencil_stroke_set_random_color ( struct bGPDstroke gps)

Set a random color to stroke using vertex color.

Parameters
gpsStroke

Definition at line 2992 of file gpencil_geom.cc.

References BLI_assert, BLI_hash_int_01(), BLI_hash_int_2d(), color, copy_v4_v4(), bGPDstroke::points, bGPDstroke::totpoints, bGPDspoint::vert_color, bGPDspoint::x, bGPDspoint::y, and bGPDspoint::z.

Referenced by lineart_gpencil_generate().

◆ BKE_gpencil_stroke_shrink()

bool BKE_gpencil_stroke_shrink ( struct bGPDstroke gps,
float  dist,
short  mode 
)

Shrink the stroke by length.

Parameters
gpsStroke to shrink
distdelta length
mode1->Start, 2->End

Definition at line 928 of file gpencil_geom.cc.

References BKE_gpencil_stroke_trim_points(), END, interp_v3_v3v3(), len, len_v3v3(), bGPDstroke::points, START, bGPDstroke::totpoints, x, and bGPDspoint::x.

Referenced by gpencil_modify_stroke().

◆ BKE_gpencil_stroke_simplify_adaptive()

void BKE_gpencil_stroke_simplify_adaptive ( struct bGPdata gpd,
struct bGPDstroke gps,
float  epsilon 
)

Reduce a series of points to a simplified version, but maintains the general shape of the series.

Ramer - Douglas - Peucker algorithm by http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm

Parameters
gpdGrease pencil data-block
gpsGrease pencil stroke
epsilonEpsilon value to define precision of the algorithm

Definition at line 2039 of file gpencil_geom.cc.

References BKE_gpencil_free_point_weights(), BKE_gpencil_stroke_geometry_update(), closest_to_line_segment_v3(), bGPDstroke::dvert, MDeformVert::dw, blender::robust_pred::epsilon, len_v3v3(), max_i(), MEM_callocN, MEM_dupallocN, MEM_SAFE_FREE, bGPDstroke::points, bGPDstroke::totpoints, and x.

Referenced by deformStroke(), gpencil_stroke_newfrombuffer(), and gpencil_stroke_simplify_exec().

◆ BKE_gpencil_stroke_simplify_fixed()

void BKE_gpencil_stroke_simplify_fixed ( struct bGPdata gpd,
struct bGPDstroke gps 
)

Simplify alternate vertex of stroke except extremes.

Parameters
gpdGrease pencil data-block
gpsGrease pencil stroke

Definition at line 2143 of file gpencil_geom.cc.

References BKE_gpencil_free_point_weights(), BKE_gpencil_stroke_geometry_update(), bGPDstroke::dvert, MDeformVert::dw, MEM_dupallocN, MEM_recallocN, MEM_SAFE_FREE, bGPDstroke::points, and bGPDstroke::totpoints.

Referenced by deformStroke(), gpencil_stroke_from_buffer(), and gpencil_stroke_simplify_fixed_exec().

◆ BKE_gpencil_stroke_smooth()

void BKE_gpencil_stroke_smooth ( struct bGPDstroke gps,
const float  influence,
const int  iterations,
const bool  smooth_position,
const bool  smooth_strength,
const bool  smooth_thickness,
const bool  smooth_uv,
const bool  keep_shape,
const float weights 
)

Apply smooth operation to the stroke.

Parameters
gpsStroke to smooth
influenceThe interpolation factor for the smooth and the original stroke
iterationsRadius of points to consider, equivalent to iterations
smooth_positionSmooth point locations
smooth_strengthSmooth point strength
smooth_thicknessSmooth point thickness
smooth_uvSmooth uv rotation/factor
keep_shapeUse different distribution for smooth locations to keep the shape
weightsper point weights to multiply influence with (optional, can be null)

Definition at line 1317 of file gpencil_geom.cc.

References BKE_gpencil_stroke_smooth_point(), BKE_gpencil_stroke_smooth_strength(), BKE_gpencil_stroke_smooth_thickness(), BKE_gpencil_stroke_smooth_uv(), MEM_dupallocN, MEM_freeN, bGPDstroke::points, and bGPDstroke::totpoints.

Referenced by deformStroke(), gpencil_interpolate_seq_exec(), gpencil_interpolate_set_points(), and gpencil_stroke_newfrombuffer().

◆ BKE_gpencil_stroke_smooth_point()

bool BKE_gpencil_stroke_smooth_point ( struct bGPDstroke gps,
int  point_index,
float  influence,
int  iterations,
bool  smooth_caps,
bool  keep_shape,
struct bGPDstroke r_gps 
)

Apply smooth position to stroke point.

Parameters
gpsStroke to smooth
iPoint index
infAmount of smoothing to apply
iterationsRadius of points to consider, equivalent to iterations
smooth_capsApply smooth to stroke extremes
keep_shapeSmooth out fine details first
r_gpsStroke to put the result into

Definition at line 1007 of file gpencil_geom.cc.

References add_v3_v3(), copy_v3_v3(), double(), ELEM, exp(), bGPDstroke::flag, float(), GP_STROKE_CYCLIC, interp_v3_v3v3(), is_cyclic(), M_SQRT3, madd_v3_v3fl(), mul_v3_fl(), point_index, bGPDstroke::points, sub_v3_v3v3(), bGPDstroke::totpoints, w(), and bGPDspoint::x.

Referenced by BKE_gpencil_stroke_join(), BKE_gpencil_stroke_smooth(), gpencil_brush_smooth_apply(), gpencil_smooth_stroke(), gpencil_stroke_from_buffer(), and gpencil_stroke_newfrombuffer().

◆ BKE_gpencil_stroke_smooth_strength()

bool BKE_gpencil_stroke_smooth_strength ( struct bGPDstroke gps,
int  point_index,
float  influence,
int  iterations,
struct bGPDstroke r_gps 
)

Apply smooth strength to stroke point.

Parameters
gpsStroke to smooth
point_indexPoint index
influenceAmount of smoothing to apply
iterationsRadius of points to consider, equivalent to iterations
r_gpsStroke to put the result into

Definition at line 1127 of file gpencil_geom.cc.

References CLAMP_MAX, CLAMP_MIN, bGPDstroke::flag, float(), GP_STROKE_CYCLIC, is_cyclic(), point_index, bGPDstroke::points, bGPDspoint::strength, bGPDstroke::totpoints, and w().

Referenced by BKE_gpencil_stroke_smooth(), gpencil_brush_smooth_apply(), gpencil_smooth_stroke(), and gpencil_stroke_newfrombuffer().

◆ BKE_gpencil_stroke_smooth_thickness()

bool BKE_gpencil_stroke_smooth_thickness ( struct bGPDstroke gps,
int  point_index,
float  influence,
int  iterations,
struct bGPDstroke r_gps 
)

Apply smooth for thickness to stroke point (use pressure).

Parameters
gpsStroke to smooth
point_indexPoint index
influenceAmount of smoothing to apply
iterationsRadius of points to consider, equivalent to iterations
r_gpsStroke to put the result into

Definition at line 1185 of file gpencil_geom.cc.

References CLAMP_MAX, CLAMP_MIN, bGPDstroke::flag, float(), GP_STROKE_CYCLIC, is_cyclic(), point_index, bGPDstroke::points, bGPDspoint::pressure, bGPDstroke::totpoints, and w().

Referenced by BKE_gpencil_stroke_smooth(), gpencil_brush_smooth_apply(), and gpencil_smooth_stroke().

◆ BKE_gpencil_stroke_smooth_uv()

bool BKE_gpencil_stroke_smooth_uv ( struct bGPDstroke gps,
int  point_index,
float  influence,
int  iterations,
struct bGPDstroke r_gps 
)

Apply smooth for UV rotation/factor to stroke point.

Parameters
gpsStroke to smooth
point_indexPoint index
influenceAmount of smoothing to apply
iterationsRadius of points to consider, equivalent to iterations
r_gpsStroke to put the result into

Definition at line 1243 of file gpencil_geom.cc.

References ELEM, bGPDstroke::flag, float(), GP_STROKE_CYCLIC, is_cyclic(), point_index, bGPDstroke::points, bGPDstroke::totpoints, bGPDspoint::uv_fac, bGPDspoint::uv_rot, and w().

Referenced by BKE_gpencil_stroke_smooth(), gpencil_brush_smooth_apply(), and gpencil_smooth_stroke().

◆ BKE_gpencil_stroke_split()

bool BKE_gpencil_stroke_split ( struct bGPdata gpd,
struct bGPDframe gpf,
struct bGPDstroke gps,
int  before_index,
struct bGPDstroke **  remaining_gps 
)

Split stroke.

Parameters
gpdGrease pencil data-block.
gpfGrease pencil frame.
gpsGrease pencil original stroke.
before_indexPosition of the point to split.
remaining_gpsSecondary stroke after split.
Returns
True if the split was done

Definition at line 870 of file gpencil_geom.cc.

References BKE_gpencil_stroke_add_existing_style(), BKE_gpencil_stroke_geometry_update(), BKE_gpencil_stroke_trim_points(), MDeformWeight::def_nr, bGPDstroke::dvert, MDeformVert::dw, MDeformVert::flag, bGPDstroke::mat_nr, MEM_mallocN, bGPDstroke::points, bGPDstroke::thickness, bGPDstroke::totpoints, MDeformVert::totweight, and MDeformWeight::weight.

◆ BKE_gpencil_stroke_stretch()

bool BKE_gpencil_stroke_stretch ( struct bGPDstroke gps,
float  dist,
float  overshoot_fac,
short  mode,
bool  follow_curvature,
int  extra_point_count,
float  segment_influence,
float  max_angle,
bool  invert_curvature 
)

Backbone stretch similar to Freestyle.

Parameters
gpsStroke to sample.
distLength of the added section.
overshoot_facRelative length of the curve which is used to determine the extension.
modeAffect to Start, End or Both extremes (0->Both, 1->Start, 2->End).
follow_curvatureTrue for approximating curvature of given overshoot.
extra_point_countWhen follow_curvature is true, use this amount of extra points.

Definition at line 630 of file gpencil_geom.cc.

References add_v3_v3(), add_v3_v3v3(), angle(), angle_normalized_v3v3(), axis_angle_to_quat(), BKE_gpencil_stroke_extra_points(), BOTH, ceil(), CLAMP, copy_v3_v3(), cross_v3_v3v3(), ELEM, END, fabs(), fabsf, blender::math::floor(), fmaxf, fminf, fmodf, interp_v3_v3v3(), is_zero_v3(), CCL_NAMESPACE_BEGIN::isfinite(), len, len_v3(), M_PI, madd_v3_v3fl(), mul_qt_v3(), mul_v3_m3v3(), normalize_v3(), normalize_v3_length(), bGPDstroke::points, powf, quat_to_mat3(), result, rot, KDL::sin(), START, sub_v3_v3(), sub_v3_v3v3(), bGPDstroke::totpoints, UNLIKELY, bGPDspoint::x, and zero_v3().

Referenced by gpencil_modify_stroke().

◆ BKE_gpencil_stroke_subdivide()

void BKE_gpencil_stroke_subdivide ( struct bGPdata gpd,
struct bGPDstroke gps,
int  level,
int  type 
)

◆ BKE_gpencil_stroke_to_view_space()

void BKE_gpencil_stroke_to_view_space ( struct RegionView3D rv3d,
struct bGPDstroke gps,
const float  diff_mat[4][4] 
)

Stroke to view space Transforms a stroke to view space. This allows for manipulations in 2D but also easy conversion back to 3D.

Note
also takes care of parent space transform.

Definition at line 3795 of file gpencil_geom.cc.

References mul_m4_v3(), mul_v3_m4v3(), bGPDstroke::points, bGPDstroke::totpoints, RegionView3D::viewmat, and bGPDspoint::x.

Referenced by BKE_gpencil_stroke_perimeter_from_view().

◆ BKE_gpencil_stroke_trim()

bool BKE_gpencil_stroke_trim ( struct bGPdata gpd,
struct bGPDstroke gps 
)

◆ BKE_gpencil_stroke_trim_points()

bool BKE_gpencil_stroke_trim_points ( struct bGPDstroke gps,
int  index_from,
int  index_to 
)

Trim stroke to needed segments.

Parameters
gpsTarget stroke.
index_fromthe index of the first point to be used in the trimmed result.
index_tothe index of the last point to be used in the trimmed result.

Definition at line 812 of file gpencil_geom.cc.

References BKE_gpencil_free_stroke_weights(), MDeformWeight::def_nr, bGPDstroke::dvert, MDeformVert::dw, MDeformVert::flag, MEM_freeN, MEM_mallocN, bGPDstroke::points, bGPDstroke::totpoints, MDeformVert::totweight, and MDeformWeight::weight.

Referenced by BKE_gpencil_stroke_shrink(), and BKE_gpencil_stroke_split().

◆ BKE_gpencil_stroke_uniform_subdivide()

void BKE_gpencil_stroke_uniform_subdivide ( struct bGPdata gpd,
struct bGPDstroke gps,
uint32_t  target_number,
bool  select 
)

Subdivide the grease pencil stroke so the number of points is target_number. Does not change the shape of the stroke. The new points will be distributed as uniformly as possible by repeatedly subdividing the current longest edge.

Parameters
gpsThe stroke to be up-sampled.
target_numberThe number of points the up-sampled stroke should have.
selectSelect/Deselect the stroke.

Definition at line 3660 of file gpencil_geom.cc.

References BKE_gpencil_stroke_geometry_update(), BKE_gpencil_stroke_select_index_set(), BLI_addtail(), BLI_assert, BLI_heap_free(), BLI_heap_insert(), BLI_heap_new(), BLI_heap_pop_min(), BLI_insertlinkafter(), copy_v3_v3(), copy_v4_v4(), MDeformWeight::def_nr, bGPDstroke::dvert, tSamplePoint::dw, MDeformVert::dw, ListBase::first, bGPDspoint::flag, bGPDstroke::flag, tSampleEdge::from, GP_SPOINT_SELECT, GP_STROKE_CYCLIC, GP_STROKE_SELECT, interp_v3_v3v3(), interp_v4_v4v4(), interpf(), is_cyclic(), ListBase::last, tSampleEdge::length_sq, LISTBASE_FOREACH_MUTABLE, MEM_callocN, MEM_freeN, MEM_recallocN, MEM_SAFE_FREE, MIN2, new_sample_edge_from_sample_points(), new_sample_point_from_gp_point(), tSamplePoint::next, bGPDstroke::points, tSamplePoint::pressure, bGPDspoint::pressure, select(), tSamplePoint::strength, bGPDspoint::strength, tSamplePoint::time, bGPDspoint::time, tSampleEdge::to, bGPDstroke::totpoints, tSamplePoint::totweight, MDeformVert::totweight, bGPDspoint::vert_color, tSamplePoint::vertex_color, MDeformWeight::weight, tSamplePoint::x, and bGPDspoint::x.

Referenced by gpencil_interpolate_seq_exec(), and gpencil_interpolate_set_points().

◆ BKE_gpencil_stroke_uv_update()

void BKE_gpencil_stroke_uv_update ( struct bGPDstroke gps)

Update Stroke UV data.

Parameters
gpsGrease pencil stroke

Definition at line 1629 of file gpencil_geom.cc.

References len_v3v3(), bGPDstroke::points, bGPDstroke::totpoints, bGPDspoint::uv_fac, and x.

Referenced by BKE_gpencil_stroke_geometry_update(), ED_gpencil_update_color_uv(), and gpencil_sbuffer_stroke_ensure().

◆ BKE_gpencil_transform()

void BKE_gpencil_transform ( struct bGPdata gpd,
const float  mat[4][4] 
)

Apply grease pencil Transforms.

Parameters
gpdGrease pencil data-block
matTransformation matrix

Definition at line 2834 of file gpencil_geom.cc.

References BKE_gpencil_stroke_geometry_update(), bGPdata::layers, LISTBASE_FOREACH, mat4_to_scale(), mul_m4_v3(), bGPDstroke::points, bGPDspoint::pressure, and bGPDspoint::x.

Referenced by apply_objects_internal().