diff options
author | Nathan Craddock <nzcraddock@gmail.com> | 2020-09-15 23:50:21 +0300 |
---|---|---|
committer | Nathan Craddock <nzcraddock@gmail.com> | 2020-09-16 00:29:19 +0300 |
commit | 18701c19fa91572cb44643de31853335a6737925 (patch) | |
tree | 73e97db5da83847f7ffc0e3c77251893974021dc /source/blender/editors | |
parent | 1c5d0deb2ac352a37be3b39d0f5e20321cdd0942 (diff) |
GPencil: Add link and copy functions for shaderfx
Adds two functions: one to copy a shaderfx between two gpencil objects,
and another to link all shaderfx between two gpencil objects. Added in
preparation for outliner shaderfx drag and drop.
Differential Revision: https://developer.blender.org/D8642
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_object.h | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_shader_fx.c | 21 |
2 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index b0ef22575ee..8762ac6d0bb 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -477,6 +477,8 @@ bool ED_object_shaderfx_move_to_index(struct ReportList *reports, struct Object *ob, struct ShaderFxData *fx, const int index); +void ED_object_shaderfx_link(struct Object *dst, struct Object *src); +void ED_object_shaderfx_copy(struct Object *dst, struct ShaderFxData *fx); /* object_select.c */ void ED_object_select_linked_by_id(struct bContext *C, struct ID *id); diff --git a/source/blender/editors/object/object_shader_fx.c b/source/blender/editors/object/object_shader_fx.c index e2a30c4ce98..2dbde095e39 100644 --- a/source/blender/editors/object/object_shader_fx.c +++ b/source/blender/editors/object/object_shader_fx.c @@ -34,6 +34,7 @@ #include "DNA_shader_fx_types.h" #include "BLI_listbase.h" +#include "BLI_string.h" #include "BLI_string_utf8.h" #include "BLI_utildefines.h" @@ -237,6 +238,26 @@ bool ED_object_shaderfx_move_to_index(ReportList *reports, return true; } +void ED_object_shaderfx_link(Object *dst, Object *src) +{ + BLI_freelistN(&dst->shader_fx); + BKE_shaderfx_copy(&dst->shader_fx, &src->shader_fx); + + DEG_id_tag_update(&dst->id, ID_RECALC_GEOMETRY); + WM_main_add_notifier(NC_OBJECT | ND_SHADERFX, dst); +} + +void ED_object_shaderfx_copy(Object *dst, ShaderFxData *fx) +{ + ShaderFxData *nfx = BKE_shaderfx_new(fx->type); + BLI_strncpy(nfx->name, fx->name, sizeof(nfx->name)); + BKE_shaderfx_copydata(fx, nfx); + BLI_addtail(&dst->shader_fx, nfx); + + DEG_id_tag_update(&dst->id, ID_RECALC_GEOMETRY); + WM_main_add_notifier(NC_OBJECT | ND_SHADERFX, dst); +} + /************************ add effect operator *********************/ static int shaderfx_add_exec(bContext *C, wmOperator *op) |