diff --git a/src/slic3r/GUI/GUI_ObjectManipulation.cpp b/src/slic3r/GUI/GUI_ObjectManipulation.cpp index a13206cbf..2fa985a0a 100644 --- a/src/slic3r/GUI/GUI_ObjectManipulation.cpp +++ b/src/slic3r/GUI/GUI_ObjectManipulation.cpp @@ -712,25 +712,29 @@ void ObjectManipulation::update_settings_value(const Selection& selection) #if ENABLE_WORLD_COORDINATE if (is_world_coordinates()) { m_new_position = volume->get_instance_offset(); + m_new_scale_label_string = L("Scale"); + m_new_scale = Vec3d(100.0, 100.0, 100.0); #else if (m_world_coordinates) { + m_new_scale = m_new_size.cwiseQuotient(selection.get_unscaled_instance_bounding_box().size()) * 100.0; #endif // ENABLE_WORLD_COORDINATE m_new_rotate_label_string = L("Rotate"); m_new_rotation = Vec3d::Zero(); m_new_size = selection.get_scaled_instance_bounding_box().size(); - m_new_scale = m_new_size.cwiseQuotient(selection.get_unscaled_instance_bounding_box().size()) * 100.0; } else { #if ENABLE_WORLD_COORDINATE m_new_move_label_string = L("Translate"); m_new_rotate_label_string = L("Rotate"); + m_new_scale_label_string = L("Scale"); m_new_position = Vec3d::Zero(); m_new_rotation = Vec3d::Zero(); + m_new_scale = Vec3d(100.0, 100.0, 100.0); #else m_new_rotation = volume->get_instance_rotation() * (180.0 / M_PI); + m_new_scale = volume->get_instance_scaling_factor() * 100.0; #endif // ENABLE_WORLD_COORDINATE m_new_size = volume->get_instance_scaling_factor().cwiseProduct(wxGetApp().model().objects[volume->object_idx()]->raw_mesh_bounding_box().size()); - m_new_scale = volume->get_instance_scaling_factor() * 100.0; } m_new_enabled = true; @@ -760,9 +764,10 @@ void ObjectManipulation::update_settings_value(const Selection& selection) m_new_position = offset; m_new_rotate_label_string = L("Rotate"); + m_new_scale_label_string = L("Scale"); + m_new_scale = Vec3d(100.0, 100.0, 100.0); m_new_rotation = Vec3d::Zero(); m_new_size = volume->transformed_convex_hull_bounding_box(trafo.get_matrix()).size(); - m_new_scale = m_new_size.cwiseQuotient(volume->transformed_convex_hull_bounding_box(volume->get_instance_transformation().get_matrix() * volume->get_volume_transformation().get_matrix_no_scaling_factor()).size()) * 100.0; } else if (is_local_coordinates()) { m_new_move_label_string = L("Translate"); @@ -778,8 +783,9 @@ void ObjectManipulation::update_settings_value(const Selection& selection) m_new_rotate_label_string = L("Rotate"); m_new_rotation = Vec3d::Zero(); #if ENABLE_WORLD_COORDINATE + m_new_scale_label_string = L("Scale"); m_new_size = volume->transformed_convex_hull_bounding_box(volume->get_volume_transformation().get_matrix()).size(); - m_new_scale = m_new_size.cwiseQuotient(volume->transformed_convex_hull_bounding_box(volume->get_volume_transformation().get_matrix_no_scaling_factor()).size()) * 100.0; + m_new_scale = Vec3d(100.0, 100.0, 100.0); } #else m_new_scale = volume->get_volume_scaling_factor() * 100.0; @@ -1270,7 +1276,7 @@ void ObjectManipulation::do_scale(int axis, const Vec3d &scale) const else if (is_instance_coordinates()) transformation_type.set_instance(); - if (!selection.is_single_full_instance() && !selection.is_single_volume_or_modifier()) + if (!(selection.is_single_volume_or_modifier() && is_local_coordinates())) transformation_type.set_relative(); const Vec3d scaling_factor = m_uniform_scale ? scale(axis) * Vec3d::Ones() : scale; diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index 014a30322..60c069d4e 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -835,10 +835,8 @@ void Selection::translate(const Vec3d& displacement, TransformationType transfor else assert(false); } - else { - assert(transformation_type.relative()); + else transform_volume_relative(v, volume_data, transformation_type, Geometry::translation_transform(displacement), m_cache.dragging_center); - } } #if !DISABLE_INSTANCES_SYNCH @@ -935,7 +933,6 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_ transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center); } else { - assert(transformation_type.relative()); transformation_type.set_independent(); transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center); } @@ -1331,6 +1328,7 @@ void Selection::scale_and_translate(const Vec3d& scale, const Vec3d& translation if (transformation_type.absolute()) { // convert from absolute scaling to relative scaling BoundingBoxf3 original_box; + BoundingBoxf3 reference_box = m_box.get_bounding_box(); if (m_mode == Instance) { if (is_single_full_instance()) { if (transformation_type.world()) @@ -1348,11 +1346,14 @@ void Selection::scale_and_translate(const Vec3d& scale, const Vec3d& translation original_box = get_bounding_box(); else if (transformation_type.instance()) original_box = v.transformed_convex_hull_bounding_box(volume_data.get_volume_transform().get_matrix()); - else + else { original_box = v.bounding_box(); + reference_box = v.bounding_box().transformed(volume_data.get_volume_transform().get_scaling_factor_matrix()); + } + transformation_type.set_relative(); } - - relative_scale = original_box.size().cwiseProduct(scale).cwiseQuotient(m_box.get_bounding_box().size()); + + relative_scale = original_box.size().cwiseProduct(scale).cwiseQuotient(reference_box.size()); } if (m_mode == Instance) { @@ -1389,7 +1390,6 @@ void Selection::scale_and_translate(const Vec3d& scale, const Vec3d& translation transform_volume_relative(v, volume_data, transformation_type, Geometry::translation_transform(translation) * Geometry::scale_transform(relative_scale), m_cache.dragging_center); } else { - assert(transformation_type.relative()); transformation_type.set_independent(); transform_volume_relative(v, volume_data, transformation_type, Geometry::translation_transform(translation) * Geometry::scale_transform(relative_scale), m_cache.dragging_center); }