Fixed synchronization of instances after resetting rotation
This commit is contained in:
parent
e5efbbc2c2
commit
2630c62f04
3 changed files with 15 additions and 4 deletions
|
@ -446,7 +446,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||
m_reset_rotation_button->Bind(wxEVT_BUTTON, [this](wxCommandEvent& e) {
|
||||
GLCanvas3D* canvas = wxGetApp().plater()->canvas3D();
|
||||
Selection& selection = canvas->get_selection();
|
||||
|
||||
selection.setup_cache();
|
||||
#if ENABLE_WORLD_COORDINATE
|
||||
if (selection.is_single_volume_or_modifier()) {
|
||||
GLVolume* vol = const_cast<GLVolume*>(selection.get_first_volume());
|
||||
|
@ -468,9 +468,11 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||
else
|
||||
return;
|
||||
|
||||
// Update rotation at the GLVolumes.
|
||||
selection.synchronize_unselected_instances(Selection::SyncRotationType::GENERAL);
|
||||
// Synchronize instances/volumes.
|
||||
|
||||
selection.synchronize_unselected_instances(Selection::SyncRotationType::RESET);
|
||||
selection.synchronize_unselected_volumes();
|
||||
|
||||
// Copy rotation values from GLVolumes into Model (ModelInstance / ModelVolume), trigger background processing.
|
||||
canvas->do_rotate(L("Reset Rotation"));
|
||||
|
||||
|
|
|
@ -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();
|
||||
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();
|
||||
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();
|
||||
if (wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA)
|
||||
new_inst_trafo_j.translation().z() = curr_inst_trafo_i.translation().z();
|
||||
|
|
|
@ -499,6 +499,10 @@ public:
|
|||
NONE = 0,
|
||||
// Synchronize after rotation by an axis not parallel with Z.
|
||||
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_volumes();
|
||||
|
|
Loading…
Add table
Reference in a new issue