Blender V4.3
BKE_gpencil_geom_legacy.h File Reference
#include <optional>
#include "BLI_bounds_types.hh"
#include "BLI_math_vector_types.hh"

Go to the source code of this file.

Classes

struct  GPencilPointCoordinates
 

Typedefs

typedef struct GPencilPointCoordinates GPencilPointCoordinates
 

Functions

std::optional< blender::Bounds< blender::float3 > > BKE_gpencil_data_minmax (const struct bGPdata *gpd)
 
bool BKE_gpencil_stroke_minmax (const struct bGPDstroke *gps, bool use_select, float r_min[3], float r_max[3])
 
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])
 
bool BKE_gpencil_stroke_trim (struct bGPdata *gpd, struct bGPDstroke *gps)
 
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_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)
 
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_stroke_flip (struct bGPDstroke *gps)
 
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, bool auto_flip)
 
void BKE_gpencil_stroke_to_view_space (struct bGPDstroke *gps, float viewmat[4][4], const float diff_mat[4][4])
 
void BKE_gpencil_stroke_from_view_space (struct bGPDstroke *gps, float viewinv[4][4], 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

typedef struct GPencilPointCoordinates GPencilPointCoordinates

Function Documentation

◆ 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 110 of file gpencil_geom_legacy.cc.

References BKE_gpencil_data_minmax(), bounds(), copy_v3_v3(), and blender::math::midpoint().

Referenced by blender::ed::object::object_origin_set_exec().

◆ BKE_gpencil_data_minmax()

std::optional< blender::Bounds< blender::float3 > > BKE_gpencil_data_minmax ( const struct bGPdata * gpd)

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

Referenced by BKE_object_boundbox_get().

◆ BKE_gpencil_point_coords_apply()

◆ BKE_gpencil_point_coords_apply_with_mat4()

◆ BKE_gpencil_point_coords_get()

◆ 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)

◆ 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)

◆ BKE_gpencil_stroke_average_pressure_get()

float BKE_gpencil_stroke_average_pressure_get ( struct bGPDstroke * gps)

Get average pressure.

Definition at line 1714 of file gpencil_geom_legacy.cc.

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

◆ BKE_gpencil_stroke_boundingbox_calc()

void BKE_gpencil_stroke_boundingbox_calc ( struct bGPDstroke * gps)

Compute stroke bounding box.

Parameters
gpsGrease pencil Stroke

Definition at line 117 of file gpencil_geom_legacy.cc.

References BKE_gpencil_stroke_minmax(), bGPDstroke::boundbox_max, bGPDstroke::boundbox_min, and INIT_MINMAX.

Referenced by BKE_gpencil_stroke_geometry_update().

◆ BKE_gpencil_stroke_close()

◆ 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)

Flip stroke.

Definition at line 1225 of file gpencil_geom_legacy.cc.

References BLI_array_reverse, bGPDstroke::dvert, bGPDstroke::points, and bGPDstroke::totpoints.

Referenced by BKE_gpencil_stroke_join().

◆ BKE_gpencil_stroke_from_view_space()

void BKE_gpencil_stroke_from_view_space ( struct bGPDstroke * gps,
float viewinv[4][4],
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 1698 of file gpencil_geom_legacy.cc.

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

◆ BKE_gpencil_stroke_geometry_update()

◆ 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 1730 of file gpencil_geom_legacy.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,
bool auto_flip )

Join two strokes using the shortest distance (reorder stroke if necessary).

Parameters
auto_flipFlip the stroke if the join between two strokes is not end->start points.

Definition at line 1552 of file gpencil_geom_legacy.cc.

References BKE_gpencil_stroke_flip(), BKE_gpencil_stroke_smooth_point(), copy_v3_v3(), bGPDstroke::dvert, ELEM, float, gpencil_stroke_copy_point(), len, len_squared_v3v3(), point, bGPDstroke::points, bGPDspoint::pressure, bGPDspoint::strength, bGPDstroke::thickness, bGPDstroke::totpoints, and bGPDspoint::x.

◆ 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.

◆ 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

◆ 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

◆ 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.cc.

Referenced by blender::ed::object::data_xform_create_ex().

◆ 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.

◆ 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 1210 of file gpencil_geom_legacy.cc.

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

◆ 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 438 of file gpencil_geom_legacy.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.

◆ 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 129 of file gpencil_geom_legacy.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(), bGPDstroke::points, sub_v3_v3v3(), bGPDstroke::totpoints, w(), and bGPDspoint::x.

Referenced by BKE_gpencil_stroke_join(), and BKE_gpencil_stroke_smooth().

◆ 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 251 of file gpencil_geom_legacy.cc.

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

Referenced by BKE_gpencil_stroke_smooth().

◆ 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 309 of file gpencil_geom_legacy.cc.

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

Referenced by BKE_gpencil_stroke_smooth().

◆ 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 367 of file gpencil_geom_legacy.cc.

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

Referenced by BKE_gpencil_stroke_smooth().

◆ BKE_gpencil_stroke_to_view_space()

void BKE_gpencil_stroke_to_view_space ( struct bGPDstroke * gps,
float viewmat[4][4],
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 1685 of file gpencil_geom_legacy.cc.

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

◆ BKE_gpencil_stroke_trim()

bool BKE_gpencil_stroke_trim ( struct bGPdata * gpd,
struct bGPDstroke * gps )

◆ 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 750 of file gpencil_geom_legacy.cc.

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

Referenced by BKE_gpencil_stroke_geometry_update().

◆ 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 1052 of file gpencil_geom_legacy.cc.

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

Referenced by blender::ed::object::apply_objects_internal().