Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Parborg <darkdefende@gmail.com>2021-04-02 15:44:26 +0300
committerSebastian Parborg <darkdefende@gmail.com>2021-04-02 15:44:26 +0300
commitfa9b05149c2ca3915a4fb2670c87a648d927336c (patch)
treecd7e57cc72697b62260297b993507ff79a6114a9 /source/blender/makesrna
parente7a0a75919fd2e33869b4b8efbf0e69bf5904ea7 (diff)
Fix T84520: Make the different weight paint code paths exclusive to each other
Before this change, you could have the new sculpt symmetry code and the older weight paint symmetry code active at the same time. This would lead to users easily trashing their weigh paint data if they were not careful when switching between modes. Now the specific weight paint symmetry code is an exclusive toggle so the user can't accidentally mirror strokes and vertex groups at the same time. This also paves the way of supporting Y and Z symmetry in the future for weight groups mirroring if we decide to add it in the future. Reviewed By: Sybren Differential Revision: http://developer.blender.org/D10426
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c10
-rw-r--r--source/blender/makesrna/intern/rna_object.c97
2 files changed, 103 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index cf7d1f30dde..03b3d92eea8 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -3289,10 +3289,12 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Z", "Enable symmetry in the Z axis");
RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
- prop = RNA_def_property(srna, "use_mirror_vertex_group_x", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_VERTEX_GROUPS_X_SYMMETRY);
- RNA_def_property_ui_text(
- prop, "Vertex Groups X Symmetry", "Mirror the left/right vertex groups when painting");
+ prop = RNA_def_property(srna, "use_mirror_vertex_groups", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_MIRROR_VERTEX_GROUPS);
+ RNA_def_property_ui_text(prop,
+ "Mirror Vertex Groups",
+ "Mirror the left/right vertex groups when painting. The symmetry axis "
+ "is determined by the symmetry settings");
RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
/* End Symmetry */
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 21e9328d043..6b93a1c223c 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -2106,6 +2106,81 @@ static void rna_object_lineart_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ptr->owner_id);
}
+static bool mesh_symmetry_get_common(PointerRNA *ptr, const eMeshSymmetryType sym)
+{
+ const Object *ob = (Object *)ptr->owner_id;
+ if (ob->type != OB_MESH) {
+ return false;
+ }
+
+ const Mesh *mesh = ob->data;
+ return mesh->symmetry & sym;
+}
+
+static bool rna_Object_mesh_symmetry_x_get(PointerRNA *ptr)
+{
+ return mesh_symmetry_get_common(ptr, ME_SYMMETRY_X);
+}
+
+static bool rna_Object_mesh_symmetry_y_get(PointerRNA *ptr)
+{
+ return mesh_symmetry_get_common(ptr, ME_SYMMETRY_Y);
+}
+
+static bool rna_Object_mesh_symmetry_z_get(PointerRNA *ptr)
+{
+ return mesh_symmetry_get_common(ptr, ME_SYMMETRY_Z);
+}
+
+static void mesh_symmetry_set_common(PointerRNA *ptr,
+ const bool value,
+ const eMeshSymmetryType sym)
+{
+ Object *ob = (Object *)ptr->owner_id;
+ if (ob->type != OB_MESH) {
+ return;
+ }
+
+ Mesh *mesh = ob->data;
+ if (value) {
+ mesh->symmetry |= sym;
+ }
+ else {
+ mesh->symmetry &= ~sym;
+ }
+}
+
+static void rna_Object_mesh_symmetry_x_set(PointerRNA *ptr, bool value)
+{
+ mesh_symmetry_set_common(ptr, value, ME_SYMMETRY_X);
+}
+
+static void rna_Object_mesh_symmetry_y_set(PointerRNA *ptr, bool value)
+{
+ mesh_symmetry_set_common(ptr, value, ME_SYMMETRY_Y);
+}
+
+static void rna_Object_mesh_symmetry_z_set(PointerRNA *ptr, bool value)
+{
+ mesh_symmetry_set_common(ptr, value, ME_SYMMETRY_Z);
+}
+
+static int rna_Object_mesh_symmetry_yz_editable(PointerRNA *ptr, const char **UNUSED(r_info))
+{
+ const Object *ob = (Object *)ptr->owner_id;
+ if (ob->type != OB_MESH) {
+ return 0;
+ }
+
+ const Mesh *mesh = ob->data;
+ if (ob->mode == OB_MODE_WEIGHT_PAINT && mesh->editflag & ME_EDIT_MIRROR_VERTEX_GROUPS) {
+ /* Only X symmetry is available in weightpaint mode. */
+ return 0;
+ }
+
+ return PROP_EDITABLE;
+}
+
#else
static void rna_def_vertex_group(BlenderRNA *brna)
@@ -3499,6 +3574,28 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "ObjectLineArt");
RNA_def_property_ui_text(prop, "Line Art", "Line art settings for the object");
+ /* Mesh Symmetry Settings */
+
+ prop = RNA_def_property(srna, "use_mesh_mirror_x", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_Object_mesh_symmetry_x_get", "rna_Object_mesh_symmetry_x_set");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "X", "Enable mesh symmetry in the X axis");
+
+ prop = RNA_def_property(srna, "use_mesh_mirror_y", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_Object_mesh_symmetry_y_get", "rna_Object_mesh_symmetry_y_set");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_editable_func(prop, "rna_Object_mesh_symmetry_yz_editable");
+ RNA_def_property_ui_text(prop, "Y", "Enable mesh symmetry in the Y axis");
+
+ prop = RNA_def_property(srna, "use_mesh_mirror_z", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_Object_mesh_symmetry_z_get", "rna_Object_mesh_symmetry_z_set");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_editable_func(prop, "rna_Object_mesh_symmetry_yz_editable");
+ RNA_def_property_ui_text(prop, "Z", "Enable mesh symmetry in the Z axis");
+
RNA_define_lib_overridable(false);
/* anim */