Merge branch 'et_transformations' of https://github.com/Prusa-Development/PrusaSlicerPrivate into et_transformations

This commit is contained in:
enricoturri1966 2023-02-24 11:00:06 +01:00
commit bc61c688a4
3 changed files with 15 additions and 4 deletions

View File

@ -446,7 +446,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
m_reset_rotation_button->Bind(wxEVT_BUTTON, [this](wxCommandEvent& e) { m_reset_rotation_button->Bind(wxEVT_BUTTON, [this](wxCommandEvent& e) {
GLCanvas3D* canvas = wxGetApp().plater()->canvas3D(); GLCanvas3D* canvas = wxGetApp().plater()->canvas3D();
Selection& selection = canvas->get_selection(); Selection& selection = canvas->get_selection();
selection.setup_cache();
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
if (selection.is_single_volume_or_modifier()) { if (selection.is_single_volume_or_modifier()) {
GLVolume* vol = const_cast<GLVolume*>(selection.get_first_volume()); GLVolume* vol = const_cast<GLVolume*>(selection.get_first_volume());
@ -468,9 +468,11 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
else else
return; return;
// Update rotation at the GLVolumes. // Synchronize instances/volumes.
selection.synchronize_unselected_instances(Selection::SyncRotationType::GENERAL);
selection.synchronize_unselected_instances(Selection::SyncRotationType::RESET);
selection.synchronize_unselected_volumes(); selection.synchronize_unselected_volumes();
// Copy rotation values from GLVolumes into Model (ModelInstance / ModelVolume), trigger background processing. // Copy rotation values from GLVolumes into Model (ModelInstance / ModelVolume), trigger background processing.
canvas->do_rotate(L("Reset Rotation")); canvas->do_rotate(L("Reset Rotation"));

View File

@ -3010,7 +3010,12 @@ void Selection::synchronize_unselected_instances(SyncRotationType sync_rotation_
const Transform3d& old_inst_trafo_j = m_cache.volumes_data[j].get_instance_transform().get_matrix(); const Transform3d& old_inst_trafo_j = m_cache.volumes_data[j].get_instance_transform().get_matrix();
assert(is_rotation_xy_synchronized(old_inst_trafo_i, old_inst_trafo_j)); assert(is_rotation_xy_synchronized(old_inst_trafo_i, old_inst_trafo_j));
Transform3d new_inst_trafo_j = volume_j->get_instance_transformation().get_matrix(); Transform3d new_inst_trafo_j = volume_j->get_instance_transformation().get_matrix();
if (sync_rotation_type != SyncRotationType::NONE || mirrored) if (sync_rotation_type == SyncRotationType::RESET) {
Geometry::Transformation new_inst_trafo_j_no_rotation(new_inst_trafo_j);
new_inst_trafo_j_no_rotation.reset_rotation();
new_inst_trafo_j = new_inst_trafo_j_no_rotation.get_matrix();
}
else if (sync_rotation_type != SyncRotationType::NONE || mirrored)
new_inst_trafo_j.linear() = (old_inst_trafo_j.linear() * old_inst_trafo_i.linear().inverse()) * curr_inst_trafo_i.linear(); new_inst_trafo_j.linear() = (old_inst_trafo_j.linear() * old_inst_trafo_i.linear().inverse()) * curr_inst_trafo_i.linear();
if (wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA) if (wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA)
new_inst_trafo_j.translation().z() = curr_inst_trafo_i.translation().z(); new_inst_trafo_j.translation().z() = curr_inst_trafo_i.translation().z();

View File

@ -499,6 +499,10 @@ public:
NONE = 0, NONE = 0,
// Synchronize after rotation by an axis not parallel with Z. // Synchronize after rotation by an axis not parallel with Z.
GENERAL = 1, GENERAL = 1,
#if ENABLE_WORLD_COORDINATE
// Synchronize after rotation reset.
RESET = 2
#endif // ENABLE_WORLD_COORDINATE
}; };
void synchronize_unselected_instances(SyncRotationType sync_rotation_type); void synchronize_unselected_instances(SyncRotationType sync_rotation_type);
void synchronize_unselected_volumes(); void synchronize_unselected_volumes();