From 18701c19fa91572cb44643de31853335a6737925 Mon Sep 17 00:00:00 2001 From: Nathan Craddock Date: Tue, 15 Sep 2020 14:50:21 -0600 Subject: 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 --- source/blender/editors/object/object_shader_fx.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source/blender/editors/object/object_shader_fx.c') 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) -- cgit v1.2.3