Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain mirror state when scaling using text input (#3643) #3719

Merged
merged 1 commit into from
Jan 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/slic3r/GUI/Selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1324,8 +1324,11 @@ void Selection::scale_legacy(const Vec3d& scale, TransformationType transformati
v.set_instance_offset(m_cache.dragging_center + m * (m_cache.volumes_data[i].get_instance_position() - m_cache.dragging_center));

v.set_instance_scaling_factor(new_scale);
// Restore mirror state
v.set_instance_mirror(m_cache.volumes_data[i].get_instance_transform().get_mirror());
}
else {
const auto mirror = v.get_instance_mirror();
if (transformation_type.world() && (std::abs(scale.x() - scale.y()) > EPSILON || std::abs(scale.x() - scale.z()) > EPSILON)) {
// Non-uniform scaling. Transform the scaling factors into the local coordinate system.
// This is only possible, if the instance rotation is mulitples of ninety degrees.
Expand All @@ -1334,16 +1337,24 @@ void Selection::scale_legacy(const Vec3d& scale, TransformationType transformati
}
else
v.set_instance_scaling_factor(scale);
// Restore mirror state
v.set_instance_mirror(mirror);
}

// update the instance assemble transform
ModelObject* object = m_model->objects[v.object_idx()];
Geometry::Transformation assemble_transform = object->instances[v.instance_idx()]->get_assemble_transformation();
const auto mirror = assemble_transform.get_mirror();
assemble_transform.set_scaling_factor(v.get_instance_scaling_factor());
assemble_transform.set_mirror(mirror);
object->instances[v.instance_idx()]->set_assemble_transformation(assemble_transform);
}
else if (is_single_volume() || is_single_modifier())
else if (is_single_volume() || is_single_modifier()) {
const auto mirror = v.get_volume_transformation().get_mirror();
v.set_volume_scaling_factor(scale);
// Restore mirror state
v.set_volume_mirror(mirror);
}
else {
Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), scale);
if (m_mode == Instance) {
Expand All @@ -1354,6 +1365,8 @@ void Selection::scale_legacy(const Vec3d& scale, TransformationType transformati
v.set_instance_offset(m_cache.dragging_center + m * (m_cache.volumes_data[i].get_instance_position() - m_cache.dragging_center));

v.set_instance_scaling_factor(new_scale);
// Restore mirror state
v.set_instance_mirror(m_cache.volumes_data[i].get_instance_transform().get_mirror());
}
else if (m_mode == Volume) {
Eigen::Matrix<double, 3, 3, Eigen::DontAlign> new_matrix = (m * m_cache.volumes_data[i].get_volume_scale_matrix()).matrix().block(0, 0, 3, 3);
Expand All @@ -1364,6 +1377,8 @@ void Selection::scale_legacy(const Vec3d& scale, TransformationType transformati
v.set_volume_offset(m_cache.dragging_center - m_cache.volumes_data[i].get_instance_position() + offset);
}
v.set_volume_scaling_factor(new_scale);
// Restore mirror state
v.set_volume_mirror(m_cache.volumes_data[i].get_volume_transform().get_mirror());
}
}
}
Expand Down