Fix T85051: Add bisect distance as a parameter to the mirror modifier
The `bisect_distance` in the mirror modifier was hard-coded to `0.001`. This would result in some unexpected behavior like vertices close to the mirror plane being deleted or merged. The fix now adds a parameter to the mirror modifier to expose the bisect distance to the user. The default is set to the previous hard-coded value to not "change" previous files. Ref D10201
This commit is contained in:
@@ -39,7 +39,7 @@ extern "C" {
|
||||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 18
|
||||
#define BLENDER_FILE_SUBVERSION 19
|
||||
|
||||
/* Minimum Blender version that supports reading file written with the current
|
||||
* version. Older Blender versions will test this and show a warning if the file
|
||||
|
||||
@@ -51,7 +51,7 @@ Mesh *BKE_mesh_mirror_bisect_on_mirror_plane_for_modifier(MirrorModifierData *mm
|
||||
(axis == 1 && mmd->flag & MOD_MIR_BISECT_FLIP_AXIS_Y) ||
|
||||
(axis == 2 && mmd->flag & MOD_MIR_BISECT_FLIP_AXIS_Z));
|
||||
|
||||
const float bisect_distance = 0.001f;
|
||||
const float bisect_distance = mmd->bisect_threshold;
|
||||
|
||||
Mesh *result;
|
||||
BMesh *bm;
|
||||
|
||||
@@ -2059,6 +2059,19 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
||||
}
|
||||
}
|
||||
|
||||
/* Set default value for the new bisect_threshold parameter in the mirror modifier. */
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 293, 19)) {
|
||||
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
|
||||
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
|
||||
if (md->type == eModifierType_Mirror) {
|
||||
MirrorModifierData *mmd = (MirrorModifierData *)md;
|
||||
/* This was the previous hard-coded value. */
|
||||
mmd->bisect_threshold = 0.001f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
|
||||
@@ -429,6 +429,7 @@
|
||||
{ \
|
||||
.flag = MOD_MIR_AXIS_X | MOD_MIR_VGROUP, \
|
||||
.tolerance = 0.001f, \
|
||||
.bisect_threshold = 0.001f, \
|
||||
.uv_offset = {0.0f, 0.0f}, \
|
||||
.uv_offset_copy = {0.0f, 0.0f}, \
|
||||
.mirror_ob = NULL, \
|
||||
|
||||
@@ -368,6 +368,8 @@ typedef struct MirrorModifierData {
|
||||
short axis DNA_DEPRECATED;
|
||||
short flag;
|
||||
float tolerance;
|
||||
float bisect_threshold;
|
||||
char _pad[4];
|
||||
float uv_offset[2];
|
||||
float uv_offset_copy[2];
|
||||
struct Object *mirror_ob;
|
||||
|
||||
@@ -2226,6 +2226,14 @@ static void rna_def_modifier_mirror(BlenderRNA *brna)
|
||||
prop, "Merge Distance", "Distance within which mirrored vertices are merged");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "bisect_threshold", PROP_FLOAT, PROP_DISTANCE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "bisect_threshold");
|
||||
RNA_def_property_range(prop, 0, FLT_MAX);
|
||||
RNA_def_property_ui_range(prop, 0, 1, 0.01, 6);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Bisect Distance", "Distance from the bisect plane within which vertices are removed");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "mirror_object", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_pointer_sdna(prop, NULL, "mirror_ob");
|
||||
RNA_def_property_ui_text(prop, "Mirror Object", "Object to use as mirror");
|
||||
|
||||
@@ -165,6 +165,13 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_mirror_merge"));
|
||||
uiItemR(sub, ptr, "merge_threshold", 0, "", ICON_NONE);
|
||||
|
||||
bool is_bisect_set[3];
|
||||
RNA_boolean_get_array(ptr, "use_bisect_axis", is_bisect_set);
|
||||
|
||||
sub = uiLayoutRow(col, true);
|
||||
uiLayoutSetActive(sub, is_bisect_set[0] || is_bisect_set[1] || is_bisect_set[2]);
|
||||
uiItemR(sub, ptr, "bisect_threshold", 0, IFACE_("Bisect Distance"), ICON_NONE);
|
||||
|
||||
modifier_panel_end(layout, ptr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user