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:
authorPablo Dobarro <pablodp606@gmail.com>2020-09-18 20:58:48 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-09-18 20:58:58 +0300
commit5502517c3c12086c111ae5477fae9c0d2eb8a84c (patch)
tree07a1978b5b81b5c1679a002111457acf73561a37 /source/blender
parent827dfd76dddec962e67825815931d4f2953c741b (diff)
Unify all XYZ symmetry options using Mesh Symmetry
This adds XYZ symmetry as a property of meshes and updates all modes to use the mesh symmetry by default to have a consistent tool behavior between all modes and when switching objects. Reviewed By: brecht, mano-wii, campbellbarton Maniphest Tasks: T79785 Differential Revision: https://developer.blender.org/D8587
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenloader/intern/versioning_290.c9
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c2
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c8
-rw-r--r--source/blender/editors/object/object_remesh.c7
-rw-r--r--source/blender/editors/object/object_vgroup.c28
-rw-r--r--source/blender/editors/physics/particle_edit.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c3
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c13
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c15
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c12
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_automasking.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_boundary.c10
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h3
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_mask_expand.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_pose.c8
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_transform.c5
-rw-r--r--source/blender/editors/transform/transform_generics.c6
-rw-r--r--source/blender/makesdna/DNA_mesh_types.h13
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c36
22 files changed, 117 insertions, 75 deletions
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 1d4912db330..a8452887791 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -750,5 +750,14 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
+
+ /* Unify symmetry as a mesh property. */
+ if (!DNA_struct_elem_find(fd->filesdna, "Mesh", "char", "symmetry")) {
+ LISTBASE_FOREACH (Mesh *, mesh, &bmain->meshes) {
+ /* The previous flags used to store mesh symmery in edit mode match the new ones that are
+ * used in mesh->symmery. */
+ mesh->symmetry = mesh->editflag & (ME_SYMMETRY_X | ME_SYMMETRY_Y | ME_SYMMETRY_Z);
+ }
+ }
}
}
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 6df0c7cc5ad..66865fcfde6 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -395,7 +395,7 @@ static void drw_mesh_weight_state_extract(Object *ob,
wstate->flags |= DRW_MESH_WEIGHT_STATE_MULTIPAINT |
(ts->auto_normalize ? DRW_MESH_WEIGHT_STATE_AUTO_NORMALIZE : 0);
- if (me->editflag & ME_EDIT_MIRROR_X) {
+ if (me->symmetry & ME_SYMMETRY_X) {
BKE_object_defgroup_mirror_selection(ob,
wstate->defgroup_len,
wstate->defgroup_sel,
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 4e1a56b3b55..c52381b5e2a 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -2512,7 +2512,7 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op)
}
/* mirror before smooth */
- if (((Mesh *)obedit->data)->editflag & ME_EDIT_MIRROR_X) {
+ if (((Mesh *)obedit->data)->symmetry & ME_SYMMETRY_X) {
EDBM_verts_mirror_cache_begin(em, 0, false, true, false, use_topology);
}
@@ -2559,7 +2559,7 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op)
}
/* apply mirror */
- if (((Mesh *)obedit->data)->editflag & ME_EDIT_MIRROR_X) {
+ if (((Mesh *)obedit->data)->symmetry & ME_SYMMETRY_X) {
EDBM_verts_mirror_apply(em, BM_ELEM_SELECT, 0);
EDBM_verts_mirror_cache_end(em);
}
@@ -2657,7 +2657,7 @@ static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op)
}
/* Mirror before smooth. */
- if (((Mesh *)obedit->data)->editflag & ME_EDIT_MIRROR_X) {
+ if (((Mesh *)obedit->data)->symmetry & ME_SYMMETRY_X) {
EDBM_verts_mirror_cache_begin(em, 0, false, true, false, use_topology);
}
@@ -2683,7 +2683,7 @@ static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op)
}
/* Apply mirror. */
- if (((Mesh *)obedit->data)->editflag & ME_EDIT_MIRROR_X) {
+ if (((Mesh *)obedit->data)->symmetry & ME_SYMMETRY_X) {
EDBM_verts_mirror_apply(em, BM_ELEM_SELECT, 0);
EDBM_verts_mirror_cache_end(em);
}
diff --git a/source/blender/editors/object/object_remesh.c b/source/blender/editors/object/object_remesh.c
index f14c734da4e..a0cfdac1ac6 100644
--- a/source/blender/editors/object/object_remesh.c
+++ b/source/blender/editors/object/object_remesh.c
@@ -952,9 +952,10 @@ static int quadriflow_remesh_exec(bContext *C, wmOperator *op)
job->smooth_normals = RNA_boolean_get(op->ptr, "smooth_normals");
/* Update the target face count if symmetry is enabled */
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- if (sd && job->use_paint_symmetry) {
- job->symmetry_axes = (eSymmetryAxes)(sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL);
+ Object *ob = CTX_data_active_object(C);
+ if (ob && job->use_paint_symmetry) {
+ Mesh *mesh = BKE_mesh_from_object(ob);
+ job->symmetry_axes = (eSymmetryAxes)mesh->symmetry;
for (char i = 0; i < 3; i++) {
eSymmetryAxes symm_it = (eSymmetryAxes)(1 << i);
if (job->symmetry_axes & symm_it) {
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index b8811408339..1b8042b2f02 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -578,7 +578,7 @@ void ED_vgroup_vert_active_mirror(Object *ob, int def_nr)
BMEditMesh *em = me->edit_mesh;
MDeformVert *dvert_act;
- if (me->editflag & ME_EDIT_MIRROR_X) {
+ if (me->symmetry & ME_SYMMETRY_X) {
if (em) {
BMVert *eve_act;
dvert_act = ED_mesh_active_dvert_get_em(ob, &eve_act);
@@ -634,7 +634,7 @@ static bool vgroup_normalize_active_vertex(Object *ob, eVGroupSelect subset_type
BKE_defvert_normalize_subset(dvert_act, vgroup_validmap, vgroup_tot);
MEM_freeN((void *)vgroup_validmap);
- if (me->editflag & ME_EDIT_MIRROR_X) {
+ if (me->symmetry & ME_SYMMETRY_X) {
if (em) {
const int cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT);
ED_mesh_defvert_mirror_update_em(ob, eve_act, -1, -1, cd_dvert_offset);
@@ -667,7 +667,7 @@ static void vgroup_copy_active_to_sel(Object *ob, eVGroupSelect subset_type)
if (BM_elem_flag_test(eve, BM_ELEM_SELECT) && eve != eve_act) {
MDeformVert *dv = BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset);
BKE_defvert_copy_subset(dv, dvert_act, vgroup_validmap, vgroup_tot);
- if (me->editflag & ME_EDIT_MIRROR_X) {
+ if (me->symmetry & ME_SYMMETRY_X) {
ED_mesh_defvert_mirror_update_em(ob, eve, -1, i, cd_dvert_offset);
}
}
@@ -684,7 +684,7 @@ static void vgroup_copy_active_to_sel(Object *ob, eVGroupSelect subset_type)
for (i = 0; i < me->totvert; i++, dv++) {
if ((me->mvert[i].flag & SELECT) && dv != dvert_act) {
BKE_defvert_copy_subset(dv, dvert_act, vgroup_validmap, vgroup_tot);
- if (me->editflag & ME_EDIT_MIRROR_X) {
+ if (me->symmetry & ME_SYMMETRY_X) {
ED_mesh_defvert_mirror_update_ob(ob, -1, i);
}
}
@@ -1592,7 +1592,7 @@ static void vgroup_levels_subset(Object *ob,
const bool use_vert_sel = vertex_group_use_vert_sel(ob);
const bool use_mirror = (ob->type == OB_MESH) ?
- (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X) != 0 :
+ (((Mesh *)ob->data)->symmetry & ME_SYMMETRY_X) != 0 :
false;
ED_vgroup_parray_alloc(ob->data, &dvert_array, &dvert_tot, use_vert_sel);
@@ -1747,7 +1747,7 @@ static bool *vgroup_selected_get(Object *ob)
/* Mirror the selection if X Mirror is enabled. */
Mesh *me = BKE_mesh_from_object(ob);
- if (me && (me->editflag & ME_EDIT_MIRROR_X) != 0) {
+ if (me && (me->symmetry & ME_SYMMETRY_X) != 0) {
BKE_object_defgroup_mirror_selection(ob, defbase_tot, mask, mask, &sel_count);
}
}
@@ -1847,7 +1847,7 @@ static void vgroup_invert_subset(Object *ob,
int dvert_tot = 0;
const bool use_vert_sel = vertex_group_use_vert_sel(ob);
const bool use_mirror = (ob->type == OB_MESH) ?
- (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X) != 0 :
+ (((Mesh *)ob->data)->symmetry & ME_SYMMETRY_X) != 0 :
false;
ED_vgroup_parray_alloc(ob->data, &dvert_array, &dvert_tot, use_vert_sel);
@@ -1905,7 +1905,7 @@ static void vgroup_smooth_subset(Object *ob,
int *vgroup_subset_map = BLI_array_alloca(vgroup_subset_map, subset_count);
float *vgroup_subset_weights = BLI_array_alloca(vgroup_subset_weights, subset_count);
const bool use_mirror = (ob->type == OB_MESH) ?
- (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X) != 0 :
+ (((Mesh *)ob->data)->symmetry & ME_SYMMETRY_X) != 0 :
false;
const bool use_select = vertex_group_use_vert_sel(ob);
const bool use_hide = use_select;
@@ -2219,7 +2219,7 @@ static void vgroup_clean_subset(Object *ob,
int dvert_tot = 0;
const bool use_vert_sel = vertex_group_use_vert_sel(ob);
const bool use_mirror = (ob->type == OB_MESH) ?
- (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X) != 0 :
+ (((Mesh *)ob->data)->symmetry & ME_SYMMETRY_X) != 0 :
false;
ED_vgroup_parray_alloc(ob->data, &dvert_array, &dvert_tot, use_vert_sel);
@@ -2249,7 +2249,7 @@ static void vgroup_quantize_subset(Object *ob,
int dvert_tot = 0;
const bool use_vert_sel = vertex_group_use_vert_sel(ob);
const bool use_mirror = (ob->type == OB_MESH) ?
- (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X) != 0 :
+ (((Mesh *)ob->data)->symmetry & ME_SYMMETRY_X) != 0 :
false;
ED_vgroup_parray_alloc(ob->data, &dvert_array, &dvert_tot, use_vert_sel);
@@ -4286,14 +4286,14 @@ static void vgroup_copy_active_to_sel_single(Object *ob, const int def_nr)
if (dw) {
dw->weight = weight_act;
- if (me->editflag & ME_EDIT_MIRROR_X) {
+ if (me->symmetry & ME_SYMMETRY_X) {
ED_mesh_defvert_mirror_update_em(ob, eve, -1, i, cd_dvert_offset);
}
}
}
}
- if (me->editflag & ME_EDIT_MIRROR_X) {
+ if (me->symmetry & ME_SYMMETRY_X) {
ED_mesh_defvert_mirror_update_em(ob, eve_act, -1, -1, cd_dvert_offset);
}
}
@@ -4313,14 +4313,14 @@ static void vgroup_copy_active_to_sel_single(Object *ob, const int def_nr)
MDeformWeight *dw = BKE_defvert_find_index(dv, def_nr);
if (dw) {
dw->weight = weight_act;
- if (me->editflag & ME_EDIT_MIRROR_X) {
+ if (me->symmetry & ME_SYMMETRY_X) {
ED_mesh_defvert_mirror_update_ob(ob, -1, i);
}
}
}
}
- if (me->editflag & ME_EDIT_MIRROR_X) {
+ if (me->symmetry & ME_SYMMETRY_X) {
ED_mesh_defvert_mirror_update_ob(ob, -1, v_act);
}
}
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 65d83b5a776..6ee038a9527 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -403,7 +403,7 @@ void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra)
static int pe_x_mirror(Object *ob)
{
if (ob->type == OB_MESH) {
- return (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X);
+ return (((Mesh *)ob->data)->symmetry & ME_SYMMETRY_X);
}
return 0;
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 55abb269660..69b2a7d1fbb 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -1090,7 +1090,7 @@ static void cursor_draw_point_with_symmetry(const uint gpuattr,
Object *ob,
const float radius)
{
- const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
float location[3], symm_rot_mat[4][4];
for (int i = 0; i <= symm; i++) {
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index b0ad3ae1302..6f115acc856 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -5887,7 +5887,8 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m
ps_handle->orig_brush_size = BKE_brush_size_get(scene, ps_handle->brush);
- ps_handle->symmetry_flags = settings->imapaint.paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ Mesh *mesh = BKE_mesh_from_object(ob);
+ ps_handle->symmetry_flags = mesh->symmetry;
ps_handle->ps_views_tot = 1 + (pow_i(2, count_bits_i(ps_handle->symmetry_flags)) - 1);
bool is_multi_view = (ps_handle->ps_views_tot != 1);
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index 1f86fc84f59..fc17af8d2cb 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -312,8 +312,6 @@ static void sculpt_gesture_context_init_common(bContext *C,
{
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ED_view3d_viewcontext_init(C, &sgcontext->vc, depsgraph);
-
- Sculpt *sd = sgcontext->vc.scene->toolsettings->sculpt;
Object *ob = sgcontext->vc.obact;
/* Operator properties. */
@@ -323,7 +321,7 @@ static void sculpt_gesture_context_init_common(bContext *C,
sgcontext->ss = ob->sculpt;
/* Symmetry. */
- sgcontext->symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ sgcontext->symm = SCULPT_mesh_symmetry_xyz_get(ob);
/* View Normal. */
float mat[3][3];
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 3753709875b..4a3babde5f3 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -765,7 +765,7 @@ static void do_weight_paint_vertex_single(
MDeformWeight *dw_mirr;
/* from now on we can check if mirrors enabled if this var is -1 and not bother with the flag */
- if (me->editflag & ME_EDIT_MIRROR_X) {
+ if (me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY) {
index_mirr = mesh_get_x_mirror_vert(ob, NULL, index, topology);
vgroup_mirr = wpi->mirror.index;
@@ -961,7 +961,7 @@ static void do_weight_paint_vertex_multi(
float dw_rel_free, dw_rel_locked;
/* from now on we can check if mirrors enabled if this var is -1 and not bother with the flag */
- if (me->editflag & ME_EDIT_MIRROR_X) {
+ if (me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY) {
index_mirr = mesh_get_x_mirror_vert(ob, NULL, index, topology);
if (index_mirr != -1 && index_mirr != index) {
@@ -1610,7 +1610,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo
int i;
bDeformGroup *dg;
- if (me->editflag & ME_EDIT_MIRROR_X) {
+ if (me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY) {
BKE_object_defgroup_mirror_selection(
ob, defbase_tot, defbase_sel, defbase_sel, &defbase_tot_sel);
}
@@ -2173,7 +2173,8 @@ static void wpaint_paint_leaves(bContext *C,
/* NOTE: current mirroring code cannot be run in parallel */
TaskParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, !(me->editflag & ME_EDIT_MIRROR_X), totnode);
+ BKE_pbvh_parallel_range_settings(
+ &settings, !(me->flag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY), totnode);
switch ((eBrushWeightPaintTool)brush->weightpaint_tool) {
case WPAINT_TOOL_AVERAGE:
@@ -2291,7 +2292,7 @@ static void wpaint_do_symmetrical_brush_actions(
Mesh *me = ob->data;
SculptSession *ss = ob->sculpt;
StrokeCache *cache = ss->cache;
- const char symm = wp->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
int i = 0;
/* initial stroke */
@@ -3311,7 +3312,7 @@ static void vpaint_do_symmetrical_brush_actions(
Mesh *me = ob->data;
SculptSession *ss = ob->sculpt;
StrokeCache *cache = ss->cache;
- const char symm = vp->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
int i = 0;
/* initial stroke */
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
index 9b8252e1add..eea79bad789 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -120,8 +120,13 @@ static int weight_from_bones_exec(bContext *C, wmOperator *op)
Mesh *me = ob->data;
int type = RNA_enum_get(op->ptr, "type");
- ED_object_vgroup_calc_from_armature(
- op->reports, depsgraph, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X));
+ ED_object_vgroup_calc_from_armature(op->reports,
+ depsgraph,
+ scene,
+ ob,
+ armob,
+ type,
+ (me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY));
DEG_id_tag_update(&me->id, 0);
DEG_relations_tag_update(CTX_data_main(C));
@@ -232,7 +237,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *even
vc.obact, defbase_tot, &defbase_tot_sel);
if (defbase_tot_sel > 1) {
- if (me->editflag & ME_EDIT_MIRROR_X) {
+ if (me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY) {
BKE_object_defgroup_mirror_selection(
vc.obact, defbase_tot, defbase_sel, defbase_sel, &defbase_tot_sel);
}
@@ -458,7 +463,7 @@ static bool weight_paint_set(Object *ob, float paintweight)
vgroup_active = ob->actdef - 1;
/* if mirror painting, find the other group */
- if (me->editflag & ME_EDIT_MIRROR_X) {
+ if (me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY) {
vgroup_mirror = ED_wpaint_mirror_vgroup_ensure(ob, vgroup_active);
}
@@ -486,7 +491,7 @@ static bool weight_paint_set(Object *ob, float paintweight)
dw_prev->weight = dw->weight; /* set the undo weight */
dw->weight = paintweight;
- if (me->editflag & ME_EDIT_MIRROR_X) { /* x mirror painting */
+ if (me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY) { /* x mirror painting */
int j = mesh_get_x_mirror_vert(ob, NULL, vidx, topology);
if (j >= 0) {
/* copy, not paint again */
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
index a483f63bc06..dc777572858 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
@@ -118,7 +118,7 @@ bool ED_wpaint_ensure_data(bContext *C,
}
if (flag & WPAINT_ENSURE_MIRROR) {
- if (me->editflag & ME_EDIT_MIRROR_X) {
+ if (me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY) {
int mirror = ED_wpaint_mirror_vgroup_ensure(ob, ob->actdef - 1);
if (vgroup_index) {
vgroup_index->mirror = mirror;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index a577760cf9b..0b4f853b677 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -296,6 +296,12 @@ float *SCULPT_brush_deform_target_vertex_co_get(SculptSession *ss,
return iter->co;
}
+char SCULPT_mesh_symmetry_xyz_get(Object *object)
+{
+ const Mesh *mesh = BKE_mesh_from_object(object);
+ return mesh->symmetry;
+}
+
/* Sculpt Face Sets and Visibility. */
int SCULPT_active_face_set_get(SculptSession *ss)
@@ -1057,7 +1063,7 @@ void SCULPT_floodfill_add_initial_with_symmetry(
Sculpt *sd, Object *ob, SculptSession *ss, SculptFloodFill *flood, int index, float radius)
{
/* Add active vertex and symmetric vertices to the queue. */
- const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
for (char i = 0; i <= symm; ++i) {
if (SCULPT_is_symmetry_iteration_valid(i, symm)) {
int v = -1;
@@ -1081,7 +1087,7 @@ void SCULPT_floodfill_add_active(
Sculpt *sd, Object *ob, SculptSession *ss, SculptFloodFill *flood, float radius)
{
/* Add active vertex and symmetric vertices to the queue. */
- const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
for (char i = 0; i <= symm; ++i) {
if (SCULPT_is_symmetry_iteration_valid(i, symm)) {
int v = -1;
@@ -6247,7 +6253,7 @@ static void do_symmetrical_brush_actions(Sculpt *sd,
Brush *brush = BKE_paint_brush(&sd->paint);
SculptSession *ss = ob->sculpt;
StrokeCache *cache = ss->cache;
- const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
float feather = calc_symmetry_feather(sd, ss->cache);
diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.c b/source/blender/editors/sculpt_paint/sculpt_automasking.c
index eef090f484e..241f1167316 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.c
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.c
@@ -213,7 +213,7 @@ static float *SCULPT_topology_automasking_init(Sculpt *sd, Object *ob, float *au
.automask_factor = automask_factor,
.radius = ss->cache->radius,
.use_radius = sculpt_automasking_is_constrained_by_radius(brush),
- .symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL,
+ .symm = SCULPT_mesh_symmetry_xyz_get(ob),
};
copy_v3_v3(fdata.location, SCULPT_active_vertex_co_get(ss));
SCULPT_floodfill_execute(ss, &flood, automask_floodfill_cb, &fdata);
diff --git a/source/blender/editors/sculpt_paint/sculpt_boundary.c b/source/blender/editors/sculpt_paint/sculpt_boundary.c
index b07dd18b6fc..ce8b63ce4f8 100644
--- a/source/blender/editors/sculpt_paint/sculpt_boundary.c
+++ b/source/blender/editors/sculpt_paint/sculpt_boundary.c
@@ -648,7 +648,7 @@ static void do_boundary_brush_bend_task_cb_ex(void *__restrict userdata,
SculptSession *ss = data->ob->sculpt;
const int symm_area = ss->cache->mirror_symmetry_pass;
SculptBoundary *boundary = ss->cache->boundaries[symm_area];
- const ePaintSymmetryFlags symm = data->sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ const ePaintSymmetryFlags symm = SCULPT_mesh_symmetry_xyz_get(data->ob);
const Brush *brush = data->brush;
const float strength = ss->cache->bstrength;
@@ -699,7 +699,7 @@ static void do_boundary_brush_slide_task_cb_ex(void *__restrict userdata,
SculptSession *ss = data->ob->sculpt;
const int symm_area = ss->cache->mirror_symmetry_pass;
SculptBoundary *boundary = ss->cache->boundaries[symm_area];
- const ePaintSymmetryFlags symm = data->sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ const ePaintSymmetryFlags symm = SCULPT_mesh_symmetry_xyz_get(data->ob);
const Brush *brush = data->brush;
const float strength = ss->cache->bstrength;
@@ -741,7 +741,7 @@ static void do_boundary_brush_inflate_task_cb_ex(void *__restrict userdata,
SculptSession *ss = data->ob->sculpt;
const int symm_area = ss->cache->mirror_symmetry_pass;
SculptBoundary *boundary = ss->cache->boundaries[symm_area];
- const ePaintSymmetryFlags symm = data->sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ const ePaintSymmetryFlags symm = SCULPT_mesh_symmetry_xyz_get(data->ob);
const Brush *brush = data->brush;
const float strength = ss->cache->bstrength;
@@ -785,7 +785,7 @@ static void do_boundary_brush_grab_task_cb_ex(void *__restrict userdata,
SculptSession *ss = data->ob->sculpt;
const int symm_area = ss->cache->mirror_symmetry_pass;
SculptBoundary *boundary = ss->cache->boundaries[symm_area];
- const ePaintSymmetryFlags symm = data->sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ const ePaintSymmetryFlags symm = SCULPT_mesh_symmetry_xyz_get(data->ob);
const Brush *brush = data->brush;
const float strength = ss->cache->bstrength;
@@ -825,7 +825,7 @@ static void do_boundary_brush_twist_task_cb_ex(void *__restrict userdata,
SculptSession *ss = data->ob->sculpt;
const int symm_area = ss->cache->mirror_symmetry_pass;
SculptBoundary *boundary = ss->cache->boundaries[symm_area];
- const ePaintSymmetryFlags symm = data->sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ const ePaintSymmetryFlags symm = SCULPT_mesh_symmetry_xyz_get(data->ob);
const Brush *brush = data->brush;
const float strength = ss->cache->bstrength;
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 53641dae447..bc88793b993 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -88,6 +88,9 @@ float SCULPT_raycast_init(struct ViewContext *vc,
float ray_normal[3],
bool original);
+/* Symmetry */
+char SCULPT_mesh_symmetry_xyz_get(Object *object);
+
/* Sculpt PBVH abstraction API */
void SCULPT_vertex_random_access_ensure(struct SculptSession *ss);
diff --git a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c
index 0ae9baf7e2e..e403bada316 100644
--- a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c
@@ -213,7 +213,7 @@ static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent *
/* Pivot position. */
if (RNA_boolean_get(op->ptr, "update_pivot")) {
- const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
const float threshold = 0.2f;
float avg[3];
int total = 0;
diff --git a/source/blender/editors/sculpt_paint/sculpt_pose.c b/source/blender/editors/sculpt_paint/sculpt_pose.c
index e53e33c1186..4081e7a962f 100644
--- a/source/blender/editors/sculpt_paint/sculpt_pose.c
+++ b/source/blender/editors/sculpt_paint/sculpt_pose.c
@@ -230,7 +230,7 @@ static void pose_brush_grow_factor_task_cb_ex(void *__restrict userdata,
SculptThreadedTaskData *data = userdata;
PoseGrowFactorTLSData *gftd = tls->userdata_chunk;
SculptSession *ss = data->ob->sculpt;
- const char symm = data->sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ const char symm = SCULPT_mesh_symmetry_xyz_get(data->ob);
PBVHVertexIter vd;
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
@@ -561,7 +561,7 @@ void SCULPT_pose_calc_pose_data(Sculpt *sd,
PoseFloodFillData fdata = {
.radius = radius,
- .symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL,
+ .symm = SCULPT_mesh_symmetry_xyz_get(ob),
.pose_factor = r_pose_factor,
.tot_co = 0,
};
@@ -777,7 +777,7 @@ static SculptPoseIKChain *pose_ik_chain_init_face_sets(
PoseFloodFillData fdata = {
.radius = radius,
- .symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL,
+ .symm = SCULPT_mesh_symmetry_xyz_get(ob),
.pose_factor = ik_chain->segments[s].weights,
.tot_co = 0,
.fallback_count = 0,
@@ -1134,7 +1134,7 @@ void SCULPT_do_pose_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
Brush *brush = BKE_paint_brush(&sd->paint);
- const ePaintSymmetryFlags symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ const ePaintSymmetryFlags symm = SCULPT_mesh_symmetry_xyz_get(ob);
/* The pose brush applies all enabled symmetry axis in a single iteration, so the rest can be
* ignored. */
diff --git a/source/blender/editors/sculpt_paint/sculpt_transform.c b/source/blender/editors/sculpt_paint/sculpt_transform.c
index b52b04eba3a..479f70b5ff1 100644
--- a/source/blender/editors/sculpt_paint/sculpt_transform.c
+++ b/source/blender/editors/sculpt_paint/sculpt_transform.c
@@ -124,7 +124,7 @@ void ED_sculpt_update_modal_transform(struct bContext *C)
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
- const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
SCULPT_vertex_random_access_ensure(ss);
BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false, false);
@@ -243,12 +243,11 @@ static EnumPropertyItem prop_sculpt_pivot_position_types[] = {
static int sculpt_set_pivot_position_exec(bContext *C, wmOperator *op)
{
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
ARegion *region = CTX_wm_region(C);
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
+ const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
int mode = RNA_enum_get(op->ptr, "mode");
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 8f590d87f4c..a2e1c50e375 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -165,9 +165,9 @@ void initTransDataContainers_FromObjectData(TransInfo *t,
TransDataContainer *tc = &t->data_container[i];
if (((t->flag & T_NO_MIRROR) == 0) && ((t->options & CTX_NO_MIRROR) == 0) &&
(objects[i]->type == OB_MESH)) {
- tc->use_mirror_axis_x = (((Mesh *)objects[i]->data)->editflag & ME_EDIT_MIRROR_X) != 0;
- tc->use_mirror_axis_y = (((Mesh *)objects[i]->data)->editflag & ME_EDIT_MIRROR_Y) != 0;
- tc->use_mirror_axis_z = (((Mesh *)objects[i]->data)->editflag & ME_EDIT_MIRROR_Z) != 0;
+ tc->use_mirror_axis_x = (((Mesh *)objects[i]->data)->symmetry & ME_SYMMETRY_X) != 0;
+ tc->use_mirror_axis_y = (((Mesh *)objects[i]->data)->symmetry & ME_SYMMETRY_Y) != 0;
+ tc->use_mirror_axis_z = (((Mesh *)objects[i]->data)->symmetry & ME_SYMMETRY_Z) != 0;
}
if (object_mode & OB_MODE_EDIT) {
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index abfa3cc1b2e..a0baf0ed905 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -221,7 +221,9 @@ typedef struct Mesh {
float remesh_voxel_adaptivity;
char remesh_mode;
- char _pad1[3];
+ char symmetry;
+
+ char _pad1[2];
int face_sets_color_seed;
/* Stores the initial Face Set to be rendered white. This way the overlay can be enabled by
@@ -265,7 +267,7 @@ enum {
/* me->editflag */
enum {
- ME_EDIT_MIRROR_X = 1 << 0,
+ ME_EDIT_VERTEX_GROUPS_X_SYMMETRY = 1 << 0,
ME_EDIT_MIRROR_Y = 1 << 1, /* unused so far */
ME_EDIT_MIRROR_Z = 1 << 2, /* unused so far */
@@ -320,6 +322,13 @@ enum {
ME_SIMPLE_SUBSURF = 1,
};
+/* me->symmetry */
+typedef enum eMeshSymmetryType {
+ ME_SYMMETRY_X = 1 << 0,
+ ME_SYMMETRY_Y = 1 << 1,
+ ME_SYMMETRY_Z = 1 << 2,
+} eMeshSymmetryType;
+
#define MESH_MAX_VERTS 2000000000L
#ifdef __cplusplus
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index 346946dfb0d..b69d6b40590 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -3271,6 +3271,29 @@ static void rna_def_mesh(BlenderRNA *brna)
/* End remesh */
+ /* Symmetry */
+ prop = RNA_def_property(srna, "use_mirror_x", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "symmetry", ME_SYMMETRY_X);
+ RNA_def_property_ui_text(prop, "X", "Enable symmetry in the X axis");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
+
+ prop = RNA_def_property(srna, "use_mirror_y", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "symmetry", ME_SYMMETRY_Y);
+ RNA_def_property_ui_text(prop, "Y", "Enable symmetry in the Y axis");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
+
+ prop = RNA_def_property(srna, "use_mirror_z", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "symmetry", ME_SYMMETRY_Z);
+ 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");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
+ /* End Symmetry */
+
prop = RNA_def_property(srna, "use_auto_smooth", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_AUTOSMOOTH);
RNA_def_property_ui_text(
@@ -3331,19 +3354,6 @@ static void rna_def_mesh(BlenderRNA *brna)
# endif
/* editflag */
- prop = RNA_def_property(srna, "use_mirror_x", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_MIRROR_X);
- RNA_def_property_ui_text(prop, "X Mirror", "X Axis mirror editing");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
-
- prop = RNA_def_property(srna, "use_mirror_y", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_MIRROR_Y);
- RNA_def_property_ui_text(prop, "Y Mirror", "Y Axis mirror editing");
-
- prop = RNA_def_property(srna, "use_mirror_z", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_MIRROR_Z);
- RNA_def_property_ui_text(prop, "Z Mirror", "Z Axis mirror editing");
-
prop = RNA_def_property(srna, "use_mirror_topology", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_MIRROR_TOPO);
RNA_def_property_ui_text(prop,