[Bf-blender-cvs] [158b4e6] master: Mesh Modifiers: refactor copying using a generic function

Campbell Barton noreply at git.blender.org
Sat Dec 21 18:39:46 CET 2013


Commit: 158b4e61a050a25fec47a00797ab7db46fc3198c
Author: Campbell Barton
Date:   Sun Dec 22 04:35:52 2013 +1100
http://developer.blender.org/rB158b4e61a050a25fec47a00797ab7db46fc3198c

Mesh Modifiers: refactor copying using a generic function

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

M	source/blender/blenkernel/BKE_modifier.h
M	source/blender/blenkernel/intern/modifier.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/modifiers/intern/MOD_array.c
M	source/blender/modifiers/intern/MOD_boolean.c
M	source/blender/modifiers/intern/MOD_build.c
M	source/blender/modifiers/intern/MOD_cast.c
M	source/blender/modifiers/intern/MOD_curve.c
M	source/blender/modifiers/intern/MOD_decimate.c
M	source/blender/modifiers/intern/MOD_displace.c
M	source/blender/modifiers/intern/MOD_edgesplit.c
M	source/blender/modifiers/intern/MOD_explode.c
M	source/blender/modifiers/intern/MOD_hook.c
M	source/blender/modifiers/intern/MOD_laplaciandeform.c
M	source/blender/modifiers/intern/MOD_laplaciansmooth.c
M	source/blender/modifiers/intern/MOD_lattice.c
M	source/blender/modifiers/intern/MOD_mask.c
M	source/blender/modifiers/intern/MOD_meshcache.c
M	source/blender/modifiers/intern/MOD_mirror.c
M	source/blender/modifiers/intern/MOD_multires.c
M	source/blender/modifiers/intern/MOD_particleinstance.c
M	source/blender/modifiers/intern/MOD_particlesystem.c
M	source/blender/modifiers/intern/MOD_remesh.c
M	source/blender/modifiers/intern/MOD_screw.c
M	source/blender/modifiers/intern/MOD_shrinkwrap.c
M	source/blender/modifiers/intern/MOD_simpledeform.c
M	source/blender/modifiers/intern/MOD_skin.c
M	source/blender/modifiers/intern/MOD_smooth.c
M	source/blender/modifiers/intern/MOD_solidify.c
M	source/blender/modifiers/intern/MOD_subsurf.c
M	source/blender/modifiers/intern/MOD_triangulate.c
M	source/blender/modifiers/intern/MOD_uvproject.c
M	source/blender/modifiers/intern/MOD_uvwarp.c
M	source/blender/modifiers/intern/MOD_warp.c
M	source/blender/modifiers/intern/MOD_wave.c
M	source/blender/modifiers/intern/MOD_weightvgedit.c
M	source/blender/modifiers/intern/MOD_weightvgmix.c
M	source/blender/modifiers/intern/MOD_weightvgproximity.c

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

diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 3275adf..25dee61 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -318,6 +318,7 @@ void          modifier_free(struct ModifierData *md);
 
 void          modifier_unique_name(struct ListBase *modifiers, struct ModifierData *md);
 
+void          modifier_copyData_generic(const struct ModifierData *md, struct ModifierData *target);
 void          modifier_copyData(struct ModifierData *md, struct ModifierData *target);
 bool          modifier_dependsOnTime(struct ModifierData *md);
 bool          modifier_supportsMapping(struct ModifierData *md);
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 4d2f697..f9a0d46 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -253,6 +253,19 @@ void modifiers_foreachTexLink(Object *ob, TexWalkFunc walk, void *userData)
 	}
 }
 
+/* callback's can use this
+ * to avoid copying every member.
+ */
+void modifier_copyData_generic(const ModifierData *md_src, ModifierData *md_dst)
+{
+	ModifierTypeInfo *mti = modifierType_getInfo(md_src->type);
+	const size_t data_size = sizeof(ModifierData);
+	const char *md_src_data = ((char *)md_src) + data_size;
+	char       *md_dst_data = ((char *)md_dst) + data_size;
+	BLI_assert(data_size <= (size_t)mti->structSize);
+	memcpy(md_dst_data, md_src_data, (size_t)mti->structSize - data_size);
+}
+
 void modifier_copyData(ModifierData *md, ModifierData *target)
 {
 	ModifierTypeInfo *mti = modifierType_getInfo(md->type);
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 92055fd..b3c7427 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -646,7 +646,7 @@ typedef struct ParticleSystemModifierData {
 	struct ParticleSystem *psys;
 	struct DerivedMesh *dm;
 	int totdmvert, totdmedge, totdmface;
-	short flag, rt;
+	short flag, pad;
 } ParticleSystemModifierData;
 
 typedef enum {
@@ -670,7 +670,7 @@ typedef struct ParticleInstanceModifierData {
 	ModifierData modifier;
 
 	struct Object *ob;
-	short psys, flag, axis, rt;
+	short psys, flag, axis, pad;
 	float position, random_position;
 } ParticleInstanceModifierData;
 
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index bc38b0e..2bf7bb5 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -84,21 +84,11 @@ static void initData(ModifierData *md)
 
 static void copyData(ModifierData *md, ModifierData *target)
 {
+#if 0
 	ArrayModifierData *amd = (ArrayModifierData *) md;
 	ArrayModifierData *tamd = (ArrayModifierData *) target;
-
-	tamd->start_cap = amd->start_cap;
-	tamd->end_cap = amd->end_cap;
-	tamd->curve_ob = amd->curve_ob;
-	tamd->offset_ob = amd->offset_ob;
-	tamd->count = amd->count;
-	copy_v3_v3(tamd->offset, amd->offset);
-	copy_v3_v3(tamd->scale, amd->scale);
-	tamd->length = amd->length;
-	tamd->merge_dist = amd->merge_dist;
-	tamd->fit_type = amd->fit_type;
-	tamd->offset_type = amd->offset_type;
-	tamd->flags = amd->flags;
+#endif
+	modifier_copyData_generic(md, target);
 }
 
 static void foreachObjectLink(
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index 03d40eb..bee7a32 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -52,11 +52,11 @@
 
 static void copyData(ModifierData *md, ModifierData *target)
 {
+#if 0
 	BooleanModifierData *bmd = (BooleanModifierData *) md;
 	BooleanModifierData *tbmd = (BooleanModifierData *) target;
-
-	tbmd->object = bmd->object;
-	tbmd->operation = bmd->operation;
+#endif
+	modifier_copyData_generic(md, target);
 }
 
 static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c
index a54cc80..d74044f 100644
--- a/source/blender/modifiers/intern/MOD_build.c
+++ b/source/blender/modifiers/intern/MOD_build.c
@@ -62,13 +62,11 @@ static void initData(ModifierData *md)
 
 static void copyData(ModifierData *md, ModifierData *target)
 {
+#if 0
 	BuildModifierData *bmd = (BuildModifierData *) md;
 	BuildModifierData *tbmd = (BuildModifierData *) target;
-
-	tbmd->start = bmd->start;
-	tbmd->length = bmd->length;
-	tbmd->randomize = bmd->randomize;
-	tbmd->seed = bmd->seed;
+#endif
+	modifier_copyData_generic(md, target);
 }
 
 static bool dependsOnTime(ModifierData *UNUSED(md))
diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c
index 05b51c2..44cf240 100644
--- a/source/blender/modifiers/intern/MOD_cast.c
+++ b/source/blender/modifiers/intern/MOD_cast.c
@@ -66,16 +66,11 @@ static void initData(ModifierData *md)
 
 static void copyData(ModifierData *md, ModifierData *target)
 {
+#if 0
 	CastModifierData *cmd = (CastModifierData *) md;
 	CastModifierData *tcmd = (CastModifierData *) target;
-
-	tcmd->fac = cmd->fac;
-	tcmd->radius = cmd->radius;
-	tcmd->size = cmd->size;
-	tcmd->flag = cmd->flag;
-	tcmd->type = cmd->type;
-	tcmd->object = cmd->object;
-	BLI_strncpy(tcmd->defgrp_name, cmd->defgrp_name, sizeof(tcmd->defgrp_name));
+#endif
+	modifier_copyData_generic(md, target);
 }
 
 static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c
index 28749d5..2804218 100644
--- a/source/blender/modifiers/intern/MOD_curve.c
+++ b/source/blender/modifiers/intern/MOD_curve.c
@@ -59,12 +59,11 @@ static void initData(ModifierData *md)
 
 static void copyData(ModifierData *md, ModifierData *target)
 {
+#if 0
 	CurveModifierData *cmd = (CurveModifierData *) md;
 	CurveModifierData *tcmd = (CurveModifierData *) target;
-
-	tcmd->defaxis = cmd->defaxis;
-	tcmd->object = cmd->object;
-	BLI_strncpy(tcmd->name, cmd->name, sizeof(tcmd->name));
+#endif
+	modifier_copyData_generic(md, target);
 }
 
 static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c
index e4399d1..155ccf0 100644
--- a/source/blender/modifiers/intern/MOD_decimate.c
+++ b/source/blender/modifiers/intern/MOD_decimate.c
@@ -70,15 +70,11 @@ static void initData(ModifierData *md)
 
 static void copyData(ModifierData *md, ModifierData *target)
 {
+#if 0
 	DecimateModifierData *dmd = (DecimateModifierData *) md;
 	DecimateModifierData *tdmd = (DecimateModifierData *) target;
-
-	tdmd->percent = dmd->percent;
-	tdmd->iter = dmd->iter;
-	tdmd->angle = dmd->angle;
-	BLI_strncpy(tdmd->defgrp_name, dmd->defgrp_name, sizeof(tdmd->defgrp_name));
-	tdmd->flag = dmd->flag;
-	tdmd->mode = dmd->mode;
+#endif
+	modifier_copyData_generic(md, target);
 }
 
 static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index 61f5495..54f2e68 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -69,17 +69,12 @@ static void initData(ModifierData *md)
 
 static void copyData(ModifierData *md, ModifierData *target)
 {
+#if 0
 	DisplaceModifierData *dmd = (DisplaceModifierData *) md;
+#endif
 	DisplaceModifierData *tdmd = (DisplaceModifierData *) target;
 
-	tdmd->texture = dmd->texture;
-	tdmd->strength = dmd->strength;
-	tdmd->direction = dmd->direction;
-	BLI_strncpy(tdmd->defgrp_name, dmd->defgrp_name, sizeof(tdmd->defgrp_name));
-	tdmd->midlevel = dmd->midlevel;
-	tdmd->texmapping = dmd->texmapping;
-	tdmd->map_object = dmd->map_object;
-	BLI_strncpy(tdmd->uvlayer_name, dmd->uvlayer_name, sizeof(tdmd->uvlayer_name));
+	modifier_copyData_generic(md, target);
 
 	if (tdmd->texture) {
 		id_us_plus(&tdmd->texture->id);
diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c
index a17858d..609d37a 100644
--- a/source/blender/modifiers/intern/MOD_edgesplit.c
+++ b/source/blender/modifiers/intern/MOD_edgesplit.c
@@ -113,11 +113,11 @@ static void initData(ModifierData *md)
 
 static void copyData(ModifierData *md, ModifierData *target)
 {
+#if 0
 	EdgeSplitModifierData *emd = (EdgeSplitModifierData *) md;
 	EdgeSplitModifierData *temd = (EdgeSplitModifierData *) target;
-
-	temd->split_angle = emd->split_angle;
-	temd->flags = emd->flags;
+#endif
+	modifier_copyData_generic(md, target);
 }
 
 static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), DerivedMesh *dm,
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c
index 9fd11f7..aef6a12 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -72,13 +72,14 @@ static void freeData(ModifierData *md)
 }
 static void copyData(ModifierData *md, ModifierData *target)
 {
+#if 0
 	ExplodeModifierData *emd = (ExplodeModifierData *) md;
+#endif
 	ExplodeModifierData *temd = (ExplodeModifierData *) target;
 
+	modifier_copyData_generic(md, target);
+
 	temd->facepa = NULL;
-	temd->flag = emd->flag;
-	temd->protect = emd->protect;
-	temd->vgroup = emd->vgroup;
 }
 static bool dependsOnTime(ModifierData *UNUSED(md))
 {
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c
index 4e8af65..31aad53 100644
--- a/source/blender/modifiers/intern/MOD_hook.c
+++ b/source/blender/modifiers/intern/MOD_hook.c
@@ -64,15 +64,9 @@ static void copyData(ModifierData *md, ModifierData *target)
 	HookModifierData *hmd = (HookModifierData *) md;
 	HookModifierData *thmd = (HookModifierData *) target;
 
-	copy_v3_v3(thmd->cent, hmd->cent);
-	thmd->falloff = hmd->falloff;
-	thmd->force = hmd->force;
-	thmd->object = hmd->object;
-	thmd->totindex = hmd->totindex;
+	modifier_copyData_generic(md, target);
+
 	thmd->indexar = MEM_dupa

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list