Cleanup: Grease Pencil: Remove unused legacy functions
Some BKE_ functions are not relevant anymore. They are specific to legacy structure dealing with masks and vertex weights. Pull Request: https://projects.blender.org/blender/blender/pulls/135563
This commit is contained in:
committed by
Pratik Borhade
parent
dce3ce7a04
commit
18421a3f48
@@ -221,41 +221,6 @@ void BKE_gpencil_layer_active_set(struct bGPdata *gpd, struct bGPDlayer *active)
|
||||
* \param gpl: Grease pencil layer
|
||||
*/
|
||||
void BKE_gpencil_layer_delete(struct bGPdata *gpd, struct bGPDlayer *gpl);
|
||||
/**
|
||||
* Set locked layers for autolock mode.
|
||||
* \param gpd: Grease pencil data-block
|
||||
* \param unlock: Unlock flag
|
||||
*/
|
||||
void BKE_gpencil_layer_autolock_set(struct bGPdata *gpd, bool unlock);
|
||||
|
||||
/**
|
||||
* Remove grease pencil mask layer.
|
||||
* \param gpl: Grease pencil layer
|
||||
* \param mask: Grease pencil mask layer
|
||||
*/
|
||||
void BKE_gpencil_layer_mask_remove(struct bGPDlayer *gpl, struct bGPDlayer_Mask *mask);
|
||||
/**
|
||||
* Remove any reference to mask layer.
|
||||
* \param gpd: Grease pencil data-block
|
||||
* \param name: Name of the mask layer
|
||||
*/
|
||||
void BKE_gpencil_layer_mask_remove_ref(struct bGPdata *gpd, const char *name);
|
||||
/**
|
||||
* Sort grease pencil mask layers.
|
||||
* \param gpd: Grease pencil data-block
|
||||
* \param gpl: Grease pencil layer
|
||||
*/
|
||||
void BKE_gpencil_layer_mask_sort(struct bGPdata *gpd, struct bGPDlayer *gpl);
|
||||
/**
|
||||
* Sort all grease pencil mask layer.
|
||||
* \param gpd: Grease pencil data-block
|
||||
*/
|
||||
void BKE_gpencil_layer_mask_sort_all(struct bGPdata *gpd);
|
||||
/**
|
||||
* Make a copy of a given gpencil mask layers.
|
||||
*/
|
||||
void BKE_gpencil_layer_mask_copy(const struct bGPDlayer *gpl_src, struct bGPDlayer *gpl_dst);
|
||||
|
||||
/**
|
||||
* Sort grease pencil frames.
|
||||
* \param gpl: Grease pencil layer
|
||||
|
||||
@@ -781,9 +781,6 @@ bGPDlayer *BKE_gpencil_layer_duplicate(const bGPDlayer *gpl_src,
|
||||
gpl_dst = static_cast<bGPDlayer *>(MEM_dupallocN(gpl_src));
|
||||
gpl_dst->prev = gpl_dst->next = nullptr;
|
||||
|
||||
/* Copy masks. */
|
||||
BKE_gpencil_layer_mask_copy(gpl_src, gpl_dst);
|
||||
|
||||
/* copy frames */
|
||||
BLI_listbase_clear(&gpl_dst->frames);
|
||||
if (dup_frames) {
|
||||
@@ -1059,29 +1056,6 @@ bGPDlayer *BKE_gpencil_layer_named_get(bGPdata *gpd, const char *name)
|
||||
return static_cast<bGPDlayer *>(BLI_findstring(&gpd->layers, name, offsetof(bGPDlayer, info)));
|
||||
}
|
||||
|
||||
void BKE_gpencil_layer_mask_remove(bGPDlayer *gpl, bGPDlayer_Mask *mask)
|
||||
{
|
||||
BLI_freelinkN(&gpl->mask_layers, mask);
|
||||
gpl->act_mask--;
|
||||
CLAMP_MIN(gpl->act_mask, 0);
|
||||
}
|
||||
|
||||
void BKE_gpencil_layer_mask_remove_ref(bGPdata *gpd, const char *name)
|
||||
{
|
||||
bGPDlayer_Mask *mask_next;
|
||||
|
||||
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
|
||||
for (bGPDlayer_Mask *mask = static_cast<bGPDlayer_Mask *>(gpl->mask_layers.first); mask;
|
||||
mask = mask_next)
|
||||
{
|
||||
mask_next = mask->next;
|
||||
if (STREQ(mask->name, name)) {
|
||||
BKE_gpencil_layer_mask_remove(gpl, mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int gpencil_cb_sort_masks(const void *arg1, const void *arg2)
|
||||
{
|
||||
/* sort is inverted as layer list. */
|
||||
@@ -1099,38 +1073,6 @@ static int gpencil_cb_sort_masks(const void *arg1, const void *arg2)
|
||||
return val;
|
||||
}
|
||||
|
||||
void BKE_gpencil_layer_mask_sort(bGPdata *gpd, bGPDlayer *gpl)
|
||||
{
|
||||
/* Update sort index. */
|
||||
LISTBASE_FOREACH (bGPDlayer_Mask *, mask, &gpl->mask_layers) {
|
||||
bGPDlayer *gpl_mask = BKE_gpencil_layer_named_get(gpd, mask->name);
|
||||
if (gpl_mask != nullptr) {
|
||||
mask->sort_index = BLI_findindex(&gpd->layers, gpl_mask);
|
||||
}
|
||||
else {
|
||||
mask->sort_index = 0;
|
||||
}
|
||||
}
|
||||
BLI_listbase_sort(&gpl->mask_layers, gpencil_cb_sort_masks);
|
||||
}
|
||||
|
||||
void BKE_gpencil_layer_mask_sort_all(bGPdata *gpd)
|
||||
{
|
||||
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
|
||||
BKE_gpencil_layer_mask_sort(gpd, gpl);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_gpencil_layer_mask_copy(const bGPDlayer *gpl_src, bGPDlayer *gpl_dst)
|
||||
{
|
||||
BLI_listbase_clear(&gpl_dst->mask_layers);
|
||||
LISTBASE_FOREACH (bGPDlayer_Mask *, mask_src, &gpl_src->mask_layers) {
|
||||
bGPDlayer_Mask *mask_dst = static_cast<bGPDlayer_Mask *>(MEM_dupallocN(mask_src));
|
||||
mask_dst->prev = mask_dst->next = nullptr;
|
||||
BLI_addtail(&gpl_dst->mask_layers, mask_dst);
|
||||
}
|
||||
}
|
||||
|
||||
static int gpencil_cb_cmp_frame(void *thunk, const void *a, const void *b)
|
||||
{
|
||||
const bGPDframe *frame_a = static_cast<const bGPDframe *>(a);
|
||||
@@ -1197,36 +1139,6 @@ void BKE_gpencil_layer_active_set(bGPdata *gpd, bGPDlayer *active)
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_gpencil_layer_autolock_set(bGPdata *gpd, const bool unlock)
|
||||
{
|
||||
BLI_assert(gpd != nullptr);
|
||||
|
||||
if (gpd->flag & GP_DATA_AUTOLOCK_LAYERS) {
|
||||
bGPDlayer *layer_active = BKE_gpencil_layer_active_get(gpd);
|
||||
|
||||
/* Lock all other layers */
|
||||
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
|
||||
/* unlock active layer */
|
||||
if (gpl == layer_active) {
|
||||
gpl->flag &= ~GP_LAYER_LOCKED;
|
||||
}
|
||||
else {
|
||||
gpl->flag |= GP_LAYER_LOCKED;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* If disable is better unlock all layers by default or it looks there is
|
||||
* a problem in the UI because the user expects all layers will be unlocked
|
||||
*/
|
||||
if (unlock) {
|
||||
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
|
||||
gpl->flag &= ~GP_LAYER_LOCKED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_gpencil_layer_delete(bGPdata *gpd, bGPDlayer *gpl)
|
||||
{
|
||||
/* error checking */
|
||||
@@ -1240,9 +1152,6 @@ void BKE_gpencil_layer_delete(bGPdata *gpd, bGPDlayer *gpl)
|
||||
/* Free Masks. */
|
||||
BKE_gpencil_free_layer_masks(gpl);
|
||||
|
||||
/* Remove any reference to that layer in masking lists. */
|
||||
BKE_gpencil_layer_mask_remove_ref(gpd, gpl->info);
|
||||
|
||||
/* free icon providing preview of icon color */
|
||||
BKE_icon_delete(gpl->runtime.icon_id);
|
||||
|
||||
|
||||
@@ -4550,7 +4550,6 @@ static int click_select_channel_gplayer(bContext *C,
|
||||
ANIMTYPE_GPLAYER);
|
||||
/* update other layer status */
|
||||
BKE_gpencil_layer_active_set(gpd, gpl);
|
||||
BKE_gpencil_layer_autolock_set(gpd, false);
|
||||
DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +221,6 @@ void ED_gpencil_set_active_channel(bGPdata *gpd, bGPDlayer *gpl)
|
||||
/* Update other layer status. */
|
||||
if (BKE_gpencil_layer_active_get(gpd) != gpl) {
|
||||
BKE_gpencil_layer_active_set(gpd, gpl);
|
||||
BKE_gpencil_layer_autolock_set(gpd, false);
|
||||
WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,9 +255,6 @@ static wmOperatorStatus gpencil_layer_remove_exec(bContext *C, wmOperator *op)
|
||||
/* delete the layer now... */
|
||||
BKE_gpencil_layer_delete(gpd, gpl);
|
||||
|
||||
/* Reorder masking. */
|
||||
BKE_gpencil_layer_mask_sort_all(gpd);
|
||||
|
||||
/* notifiers */
|
||||
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
|
||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, nullptr);
|
||||
@@ -319,9 +316,6 @@ static wmOperatorStatus gpencil_layer_move_exec(bContext *C, wmOperator *op)
|
||||
|
||||
BLI_assert(ELEM(direction, -1, 0, 1)); /* we use value below */
|
||||
if (BLI_listbase_link_move(&gpd->layers, gpl, direction)) {
|
||||
/* Reorder masking. */
|
||||
BKE_gpencil_layer_mask_sort_all(gpd);
|
||||
|
||||
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
|
||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, nullptr);
|
||||
}
|
||||
|
||||
@@ -49,59 +49,6 @@
|
||||
|
||||
#include "gpencil_intern.hh"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Copy/Paste Strokes Utilities
|
||||
*
|
||||
* Grease Pencil stroke data copy/paste buffer:
|
||||
* - The copy operation collects all segments of selected strokes,
|
||||
* dumping "ready to be copied" copies of the strokes into the buffer.
|
||||
* - The paste operation makes a copy of those elements, and adds them
|
||||
* to the active layer. This effectively flattens down the strokes
|
||||
* from several different layers into a single layer.
|
||||
* \{ */
|
||||
|
||||
ListBase gpencil_strokes_copypastebuf = {nullptr, nullptr};
|
||||
|
||||
/* Hash for hanging on to all the colors used by strokes in the buffer
|
||||
*
|
||||
* This is needed to prevent dangling and unsafe pointers when pasting across data-blocks,
|
||||
* or after a color used by a stroke in the buffer gets deleted (via user action or undo).
|
||||
*/
|
||||
static GHash *gpencil_strokes_copypastebuf_colors = nullptr;
|
||||
|
||||
void ED_gpencil_strokes_copybuf_free()
|
||||
{
|
||||
bGPDstroke *gps, *gpsn;
|
||||
|
||||
/* Free the colors buffer.
|
||||
* NOTE: This is done before the strokes so that the pointers are still safe. */
|
||||
if (gpencil_strokes_copypastebuf_colors) {
|
||||
BLI_ghash_free(gpencil_strokes_copypastebuf_colors, nullptr, MEM_freeN);
|
||||
gpencil_strokes_copypastebuf_colors = nullptr;
|
||||
}
|
||||
|
||||
/* Free the stroke buffer */
|
||||
for (gps = static_cast<bGPDstroke *>(gpencil_strokes_copypastebuf.first); gps; gps = gpsn) {
|
||||
gpsn = gps->next;
|
||||
|
||||
if (gps->points) {
|
||||
MEM_freeN(gps->points);
|
||||
}
|
||||
if (gps->dvert) {
|
||||
BKE_gpencil_free_stroke_weights(gps);
|
||||
MEM_freeN(gps->dvert);
|
||||
}
|
||||
|
||||
MEM_SAFE_FREE(gps->triangles);
|
||||
|
||||
BLI_freelinkN(&gpencil_strokes_copypastebuf, gps);
|
||||
}
|
||||
|
||||
gpencil_strokes_copypastebuf.first = gpencil_strokes_copypastebuf.last = nullptr;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Delete Active Frame Operator
|
||||
* \{ */
|
||||
|
||||
@@ -91,13 +91,6 @@ void gpencil_point_to_xy(const GP_SpaceConversion *gsc,
|
||||
/* Copy/Paste Buffer --------------------------------- */
|
||||
/* `gpencil_edit.cc` */
|
||||
|
||||
/**
|
||||
* list of #bGPDstroke instances
|
||||
*
|
||||
* \note is exposed within the editors/gpencil module so that other tools can use it too.
|
||||
*/
|
||||
extern ListBase gpencil_strokes_copypastebuf;
|
||||
|
||||
/* ***************************************************** */
|
||||
/* Operator Defines */
|
||||
|
||||
|
||||
@@ -289,23 +289,6 @@ static void gpencil_stroke_convertcoords(ARegion *region,
|
||||
}
|
||||
}
|
||||
|
||||
void ED_gpencil_tpoint_to_point(ARegion *region,
|
||||
float origin[3],
|
||||
const tGPspoint *tpt,
|
||||
bGPDspoint *pt)
|
||||
{
|
||||
float p3d[3];
|
||||
/* conversion to 3d format */
|
||||
gpencil_stroke_convertcoords(region, tpt, origin, p3d);
|
||||
copy_v3_v3(&pt->x, p3d);
|
||||
zero_v4(pt->vert_color);
|
||||
|
||||
pt->pressure = tpt->pressure;
|
||||
pt->strength = tpt->strength;
|
||||
pt->uv_fac = tpt->uv_fac;
|
||||
pt->uv_rot = tpt->uv_rot;
|
||||
}
|
||||
|
||||
tGPspoint *ED_gpencil_sbuffer_ensure(tGPspoint *buffer_array,
|
||||
int *buffer_size,
|
||||
int *buffer_used,
|
||||
|
||||
@@ -111,13 +111,6 @@ void ED_keymap_gpencil_legacy(wmKeyConfig *keyconf);
|
||||
|
||||
void ED_operatortypes_gpencil_legacy();
|
||||
|
||||
/* ------------- Copy-Paste Buffers -------------------- */
|
||||
|
||||
/**
|
||||
* Free copy/paste buffer data.
|
||||
*/
|
||||
void ED_gpencil_strokes_copybuf_free();
|
||||
|
||||
/* ------------ Grease-Pencil Drawing API ------------------ */
|
||||
/* `drawgpencil.cc` */
|
||||
|
||||
@@ -234,14 +227,6 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, short offset_mode);
|
||||
|
||||
/* texture coordinate utilities */
|
||||
|
||||
/**
|
||||
* Convert 2d #tGPspoint to 3d #bGPDspoint.
|
||||
*/
|
||||
void ED_gpencil_tpoint_to_point(ARegion *region,
|
||||
float origin[3],
|
||||
const tGPspoint *tpt,
|
||||
bGPDspoint *pt);
|
||||
|
||||
/**
|
||||
* Ensure the #tGPspoint buffer (while drawing stroke)
|
||||
* size is enough to save all points of the stroke.
|
||||
|
||||
@@ -600,7 +600,6 @@ void WM_exit_ex(bContext *C, const bool do_python_exit, const bool do_user_exit_
|
||||
ANIM_driver_vars_copybuf_free();
|
||||
ANIM_fmodifiers_copybuf_free();
|
||||
ED_gpencil_anim_copybuf_free();
|
||||
ED_gpencil_strokes_copybuf_free();
|
||||
|
||||
/* Free gizmo-maps after freeing blender,
|
||||
* so no deleted data get accessed during cleaning up of areas. */
|
||||
|
||||
Reference in New Issue
Block a user