[Bf-blender-cvs] [3815452e473] soc-2020-outliner: Outliner: Add uistack shaderfx copy
Nathan Craddock
noreply at git.blender.org
Sat Jul 25 22:03:52 CEST 2020
Commit: 3815452e473e75d58bc38e66b05596a04b8a6c46
Author: Nathan Craddock
Date: Sat Jul 25 14:03:20 2020 -0600
Branches: soc-2020-outliner
https://developer.blender.org/rB3815452e473e75d58bc38e66b05596a04b8a6c46
Outliner: Add uistack shaderfx copy
This finishes the uistack drop operator.
===================================================================
M source/blender/blenkernel/BKE_shader_fx.h
M source/blender/blenkernel/intern/shader_fx.c
M source/blender/editors/space_outliner/outliner_dragdrop.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_shader_fx.h b/source/blender/blenkernel/BKE_shader_fx.h
index 31e14c6c884..cc115b92c6c 100644
--- a/source/blender/blenkernel/BKE_shader_fx.h
+++ b/source/blender/blenkernel/BKE_shader_fx.h
@@ -182,6 +182,7 @@ void BKE_shaderfx_copydata(struct ShaderFxData *fx, struct ShaderFxData *target)
void BKE_shaderfx_copydata_ex(struct ShaderFxData *fx,
struct ShaderFxData *target,
const int flag);
+void BKE_shaderfx_copy(struct ListBase *dst, const struct ListBase *src);
void BKE_shaderfx_foreach_ID_link(struct Object *ob, ShaderFxIDWalkFunc walk, void *userData);
bool BKE_shaderfx_has_gpencil(struct Object *ob);
diff --git a/source/blender/blenkernel/intern/shader_fx.c b/source/blender/blenkernel/intern/shader_fx.c
index 2923298c5d5..1b1228e09a8 100644
--- a/source/blender/blenkernel/intern/shader_fx.c
+++ b/source/blender/blenkernel/intern/shader_fx.c
@@ -235,6 +235,19 @@ void BKE_shaderfx_copydata(ShaderFxData *fx, ShaderFxData *target)
BKE_shaderfx_copydata_ex(fx, target, 0);
}
+void BKE_shaderfx_copy(ListBase *dst, const ListBase *src)
+{
+ ShaderFxData *fx;
+ ShaderFxData *srcfx;
+
+ BLI_listbase_clear(dst);
+ BLI_duplicatelist(dst, src);
+
+ for (srcfx = src->first, fx = dst->first; srcfx && fx; srcfx = srcfx->next, fx = fx->next) {
+ BKE_shaderfx_copydata(srcfx, fx);
+ }
+}
+
ShaderFxData *BKE_shaderfx_findby_type(Object *ob, ShaderFxType type)
{
ShaderFxData *fx = ob->shader_fx.first;
diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c
index e16f5bc0503..469191fe6e4 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.c
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.c
@@ -47,6 +47,7 @@
#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_scene.h"
+#include "BKE_shader_fx.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
@@ -942,6 +943,13 @@ static void uistack_drop_link(bContext *C, OutlinerDropData *drop_data)
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, NULL);
}
else if (drop_data->drag_tselem->type == TSE_EFFECT_BASE) {
+ if (ob_dst->type != OB_GPENCIL) {
+ return;
+ }
+ BKE_shaderfx_copy(&ob_dst->shader_fx, &drop_data->ob_parent->shader_fx);
+
+ DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_OBJECT | ND_SHADERFX, ob_dst);
}
}
@@ -976,6 +984,17 @@ static void uistack_drop_copy(bContext *C, OutlinerDropData *drop_data)
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, ob_dst);
}
else if (drop_data->drag_tselem->type == TSE_EFFECT) {
+ if (ob_dst->type != OB_GPENCIL) {
+ return;
+ }
+ ShaderFxData *fx = drop_data->drag_directdata;
+ ShaderFxData *nfx = BKE_shaderfx_new(fx->type);
+ BLI_strncpy(nfx->name, fx->name, sizeof(nfx->name));
+ BKE_shaderfx_copydata(fx, nfx);
+ BLI_addtail(&ob_dst->shader_fx, nfx);
+
+ DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_OBJECT | ND_SHADERFX, ob_dst);
}
}
More information about the Bf-blender-cvs
mailing list