Fix #123181: Sculpt Transform tools dont keep verts on the symmetry axis
From the user perspective, the transform tools in editmode and sculptmode look like the same tools, the equal behavior could be expected. So now set vertices on the mirror axis (check with the same epsilon as editmode transform) while transforming, replicating what `mesh_transdata_mirror_apply` does. Pull Request: https://projects.blender.org/blender/blender/pulls/123428
This commit is contained in:
committed by
Philipp Oeser
parent
ada367a0e9
commit
5a8003091c
@@ -138,6 +138,8 @@ static std::array<float4x4, 8> transform_matrices_init(
|
||||
return mats;
|
||||
}
|
||||
|
||||
static constexpr float transform_mirror_max_distance_eps = 0.00002f;
|
||||
|
||||
static void transform_node(Object &ob,
|
||||
const std::array<float4x4, 8> &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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user