28#define DNA_DEPRECATED_ALLOW
71 std::optional<Library *> ,
76 bGPdata *gpd_dst = id_cast<bGPdata *>(id_dst);
77 const bGPdata *gpd_src = id_cast<const bGPdata *>(id_src);
81 gpd_dst->
mat = MEM_dupalloc(gpd_src->
mat);
87 gpd_dst->
layers.clear_no_delete();
133 bGPdata *annotations = id_cast<bGPdata *>(
id);
135 for (
int i = 0; i < annotations->
totcol; i++) {
146 bGPdata *gpd = id_cast<bGPdata *>(
id);
190 if (gpd ==
nullptr) {
210 if (gpd->
palettes.first() !=
nullptr) {
265 bGPdata *gpd = id_cast<bGPdata *>(
id);
270 .id_code = bGPdata::id_type,
274 .struct_size =
sizeof(
bGPdata),
275 .name =
"Annotation",
276 .name_plural =
N_(
"annotations"),
279 .asset_type_info =
nullptr,
281 .init_data =
nullptr,
284 .make_local =
nullptr,
286 .foreach_cache =
nullptr,
287 .foreach_path =
nullptr,
288 .foreach_working_space_color =
nullptr,
289 .foreach_asset_weak_reference =
nullptr,
290 .owner_pointer_get =
nullptr,
294 .blend_read_after_liblink =
nullptr,
296 .blend_read_undo_preserve =
nullptr,
298 .lib_override_apply_post =
nullptr,
306 if (dvert ==
nullptr) {
309 MEM_SAFE_DELETE(dvert->
dw);
314 if (gps ==
nullptr) {
318 if (gps->
dvert ==
nullptr) {
322 for (
int i = 0; i < gps->
totpoints; i++) {
330 if (gps ==
nullptr) {
334 if (editcurve ==
nullptr) {
338 MEM_delete(editcurve);
344 if (gps ==
nullptr) {
353 MEM_delete(gps->
dvert);
367 bool changed = (gpf->
strokes.is_empty() ==
false);
373 gpf->
strokes.clear_no_delete();
383 if (gpl ==
nullptr) {
389 gpf_next = gpf->
next;
403 mask_next =
mask->next;
412 if (
list ==
nullptr) {
418 gpl_next = gpl->
next;
433 palette.colors.free_no_destruct();
434 MEM_delete(&palette);
436 list->clear_no_delete();
446 MEM_SAFE_DELETE(gpd->
mat);
465 if (gpl ==
nullptr) {
470 gpf = MEM_new<bGPDframe>(
"bGPDframe");
474 if (gpl->
frames.first()) {
475 for (gf = gpl->
frames.first(); gf; gf = gf->next) {
477 if (gf->framenum == cframe) {
483 if (gf->framenum > cframe) {
494 &
LOG,
"Frame (%d) existed already for this layer_active. Using existing frame", cframe);
503 else if (
state == 0) {
518 if (gpl ==
nullptr) {
544 MEM_delete(new_frame);
552 if (found ==
false) {
568 const bool setactive,
569 const bool add_to_header)
575 if (gpd ==
nullptr) {
580 gpl = MEM_new<bGPDlayer>(
"bGPDlayer");
589 if (gpl_active ==
nullptr) {
704 if (gps_src ==
nullptr) {
713 const bool dup_points,
718 gps_dst = MEM_dupalloc(gps_src);
719 gps_dst->
prev = gps_dst->
next =
nullptr;
725 if (gps_src->
dvert !=
nullptr) {
726 gps_dst->
dvert = MEM_dupalloc(gps_src->
dvert);
730 gps_dst->
dvert =
nullptr;
734 gps_dst->
points =
nullptr;
735 gps_dst->
dvert =
nullptr;
750 if (gpf_src ==
nullptr) {
755 gpf_dst = MEM_dupalloc(gpf_src);
756 gpf_dst->
prev = gpf_dst->
next =
nullptr;
759 gpf_dst->
strokes.clear_no_delete();
773 const bool dup_frames,
774 const bool dup_strokes)
780 if (gpl_src ==
nullptr) {
785 gpl_dst = MEM_dupalloc(gpl_src);
786 gpl_dst->
prev = gpl_dst->
next =
nullptr;
789 gpl_dst->
frames.clear_no_delete();
797 if (&gpf_src == gpl_dst->
actframe) {
816 if (gpd_src ==
nullptr) {
822 gpd_dst = MEM_dupalloc(gpd_src);
826 gpd_dst = id_cast<bGPdata *>(
BKE_id_copy(bmain, &gpd_src->
id));
842 if (gpl ==
nullptr) {
861 if (gpf.framenum == cframe) {
875 if (gpl ==
nullptr) {
896 for (; gpf; gpf = gpf->
next) {
911 if ((found) && (gpf->
framenum == cframe)) {
932 for (; gpf; gpf = gpf->
prev) {
941 if ((found) && (gpf->
framenum == cframe)) {
962 else if (gpl->
frames.first()) {
964 const int first = (gpl->
frames.first())->framenum;
965 const int last = (gpl->
frames.last())->framenum;
967 if (
abs(cframe - first) >
abs(cframe - last)) {
969 for (gpf = gpl->
frames.last(); gpf; gpf = gpf->
prev) {
978 for (gpf = gpl->
frames.first(); gpf; gpf = gpf->
next) {
988 if ((found) && (gpf->
framenum == cframe)) {
1000 if (gpl->
frames.first() !=
nullptr) {
1034 bool changed =
false;
1037 if (
ELEM(
nullptr, gpl, gpf)) {
1057 if (name[0] ==
'\0') {
1074 if (thunk !=
nullptr) {
1075 *(
static_cast<bool *
>(thunk)) =
true;
1092 if (
ELEM(
nullptr, gpd, gpd->
layers.first())) {
1110 if (
ELEM(
nullptr, gpd, gpd->
layers.first(), active)) {
1132 if (
ELEM(
nullptr, gpd, gpl)) {
Blender kernel action and pose functionality.
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
General operations, lookup, etc. for materials.
#define STRNCPY_UTF8(dst, src)
#define BLO_read_struct_list(reader, struct_name, list)
#define BLO_read_struct(reader, struct_name, ptr_p)
#define BLT_I18NCONTEXT_ID_GPENCIL
#define CLOG_ERROR(clg_ref,...)
#define CLOG_STR_ERROR(clg_ref, str)
#define FILTER_ID_GD_LEGACY
#define ID_IS_LINKED(_id)
#define GP_DEFAULT_CURVE_EDIT_CORNER_ANGLE
#define GP_DEFAULT_PIX_FACTOR
#define GP_DEFAULT_CURVE_RESOLUTION
#define GP_DEFAULT_GRID_LINES
#define GP_DEFAULT_CURVE_ERROR
Read Blender memory allocation and freeing.
#define ARRAY_SET_ITEMS(...)
struct bGPDframe * BKE_annotations_frame_addnew(struct bGPDlayer *gpl, int cframe)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BKE_annotations_layer_active_set(struct bGPdata *gpd, struct bGPDlayer *active)
static void greasepencil_blend_write(BlendWriter *writer, ID *id, const void *id_address)
struct bGPDframe * BKE_annotations_frame_addcopy(struct bGPDlayer *gpl, int cframe)
static void greasepencil_blend_read_data(BlendDataReader *reader, ID *id)
void BKE_defbase_blend_write(BlendWriter *writer, const ListBaseT< bDeformGroup > *defbase)
struct bGPDframe * BKE_annotations_layer_frame_get(struct bGPDlayer *gpl, int cframe, eGP_GetFrame_Mode addnew)
void BKE_defvert_array_copy(MDeformVert *dst, const MDeformVert *src, int totvert)
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
struct bGPdata * BKE_annotations_data_duplicate(struct Main *bmain, const struct bGPdata *gpd, bool internal_copy)
void BLO_read_pointer_array_and_validate_size(BlendDataReader *reader, T **ptr_p, SizeT *array_size)
static void greasepencil_copy_data(Main *, std::optional< Library * >, ID *id_dst, const ID *id_src, const int)
void BKE_annotations_free_stroke_weights(struct bGPDstroke *gps)
struct bGPDlayer * BKE_annotations_layer_addnew(struct bGPdata *gpd, const char *name, bool setactive, bool add_to_header)
void BKE_defvert_blend_read(BlendDataReader *reader, int count, MDeformVert *mdverts)
void BKE_defvert_blend_write(BlendWriter *writer, int count, const MDeformVert *dvlist)
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BKE_annotations_free_frames(struct bGPDlayer *gpl)
void BKE_annotations_free_stroke(struct bGPDstroke *gps)
void BKE_id_blend_write(BlendWriter *writer, ID *id)
@ GP_DATA_STROKE_PAINTMODE
@ GP_DATA_STROKE_VERTEXMODE
@ GP_DATA_STROKE_EDITMODE
@ GP_DATA_SHOW_ONIONSKINS
@ GP_DATA_STROKE_SCULPTMODE
@ GP_DATA_CURVE_ADAPTIVE_RESOLUTION
@ GP_DATA_AUTOLOCK_LAYERS
@ GP_DATA_STROKE_WEIGHTMODE
struct bGPdata * BKE_annotations_data_addnew(struct Main *bmain, const char name[])
IDTypeInfo IDType_ID_GD_LEGACY
struct bGPDframe * BKE_annotations_layer_frame_find(struct bGPDlayer *gpl, int cframe)
void BKE_annotations_layer_delete(struct bGPdata *gpd, struct bGPDlayer *gpl)
void mul_m4_v3(const float M[4][4], float r[3])
void BLI_uniquename(const ListBase *list, void *vlink, const char *defname, char delim, int name_offset, size_t name_maxncpy) ATTR_NONNULL(1
void void void BLI_listbase_sort_r(ListBase *listbase, int(*cmp)(void *, const void *, const void *), void *thunk) ATTR_NONNULL(1
void BKE_gpencil_stroke_weights_duplicate(struct bGPDstroke *gps_src, struct bGPDstroke *gps_dst)
void loc_eul_size_to_mat4(float R[4][4], const float loc[3], const float eul[3], const float size[3])
void DEG_id_tag_update(ID *id, unsigned int flags)
BMesh const char void * data
void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
void BKE_annotations_free_layers(ListBaseT< bGPDlayer > *list)
struct bGPDlayer * BKE_annotations_layer_named_get(struct bGPdata *gpd, const char *name)
void BKE_annotations_blend_read_data(struct BlendDataReader *reader, struct bGPdata *gpd)
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE bool is_one_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
void BKE_annotations_free_legacy_palette_data(ListBaseT< bGPDpalette > *list)
struct bGPDstroke * BKE_gpencil_stroke_duplicate(struct bGPDstroke *gps_src, bool dup_points, bool dup_curve)
static int annotations_cb_cmp_frame(void *thunk, const void *a, const void *b)
struct bGPDlayer * BKE_annotations_layer_active_get(struct bGPdata *gpd)
MINLINE void zero_v3(float r[3])
void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
bool BLO_read_array(BlendDataReader *reader, T **ptr_p, const SizeT array_size, const int elems=1)
void BLO_read_array_and_validate_size(BlendDataReader *reader, T **ptr_p, SizeT *array_size, const int elems=1)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BKE_annotations_tag(struct bGPdata *gpd)
void BKE_annotations_free_data(struct bGPdata *gpd, bool free_all)
MINLINE void copy_v3_fl(float r[3], float f)
bool BKE_annotations_layer_is_editable(const struct bGPDlayer *gpl)
void BKE_annotations_free_layer_masks(struct bGPDlayer *gpl)
void BKE_defgroup_copy_list(ListBaseT< bDeformGroup > *outbase, const ListBaseT< bDeformGroup > *inbase)
bool BKE_annotations_layer_frame_delete(struct bGPDlayer *gpl, struct bGPDframe *gpf)
void BKE_annotations_free_point_weights(struct MDeformVert *dvert)
static void greasepencil_free_data(ID *id)
static void greasepencil_foreach_id(ID *id, LibraryForeachIDData *data)
MINLINE void copy_v4_v4(float r[4], const float a[4])
void BKE_annotations_layer_frames_sort(struct bGPDlayer *gpl, bool *r_has_duplicate_frames)
bool BKE_annotations_free_strokes(struct bGPDframe *gpf)
void BKE_annotations_free_stroke_editcurve(struct bGPDstroke *gps)
bool BKE_icon_delete(int icon_id)
ID * BKE_id_copy(Main *bmain, const ID *id)
void * BKE_libblock_alloc(Main *bmain, short type, const char *name, int flag) ATTR_WARN_UNUSED_RESULT
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
struct bGPDlayer * BKE_annotations_layer_duplicate(const struct bGPDlayer *gpl_src, bool dup_frames, bool dup_strokes)
struct bGPDframe * BKE_annotations_frame_duplicate(const struct bGPDframe *gpf_src, bool dup_strokes)
@ IDTYPE_FLAGS_APPEND_IS_REUSABLE
void write_pointer_array(int64_t num, const void *data)
void write_id_struct(const void *id_address, const T *id, BlendStructWriterTypedFn< T > fn=nullptr)
void write_struct_list(const ListBaseT< T > *list, BlendStructWriterTypedFn< T > fn=nullptr)
void write_struct(const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
void write_struct_array(const int64_t array_size, const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
bGPDcurve_point * curve_points
ListBaseT< bGPDstroke > strokes
ListBaseT< bGPDframe > frames
eGPDlayer_OnionFlag onion_flag
ListBaseT< bGPDlayer_Mask > mask_layers
float vertex_paint_opacity
bGPDlayer_Runtime runtime
ListBaseT< bGPDpalettecolor > colors
struct bGPDcurve * editcurve
struct MDeformVert * dvert
int curve_edit_resolution
float curve_edit_corner_angle
eGP_OnionModes onion_mode
ListBaseT< bGPDpalette > palettes
ListBaseT< bGPDlayer > layers
ListBaseT< bDeformGroup > vertex_group_names
eGPD_OnionFlag onion_flag
float curve_edit_threshold