mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-05 15:50:48 +08:00
Merge branch 'et_transformations' of https://github.com/Prusa-Development/PrusaSlicerPrivate into et_transformations
This commit is contained in:
commit
7ea3f12c42
@ -3746,12 +3746,22 @@ void GLCanvas3D::do_reset_skew(const std::string& snapshot_type)
|
|||||||
if (!snapshot_type.empty())
|
if (!snapshot_type.empty())
|
||||||
wxGetApp().plater()->take_snapshot(_(snapshot_type));
|
wxGetApp().plater()->take_snapshot(_(snapshot_type));
|
||||||
|
|
||||||
|
// stores current min_z of instances
|
||||||
|
std::map<std::pair<int, int>, double> min_zs;
|
||||||
|
if (!snapshot_type.empty()) {
|
||||||
|
for (int i = 0; i < static_cast<int>(m_model->objects.size()); ++i) {
|
||||||
|
const ModelObject* obj = m_model->objects[i];
|
||||||
|
for (int j = 0; j < static_cast<int>(obj->instances.size()); ++j) {
|
||||||
|
min_zs[{ i, j }] = obj->instance_bounding_box(j).min.z();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::set<std::pair<int, int>> done; // keeps track of modified instances
|
std::set<std::pair<int, int>> done; // keeps track of modified instances
|
||||||
|
|
||||||
const Selection::IndicesList& idxs = m_selection.get_volume_idxs();
|
Selection::EMode selection_mode = m_selection.get_mode();
|
||||||
|
|
||||||
for (unsigned int id : idxs) {
|
for (const GLVolume* v : m_volumes.volumes) {
|
||||||
const GLVolume* v = m_volumes.volumes[id];
|
|
||||||
int object_idx = v->object_idx();
|
int object_idx = v->object_idx();
|
||||||
if (object_idx < 0 || (int)m_model->objects.size() <= object_idx)
|
if (object_idx < 0 || (int)m_model->objects.size() <= object_idx)
|
||||||
continue;
|
continue;
|
||||||
@ -3761,14 +3771,30 @@ void GLCanvas3D::do_reset_skew(const std::string& snapshot_type)
|
|||||||
|
|
||||||
done.insert(std::pair<int, int>(object_idx, instance_idx));
|
done.insert(std::pair<int, int>(object_idx, instance_idx));
|
||||||
|
|
||||||
|
// Mirror instances/volumes
|
||||||
ModelObject* model_object = m_model->objects[object_idx];
|
ModelObject* model_object = m_model->objects[object_idx];
|
||||||
if (model_object != nullptr) {
|
if (model_object != nullptr) {
|
||||||
model_object->instances[instance_idx]->set_transformation(v->get_instance_transformation());
|
if (selection_mode == Selection::Instance)
|
||||||
model_object->volumes[volume_idx]->set_transformation(v->get_volume_transformation());
|
model_object->instances[instance_idx]->set_transformation(v->get_instance_transformation());
|
||||||
|
else if (selection_mode == Selection::Volume)
|
||||||
|
model_object->volumes[volume_idx]->set_transformation(v->get_volume_transformation());
|
||||||
model_object->invalidate_bounding_box();
|
model_object->invalidate_bounding_box();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fixes sinking/flying instances
|
||||||
|
for (const std::pair<int, int>& i : done) {
|
||||||
|
ModelObject* m = m_model->objects[i.first];
|
||||||
|
double shift_z = m->get_instance_min_z(i.second);
|
||||||
|
// leave sinking instances as sinking
|
||||||
|
if (min_zs.empty() || min_zs.find({ i.first, i.second })->second >= SINKING_Z_THRESHOLD || shift_z > SINKING_Z_THRESHOLD) {
|
||||||
|
Vec3d shift(0.0, 0.0, -shift_z);
|
||||||
|
m_selection.translate(i.first, i.second, shift);
|
||||||
|
m->translate_instance(i.second, shift);
|
||||||
|
}
|
||||||
|
wxGetApp().obj_list()->update_info_items(static_cast<size_t>(i.first));
|
||||||
|
}
|
||||||
|
|
||||||
post_event(SimpleEvent(EVT_GLCANVAS_RESET_SKEW));
|
post_event(SimpleEvent(EVT_GLCANVAS_RESET_SKEW));
|
||||||
|
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
|
@ -506,6 +506,10 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Synchronize instances/volumes.
|
||||||
|
selection.synchronize_unselected_instances(Selection::SyncRotationType::GENERAL);
|
||||||
|
selection.synchronize_unselected_volumes();
|
||||||
|
|
||||||
canvas->do_scale(L("Reset scale"));
|
canvas->do_scale(L("Reset scale"));
|
||||||
UpdateAndShow(true);
|
UpdateAndShow(true);
|
||||||
#else
|
#else
|
||||||
|
@ -1543,6 +1543,15 @@ void Selection::reset_skew()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !DISABLE_INSTANCES_SYNCH
|
||||||
|
if (m_mode == Instance)
|
||||||
|
// even if there is no rotation, we pass SyncRotationType::GENERAL to force
|
||||||
|
// synchronize_unselected_instances() to remove skew from the other instances
|
||||||
|
synchronize_unselected_instances(SyncRotationType::GENERAL);
|
||||||
|
else if (m_mode == Volume)
|
||||||
|
synchronize_unselected_volumes();
|
||||||
|
#endif // !DISABLE_INSTANCES_SYNCH
|
||||||
|
|
||||||
ensure_on_bed();
|
ensure_on_bed();
|
||||||
set_bounding_boxes_dirty();
|
set_bounding_boxes_dirty();
|
||||||
wxGetApp().plater()->canvas3D()->requires_check_outside_state();
|
wxGetApp().plater()->canvas3D()->requires_check_outside_state();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user