mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-31 09:12:07 +08:00
Tech ENABLE_WORLD_COORDINATE - Fixed drop to bed button behavior
This commit is contained in:
parent
b3decbe07f
commit
34ca3d086e
@ -328,27 +328,58 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||||||
Selection& selection = canvas->get_selection();
|
Selection& selection = canvas->get_selection();
|
||||||
|
|
||||||
if (selection.is_single_volume() || selection.is_single_modifier()) {
|
if (selection.is_single_volume() || selection.is_single_modifier()) {
|
||||||
|
#if ENABLE_WORLD_COORDINATE
|
||||||
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||||
|
const double min_z = get_volume_min_z(*volume);
|
||||||
|
if (!m_world_coordinates) {
|
||||||
|
const Vec3d diff = m_cache.position - volume->get_instance_transformation().get_matrix(true).inverse() * (min_z * Vec3d::UnitZ());
|
||||||
|
|
||||||
const Geometry::Transformation& instance_trafo = volume->get_instance_transformation();
|
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Drop to bed"));
|
||||||
const Vec3d diff = m_cache.position - instance_trafo.get_matrix(true).inverse() * Vec3d(0., 0., get_volume_min_z(*volume));
|
change_position_value(0, diff.x());
|
||||||
|
change_position_value(1, diff.y());
|
||||||
|
change_position_value(2, diff.z());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Drop to bed"));
|
||||||
|
change_position_value(2, m_cache.position.z() - min_z);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||||
|
const Vec3d diff = m_cache.position - volume->get_instance_transformation().get_matrix(true).inverse() * (get_volume_min_z(*volume) * Vec3d::UnitZ());
|
||||||
|
|
||||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Drop to bed"));
|
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Drop to bed"));
|
||||||
change_position_value(0, diff.x());
|
change_position_value(0, diff.x());
|
||||||
change_position_value(1, diff.y());
|
change_position_value(1, diff.y());
|
||||||
change_position_value(2, diff.z());
|
change_position_value(2, diff.z());
|
||||||
|
#endif // ENABLE_WORLD_COORDINATE
|
||||||
}
|
}
|
||||||
else if (selection.is_single_full_instance()) {
|
else if (selection.is_single_full_instance()) {
|
||||||
|
#if ENABLE_WORLD_COORDINATE
|
||||||
|
const double min_z = selection.get_scaled_instance_bounding_box().min.z();
|
||||||
|
if (!m_world_coordinates) {
|
||||||
|
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||||
|
const Vec3d diff = m_cache.position - volume->get_instance_transformation().get_matrix(true).inverse() * (min_z * Vec3d::UnitZ());
|
||||||
|
|
||||||
|
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Drop to bed"));
|
||||||
|
change_position_value(0, diff.x());
|
||||||
|
change_position_value(1, diff.y());
|
||||||
|
change_position_value(2, diff.z());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#else
|
||||||
const ModelObjectPtrs& objects = wxGetApp().model().objects;
|
const ModelObjectPtrs& objects = wxGetApp().model().objects;
|
||||||
const int idx = selection.get_object_idx();
|
const int idx = selection.get_object_idx();
|
||||||
if (0 <= idx && idx < static_cast<int>(objects.size())) {
|
if (0 <= idx && idx < static_cast<int>(objects.size())) {
|
||||||
const ModelObject* mo = wxGetApp().model().objects[idx];
|
const ModelObject* mo = wxGetApp().model().objects[idx];
|
||||||
const double min_z = mo->bounding_box().min.z();
|
const double min_z = mo->bounding_box().min.z();
|
||||||
if (std::abs(min_z) > SINKING_Z_THRESHOLD) {
|
if (std::abs(min_z) > SINKING_Z_THRESHOLD) {
|
||||||
|
#endif // ENABLE_WORLD_COORDINATE
|
||||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Drop to bed"));
|
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Drop to bed"));
|
||||||
change_position_value(2, m_cache.position.z() - min_z);
|
change_position_value(2, m_cache.position.z() - min_z);
|
||||||
}
|
}
|
||||||
|
#if !ENABLE_WORLD_COORDINATE
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_WORLD_COORDINATE
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
editors_grid_sizer->Add(m_drop_to_bed_button);
|
editors_grid_sizer->Add(m_drop_to_bed_button);
|
||||||
@ -733,7 +764,7 @@ void ObjectManipulation::update_reset_buttons_visibility()
|
|||||||
#endif // ENABLE_WORLD_COORDINATE
|
#endif // ENABLE_WORLD_COORDINATE
|
||||||
rotation = volume->get_instance_rotation();
|
rotation = volume->get_instance_rotation();
|
||||||
scale = volume->get_instance_scaling_factor();
|
scale = volume->get_instance_scaling_factor();
|
||||||
min_z = wxGetApp().model().objects[volume->composite_id.object_id]->bounding_box().min.z();
|
min_z = selection.get_scaled_instance_bounding_box().min.z();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rotation = volume->get_volume_rotation();
|
rotation = volume->get_volume_rotation();
|
||||||
@ -743,7 +774,7 @@ void ObjectManipulation::update_reset_buttons_visibility()
|
|||||||
show_rotation = !rotation.isApprox(Vec3d::Zero());
|
show_rotation = !rotation.isApprox(Vec3d::Zero());
|
||||||
show_scale = !scale.isApprox(Vec3d::Ones());
|
show_scale = !scale.isApprox(Vec3d::Ones());
|
||||||
#if ENABLE_WORLD_COORDINATE
|
#if ENABLE_WORLD_COORDINATE
|
||||||
show_drop_to_bed = min_z > EPSILON;
|
show_drop_to_bed = min_z < SINKING_Z_THRESHOLD;
|
||||||
#else
|
#else
|
||||||
show_drop_to_bed = std::abs(min_z) > SINKING_Z_THRESHOLD;
|
show_drop_to_bed = std::abs(min_z) > SINKING_Z_THRESHOLD;
|
||||||
#endif // ENABLE_WORLD_COORDINATE
|
#endif // ENABLE_WORLD_COORDINATE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user