Blender  V3.3
Functions
gpencil_utils.c File Reference
#include <math.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_ghash.h"
#include "BLI_hash.h"
#include "BLI_lasso_2d.h"
#include "BLI_math.h"
#include "BLI_rand.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "PIL_time.h"
#include "DNA_brush_types.h"
#include "DNA_collection_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_material_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
#include "BKE_action.h"
#include "BKE_brush.h"
#include "BKE_collection.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_deform.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 "BKE_paint.h"
#include "BKE_tracking.h"
#include "WM_api.h"
#include "WM_toolsystem.h"
#include "WM_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "RNA_prototypes.h"
#include "UI_resources.h"
#include "UI_view2d.h"
#include "ED_clip.h"
#include "ED_gpencil.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_transform_snap_object_context.h"
#include "ED_view3d.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_state.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
#include "gpencil_intern.h"

Go to the source code of this file.

Functions

bGPdata ** ED_gpencil_data_get_pointers_direct (ScrArea *area, Object *ob, PointerRNA *r_ptr)
 
bGPdata ** ED_annotation_data_get_pointers_direct (ID *screen_id, ScrArea *area, Scene *scene, PointerRNA *r_ptr)
 
bGPdata ** ED_gpencil_data_get_pointers (const bContext *C, PointerRNA *r_ptr)
 
bGPdata ** ED_annotation_data_get_pointers (const bContext *C, PointerRNA *r_ptr)
 
bGPdataED_gpencil_data_get_active_direct (ScrArea *area, Object *ob)
 
bGPdataED_annotation_data_get_active_direct (ID *screen_id, ScrArea *area, Scene *scene)
 
bGPdataED_gpencil_data_get_active (const bContext *C)
 
bGPdataED_annotation_data_get_active (const bContext *C)
 
bGPdataED_gpencil_data_get_active_evaluated (const bContext *C)
 
bool ED_gpencil_data_owner_is_annotation (PointerRNA *owner_ptr)
 
bool ED_gpencil_has_keyframe_v3d (Scene *UNUSED(scene), Object *ob, int cfra)
 
bool gpencil_add_poll (bContext *C)
 
bool gpencil_active_layer_poll (bContext *C)
 
bool gpencil_active_brush_poll (bContext *C)
 
const EnumPropertyItemED_gpencil_layers_enum_itemf (bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
 
const EnumPropertyItemED_gpencil_layers_with_new_enum_itemf (bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
 
const EnumPropertyItemED_gpencil_material_enum_itemf (bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
 
bool gpencil_stroke_inside_circle (const float mval[2], int rad, int x0, int y0, int x1, int y1)
 
bool ED_gpencil_frame_has_selected_stroke (const bGPDframe *gpf)
 
bool ED_gpencil_layer_has_selected_stroke (const bGPDlayer *gpl, const bool is_multiedit)
 
bool ED_gpencil_stroke_can_use_direct (const ScrArea *area, const bGPDstroke *gps)
 
bool ED_gpencil_stroke_can_use (const bContext *C, const bGPDstroke *gps)
 
bool ED_gpencil_stroke_material_editable (Object *ob, const bGPDlayer *gpl, const bGPDstroke *gps)
 
bool ED_gpencil_stroke_material_visible (Object *ob, const bGPDstroke *gps)
 
void gpencil_point_conversion_init (bContext *C, GP_SpaceConversion *r_gsc)
 
void gpencil_point_to_parent_space (const bGPDspoint *pt, const float diff_mat[4][4], bGPDspoint *r_pt)
 
void gpencil_apply_parent (Depsgraph *depsgraph, Object *obact, bGPDlayer *gpl, bGPDstroke *gps)
 
void gpencil_apply_parent_point (Depsgraph *depsgraph, Object *obact, bGPDlayer *gpl, bGPDspoint *pt)
 
void gpencil_point_to_xy (const GP_SpaceConversion *gsc, const bGPDstroke *gps, const bGPDspoint *pt, int *r_x, int *r_y)
 
void gpencil_point_to_xy_fl (const GP_SpaceConversion *gsc, const bGPDstroke *gps, const bGPDspoint *pt, float *r_x, float *r_y)
 
void gpencil_point_3d_to_xy (const GP_SpaceConversion *gsc, const short flag, const float pt[3], float xy[2])
 
bool gpencil_point_xy_to_3d (const GP_SpaceConversion *gsc, Scene *scene, const float screen_co[2], float r_out[3])
 
void gpencil_stroke_convertcoords_tpoint (Scene *scene, ARegion *region, Object *ob, const tGPspoint *point2D, float *depth, float r_out[3])
 
void ED_gpencil_drawing_reference_get (const Scene *scene, const Object *ob, char align_flag, float r_vec[3])
 
void ED_gpencil_project_stroke_to_view (bContext *C, bGPDlayer *gpl, bGPDstroke *gps)
 
void ED_gpencil_project_stroke_to_plane (const Scene *scene, const Object *ob, const RegionView3D *rv3d, bGPDlayer *gpl, bGPDstroke *gps, const float origin[3], const int axis)
 
void ED_gpencil_stroke_reproject (Depsgraph *depsgraph, const GP_SpaceConversion *gsc, SnapObjectContext *sctx, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, const eGP_ReprojectModes mode, const bool keep_original)
 
void ED_gpencil_project_point_to_plane (const Scene *scene, const Object *ob, bGPDlayer *gpl, const RegionView3D *rv3d, const float origin[3], const int axis, bGPDspoint *pt)
 
void gpencil_subdivide_stroke (bGPdata *gpd, bGPDstroke *gps, const int subdivide)
 
void ED_gpencil_reset_layers_parent (Depsgraph *depsgraph, Object *obact, bGPdata *gpd)
 
ObjectED_gpencil_add_object (bContext *C, const float loc[3], ushort local_view_bits)
 
void ED_gpencil_add_defaults (bContext *C, Object *ob)
 
void ED_gpencil_vgroup_assign (bContext *C, Object *ob, float weight)
 
void ED_gpencil_vgroup_remove (bContext *C, Object *ob)
 
void ED_gpencil_vgroup_select (bContext *C, Object *ob)
 
void ED_gpencil_vgroup_deselect (bContext *C, Object *ob)
 
static bool gpencil_check_cursor_region (bContext *C, const int mval_i[2])
 
void ED_gpencil_brush_draw_eraser (Brush *brush, int x, int y)
 
static bool gpencil_brush_cursor_poll (bContext *C)
 
static void gpencil_brush_cursor_draw (bContext *C, int x, int y, void *customdata)
 
void ED_gpencil_toggle_brush_cursor (bContext *C, bool enable, void *customdata)
 
void ED_gpencil_setup_modes (bContext *C, bGPdata *gpd, int newmode)
 
static void gpencil_stroke_convertcoords (ARegion *region, const tGPspoint *point2D, const float origin[3], float out[3])
 
void ED_gpencil_tpoint_to_point (ARegion *region, float origin[3], const tGPspoint *tpt, bGPDspoint *pt)
 
void ED_gpencil_update_color_uv (Main *bmain, Material *mat)
 
static bool gpencil_check_collision (bGPDstroke *gps, bGPDstroke **gps_array, GHash *all_2d, int totstrokes, const float p2d_a1[2], const float p2d_a2[2], float r_hit[2])
 
static void gpencil_copy_points (bGPDstroke *gps, bGPDspoint *pt, bGPDspoint *pt_final, int i, int i2)
 
static void gpencil_insert_point (bGPdata *gpd, bGPDstroke *gps, bGPDspoint *a_pt, bGPDspoint *b_pt, const float co_a[3], const float co_b[3])
 
static float gpencil_calc_factor (const float p2d_a1[2], const float p2d_a2[2], const float r_hit2d[2])
 
int ED_gpencil_select_stroke_segment (bGPdata *gpd, bGPDlayer *gpl, bGPDstroke *gps, bGPDspoint *pt, bool select, bool insert, const float scale, float r_hita[3], float r_hitb[3])
 
void ED_gpencil_select_toggle_all (bContext *C, int action)
 
void ED_gpencil_select_curve_toggle_all (bContext *C, int action)
 
tGPspointED_gpencil_sbuffer_ensure (tGPspoint *buffer_array, int *buffer_size, int *buffer_used, const bool clear)
 
void ED_gpencil_sbuffer_update_eval (bGPdata *gpd, Object *ob_eval)
 
void ED_gpencil_tag_scene_gpencil (Scene *scene)
 
void ED_gpencil_fill_vertex_color_set (ToolSettings *ts, Brush *brush, bGPDstroke *gps)
 
void ED_gpencil_point_vertex_color_set (ToolSettings *ts, Brush *brush, bGPDspoint *pt, tGPspoint *tpt)
 
void ED_gpencil_init_random_settings (Brush *brush, const int mval[2], GpRandomSettings *random_settings)
 
static void gpencil_sbuffer_vertex_color_random (bGPdata *gpd, Brush *brush, tGPspoint *tpt, const float random_color[3], float pen_pressure)
 
void ED_gpencil_sbuffer_vertex_color_set (Depsgraph *depsgraph, Object *ob, ToolSettings *ts, Brush *brush, Material *material, float random_color[3], float pen_pressure)
 
void ED_gpencil_projected_2d_bound_box (const GP_SpaceConversion *gsc, const bGPDstroke *gps, const float diff_mat[4][4], float r_min[2], float r_max[2])
 
bool ED_gpencil_stroke_check_collision (const GP_SpaceConversion *gsc, bGPDstroke *gps, const float mval[2], const int radius, const float diff_mat[4][4])
 
bool ED_gpencil_stroke_point_is_inside (const bGPDstroke *gps, const GP_SpaceConversion *gsc, const int mval[2], const float diff_mat[4][4])
 
void ED_gpencil_stroke_extremes_to2d (const GP_SpaceConversion *gsc, const float diff_mat[4][4], bGPDstroke *gps, float r_ctrl1[2], float r_ctrl2[2])
 
bGPDstrokeED_gpencil_stroke_nearest_to_ends (bContext *C, const GP_SpaceConversion *gsc, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, const float ctrl1[2], const float ctrl2[2], const float radius, int *r_index)
 
bGPDstrokeED_gpencil_stroke_join_and_trim (bGPdata *gpd, bGPDframe *gpf, bGPDstroke *gps, bGPDstroke *gps_dst, const int pt_index)
 
void ED_gpencil_stroke_close_by_distance (bGPDstroke *gps, const float threshold)
 
void ED_gpencil_layer_merge (bGPdata *gpd, bGPDlayer *gpl_src, bGPDlayer *gpl_dst, const bool reverse)
 

Function Documentation

◆ ED_annotation_data_get_active()

bGPdata* ED_annotation_data_get_active ( const bContext C)

◆ ED_annotation_data_get_active_direct()

bGPdata* ED_annotation_data_get_active_direct ( struct ID screen_id,
struct ScrArea area,
struct Scene scene 
)

Get the active Grease Pencil data-block, when context is not available.

Definition at line 236 of file gpencil_utils.c.

References blender::compositor::area(), ED_annotation_data_get_pointers_direct(), NULL, and scene.

Referenced by screen_ctx_active_annotation_layer(), and screen_ctx_annotation_data().

◆ ED_annotation_data_get_pointers()

bGPdata** ED_annotation_data_get_pointers ( const bContext C,
PointerRNA r_ptr 
)

◆ ED_annotation_data_get_pointers_direct()

bGPdata** ED_annotation_data_get_pointers_direct ( struct ID screen_id,
struct ScrArea area,
struct Scene scene,
struct PointerRNA r_ptr 
)

◆ ED_gpencil_add_defaults()

void ED_gpencil_add_defaults ( struct bContext C,
struct Object ob 
)

◆ ED_gpencil_add_object()

Object* ED_gpencil_add_object ( struct bContext C,
const float  loc[3],
unsigned short  local_view_bits 
)

◆ ED_gpencil_brush_draw_eraser()

void ED_gpencil_brush_draw_eraser ( struct Brush brush,
int  x,
int  y 
)

◆ ED_gpencil_data_get_active()

bGPdata* ED_gpencil_data_get_active ( const bContext C)

Definition at line 242 of file gpencil_utils.c.

References C, CTX_data_active_object(), Object::data, NULL, OB_GPENCIL, and Object::type.

Referenced by gpencil_actframe_delete_all_exec(), gpencil_actframe_delete_all_poll(), gpencil_actframe_delete_exec(), gpencil_actframe_delete_poll(), gpencil_blank_frame_add_exec(), gpencil_brush_cursor_draw(), gpencil_circle_select_exec(), gpencil_cutter_lasso_select(), gpencil_cutter_poll(), gpencil_cyclical_set_curve_edit_poll_property(), gpencil_delete_selected_points(), gpencil_delete_selected_strokes(), gpencil_duplicate_exec(), gpencil_editmode_toggle_exec(), gpencil_editmode_toggle_poll(), gpencil_frame_clean_fill_exec(), gpencil_frame_clean_loose_exec(), gpencil_frame_duplicate_exec(), gpencil_generic_select_exec(), gpencil_hide_exec(), gpencil_interpolate_reverse_exec(), gpencil_interpolate_reverse_poll(), gpencil_isolate_layer_exec(), gpencil_layer_copy_exec(), gpencil_layer_mask_move_exec(), gpencil_layer_move_exec(), gpencil_layer_remove_exec(), gpencil_lock_all_exec(), gpencil_lock_layer_exec(), gpencil_material_isolate_exec(), gpencil_material_lock_unsused_exec(), gpencil_material_select_exec(), gpencil_merge_layer_exec(), gpencil_paintmode_toggle_exec(), gpencil_paintmode_toggle_poll(), gpencil_reveal_exec(), gpencil_reveal_poll(), gpencil_sculpt_brush_init(), gpencil_sculptmode_toggle_exec(), gpencil_sculptmode_toggle_poll(), gpencil_select_all_exec(), gpencil_select_all_poll(), gpencil_select_alternate_exec(), gpencil_select_exec(), gpencil_select_first_exec(), gpencil_select_grouped_exec(), gpencil_select_last_exec(), gpencil_select_less_exec(), gpencil_select_linked_exec(), gpencil_select_more_exec(), gpencil_select_poll(), gpencil_select_random_exec(), gpencil_select_same_layer(), gpencil_select_same_material(), gpencil_select_vertex_color_exec(), gpencil_set_active_material_exec(), gpencil_snap_cursor_to_sel(), gpencil_snap_to_cursor(), gpencil_snap_to_grid(), gpencil_stroke_apply_thickness_exec(), gpencil_stroke_arrange_exec(), gpencil_stroke_caps_set_exec(), gpencil_stroke_change_color_exec(), gpencil_stroke_cyclical_set_exec(), gpencil_stroke_flip_exec(), gpencil_stroke_join_exec(), gpencil_stroke_normalize_exec(), gpencil_stroke_sample_exec(), gpencil_stroke_separate_exec(), gpencil_stroke_simplify_exec(), gpencil_stroke_simplify_fixed_exec(), gpencil_stroke_smooth_exec(), gpencil_stroke_split_exec(), gpencil_stroke_subdivide_exec(), gpencil_stroke_trim_exec(), gpencil_strokes_copy_exec(), gpencil_strokes_paste_poll(), gpencil_strokes_reproject_exec(), gpencil_subdivide_curve_edit_poll_property(), gpencil_unlock_all_exec(), gpencil_vertexmode_toggle_exec(), gpencil_vertexmode_toggle_poll(), gpencil_vertexpaint_brush_init(), gpencil_weightmode_toggle_exec(), gpencil_weightmode_toggle_poll(), gpencil_weightpaint_brush_init(), and viewRedrawForce().

◆ ED_gpencil_data_get_active_direct()

bGPdata* ED_gpencil_data_get_active_direct ( ScrArea area,
Object ob 
)

◆ ED_gpencil_data_get_active_evaluated()

bGPdata* ED_gpencil_data_get_active_evaluated ( const bContext C)

◆ ED_gpencil_data_get_pointers()

bGPdata** ED_gpencil_data_get_pointers ( const bContext C,
PointerRNA r_ptr 
)

◆ ED_gpencil_data_get_pointers_direct()

bGPdata** ED_gpencil_data_get_pointers_direct ( struct ScrArea area,
struct Object ob,
struct PointerRNA r_ptr 
)

Context independent (i.e. each required part is passed in instead).

Get pointer to active Grease Pencil data-block, and an RNA-pointer to trace back to whatever owns it, when context info is not available.

Definition at line 85 of file gpencil_utils.c.

References blender::compositor::area(), Object::data, Object::id, NULL, OB_GPENCIL, RNA_id_pointer_create(), SPACE_INFO, SPACE_PROPERTIES, SPACE_TOPBAR, SPACE_VIEW3D, and Object::type.

Referenced by ED_gpencil_data_get_active_direct(), ED_gpencil_data_get_pointers(), and screen_ctx_gpencil_data_owner().

◆ ED_gpencil_data_owner_is_annotation()

bool ED_gpencil_data_owner_is_annotation ( struct PointerRNA owner_ptr)

Utility to check whether the r_ptr output of ED_gpencil_data_get_pointers() is for annotation usage.

Definition at line 270 of file gpencil_utils.c.

References PointerRNA::type.

Referenced by annotation_session_initdata(), and gpencil_session_initdata().

◆ ED_gpencil_drawing_reference_get()

void ED_gpencil_drawing_reference_get ( const Scene scene,
const Object ob,
char  align_flag,
float  r_vec[3] 
)

◆ ED_gpencil_fill_vertex_color_set()

void ED_gpencil_fill_vertex_color_set ( ToolSettings ts,
Brush brush,
bGPDstroke gps 
)

◆ ED_gpencil_frame_has_selected_stroke()

bool ED_gpencil_frame_has_selected_stroke ( const bGPDframe gpf)

◆ ED_gpencil_has_keyframe_v3d()

bool ED_gpencil_has_keyframe_v3d ( Scene UNUSEDscene,
Object ob,
int  cfra 
)

◆ ED_gpencil_init_random_settings()

void ED_gpencil_init_random_settings ( Brush brush,
const int  mval[2],
GpRandomSettings random_settings 
)

◆ ED_gpencil_layer_has_selected_stroke()

bool ED_gpencil_layer_has_selected_stroke ( const bGPDlayer gpl,
const bool  is_multiedit 
)

◆ ED_gpencil_layer_merge()

void ED_gpencil_layer_merge ( struct bGPdata gpd,
struct bGPDlayer gpl_src,
struct bGPDlayer gpl_dst,
bool  reverse 
)

◆ ED_gpencil_layers_enum_itemf()

const EnumPropertyItem* ED_gpencil_layers_enum_itemf ( bContext C,
PointerRNA UNUSEDptr,
PropertyRNA UNUSEDprop,
bool r_free 
)

◆ ED_gpencil_layers_with_new_enum_itemf()

const EnumPropertyItem* ED_gpencil_layers_with_new_enum_itemf ( bContext C,
PointerRNA UNUSEDptr,
PropertyRNA UNUSEDprop,
bool r_free 
)

◆ ED_gpencil_material_enum_itemf()

const EnumPropertyItem* ED_gpencil_material_enum_itemf ( bContext C,
PointerRNA UNUSEDptr,
PropertyRNA UNUSEDprop,
bool r_free 
)

◆ ED_gpencil_point_vertex_color_set()

void ED_gpencil_point_vertex_color_set ( ToolSettings ts,
Brush brush,
bGPDspoint pt,
tGPspoint tpt 
)

◆ ED_gpencil_project_point_to_plane()

void ED_gpencil_project_point_to_plane ( const Scene scene,
const Object ob,
bGPDlayer gpl,
const RegionView3D rv3d,
const float  origin[3],
const int  axis,
bGPDspoint pt 
)

◆ ED_gpencil_project_stroke_to_plane()

void ED_gpencil_project_stroke_to_plane ( const Scene scene,
const Object ob,
const RegionView3D rv3d,
bGPDlayer gpl,
bGPDstroke gps,
const float  origin[3],
const int  axis 
)

◆ ED_gpencil_project_stroke_to_view()

void ED_gpencil_project_stroke_to_view ( bContext C,
bGPDlayer gpl,
bGPDstroke gps 
)

◆ ED_gpencil_projected_2d_bound_box()

void ED_gpencil_projected_2d_bound_box ( const GP_SpaceConversion gsc,
const bGPDstroke gps,
const float  diff_mat[4][4],
float  r_min[2],
float  r_max[2] 
)

◆ ED_gpencil_reset_layers_parent()

void ED_gpencil_reset_layers_parent ( struct Depsgraph depsgraph,
struct Object obact,
struct bGPdata gpd 
)

◆ ED_gpencil_sbuffer_ensure()

tGPspoint* ED_gpencil_sbuffer_ensure ( struct tGPspoint buffer_array,
int *  buffer_size,
int *  buffer_used,
bool  clear 
)

◆ ED_gpencil_sbuffer_update_eval()

void ED_gpencil_sbuffer_update_eval ( bGPdata gpd,
Object ob_eval 
)

◆ ED_gpencil_sbuffer_vertex_color_set()

void ED_gpencil_sbuffer_vertex_color_set ( Depsgraph depsgraph,
Object ob,
ToolSettings ts,
Brush brush,
Material material,
float  random_color[3],
float  pen_pressure 
)

◆ ED_gpencil_select_curve_toggle_all()

void ED_gpencil_select_curve_toggle_all ( bContext C,
int  action 
)

◆ ED_gpencil_select_stroke_segment()

int ED_gpencil_select_stroke_segment ( struct bGPdata gpd,
struct bGPDlayer gpl,
struct bGPDstroke gps,
struct bGPDspoint pt,
bool  select,
bool  insert,
float  scale,
float  r_hita[3],
float  r_hitb[3] 
)

◆ ED_gpencil_select_toggle_all()

void ED_gpencil_select_toggle_all ( bContext C,
int  action 
)

◆ ED_gpencil_setup_modes()

void ED_gpencil_setup_modes ( struct bContext C,
struct bGPdata gpd,
int  newmode 
)

◆ ED_gpencil_stroke_can_use()

bool ED_gpencil_stroke_can_use ( const bContext C,
const bGPDstroke gps 
)

Definition at line 535 of file gpencil_utils.c.

References blender::compositor::area(), C, CTX_wm_area(), and ED_gpencil_stroke_can_use_direct().

Referenced by createTransGPencil_curves(), createTransGPencil_strokes(), ED_gpencil_select_toggle_all(), ED_gpencil_vgroup_assign(), ED_gpencil_vgroup_deselect(), ED_gpencil_vgroup_remove(), ED_gpencil_vgroup_select(), ED_transform_calc_gizmo_stats(), gpencil_add_verts_to_dgroups(), gpencil_brush_clone_add(), gpencil_brush_clone_init(), gpencil_cutter_lasso_select(), gpencil_delete_selected_points(), gpencil_delete_selected_strokes(), gpencil_duplicate_exec(), gpencil_extract_palette_from_vertex(), gpencil_extrude_exec(), gpencil_frame_clean_fill_exec(), gpencil_frame_clean_loose_exec(), gpencil_interpolate_seq_exec(), gpencil_lock_layer_exec(), gpencil_material_lock_unsused_exec(), gpencil_material_select_exec(), gpencil_material_to_vertex_exec(), gpencil_reveal_select_frame(), gpencil_sculpt_brush_do_frame(), gpencil_sculpt_brush_init(), gpencil_select_same_layer(), gpencil_selected_hue_table(), gpencil_snap_to_cursor(), gpencil_snap_to_grid(), gpencil_stroke_arrange_exec(), gpencil_stroke_caps_set_exec(), gpencil_stroke_change_color_exec(), gpencil_stroke_cyclical_set_exec(), gpencil_stroke_flip_exec(), gpencil_stroke_join_exec(), gpencil_stroke_normalize_exec(), gpencil_stroke_pair_table(), gpencil_stroke_points_centroid(), gpencil_stroke_reset_vertex_color_exec(), gpencil_stroke_separate_exec(), gpencil_stroke_split_exec(), gpencil_stroke_trim_exec(), gpencil_strokes_copy_exec(), gpencil_strokes_paste_exec(), gpencil_strokes_reproject_exec(), gpencil_vertexpaint_brightness_contrast_exec(), gpencil_vertexpaint_brush_do_frame(), gpencil_vertexpaint_hsv_exec(), gpencil_vertexpaint_invert_exec(), gpencil_vertexpaint_levels_exec(), gpencil_vertexpaint_set_exec(), gpencil_weightpaint_brush_do_frame(), and is_any_stroke_selected().

◆ ED_gpencil_stroke_can_use_direct()

bool ED_gpencil_stroke_can_use_direct ( const ScrArea area,
const bGPDstroke gps 
)

◆ ED_gpencil_stroke_check_collision()

bool ED_gpencil_stroke_check_collision ( const GP_SpaceConversion gsc,
bGPDstroke gps,
const float  mval[2],
const int  radius,
const float  diff_mat[4][4] 
)

◆ ED_gpencil_stroke_close_by_distance()

void ED_gpencil_stroke_close_by_distance ( struct bGPDstroke gps,
float  threshold 
)

◆ ED_gpencil_stroke_extremes_to2d()

void ED_gpencil_stroke_extremes_to2d ( const GP_SpaceConversion gsc,
const float  diff_mat[4][4],
bGPDstroke gps,
float  r_ctrl1[2],
float  r_ctrl2[2] 
)

◆ ED_gpencil_stroke_join_and_trim()

bGPDstroke* ED_gpencil_stroke_join_and_trim ( struct bGPdata gpd,
struct bGPDframe gpf,
struct bGPDstroke gps,
struct bGPDstroke gps_dst,
int  pt_index 
)

◆ ED_gpencil_stroke_material_editable()

bool ED_gpencil_stroke_material_editable ( Object ob,
const bGPDlayer gpl,
const bGPDstroke gps 
)

◆ ED_gpencil_stroke_material_visible()

bool ED_gpencil_stroke_material_visible ( Object ob,
const bGPDstroke gps 
)

◆ ED_gpencil_stroke_nearest_to_ends()

bGPDstroke* ED_gpencil_stroke_nearest_to_ends ( bContext C,
const GP_SpaceConversion gsc,
bGPDlayer gpl,
bGPDframe gpf,
bGPDstroke gps,
const float  ctrl1[2],
const float  ctrl2[2],
const float  radius,
int *  r_index 
)

◆ ED_gpencil_stroke_point_is_inside()

bool ED_gpencil_stroke_point_is_inside ( const bGPDstroke gps,
const GP_SpaceConversion gsc,
const int  mval[2],
const float  diff_mat[4][4] 
)

◆ ED_gpencil_stroke_reproject()

void ED_gpencil_stroke_reproject ( Depsgraph depsgraph,
const GP_SpaceConversion gsc,
SnapObjectContext sctx,
bGPDlayer gpl,
bGPDframe gpf,
bGPDstroke gps,
const eGP_ReprojectModes  mode,
const bool  keep_original 
)

◆ ED_gpencil_tag_scene_gpencil()

void ED_gpencil_tag_scene_gpencil ( struct Scene scene)

◆ ED_gpencil_toggle_brush_cursor()

void ED_gpencil_toggle_brush_cursor ( struct bContext C,
bool  enable,
void customdata 
)

◆ ED_gpencil_tpoint_to_point()

void ED_gpencil_tpoint_to_point ( ARegion region,
float  origin[3],
const tGPspoint tpt,
bGPDspoint pt 
)

◆ ED_gpencil_update_color_uv()

void ED_gpencil_update_color_uv ( struct Main bmain,
struct Material mat 
)

◆ ED_gpencil_vgroup_assign()

void ED_gpencil_vgroup_assign ( struct bContext C,
struct Object ob,
float  weight 
)

◆ ED_gpencil_vgroup_deselect()

void ED_gpencil_vgroup_deselect ( struct bContext C,
struct Object ob 
)

◆ ED_gpencil_vgroup_remove()

void ED_gpencil_vgroup_remove ( struct bContext C,
struct Object ob 
)

◆ ED_gpencil_vgroup_select()

void ED_gpencil_vgroup_select ( struct bContext C,
struct Object ob 
)

◆ gpencil_active_brush_poll()

bool gpencil_active_brush_poll ( struct bContext C)

Poll callback for checking if there is an active brush.

Definition at line 323 of file gpencil_utils.c.

References Paint::brush, C, CTX_data_tool_settings(), ToolSettings::gp_paint, NULL, and GpPaint::paint.

◆ gpencil_active_layer_poll()

bool gpencil_active_layer_poll ( struct bContext C)

◆ gpencil_add_poll()

bool gpencil_add_poll ( struct bContext C)

Poll callback for adding data/layers - special.

Definition at line 300 of file gpencil_utils.c.

References C, CTX_data_active_object(), Object::data, NULL, and return().

Referenced by GPENCIL_OT_blank_frame_add(), GPENCIL_OT_layer_add(), and GPENCIL_OT_layer_mask_add().

◆ gpencil_apply_parent()

void gpencil_apply_parent ( struct Depsgraph depsgraph,
struct Object obact,
bGPDlayer gpl,
bGPDstroke gps 
)

Change points position relative to parent object Change position relative to parent object

Definition at line 625 of file gpencil_utils.c.

References BKE_gpencil_layer_transform_matrix_get(), copy_v3_v3(), depsgraph, invert_m4_m4(), mul_v3_m4v3(), bGPDstroke::points, bGPDstroke::totpoints, bGPDspoint::x, and zero_axis_bias_m4().

Referenced by gpencil_stroke_newfrombuffer().

◆ gpencil_apply_parent_point()

void gpencil_apply_parent_point ( struct Depsgraph depsgraph,
struct Object obact,
bGPDlayer gpl,
bGPDspoint pt 
)

◆ gpencil_brush_cursor_draw()

static void gpencil_brush_cursor_draw ( bContext C,
int  x,
int  y,
void customdata 
)
static

Helper callback for drawing the cursor itself.

Definition at line 1736 of file gpencil_utils.c.

References Brush::add_col, BKE_gpencil_object_material_from_brush_get(), BKE_paint_get_active_from_context(), Paint::brush, C, color, copy_v3_v3(), CTX_data_active_object(), CTX_data_scene(), CTX_wm_region(), ED_gpencil_brush_draw_eraser(), ED_gpencil_data_get_active(), BrushGpencilSettings::flag, bGPdata::flag, Paint::flags, GP_BRUSH_STABILIZE_MOUSE, GP_BRUSH_STABILIZE_MOUSE_TEMP, GP_DATA_STROKE_PAINTMODE, ToolSettings::gp_paint, GP_SCULPT_FLAG_INVERT, GP_SCULPT_FLAG_TMP_INVERT, ToolSettings::gp_sculptpaint, Material::gp_style, ToolSettings::gp_vertexpaint, ToolSettings::gp_weightpaint, GPAINT_TOOL_DRAW, GPAINT_TOOL_ERASE, GPAINT_TOOL_TINT, gpencil_check_cursor_region(), GPENCIL_PAINT_MODE, GPENCIL_SCULPT_MODE, Brush::gpencil_settings, Brush::gpencil_tool, GPENCIL_VERTEX_MODE, GPENCIL_WEIGHT_MODE, GPU_blend(), GPU_BLEND_ALPHA, GPU_BLEND_NONE, GPU_COMP_F32, GPU_FETCH_FLOAT, GPU_line_smooth(), GPU_PRIM_LINES, GPU_SHADER_2D_UNIFORM_COLOR, GPU_vertformat_attr_add(), imm_draw_circle_fill_2d(), imm_draw_circle_wire_2d(), immBegin(), immBindBuiltinProgram(), immEnd(), immUnbindProgram(), immUniformColor4f(), immVertex2f(), immVertexFormat(), mul_v3_v3fl(), NULL, GpPaint::paint, GpVertexPaint::paint, GpSculptPaint::paint, GpWeightPaint::paint, PAINT_SHOW_BRUSH, pos, Brush::rgb, bGPdata::runtime, bGPdata_Runtime::sbuffer_used, scene, BrushGpencilSettings::sculpt_flag, Brush::size, MaterialGPencilStyle::stroke_rgba, Brush::sub_col, Scene::toolsettings, ARegion::winrct, x, rcti::xmin, y, and rcti::ymin.

Referenced by ED_gpencil_toggle_brush_cursor().

◆ gpencil_brush_cursor_poll()

static bool gpencil_brush_cursor_poll ( bContext C)
static

Definition at line 1725 of file gpencil_utils.c.

References C, and WM_toolsystem_active_tool_is_brush().

Referenced by ED_gpencil_toggle_brush_cursor().

◆ gpencil_calc_factor()

static float gpencil_calc_factor ( const float  p2d_a1[2],
const float  p2d_a2[2],
const float  r_hit2d[2] 
)
static

Definition at line 2238 of file gpencil_utils.c.

References interp_v2_v2v2(), len_squared_v2v2(), and v1.

Referenced by ED_gpencil_select_stroke_segment().

◆ gpencil_check_collision()

static bool gpencil_check_collision ( bGPDstroke gps,
bGPDstroke **  gps_array,
GHash all_2d,
int  totstrokes,
const float  p2d_a1[2],
const float  p2d_a2[2],
float  r_hit[2] 
)
static

◆ gpencil_check_cursor_region()

static bool gpencil_check_cursor_region ( bContext C,
const int  mval_i[2] 
)
static

◆ gpencil_copy_points()

static void gpencil_copy_points ( bGPDstroke gps,
bGPDspoint pt,
bGPDspoint pt_final,
int  i,
int  i2 
)
static

◆ gpencil_insert_point()

static void gpencil_insert_point ( bGPdata gpd,
bGPDstroke gps,
bGPDspoint a_pt,
bGPDspoint b_pt,
const float  co_a[3],
const float  co_b[3] 
)
static

◆ gpencil_point_3d_to_xy()

void gpencil_point_3d_to_xy ( const GP_SpaceConversion gsc,
short  flag,
const float  pt[3],
float  xy[2] 
)

◆ gpencil_point_conversion_init()

void gpencil_point_conversion_init ( struct bContext C,
GP_SpaceConversion r_gsc 
)

◆ gpencil_point_to_parent_space()

void gpencil_point_to_parent_space ( const bGPDspoint pt,
const float  diff_mat[4][4],
bGPDspoint r_pt 
)

◆ gpencil_point_to_xy()

void gpencil_point_to_xy ( const GP_SpaceConversion gsc,
const bGPDstroke gps,
const bGPDspoint pt,
int *  r_x,
int *  r_y 
)

◆ gpencil_point_to_xy_fl()

void gpencil_point_to_xy_fl ( const GP_SpaceConversion gsc,
const bGPDstroke gps,
const bGPDspoint pt,
float r_x,
float r_y 
)

Convert a Grease Pencil coordinate (i.e. can be 2D or 3D) to screen-space (2D).

Just like gpencil_point_to_xy(), except the resulting coordinates are floats not ints. Use this version to solve "stair-step" artifacts which may arise when round-tripping the calculations.

Parameters
r_xThe screen-space x-coordinate of the point.
r_yThe screen-space y-coordinate of the point.
Warning
This assumes that the caller has already checked whether the stroke in question can be drawn.

Definition at line 707 of file gpencil_utils.c.

References GP_SpaceConversion::area, BLI_assert, BLI_rctf_size_x(), BLI_rctf_size_y(), ED_view3d_project_float_global(), bGPDstroke::flag, float(), GP_STROKE_2DSPACE, GP_STROKE_3DSPACE, GP_SpaceConversion::mat, mul_m4_v3(), NULL, GP_SpaceConversion::region, SPACE_VIEW3D, ScrArea::spacetype, GP_SpaceConversion::subrect, UI_view2d_view_to_region_clip(), GP_SpaceConversion::v2d, V2D_IS_CLIPPED, V3D_PROJ_RET_OK, V3D_PROJ_TEST_NOP, ARegion::winx, ARegion::winy, bGPDspoint::x, rctf::xmin, bGPDspoint::y, and rctf::ymin.

Referenced by ED_gpencil_project_stroke_to_view(), ED_gpencil_projected_2d_bound_box(), ED_gpencil_stroke_extremes_to2d(), ED_gpencil_stroke_nearest_to_ends(), ED_gpencil_stroke_reproject(), and gpencil_stroke_need_flip().

◆ gpencil_point_xy_to_3d()

bool gpencil_point_xy_to_3d ( const GP_SpaceConversion gsc,
struct Scene scene,
const float  screen_co[2],
float  r_out[3] 
)

Project screen-space coordinates to 3D-space

For use with editing tools where it is easier to perform the operations in 2D, and then later convert the transformed points back to 3D.

Parameters
screen_coThe screen-space 2D coordinates to convert to
r_outThe resulting 3D coordinates of the input point
Note
We include this as a utility function, since the standard method involves quite a few steps, which are invariably always the same for all GPencil operations. So, it's nicer to just centralize these.
Warning
Assumes that it is getting called in a 3D view only.

Definition at line 818 of file gpencil_utils.c.

References ED_gpencil_drawing_reference_get(), ED_view3d_calc_zfac(), ED_view3d_project_float_global(), ED_view3d_win_to_delta(), ToolSettings::gpencil_v3d_align, GP_SpaceConversion::ob, GP_SpaceConversion::region, ARegion::regiondata, scene, sub_v2_v2v2(), sub_v3_v3v3(), Scene::toolsettings, V3D_PROJ_RET_OK, V3D_PROJ_TEST_NOP, and zero_v3().

Referenced by ED_gpencil_project_stroke_to_view(), and ED_gpencil_stroke_reproject().

◆ gpencil_sbuffer_vertex_color_random()

static void gpencil_sbuffer_vertex_color_random ( bGPdata gpd,
Brush brush,
tGPspoint tpt,
const float  random_color[3],
float  pen_pressure 
)
static

◆ gpencil_stroke_convertcoords()

static void gpencil_stroke_convertcoords ( ARegion region,
const tGPspoint point2D,
const float  origin[3],
float  out[3] 
)
static

◆ gpencil_stroke_convertcoords_tpoint()

void gpencil_stroke_convertcoords_tpoint ( Scene scene,
ARegion region,
Object ob,
const tGPspoint point2D,
float depth,
float  r_out[3] 
)

◆ gpencil_stroke_inside_circle()

bool gpencil_stroke_inside_circle ( const float  mval[2],
int  rad,
int  x0,
int  y0,
int  x1,
int  y1 
)

Check whether a given stroke segment is inside a circular brush

Parameters
mvalThe current screen-space coordinates (midpoint) of the brush
radThe radius of the brush
x0,y0The screen-space x and y coordinates of the start of the stroke segment
x1,y1The screen-space x and y coordinates of the end of the stroke segment

Definition at line 462 of file gpencil_utils.c.

References edge_inside_circle(), and y1.

Referenced by annotation_stroke_eraser_dostroke(), get_automasking_strokes_list(), gpencil_stroke_eraser_dostroke(), gpencil_vertexpaint_select_stroke(), and gpencil_weightpaint_select_stroke().

◆ gpencil_subdivide_stroke()

void gpencil_subdivide_stroke ( bGPdata gpd,
bGPDstroke gps,
int  subdivide 
)