FIX: fix issue STUDIO-452

wrong transformation when sub model is rotated

Change-Id: I40e7ad0f808dd4d3445f4556ae517f5284e1a65c
(cherry picked from commit 6d1328a4eb630a08a9c635f0efea2a057283329e)
This commit is contained in:
zhimin.zeng 2022-07-26 15:43:30 +08:00 committed by Lane.Wei
parent eaf71e4d2f
commit 3d80bb52dc
2 changed files with 25 additions and 1 deletions

View File

@ -1977,6 +1977,30 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode
// update printable state on canvas
wxGetApp().plater()->canvas3D()->update_instance_printable_state_for_object((size_t)obj_idx);
// apply the instance transform to all volumes and reset instance transform except the offset
{
const Geometry::Transformation &instance_transformation = model_object.instances[0]->get_transformation();
Vec3d original_instance_center = instance_transformation.get_offset();
const Transform3d &transformation_matrix = instance_transformation.get_matrix();
for (ModelVolume *volume : model_object.volumes) {
const Transform3d &volume_matrix = volume->get_matrix();
Transform3d new_matrix = transformation_matrix * volume_matrix;
volume->set_transformation(new_matrix);
}
model_object.instances[0]->set_transformation(Geometry::Transformation());
model_object.ensure_on_bed();
// keep new instance center the same as the original center
model_object.translate(-original_instance_center);
model_object.origin_translation += original_instance_center;
model_object.translate_instances(model_object.origin_translation);
model_object.origin_translation = Vec3d::Zero();
// update the cache data in selection to keep the data of ModelVolume and GLVolume are consistent
wxGetApp().plater()->update();
}
selection_changed();
//BBS: notify partplate the modify

View File

@ -98,7 +98,7 @@ void GizmoObjectManipulation::update_settings_value(const Selection& selection)
if (m_world_coordinates) {
m_new_rotate_label_string = L("Rotate");
m_new_rotation = Vec3d::Zero();
m_new_rotation = volume->get_instance_rotation() * (180. / M_PI);
m_new_size = selection.get_scaled_instance_bounding_box().size();
m_new_scale = m_new_size.cwiseProduct(selection.get_unscaled_instance_bounding_box().size().cwiseInverse()) * 100.;
}