Mirror Modifier: Add offsets for mirrored UVs
The mirror modifier now has two fields that specify a -1 to 1 offset for the U and V axes when mirroring their coordinates. D1844 by @circuitfox
This commit is contained in:
@@ -569,6 +569,14 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
|
||||
col.prop(md, "use_mirror_u", text="U")
|
||||
col.prop(md, "use_mirror_v", text="V")
|
||||
|
||||
col = layout.column(align=True)
|
||||
|
||||
if md.use_mirror_u:
|
||||
col.prop(md, "mirror_offset_u")
|
||||
|
||||
if md.use_mirror_v:
|
||||
col.prop(md, "mirror_offset_v")
|
||||
|
||||
col = layout.column()
|
||||
|
||||
if md.use_mirror_merge is True:
|
||||
|
@@ -277,6 +277,7 @@ typedef struct MirrorModifierData {
|
||||
short axis DNA_DEPRECATED; /* deprecated, use flag instead */
|
||||
short flag;
|
||||
float tolerance;
|
||||
float uv_offset[2];
|
||||
struct Object *mirror_ob;
|
||||
} MirrorModifierData;
|
||||
|
||||
|
@@ -1526,6 +1526,20 @@ static void rna_def_modifier_mirror(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Mirror V", "Mirror the V texture coordinate around the 0.5 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_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_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "merge_threshold", PROP_FLOAT, PROP_DISTANCE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "tolerance");
|
||||
RNA_def_property_range(prop, 0, FLT_MAX);
|
||||
|
@@ -274,8 +274,8 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
|
||||
int j = maxLoops;
|
||||
dmloopuv += j; /* second set of loops only */
|
||||
for (; j-- > 0; dmloopuv++) {
|
||||
if (do_mirr_u) dmloopuv->uv[0] = 1.0f - dmloopuv->uv[0];
|
||||
if (do_mirr_v) dmloopuv->uv[1] = 1.0f - dmloopuv->uv[1];
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user