[Bf-blender-cvs] [692867ecc49] temp-greasepencil-vfx: WIP: First compilation without errors

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


Commit: 692867ecc49436860c4cb8ecb13b0f32f8ece28b
Author: Antonio Vazquez
Date:   Tue Jun 26 00:21:11 2018 +0200
Branches: temp-greasepencil-vfx
https://developer.blender.org/rB692867ecc49436860c4cb8ecb13b0f32f8ece28b

WIP: First compilation without errors

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

M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/object/object_intern.h
M	source/blender/editors/object/object_ops.c
M	source/blender/makesrna/intern/rna_shader_fx.c

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

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 4bef5e71425..c1845e940ed 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -156,6 +156,7 @@
 #include "BKE_scene.h"
 #include "BKE_screen.h"
 #include "BKE_sequencer.h"
+#include "BKE_shader_fx.h"
 #include "BKE_outliner_treehash.h"
 #include "BKE_sound.h"
 #include "BKE_colortools.h"
@@ -4877,6 +4878,18 @@ static void lib_link_gpencil_modifiers(FileData *fd, Object *ob)
 	}
 }
 
+static void lib_link_shaderfxs(FileData *fd, Object *ob)
+{
+	BKE_shaderfx_foreachIDLink(ob, lib_link_modifiers_common, fd);
+
+	/* If linking from a library, clear 'local' static override flag. */
+	if (ob->id.lib != NULL) {
+		for (ShaderFxData *fx = ob->shader_fx.first; fx != NULL; fx = fx->next) {
+			fx->flag &= ~eShaderFxFlag_StaticOverride_Local;
+		}
+	}
+}
+
 static void lib_link_object(FileData *fd, Main *main)
 {
 	bool warn = false;
@@ -5014,6 +5027,7 @@ static void lib_link_object(FileData *fd, Main *main)
 			lib_link_particlesystems(fd, ob, &ob->id, &ob->particlesystem);
 			lib_link_modifiers(fd, ob);
 			lib_link_gpencil_modifiers(fd, ob);
+			lib_link_shaderfxs(fd, ob);
 
 			if (ob->rigidbody_constraint) {
 				ob->rigidbody_constraint->ob1 = newlibadr(fd, ob->id.lib, ob->rigidbody_constraint->ob1);
@@ -5417,7 +5431,7 @@ static void direct_link_gpencil_modifiers(FileData *fd, ListBase *lb)
 		md->error = NULL;
 
 		/* if modifiers disappear, or for upward compatibility */
-		if (NULL == modifierType_getInfo(md->type))
+		if (NULL == BKE_gpencil_modifierType_getInfo(md->type))
 			md->type = eModifierType_None;
 
 		if (md->type == eGpencilModifierType_Lattice) {
@@ -5446,6 +5460,22 @@ static void direct_link_gpencil_modifiers(FileData *fd, ListBase *lb)
 	}
 }
 
+static void direct_link_shaderfxs(FileData *fd, ListBase *lb)
+{
+	ShaderFxData *fx;
+
+	link_list(fd, lb);
+
+	for (fx = lb->first; fx; fx = fx->next) {
+		fx->error = NULL;
+
+		/* if shader disappear, or for upward compatibility */
+		if (NULL == BKE_shaderfxType_getInfo(fx->type))
+			fx->type = eShaderFxType_None;
+
+	}
+}
+
 static void direct_link_object(FileData *fd, Object *ob)
 {
 	PartEff *paf;
@@ -5490,6 +5520,7 @@ static void direct_link_object(FileData *fd, Object *ob)
 	/* do it here, below old data gets converted */
 	direct_link_modifiers(fd, &ob->modifiers);
 	direct_link_gpencil_modifiers(fd, &ob->greasepencil_modifiers);
+	direct_link_shaderfxs(fd, &ob->shader_fx);
 
 	link_list(fd, &ob->effect);
 	paf= ob->effect.first;
@@ -9685,6 +9716,15 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob)
 		BKE_gpencil_modifiers_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data);
 	}
 
+	/* expand_object_expandShaderFx() */
+	if (ob->shader_fx.first) {
+		struct { FileData *fd; Main *mainvar; } data;
+		data.fd = fd;
+		data.mainvar = mainvar;
+
+		BKE_shaderfx_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data);
+	}
+
 	expand_pose(fd, mainvar, ob->pose);
 	expand_doit(fd, mainvar, ob->poselib);
 	expand_constraints(fd, mainvar, &ob->constraints);
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 41f3efd5f17..e5a26926fdf 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -175,6 +175,7 @@
 #include "BKE_node.h"
 #include "BKE_report.h"
 #include "BKE_sequencer.h"
+#include "BKE_shader_fx.h"
 #include "BKE_subsurf.h"
 #include "BKE_modifier.h"
 #include "BKE_fcurve.h"
@@ -1814,6 +1815,24 @@ static void write_gpencil_modifiers(WriteData *wd, ListBase *modbase)
 	}
 }
 
+static void write_shaderfxs(WriteData *wd, ListBase *fxbase)
+{
+	ShaderFxData *fx;
+
+	if (fxbase == NULL) {
+		return;
+	}
+
+	for (fx = fxbase->first; fx; fx = fx->next) {
+		const ShaderFxTypeInfo *fxi = BKE_shaderfxType_getInfo(fx->type);
+		if (fxi == NULL) {
+			return;
+		}
+
+		writestruct_id(wd, DATA, fxi->struct_name, 1, fx);
+	}
+}
+
 static void write_object(WriteData *wd, Object *ob)
 {
 	if (ob->id.us > 0 || wd->use_memfile) {
@@ -1865,6 +1884,7 @@ static void write_object(WriteData *wd, Object *ob)
 		write_particlesystems(wd, &ob->particlesystem);
 		write_modifiers(wd, &ob->modifiers);
 		write_gpencil_modifiers(wd, &ob->greasepencil_modifiers);
+		write_shaderfxs(wd, &ob->shader_fx);
 
 		writelist(wd, DATA, LinkData, &ob->pc_ids);
 		writelist(wd, DATA, LodLevel, &ob->lodlevels);
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 4050f642392..3bfcbed1f78 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -185,11 +185,11 @@ void OBJECT_OT_gpencil_modifier_apply(struct wmOperatorType *ot);
 void OBJECT_OT_gpencil_modifier_copy(struct wmOperatorType *ot);
 
 /* shader fx */
-void OBJECT_OT_shader_fx_add(struct wmOperatorType *ot);
-void OBJECT_OT_shader_fx_remove(struct wmOperatorType *ot);
-void OBJECT_OT_shader_fx_move_up(struct wmOperatorType *ot);
-void OBJECT_OT_shader_fx_move_down(struct wmOperatorType *ot);
-void OBJECT_OT_shader_fx_copy(struct wmOperatorType *ot);
+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 */
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index a5e3a5f465e..47ef805bc2d 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -156,11 +156,11 @@ void ED_operatortypes_object(void)
 	WM_operatortype_append(OBJECT_OT_gpencil_modifier_copy);
 
 	/* shader fx */
-	WM_operatortype_append(OBJECT_OT_shader_fx_add);
-	WM_operatortype_append(OBJECT_OT_shader_fx_remove);
-	WM_operatortype_append(OBJECT_OT_shader_fx_move_up);
-	WM_operatortype_append(OBJECT_OT_shader_fx_move_down);
-	WM_operatortype_append(OBJECT_OT_shader_fx_copy);
+	WM_operatortype_append(OBJECT_OT_shaderfx_add);
+	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/makesrna/intern/rna_shader_fx.c b/source/blender/makesrna/intern/rna_shader_fx.c
index 72c763959ec..542366800df 100644
--- a/source/blender/makesrna/intern/rna_shader_fx.c
+++ b/source/blender/makesrna/intern/rna_shader_fx.c
@@ -59,7 +59,7 @@
 #include "WM_api.h"
 #include "WM_types.h"
 
-const EnumPropertyItem rna_enum_object_shader_fx_type_items[] = {
+const EnumPropertyItem rna_enum_object_shaderfx_type_items[] = {
 	{ 0, "", 0, N_("Visual Effects"), "" },
 	{eShaderFxType_Blur, "FX_BLUR", ICON_SOLO_ON, "Gaussian Blur", "Apply Gaussian Blur to object" },
 	{eShaderFxType_Flip, "FX_FLIP", ICON_SOLO_ON, "Flip", "Flip image"},
@@ -126,7 +126,7 @@ static void rna_ShaderFx_name_set(PointerRNA *ptr, const char *value)
 	/* make sure the name is truly unique */
 	if (ptr->id.data) {
 		Object *ob = ptr->id.data;
-		BKE_gpencil_shaderfx_unique_name(&ob->shader_fx, gmd);
+		BKE_shaderfx_unique_name(&ob->shader_fx, gmd);
 	}
 
 	/* fix all the animation data which may link to this */
@@ -169,17 +169,17 @@ static void shaderfx_object_set(Object *self, Object **ob_p, int type, PointerRN
 	}
 }
 
-#define RNA_GP_MOD_OBJECT_SET(_type, _prop, _obtype)                                           \
+#define RNA_FX_OBJECT_SET(_type, _prop, _obtype)                                           \
 static void rna_##_type##ShaderFx_##_prop##_set(PointerRNA *ptr, PointerRNA value)          \
 {                                                                                           \
 	_type##ShaderFxData *tmd = (_type##ShaderFxData *)ptr->data;                            \
 	shaderfx_object_set(ptr->id.data, &tmd->_prop, _obtype, value);                         \
 }
 
-RNA_MOD_OBJECT_SET(Light, object, OB_EMPTY);
-RNA_MOD_OBJECT_SET(Swirl, object, OB_EMPTY);
+RNA_FX_OBJECT_SET(Light, object, OB_EMPTY);
+RNA_FX_OBJECT_SET(Swirl, object, OB_EMPTY);
 
-#undef RNA_GP_MOD_OBJECT_SET
+#undef RNA_FX_OBJECT_SET
 
 #else
 
@@ -188,7 +188,7 @@ static void rna_def_shader_fx_blur(BlenderRNA *brna)
 	StructRNA *srna;
 	PropertyRNA *prop;
 
-	srna = RNA_def_struct(brna, "BlurModifier", "Modifier");
+	srna = RNA_def_struct(brna, "ShaderFxBlur", "ShaderFx");
 	RNA_def_struct_ui_text(srna, "Gaussian Blur Modifier", "Gaussian Blur modifier");
 	RNA_def_struct_sdna(srna, "BlurShaderFxData");
 	RNA_def_struct_ui_icon(srna, ICON_SOLO_ON);
@@ -231,7 +231,7 @@ static void rna_def_shader_fx_wave(BlenderRNA *brna)
 		{ 0, NULL, 0, NULL, NULL }
 	};
 
-	srna = RNA_def_struct(brna, "WaveModifier", "Modifier");
+	srna = RNA_def_struct(brna, "ShaderFxWave", "ShaderFx");
 	RNA_def_struct_ui_text(srna, "Wave Deformation Modifier", "Wave Deformation modifier");
 	RNA_def_struct_sdna(srna, "WaveShaderFxData");
 	RNA_def_struct_ui_icon(srna, ICON_SOLO_ON);
@@ -266,7 +266,7 @@ static void rna_def_shader_fx_pixel(BlenderRNA *brna)
 	StructRNA *srna;
 	PropertyRNA *prop;
 
-	srna = RNA_def_struct(brna, "PixelModifier", "Modifier");
+	srna = RNA_def_struct(brna, "ShaderFxPixel", "ShaderFx");
 	RNA_def_struct_ui_text(srna, "Pixelate Modifier", "Pixelate modifier");
 	RNA_def_struct_sdna(srna, "PixelShaderFxData");
 	RNA_def_struct_ui_icon(srna, ICON_SOLO_ON);
@@ -295,7 +295,7 @@ static void rna_def_shader_fx_swirl(BlenderRNA *brna)
 	StructRNA *srna;
 	PropertyRNA *prop;
 
-	srna = RNA_def_struct(brna, "SwirlModifier", "Modifier");
+	srna = RNA_def_struct(brna, "ShaderFxSwirl", "ShaderFx");
 	RNA_def_struct_ui_text(srna, "Swirl Modifier", "Swirl modifier");
 	RNA_def_struct_sdna(srna, "SwirlShaderFxData");
 	RNA_def_struct_ui_icon(srna, ICON_SOLO_ON);
@@ -330,7 +330,7 @@ static void rna_def_sha

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list