diff --git a/source/blender/editors/sculpt_paint/sculpt_transform.cc b/source/blender/editors/sculpt_paint/sculpt_transform.cc index 540a5321131..f9b1f25b8e1 100644 --- a/source/blender/editors/sculpt_paint/sculpt_transform.cc +++ b/source/blender/editors/sculpt_paint/sculpt_transform.cc @@ -138,6 +138,8 @@ static std::array transform_matrices_init( return mats; } +static constexpr float transform_mirror_max_distance_eps = 0.00002f; + static void transform_node(Object &ob, const std::array &transform_mats, PBVHNode *node) @@ -149,6 +151,8 @@ static void transform_node(Object &ob, PBVHVertexIter vd; + const ePaintSymmetryFlags symm = SCULPT_mesh_symmetry_xyz_get(ob); + undo::push_node(ob, node, undo::Type::Position); BKE_pbvh_vertex_iter_begin (*ss.pbvh, node, vd, PBVH_ITER_UNIQUE) { SCULPT_orig_vert_data_update(orig_data, vd); @@ -172,6 +176,17 @@ static void transform_node(Object &ob, sub_v3_v3v3(disp, transformed_co, start_co); mul_v3_fl(disp, 1.0f - fade); add_v3_v3v3(vd.co, start_co, disp); + + /* Keep vertices on the mirror axis. */ + if ((symm & PAINT_SYMM_X) && (fabs(start_co[0]) < transform_mirror_max_distance_eps)) { + vd.co[0] = 0.0f; + } + if ((symm & PAINT_SYMM_Y) && (fabs(start_co[1]) < transform_mirror_max_distance_eps)) { + vd.co[1] = 0.0f; + } + if ((symm & PAINT_SYMM_Z) && (fabs(start_co[2]) < transform_mirror_max_distance_eps)) { + vd.co[2] = 0.0f; + } } BKE_pbvh_vertex_iter_end;