[Bf-blender-cvs] [1c5f5fb95f1] master: Mirror Modifier: option to offset UV's

Campbell Barton noreply at git.blender.org
Mon Sep 25 06:03:30 CEST 2017


Commit: 1c5f5fb95f13c81fcfad0a7cf89653f86f5bdf82
Author: Campbell Barton
Date:   Mon Sep 25 14:11:27 2017 +1000
Branches: master
https://developer.blender.org/rB1c5f5fb95f13c81fcfad0a7cf89653f86f5bdf82

Mirror Modifier: option to offset UV's

Useful for baking, so UV's can be moved outside the image
and not used to bake pixels (but still used for display).

D2801 by @Zuorion

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_mirror.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index ff76c8d7d39..8f6e5f2df39 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -571,8 +571,8 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 
         col = split.column()
         col.label(text="Textures:")
-        col.prop(md, "use_mirror_u", text="U")
-        col.prop(md, "use_mirror_v", text="V")
+        col.prop(md, "use_mirror_u", text="Flip U")
+        col.prop(md, "use_mirror_v", text="Flip V")
 
         col = layout.column(align=True)
 
@@ -582,6 +582,10 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         if md.use_mirror_v:
             col.prop(md, "mirror_offset_v")
 
+        col = layout.column(align=True)
+        col.prop(md, "offset_u")
+        col.prop(md, "offset_v")
+
         col = layout.column()
 
         if md.use_mirror_merge is True:
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index e2dde412163..64856b2eb76 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -278,6 +278,7 @@ typedef struct MirrorModifierData {
 	short flag;
 	float tolerance;
 	float uv_offset[2];
+	float uv_offset_copy[2];
 	struct Object *mirror_ob;
 } MirrorModifierData;
 
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 4db8b9e9de9..74aa3759d2d 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -1518,26 +1518,40 @@ static void rna_def_modifier_mirror(BlenderRNA *brna)
 
 	prop = RNA_def_property(srna, "use_mirror_u", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MIR_MIRROR_U);
-	RNA_def_property_ui_text(prop, "Mirror U", "Mirror the U texture coordinate around the 0.5 point");
+	RNA_def_property_ui_text(prop, "Mirror U", "Mirror the U texture coordinate around the flip offset point");
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
 	prop = RNA_def_property(srna, "use_mirror_v", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MIR_MIRROR_V);
-	RNA_def_property_ui_text(prop, "Mirror V", "Mirror the V texture coordinate around the 0.5 point");
+	RNA_def_property_ui_text(prop, "Mirror V", "Mirror the V texture coordinate around the flip offset point");
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
 	prop = RNA_def_property(srna, "mirror_offset_u", PROP_FLOAT, PROP_FACTOR);
 	RNA_def_property_float_sdna(prop, NULL, "uv_offset[0]");
 	RNA_def_property_range(prop, -1, 1);
 	RNA_def_property_ui_range(prop, -1, 1, 2, 4);
-	RNA_def_property_ui_text(prop, "U Offset", "Amount to offset mirrored UVs from the 0.5 point on the U axis");
+	RNA_def_property_ui_text(prop, "Flip U Offset", "Amount to offset mirrored UVs flipping point from the 0.5 on the U axis");
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
 	prop = RNA_def_property(srna, "mirror_offset_v", PROP_FLOAT, PROP_FACTOR);
 	RNA_def_property_float_sdna(prop, NULL, "uv_offset[1]");
 	RNA_def_property_range(prop, -1, 1);
 	RNA_def_property_ui_range(prop, -1, 1, 2, 4);
-	RNA_def_property_ui_text(prop, "V Offset", "Amount to offset mirrored UVs from the 0.5 point on the V axis");
+	RNA_def_property_ui_text(prop, "Flip V Offset", "Amount to offset mirrored UVs flipping point from the 0.5 point on the V axis");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+	prop = RNA_def_property(srna, "offset_u", PROP_FLOAT, PROP_FACTOR);
+	RNA_def_property_float_sdna(prop, NULL, "uv_offset_copy[0]");
+	RNA_def_property_range(prop, -10000.0f, 10000.0f);
+	RNA_def_property_ui_range(prop, -1, 1, 2, 4);
+	RNA_def_property_ui_text(prop, "U Offset", "Mirrored UV offset on the U axis");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+	prop = RNA_def_property(srna, "offset_v", PROP_FLOAT, PROP_FACTOR);
+	RNA_def_property_float_sdna(prop, NULL, "uv_offset_copy[1]");
+	RNA_def_property_range(prop, -10000.0f, 10000.0f);
+	RNA_def_property_ui_range(prop, -1, 1, 2, 4);
+	RNA_def_property_ui_text(prop, "V Offset", "Mirrored UV offset on the V axis");
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
 	prop = RNA_def_property(srna, "merge_threshold", PROP_FLOAT, PROP_DISTANCE);
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index 7b71e616627..157f37e973c 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -265,7 +265,7 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
 
 	/* handle uvs,
 	 * let tessface recalc handle updating the MTFace data */
-	if (mmd->flag & (MOD_MIR_MIRROR_U | MOD_MIR_MIRROR_V)) {
+	if (mmd->flag & (MOD_MIR_MIRROR_U | MOD_MIR_MIRROR_V) || (is_zero_v2(mmd->uv_offset_copy) == false)) {
 		const bool do_mirr_u = (mmd->flag & MOD_MIR_MIRROR_U) != 0;
 		const bool do_mirr_v = (mmd->flag & MOD_MIR_MIRROR_V) != 0;
 
@@ -278,6 +278,8 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
 			for (; j-- > 0; dmloopuv++) {
 				if (do_mirr_u) dmloopuv->uv[0] = 1.0f - dmloopuv->uv[0] + mmd->uv_offset[0];
 				if (do_mirr_v) dmloopuv->uv[1] = 1.0f - dmloopuv->uv[1] + mmd->uv_offset[1];
+				dmloopuv->uv[0] += mmd->uv_offset_copy[0];
+				dmloopuv->uv[1] += mmd->uv_offset_copy[1];
 			}
 		}
 	}



More information about the Bf-blender-cvs mailing list