Blender V4.3
gpencil_legacy.cc File Reference
#include <cmath>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <optional>
#include "CLG_log.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_math_matrix.h"
#include "BLI_math_vector.h"
#include "BLI_string_utils.hh"
#include "BLT_translation.hh"
#include "IMB_interp.hh"
#include "DNA_gpencil_legacy_types.h"
#include "DNA_material_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_space_types.h"
#include "BKE_action.hh"
#include "BKE_anim_data.hh"
#include "BKE_brush.hh"
#include "BKE_collection.hh"
#include "BKE_colortools.hh"
#include "BKE_deform.hh"
#include "BKE_gpencil_geom_legacy.h"
#include "BKE_gpencil_legacy.h"
#include "BKE_gpencil_update_cache_legacy.h"
#include "BKE_icons.h"
#include "BKE_idtype.hh"
#include "BKE_image.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_query.hh"
#include "BKE_main.hh"
#include "BKE_material.h"
#include "BKE_paint.hh"
#include "BLI_math_color.h"
#include "DEG_depsgraph_query.hh"
#include "BLO_read_write.hh"

Go to the source code of this file.

Macros

#define DNA_DEPRECATED_ALLOW
 

Functions

static void greasepencil_copy_data (Main *, std::optional< Library * >, ID *id_dst, const ID *id_src, const int)
 
static void greasepencil_free_data (ID *id)
 
static void greasepencil_foreach_id (ID *id, LibraryForeachIDData *data)
 
static void greasepencil_blend_write (BlendWriter *writer, ID *id, const void *id_address)
 
void BKE_gpencil_blend_read_data (BlendDataReader *reader, bGPdata *gpd)
 
static void greasepencil_blend_read_data (BlendDataReader *reader, ID *id)
 
void BKE_gpencil_batch_cache_dirty_tag (bGPdata *gpd)
 
void BKE_gpencil_batch_cache_free (bGPdata *gpd)
 
void BKE_gpencil_free_point_weights (MDeformVert *dvert)
 
void BKE_gpencil_free_stroke_weights (bGPDstroke *gps)
 
void BKE_gpencil_free_stroke_editcurve (bGPDstroke *gps)
 
void BKE_gpencil_free_stroke (bGPDstroke *gps)
 
bool BKE_gpencil_free_strokes (bGPDframe *gpf)
 
void BKE_gpencil_free_frames (bGPDlayer *gpl)
 
void BKE_gpencil_free_layer_masks (bGPDlayer *gpl)
 
void BKE_gpencil_free_layers (ListBase *list)
 
void BKE_gpencil_free_legacy_palette_data (ListBase *list)
 
void BKE_gpencil_free_data (bGPdata *gpd, bool free_all)
 
void BKE_gpencil_tag (bGPdata *gpd)
 
bGPDframeBKE_gpencil_frame_addnew (bGPDlayer *gpl, int cframe)
 
bGPDframeBKE_gpencil_frame_addcopy (bGPDlayer *gpl, int cframe)
 
bGPDlayerBKE_gpencil_layer_addnew (bGPdata *gpd, const char *name, const bool setactive, const bool add_to_header)
 
bGPdataBKE_gpencil_data_addnew (Main *bmain, const char name[])
 
bGPDstrokeBKE_gpencil_stroke_new (int mat_idx, int totpoints, short thickness)
 
bGPDstrokeBKE_gpencil_stroke_add (bGPDframe *gpf, int mat_idx, int totpoints, short thickness, const bool insert_at_head)
 
bGPDcurveBKE_gpencil_stroke_editcurve_new (const int tot_curve_points)
 
void BKE_gpencil_stroke_weights_duplicate (bGPDstroke *gps_src, bGPDstroke *gps_dst)
 
bGPDstrokeBKE_gpencil_stroke_duplicate (bGPDstroke *gps_src, const bool dup_points, const bool)
 
bGPDframeBKE_gpencil_frame_duplicate (const bGPDframe *gpf_src, const bool dup_strokes)
 
bGPDlayerBKE_gpencil_layer_duplicate (const bGPDlayer *gpl_src, const bool dup_frames, const bool dup_strokes)
 
bGPdataBKE_gpencil_data_duplicate (Main *bmain, const bGPdata *gpd_src, bool internal_copy)
 
bool BKE_gpencil_layer_is_editable (const bGPDlayer *gpl)
 
bGPDframeBKE_gpencil_layer_frame_find (bGPDlayer *gpl, int cframe)
 
bGPDframeBKE_gpencil_layer_frame_get (bGPDlayer *gpl, int cframe, eGP_GetFrame_Mode addnew)
 
bool BKE_gpencil_layer_frame_delete (bGPDlayer *gpl, bGPDframe *gpf)
 
bGPDlayerBKE_gpencil_layer_named_get (bGPdata *gpd, const char *name)
 
void BKE_gpencil_layer_mask_remove (bGPDlayer *gpl, bGPDlayer_Mask *mask)
 
void BKE_gpencil_layer_mask_remove_ref (bGPdata *gpd, const char *name)
 
static int gpencil_cb_sort_masks (const void *arg1, const void *arg2)
 
void BKE_gpencil_layer_mask_sort (bGPdata *gpd, bGPDlayer *gpl)
 
void BKE_gpencil_layer_mask_sort_all (bGPdata *gpd)
 
void BKE_gpencil_layer_mask_copy (const bGPDlayer *gpl_src, bGPDlayer *gpl_dst)
 
void BKE_gpencil_layer_mask_cleanup (bGPdata *gpd, bGPDlayer *gpl)
 
static int gpencil_cb_cmp_frame (void *thunk, const void *a, const void *b)
 
void BKE_gpencil_layer_frames_sort (bGPDlayer *gpl, bool *r_has_duplicate_frames)
 
bGPDlayerBKE_gpencil_layer_active_get (bGPdata *gpd)
 
void BKE_gpencil_layer_active_set (bGPdata *gpd, bGPDlayer *active)
 
void BKE_gpencil_layer_autolock_set (bGPdata *gpd, const bool unlock)
 
void BKE_gpencil_layer_delete (bGPdata *gpd, bGPDlayer *gpl)
 
void BKE_gpencil_brush_material_set (Brush *brush, Material *ma)
 
void BKE_gpencil_frame_range_selected (bGPDlayer *gpl, int *r_initframe, int *r_endframe)
 
float BKE_gpencil_multiframe_falloff_calc (bGPDframe *gpf, int actnum, int f_init, int f_end, CurveMapping *cur_falloff)
 
void BKE_gpencil_palette_ensure (Main *bmain, Scene *scene)
 
static bool gpencil_is_layer_mask (ViewLayer *view_layer, bGPdata *gpd, bGPDlayer *gpl_mask)
 
Advanced Iterator

Iterate over all visible stroke of all visible layers inside a gpObject. Also take into account onion-skinning.

void BKE_gpencil_visible_stroke_advanced_iter (ViewLayer *view_layer, Object *ob, gpIterCb layer_cb, gpIterCb stroke_cb, void *thunk, bool do_onion, int cfra)
 
void BKE_gpencil_frame_original_pointers_update (const bGPDframe *gpf_orig, const bGPDframe *gpf_eval)
 
void BKE_gpencil_layer_original_pointers_update (const bGPDlayer *gpl_orig, const bGPDlayer *gpl_eval)
 
void BKE_gpencil_data_update_orig_pointers (const bGPdata *gpd_orig, const bGPdata *gpd_eval)
 
void BKE_gpencil_update_orig_pointers (const Object *ob_orig, const Object *ob_eval)
 
void BKE_gpencil_layer_transform_matrix_get (const Depsgraph *depsgraph, Object *obact, bGPDlayer *gpl, float diff_mat[4][4])
 
void BKE_gpencil_update_layer_transforms (const Depsgraph *depsgraph, Object *ob)
 
int BKE_gpencil_material_find_index_by_name_prefix (Object *ob, const char *name_prefix)
 

Variables

static CLG_LogRef LOG = {"bke.gpencil"}
 
IDTypeInfo IDType_ID_GD_LEGACY
 
void(* BKE_gpencil_batch_cache_dirty_tag_cb )(bGPdata *gpd) = nullptr
 
void(* BKE_gpencil_batch_cache_free_cb )(bGPdata *gpd) = nullptr
 

Macro Definition Documentation

◆ DNA_DEPRECATED_ALLOW

#define DNA_DEPRECATED_ALLOW

Definition at line 30 of file gpencil_legacy.cc.

Function Documentation

◆ BKE_gpencil_batch_cache_dirty_tag()

void BKE_gpencil_batch_cache_dirty_tag ( bGPdata * gpd)

◆ BKE_gpencil_batch_cache_free()

void BKE_gpencil_batch_cache_free ( bGPdata * gpd)

Definition at line 313 of file gpencil_legacy.cc.

References BKE_gpencil_batch_cache_free_cb.

Referenced by BKE_gpencil_free_data().

◆ BKE_gpencil_blend_read_data()

◆ BKE_gpencil_brush_material_set()

void BKE_gpencil_brush_material_set ( struct Brush * brush,
struct Material * material )

Set grease pencil brush material.

Parameters
brushBrush
materialMaterial

Definition at line 1361 of file gpencil_legacy.cc.

References BKE_brush_tag_unsaved_changes(), BLI_assert, Brush::gpencil_settings, Material::id, id_us_min(), id_us_plus(), and BrushGpencilSettings::material.

◆ BKE_gpencil_data_addnew()

◆ BKE_gpencil_data_duplicate()

bGPdata * BKE_gpencil_data_duplicate ( Main * bmain,
const bGPdata * gpd_src,
bool internal_copy )

◆ BKE_gpencil_data_update_orig_pointers()

void BKE_gpencil_data_update_orig_pointers ( const bGPdata * gpd_orig,
const bGPdata * gpd_eval )

◆ BKE_gpencil_frame_addcopy()

bGPDframe * BKE_gpencil_frame_addcopy ( struct bGPDlayer * gpl,
int cframe )

Add a copy of the active gp-frame to the given layer.

Parameters
gplGrease pencil layer
cframeFrame number
Returns
Pointer to new frame

Definition at line 541 of file gpencil_legacy.cc.

References bGPDlayer::actframe, BKE_gpencil_frame_addnew(), BKE_gpencil_frame_duplicate(), BKE_gpencil_free_strokes(), BLI_addtail(), BLI_insertlinkbefore(), bGPDframe::framenum, bGPDlayer::frames, LISTBASE_FOREACH, and MEM_freeN().

Referenced by BKE_gpencil_layer_frame_get(), createTransGPencil_curves(), and createTransGPencil_strokes().

◆ BKE_gpencil_frame_addnew()

bGPDframe * BKE_gpencil_frame_addnew ( struct bGPDlayer * gpl,
int cframe )

Add a new gp-frame to the given layer.

Parameters
gplGrease pencil layer
cframeFrame number
Returns
Pointer to new frame

Definition at line 488 of file gpencil_legacy.cc.

References BLI_addtail(), BLI_assert, BLI_insertlinkbefore(), CLOG_ERROR, ListBase::first, bGPDframe::framenum, bGPDlayer::frames, LOG, MEM_callocN, MEM_freeN(), bGPDframe::next, and state.

Referenced by BKE_gpencil_frame_addcopy(), and BKE_gpencil_layer_frame_get().

◆ BKE_gpencil_frame_duplicate()

bGPDframe * BKE_gpencil_frame_duplicate ( const bGPDframe * gpf_src,
const bool dup_strokes )

◆ BKE_gpencil_frame_original_pointers_update()

◆ BKE_gpencil_frame_range_selected()

void BKE_gpencil_frame_range_selected ( struct bGPDlayer * gpl,
int * r_initframe,
int * r_endframe )

Get range of selected frames in layer. Always the active frame is considered as selected, so if no more selected the range will be equal to the current active frame.

Parameters
gplLayer.
r_initframeNumber of first selected frame.
r_endframeNumber of last selected frame.

Definition at line 1377 of file gpencil_legacy.cc.

References bGPDlayer::actframe, bGPDframe::framenum, bGPDlayer::frames, GP_FRAME_SELECT, and LISTBASE_FOREACH.

Referenced by createTransGPencil_curves(), and createTransGPencil_strokes().

◆ BKE_gpencil_free_data()

void BKE_gpencil_free_data ( struct bGPdata * gpd,
bool free_all )

◆ BKE_gpencil_free_frames()

void BKE_gpencil_free_frames ( struct bGPDlayer * gpl)

◆ BKE_gpencil_free_layer_masks()

void BKE_gpencil_free_layer_masks ( bGPDlayer * gpl)

◆ BKE_gpencil_free_layers()

void BKE_gpencil_free_layers ( struct ListBase * list)

Free all of the gp-layers for a viewport (list should be &gpd->layers or so).

Definition at line 428 of file gpencil_legacy.cc.

References BKE_gpencil_free_frames(), BKE_gpencil_free_layer_masks(), BLI_freelinkN(), and bGPDlayer::next.

Referenced by BKE_gpencil_free_data(), ED_gpencil_anim_copybuf_free(), and ED_undo_gpencil_step().

◆ BKE_gpencil_free_legacy_palette_data()

void BKE_gpencil_free_legacy_palette_data ( struct ListBase * list)

Free all of the palettes & colors (list should be &gpd->palettes or so).

Definition at line 451 of file gpencil_legacy.cc.

References BLI_freelistN(), BLI_listbase_clear(), LISTBASE_FOREACH_MUTABLE, and MEM_freeN().

Referenced by BKE_gpencil_free_data().

◆ BKE_gpencil_free_point_weights()

void BKE_gpencil_free_point_weights ( MDeformVert * dvert)

Definition at line 323 of file gpencil_legacy.cc.

References MDeformVert::dw, and MEM_SAFE_FREE.

Referenced by BKE_gpencil_free_stroke_weights().

◆ BKE_gpencil_free_stroke()

◆ BKE_gpencil_free_stroke_editcurve()

void BKE_gpencil_free_stroke_editcurve ( bGPDstroke * gps)

Definition at line 347 of file gpencil_legacy.cc.

References bGPDcurve::curve_points, bGPDstroke::editcurve, and MEM_freeN().

Referenced by BKE_gpencil_free_stroke().

◆ BKE_gpencil_free_stroke_weights()

void BKE_gpencil_free_stroke_weights ( bGPDstroke * gps)

◆ BKE_gpencil_free_strokes()

bool BKE_gpencil_free_strokes ( struct bGPDframe * gpf)

◆ BKE_gpencil_layer_active_get()

◆ BKE_gpencil_layer_active_set()

void BKE_gpencil_layer_active_set ( struct bGPdata * gpd,
struct bGPDlayer * active )

◆ BKE_gpencil_layer_addnew()

◆ BKE_gpencil_layer_autolock_set()

void BKE_gpencil_layer_autolock_set ( struct bGPdata * gpd,
bool unlock )

Set locked layers for autolock mode.

Parameters
gpdGrease pencil data-block
unlockUnlock flag

Definition at line 1309 of file gpencil_legacy.cc.

References BKE_gpencil_layer_active_get(), BLI_assert, bGPdata::flag, GP_DATA_AUTOLOCK_LAYERS, GP_LAYER_LOCKED, bGPdata::layers, and LISTBASE_FOREACH.

Referenced by click_select_channel_gplayer(), and ED_gpencil_set_active_channel().

◆ BKE_gpencil_layer_delete()

void BKE_gpencil_layer_delete ( struct bGPdata * gpd,
struct bGPDlayer * gpl )

◆ BKE_gpencil_layer_duplicate()

bGPDlayer * BKE_gpencil_layer_duplicate ( const bGPDlayer * gpl_src,
const bool dup_frames,
const bool dup_strokes )

◆ BKE_gpencil_layer_frame_delete()

bool BKE_gpencil_layer_frame_delete ( struct bGPDlayer * gpl,
struct bGPDframe * gpf )

Delete the given frame from a layer.

Parameters
gplGrease pencil layer
gpfGrease pencil frame
Returns
True if delete was done

Definition at line 1131 of file gpencil_legacy.cc.

References bGPDlayer::actframe, BKE_gpencil_free_strokes(), BLI_freelinkN(), ELEM, bGPDlayer::frames, and bGPDframe::prev.

Referenced by ED_gpencil_anim_copybuf_paste(), ED_gpencil_layer_frames_delete(), gpencil_actframe_delete_exec(), and posttrans_gpd_clean().

◆ BKE_gpencil_layer_frame_find()

bGPDframe * BKE_gpencil_layer_frame_find ( struct bGPDlayer * gpl,
int cframe )

Look up the gp-frame on the requested frame number, but don't add a new one.

Parameters
gplGrease pencil layer
cframeFrame number
Returns
Pointer to frame

Definition at line 954 of file gpencil_legacy.cc.

References bGPDlayer::frames, and LISTBASE_FOREACH_BACKWARD.

Referenced by ED_gpencil_select_frame().

◆ BKE_gpencil_layer_frame_get()

bGPDframe * BKE_gpencil_layer_frame_get ( struct bGPDlayer * gpl,
int cframe,
eGP_GetFrame_Mode addnew )

Get the appropriate gp-frame from a given layer

  • this sets the layer's actframe var (if allowed to)
  • extension beyond range (if first gp-frame is after all frame in interest and cannot add)
Parameters
gplGrease pencil layer
cframeFrame number
addnewAdd option
Returns
Pointer to new frame

Definition at line 968 of file gpencil_legacy.cc.

References abs(), bGPDlayer::actframe, BKE_gpencil_frame_addcopy(), BKE_gpencil_frame_addnew(), CLOG_STR_ERROR, ListBase::first, bGPDframe::flag, bGPDlayer::flag, bGPDframe::framenum, bGPDlayer::frames, GP_FRAME_PAINT, GP_GETFRAME_ADD_COPY, GP_LAYER_FRAMELOCK, ListBase::last, LOG, bGPDframe::next, and bGPDframe::prev.

Referenced by annotation_draw_data_layers(), annotation_paint_initstroke(), ED_gpencil_anim_copybuf_paste(), gpencil_actframe_delete_exec(), gpencil_layer_add_exec(), insert_gpencil_key(), view3d_ruler_from_gpencil(), and view3d_ruler_to_gpencil().

◆ BKE_gpencil_layer_frames_sort()

void BKE_gpencil_layer_frames_sort ( struct bGPDlayer * gpl,
bool * r_has_duplicate_frames )

Sort grease pencil frames.

Parameters
gplGrease pencil layer
r_has_duplicate_framesDuplicated frames flag

Definition at line 1264 of file gpencil_legacy.cc.

References BLI_listbase_sort_r(), bGPDlayer::frames, and gpencil_cb_cmp_frame().

Referenced by ANIM_animdata_update(), and posttrans_gpd_clean().

◆ BKE_gpencil_layer_is_editable()

bool BKE_gpencil_layer_is_editable ( const bGPDlayer * gpl)

Definition at line 938 of file gpencil_legacy.cc.

References bGPDlayer::flag, GP_LAYER_HIDE, and GP_LAYER_LOCKED.

◆ BKE_gpencil_layer_mask_cleanup()

void BKE_gpencil_layer_mask_cleanup ( struct bGPdata * gpd,
struct bGPDlayer * gpl )

◆ BKE_gpencil_layer_mask_copy()

void BKE_gpencil_layer_mask_copy ( const bGPDlayer * gpl_src,
bGPDlayer * gpl_dst )

◆ BKE_gpencil_layer_mask_remove()

void BKE_gpencil_layer_mask_remove ( struct bGPDlayer * gpl,
struct bGPDlayer_Mask * mask )

Remove grease pencil mask layer.

Parameters
gplGrease pencil layer
maskGrease pencil mask layer

Definition at line 1162 of file gpencil_legacy.cc.

References bGPDlayer::act_mask, BLI_freelinkN(), CLAMP_MIN, and bGPDlayer::mask_layers.

Referenced by BKE_gpencil_layer_mask_cleanup(), and BKE_gpencil_layer_mask_remove_ref().

◆ BKE_gpencil_layer_mask_remove_ref()

void BKE_gpencil_layer_mask_remove_ref ( struct bGPdata * gpd,
const char * name )

Remove any reference to mask layer.

Parameters
gpdGrease pencil data-block
nameName of the mask layer

Definition at line 1169 of file gpencil_legacy.cc.

References BKE_gpencil_layer_mask_remove(), bGPdata::layers, LISTBASE_FOREACH, mask(), bGPDlayer_Mask::next, and STREQ.

Referenced by BKE_gpencil_layer_delete().

◆ BKE_gpencil_layer_mask_sort()

void BKE_gpencil_layer_mask_sort ( struct bGPdata * gpd,
struct bGPDlayer * gpl )

Sort grease pencil mask layers.

Parameters
gpdGrease pencil data-block
gplGrease pencil layer

Definition at line 1202 of file gpencil_legacy.cc.

References BKE_gpencil_layer_named_get(), BLI_findindex(), BLI_listbase_sort(), gpencil_cb_sort_masks(), bGPdata::layers, LISTBASE_FOREACH, and bGPDlayer::mask_layers.

Referenced by BKE_gpencil_layer_mask_sort_all().

◆ BKE_gpencil_layer_mask_sort_all()

void BKE_gpencil_layer_mask_sort_all ( struct bGPdata * gpd)

Sort all grease pencil mask layer.

Parameters
gpdGrease pencil data-block

Definition at line 1217 of file gpencil_legacy.cc.

References BKE_gpencil_layer_mask_sort(), bGPdata::layers, and LISTBASE_FOREACH.

Referenced by gpencil_layer_move_exec(), and gpencil_layer_remove_exec().

◆ BKE_gpencil_layer_named_get()

bGPDlayer * BKE_gpencil_layer_named_get ( struct bGPdata * gpd,
const char * name )

Get layer by name

Parameters
gpdGrease pencil data-block
nameLayer name
Returns
Pointer to layer

Definition at line 1154 of file gpencil_legacy.cc.

References BLI_findstring(), bGPdata::layers, and offsetof.

Referenced by BKE_gpencil_layer_mask_cleanup(), BKE_gpencil_layer_mask_sort(), and gpencil_layer_cache_add().

◆ BKE_gpencil_layer_original_pointers_update()

void BKE_gpencil_layer_original_pointers_update ( const bGPDlayer * gpl_orig,
const bGPDlayer * gpl_eval )

◆ BKE_gpencil_layer_transform_matrix_get()

◆ BKE_gpencil_material_find_index_by_name_prefix()

int BKE_gpencil_material_find_index_by_name_prefix ( struct Object * ob,
const char * name_prefix )

Find material by name prefix.

Parameters
obObject pointer
name_prefixPrefix name of the material
Returns
Index

Definition at line 1932 of file gpencil_legacy.cc.

References BKE_object_material_get(), Material::gp_style, Material::id, ID::name, STREQLEN, and Object::totcol.

◆ BKE_gpencil_multiframe_falloff_calc()

float BKE_gpencil_multiframe_falloff_calc ( struct bGPDframe * gpf,
int actnum,
int f_init,
int f_end,
struct CurveMapping * cur_falloff )

Get Falloff factor base on frame range

Parameters
gpfFrame.
actnumNumber of active frame in layer.
f_initNumber of first selected frame.
f_endNumber of last selected frame.
cur_falloffCurve with falloff factors.

Definition at line 1394 of file gpencil_legacy.cc.

References BKE_curvemapping_evaluateF(), float, and bGPDframe::framenum.

Referenced by createTransGPencil_curves(), and createTransGPencil_strokes().

◆ BKE_gpencil_palette_ensure()

◆ BKE_gpencil_stroke_add()

bGPDstroke * BKE_gpencil_stroke_add ( struct bGPDframe * gpf,
int mat_idx,
int totpoints,
short thickness,
bool insert_at_head )

Create a new stroke and add to frame.

Parameters
gpfGrease pencil frame
mat_idxMaterial index
totpointsTotal points
thicknessStroke thickness
insert_at_headAdd to the head of the strokes list
Returns
Pointer to new stroke

Definition at line 767 of file gpencil_legacy.cc.

References BKE_gpencil_stroke_new(), BLI_addhead(), BLI_addtail(), and bGPDframe::strokes.

◆ BKE_gpencil_stroke_duplicate()

bGPDstroke * BKE_gpencil_stroke_duplicate ( struct bGPDstroke * gps_src,
bool dup_points,
bool dup_curve )

Make a copy of a given grease-pencil stroke.

Parameters
gps_srcSource grease pencil strokes.
dup_pointsDuplicate points data.
dup_curveDuplicate curve data.
Returns
Pointer to new stroke.

Definition at line 808 of file gpencil_legacy.cc.

References BKE_gpencil_stroke_weights_duplicate(), bGPDstroke::dvert, bGPDstroke::editcurve, MEM_dupallocN, bGPDstroke::next, bGPDstroke::points, bGPDstroke::prev, and bGPDstroke::triangles.

Referenced by annotation_stroke_newfrombuffer(), BKE_gpencil_frame_duplicate(), BKE_gpencil_stroke_delete_tagged_points(), ED_gpencil_anim_copybuf_paste(), and gpencil_stroke_join_islands().

◆ BKE_gpencil_stroke_editcurve_new()

bGPDcurve * BKE_gpencil_stroke_editcurve_new ( const int tot_curve_points)

◆ BKE_gpencil_stroke_new()

bGPDstroke * BKE_gpencil_stroke_new ( int mat_idx,
int totpoints,
short thickness )

Create a new stroke, with pre-allocated data buffers.

Parameters
mat_idxIndex of the material
totpointsTotal points
thicknessStroke thickness
Returns
Pointer to new stroke

Definition at line 730 of file gpencil_legacy.cc.

References bGPDstroke::aspect_ratio, copy_v2_fl(), bGPDstroke::dvert, bGPDstroke::editcurve, bGPDstroke::fill_opacity_fac, bGPDstroke::flag, GP_STROKE_3DSPACE, bGPDstroke::hardness, bGPDstroke::inittime, bGPDstroke::mat_nr, MEM_callocN, bGPDstroke::points, bGPDstroke::thickness, bGPDstroke::tot_triangles, bGPDstroke::totpoints, bGPDstroke::triangles, and bGPDstroke::uv_scale.

Referenced by BKE_gpencil_stroke_add().

◆ BKE_gpencil_stroke_weights_duplicate()

void BKE_gpencil_stroke_weights_duplicate ( struct bGPDstroke * gps_src,
struct bGPDstroke * gps_dst )

Make a copy of a given gpencil weights.

Parameters
gps_srcSource grease pencil stroke
gps_dstDestination grease pencil stroke

Definition at line 798 of file gpencil_legacy.cc.

References BKE_defvert_array_copy(), BLI_assert, bGPDstroke::dvert, and bGPDstroke::totpoints.

Referenced by BKE_gpencil_stroke_duplicate().

◆ BKE_gpencil_tag()

void BKE_gpencil_tag ( struct bGPdata * gpd)

Tag data-block for depsgraph update. Wrapper to avoid include Depsgraph tag functions in other modules.

Parameters
gpdGrease pencil data-block.

Definition at line 480 of file gpencil_legacy.cc.

References DEG_id_tag_update(), bGPdata::id, ID_RECALC_GEOMETRY, and ID_RECALC_TRANSFORM.

Referenced by insert_gpencil_key().

◆ BKE_gpencil_update_layer_transforms()

◆ BKE_gpencil_update_orig_pointers()

void BKE_gpencil_update_orig_pointers ( const Object * ob_orig,
const Object * ob_eval )

Definition at line 1774 of file gpencil_legacy.cc.

References BKE_gpencil_data_update_orig_pointers(), and Object::data.

◆ BKE_gpencil_visible_stroke_advanced_iter()

◆ gpencil_cb_cmp_frame()

static int gpencil_cb_cmp_frame ( void * thunk,
const void * a,
const void * b )
static

Definition at line 1243 of file gpencil_legacy.cc.

References b, bGPDframe::flag, bGPDframe::framenum, and GP_FRAME_SELECT.

Referenced by BKE_gpencil_layer_frames_sort().

◆ gpencil_cb_sort_masks()

static int gpencil_cb_sort_masks ( const void * arg1,
const void * arg2 )
static

Definition at line 1185 of file gpencil_legacy.cc.

References bGPDlayer_Mask::sort_index.

Referenced by BKE_gpencil_layer_mask_sort().

◆ gpencil_is_layer_mask()

static bool gpencil_is_layer_mask ( ViewLayer * view_layer,
bGPdata * gpd,
bGPDlayer * gpl_mask )
static

Helper to check if a layers is used as mask

Parameters
view_layerActual view layer.
gpdGrease pencil data-block.
gpl_maskActual Layer.
Returns
True if the layer is used as mask.

Definition at line 1481 of file gpencil_legacy.cc.

References GP_LAYER_DISABLE_MASKS_IN_VIEWLAYER, bGPDlayer::info, bGPdata::layers, LISTBASE_FOREACH, ViewLayer::name, and STREQ.

Referenced by BKE_gpencil_visible_stroke_advanced_iter().

◆ greasepencil_blend_read_data()

static void greasepencil_blend_read_data ( BlendDataReader * reader,
ID * id )
static

Definition at line 263 of file gpencil_legacy.cc.

References BKE_gpencil_blend_read_data().

◆ greasepencil_blend_write()

◆ greasepencil_copy_data()

◆ greasepencil_foreach_id()

static void greasepencil_foreach_id ( ID * id,
LibraryForeachIDData * data )
static

◆ greasepencil_free_data()

static void greasepencil_free_data ( ID * id)
static

Definition at line 118 of file gpencil_legacy.cc.

References BKE_gpencil_free_data().

Variable Documentation

◆ BKE_gpencil_batch_cache_dirty_tag_cb

void(* BKE_gpencil_batch_cache_dirty_tag_cb) (bGPdata *gpd) ( bGPdata * gpd) = nullptr

Definition at line 302 of file gpencil_legacy.cc.

Referenced by BKE_gpencil_batch_cache_dirty_tag(), and DRW_engines_register().

◆ BKE_gpencil_batch_cache_free_cb

void(* BKE_gpencil_batch_cache_free_cb) (bGPdata *gpd) ( bGPdata * gpd) = nullptr

Definition at line 303 of file gpencil_legacy.cc.

Referenced by BKE_gpencil_batch_cache_free(), and DRW_engines_register().

◆ IDType_ID_GD_LEGACY

IDTypeInfo IDType_ID_GD_LEGACY
Initial value:
= {
sizeof(bGPdata),
"GPencil",
N_("grease_pencils"),
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
}
@ IDTYPE_FLAGS_APPEND_IS_REUSABLE
Definition BKE_idtype.hh:39
#define BLT_I18NCONTEXT_ID_GPENCIL
#define FILTER_ID_GD_LEGACY
Definition DNA_ID.h:1169
#define FILTER_ID_MA
Definition DNA_ID.h:1175
@ INDEX_ID_GD_LEGACY
Definition DNA_ID.h:1258
@ ID_GD_LEGACY
struct bGPdata bGPdata
static void greasepencil_copy_data(Main *, std::optional< Library * >, ID *id_dst, const ID *id_src, const int)
static void greasepencil_blend_write(BlendWriter *writer, ID *id, const void *id_address)
static void greasepencil_free_data(ID *id)
static void greasepencil_foreach_id(ID *id, LibraryForeachIDData *data)
static void greasepencil_blend_read_data(BlendDataReader *reader, ID *id)
#define N_(msgid)

Definition at line 269 of file gpencil_legacy.cc.

◆ LOG

CLG_LogRef LOG = {"bke.gpencil"}
static

Definition at line 61 of file gpencil_legacy.cc.

Referenced by BKE_gpencil_frame_addnew(), and BKE_gpencil_layer_frame_get().