[Bf-blender-cvs] [126b7bdc421] temp-greasepencil-vfx: More changes and clenaup

Antonio Vazquez noreply at git.blender.org
Tue Jun 26 13:16:55 CEST 2018


Commit: 126b7bdc421f23937d3d53302e826c7f7b2c1a3a
Author: Antonio Vazquez
Date:   Tue Jun 26 10:56:49 2018 +0200
Branches: temp-greasepencil-vfx
https://developer.blender.org/rB126b7bdc421f23937d3d53302e826c7f7b2c1a3a

More changes and clenaup

===================================================================

M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/BKE_shader_fx.h
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/shader_fx.c
M	source/blender/editors/include/ED_object.h
M	source/blender/editors/object/object_add.c
M	source/blender/editors/object/object_intern.h
M	source/blender/editors/object/object_ops.c
M	source/blender/editors/object/object_shader_fx.c
M	source/blender/shader_fx/intern/FX_shader_blur.c
M	source/blender/shader_fx/intern/FX_shader_flip.c
M	source/blender/shader_fx/intern/FX_shader_light.c
M	source/blender/shader_fx/intern/FX_shader_pixel.c
M	source/blender/shader_fx/intern/FX_shader_swirl.c
M	source/blender/shader_fx/intern/FX_shader_wave.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 9f0d9efb0f7..c13983018a9 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -80,6 +80,7 @@ bool BKE_object_support_modifier_type_check(const struct Object *ob, int modifie
 
 void BKE_object_link_modifiers(struct Scene *scene, struct Object *ob_dst, const struct Object *ob_src);
 void BKE_object_free_modifiers(struct Object *ob, const int flag);
+void BKE_object_free_shaderfx(struct Object *ob, const int flag);
 
 void BKE_object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob);
 void BKE_object_copy_proxy_drivers(struct Object *ob, struct Object *target);
diff --git a/source/blender/blenkernel/BKE_shader_fx.h b/source/blender/blenkernel/BKE_shader_fx.h
index ea43c64c8fe..00c0234d2fe 100644
--- a/source/blender/blenkernel/BKE_shader_fx.h
+++ b/source/blender/blenkernel/BKE_shader_fx.h
@@ -94,20 +94,15 @@ typedef struct ShaderFxTypeInfo {
 	ShaderFxType type;
 	ShaderFxTypeFlag flags;
 
-
-	/********************* Non-optional functions *********************/
-
 	/* Copy instance data for this effect type. Should copy all user
-	 * level settings to the target effect.
-	 */
-	void (*copyData)(const struct ShaderFxData *fx, struct ShaderFxData *target);
+	* level settings to the target effect.
+	*/
+	void(*copyData)(const struct ShaderFxData *fx, struct ShaderFxData *target);
 
 	/* apply effect */
 	void(*applyEffect)(struct ShaderFxData *md, struct Depsgraph *depsgraph,
 		struct Object *ob);
 
-	/********************* Optional functions *********************/
-
 	/* Initialize new instance data for this effect type, this function
 	 * should set effect variables to their default values.
 	 * 
@@ -166,16 +161,6 @@ typedef struct ShaderFxTypeInfo {
 	 */
 	void (*foreachIDLink)(struct ShaderFxData *fx, struct Object *ob,
 	                      ShaderFxIDWalkFunc walk, void *userData);
-
-	/* Should call the given walk function for each texture that the
-	 * effect data stores. This is used for finding all textures in
-	 * the context for the UI.
-	 *
-	 * This function is optional. If it is not present, it will be
-	 * assumed the effect has no textures.
-	 */
-	void (*foreachTexLink)(struct ShaderFxData *fx, struct Object *ob,
-	                       ShaderFxTexWalkFunc walk, void *userData);
 } ShaderFxTypeInfo;
 
 /* Initialize  global data (type info and some common global storages). */
@@ -193,7 +178,6 @@ void BKE_shaderfx_copyData_generic(const struct ShaderFxData *fx_src, struct Sha
 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_foreachIDLink(struct Object *ob, ShaderFxIDWalkFunc walk, void *userData);
-void BKE_shaderfx_foreachTexLink(struct Object *ob, ShaderFxTexWalkFunc walk, void *userData);
 
 void BKE_shaderfx_apply(
 	struct Depsgraph *depsgraph, struct Object *ob, bool is_render);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index f7239450b8d..bc168db1d97 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -54,6 +54,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_sequence_types.h"
+#include "DNA_shader_fx_types.h"
 #include "DNA_smoke_types.h"
 #include "DNA_space_types.h"
 #include "DNA_view3d_types.h"
@@ -112,6 +113,7 @@
 #include "BKE_rigidbody.h"
 #include "BKE_scene.h"
 #include "BKE_sequencer.h"
+#include "BKE_shader_fx.h"
 #include "BKE_speaker.h"
 #include "BKE_softbody.h"
 #include "BKE_subsurf.h"
@@ -210,6 +212,15 @@ void BKE_object_free_modifiers(Object *ob, const int flag)
 	BKE_object_free_derived_caches(ob);
 }
 
+void BKE_object_free_shaderfx(Object *ob, const int flag)
+{
+	ShaderFxData *fx;
+
+	while ((fx = BLI_pophead(&ob->shader_fx))) {
+		BKE_shaderfx_free_ex(fx, flag);
+	}
+}
+
 void BKE_object_modifier_hook_reset(Object *ob, HookModifierData *hmd)
 {
 	/* reset functionality */
@@ -284,7 +295,7 @@ void BKE_object_link_modifiers(Scene *scene, struct Object *ob_dst, const struct
 	ModifierData *md;
 	BKE_object_free_modifiers(ob_dst, 0);
 
-	if (!ELEM(ob_dst->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE, OB_GPENCIL)) {
+	if (!ELEM(ob_dst->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) {
 		/* only objects listed above can have modifiers and linking them to objects
 		 * which doesn't have modifiers stack is quite silly */
 		return;
@@ -453,6 +464,7 @@ void BKE_object_free(Object *ob)
 
 	/* BKE_<id>_free shall never touch to ID->us. Never ever. */
 	BKE_object_free_modifiers(ob, LIB_ID_CREATE_NO_USER_REFCOUNT);
+	BKE_object_free_shaderfx(ob, LIB_ID_CREATE_NO_USER_REFCOUNT);
 
 	MEM_SAFE_FREE(ob->mat);
 	MEM_SAFE_FREE(ob->matbits);
@@ -1222,6 +1234,7 @@ void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_
 {
 	ModifierData *md;
 	GpencilModifierData *gmd;
+	ShaderFxData *fx;
 
 	/* We never handle usercount here for own data. */
 	const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
@@ -1254,6 +1267,15 @@ void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_
 		BLI_addtail(&ob_dst->greasepencil_modifiers, nmd);
 	}
 
+	BLI_listbase_clear(&ob_dst->shader_fx);
+
+	for (fx = ob_src->shader_fx.first; fx; fx = fx->next) {
+		ShaderFxData *nfx = BKE_shaderfx_new(fx->type);
+		BLI_strncpy(nfx->name, fx->name, sizeof(nfx->name));
+		BKE_shaderfx_copyData_ex(fx, nfx, flag_subdata);
+		BLI_addtail(&ob_dst->shader_fx, nfx);
+	}
+
 	if (ob_src->pose) {
 		copy_object_pose(ob_dst, ob_src, flag_subdata);
 		/* backwards compat... non-armatures can get poses in older files? */
diff --git a/source/blender/blenkernel/intern/shader_fx.c b/source/blender/blenkernel/intern/shader_fx.c
index 1618c415fab..1ee6e33ddc4 100644
--- a/source/blender/blenkernel/intern/shader_fx.c
+++ b/source/blender/blenkernel/intern/shader_fx.c
@@ -261,18 +261,6 @@ void BKE_shaderfx_foreachIDLink(Object *ob, ShaderFxIDWalkFunc walk, void *userD
 	}
 }
 
-void BKE_shaderfx_foreachTexLink(Object *ob, ShaderFxTexWalkFunc walk, void *userData)
-{
-	ShaderFxData *fx = ob->shader_fx.first;
-
-	for (; fx; fx = fx->next) {
-		const ShaderFxTypeInfo *fxi = BKE_shaderfxType_getInfo(fx->type);
-
-		if (fxi->foreachTexLink)
-			fxi->foreachTexLink(fx, ob, walk, userData);
-	}
-}
-
 ShaderFxData *BKE_shaderfx_findByName(Object *ob, const char *name)
 {
 	return BLI_findstring(&(ob->shader_fx), name, offsetof(ShaderFxData, name));
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 523b465d9f7..b027948be0f 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -293,8 +293,6 @@ int ED_object_shaderfx_move_down(
 	struct ReportList *reports, struct Object *ob, struct ShaderFxData *fx);
 int ED_object_shaderfx_move_up(
 	struct ReportList *reports, struct Object *ob, struct ShaderFxData *fx);
-int ED_object_shaderfx_copy(
-	struct ReportList *reports, struct Object *ob, 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_add.c b/source/blender/editors/object/object_add.c
index 979474280e8..de905249299 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -1890,6 +1890,10 @@ static int convert_exec(bContext *C, wmOperator *op)
 				if (ob->type == OB_MESH) {
 					BKE_object_free_modifiers(ob, 0);  /* after derivedmesh calls! */
 				}
+				if (ob->type == OB_GPENCIL) {
+					BKE_object_free_modifiers(ob, 0);  /* after derivedmesh calls! */
+					BKE_object_free_shaderfx(ob, 0);
+				}
 			}
 		}
 		else if (ob->type == OB_MESH && target == OB_CURVE) {
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 3bfcbed1f78..ffbd1fb4035 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -189,8 +189,6 @@ void OBJECT_OT_shaderfx_add(struct wmOperatorType *ot);
 void OBJECT_OT_shaderfx_remove(struct wmOperatorType *ot);
 void OBJECT_OT_shaderfx_move_up(struct wmOperatorType *ot);
 void OBJECT_OT_shaderfx_move_down(struct wmOperatorType *ot);
-void OBJECT_OT_shaderfx_copy(struct wmOperatorType *ot);
-
 
 /* object_constraint.c */
 void OBJECT_OT_constraint_add(struct wmOperatorType *ot);
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 47ef805bc2d..6470297cc85 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -160,7 +160,6 @@ void ED_operatortypes_object(void)
 	WM_operatortype_append(OBJECT_OT_shaderfx_remove);
 	WM_operatortype_append(OBJECT_OT_shaderfx_move_up);
 	WM_operatortype_append(OBJECT_OT_shaderfx_move_down);
-	WM_operatortype_append(OBJECT_OT_shaderfx_copy);
 
 	WM_operatortype_append(OBJECT_OT_correctivesmooth_bind);
 	WM_operatortype_append(OBJECT_OT_meshdeform_bind);
diff --git a/source/blender/editors/object/object_shader_fx.c b/source/blender/editors/object/object_shader_fx.c
index a6b2316ead1..4a663ff15cf 100644
--- a/source/blender/editors/object/object_shader_fx.c
+++ b/source/blender/editors/object/object_shader_fx.c
@@ -202,18 +202,6 @@ int ED_object_shaderfx_move_down(ReportList *UNUSED(reports), Object *ob, Shader
 	return 1;
 }
 
-int ED_object_shaderfx_copy(ReportList *UNUSED(reports), Object *ob, ShaderFxData *fx)
-{
-	ShaderFxData *nfx;
-
-	nfx = BKE_shaderfx_new(fx->type);
-	BKE_shaderfx_copyData(fx, nfx);
-	BLI_insertlinkafter(&ob->shader_fx, fx, nfx);
-	BKE_shaderfx_unique_name(&ob->shader_fx, nfx);
-
-	return 1;
-}
-
 /************************ add effect operator *********************/
 
 static int shaderfx_add_exec(bContext *C, wmOperator *op)
@@ -478,43 +466,3 @@ void OBJECT_OT_shaderfx_move_down(wmOperatorType *ot)
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
 	gpencil_edit

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list