mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-15 11:51:33 +00:00
Fix instance Z synchronization (#15465)
This commit is contained in:
@@ -638,26 +638,21 @@ void Selection::set_printable(bool printable)
|
||||
}
|
||||
|
||||
bool Selection::get_auto_drop() const {
|
||||
// The wipe tower is not a ModelObject and has no per-instance auto_drop;
|
||||
// The wipe tower is not a ModelObject and has no auto_drop state;
|
||||
// return the default to avoid indexing m_model->objects with its synthetic id.
|
||||
if (!m_valid || is_wipe_tower())
|
||||
return true;
|
||||
|
||||
std::set<std::pair<int, int>> instances_idxs;
|
||||
std::set<int> object_idxs;
|
||||
for (const auto& [obj_idx, inst_list] : m_cache.content) {
|
||||
for (int inst_idx : inst_list) {
|
||||
instances_idxs.insert({obj_idx, inst_idx});
|
||||
}
|
||||
object_idxs.insert(obj_idx);
|
||||
}
|
||||
|
||||
// return false, if one of the instances in the selection has auto_drop disabled, otherwise return true
|
||||
for (const auto& [obj_idx, inst_idx] : instances_idxs) {
|
||||
// Return false if one selected object has auto_drop disabled.
|
||||
for (int obj_idx : object_idxs) {
|
||||
ModelObject* object = m_model->objects[obj_idx];
|
||||
for (const auto* inst : object->instances) {
|
||||
if (!inst->auto_drop) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!object->auto_drop)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -668,22 +663,18 @@ void Selection::set_auto_drop(bool enabled)
|
||||
if (!m_valid)
|
||||
return;
|
||||
|
||||
std::set<std::pair<int, int>> instances_idxs;
|
||||
std::set<int> object_idxs;
|
||||
for (const auto& [obj_idx, inst_list] : m_cache.content) {
|
||||
for (int inst_idx : inst_list) {
|
||||
instances_idxs.insert({obj_idx, inst_idx});
|
||||
}
|
||||
object_idxs.insert(obj_idx);
|
||||
}
|
||||
|
||||
std::string snapshot_text = (boost::format("%1%") % (enabled ? "Set Selection Auto-Drop Enabled" : "Set Selection Auto-Drop Disabled")).str();
|
||||
wxGetApp().plater()->take_snapshot(snapshot_text);
|
||||
|
||||
// set auto_drop value for all instances in object
|
||||
for (const auto& [obj_idx, inst_idx] : instances_idxs) {
|
||||
// auto_drop is shared by all instances of an object.
|
||||
for (int obj_idx : object_idxs) {
|
||||
ModelObject* object = m_model->objects[obj_idx];
|
||||
for (auto* inst : object->instances) {
|
||||
inst->auto_drop = enabled;
|
||||
}
|
||||
object->auto_drop = enabled;
|
||||
}
|
||||
|
||||
// update scene
|
||||
@@ -3088,8 +3079,9 @@ void Selection::synchronize_unselected_instances(SyncRotationType sync_rotation_
|
||||
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();
|
||||
|
||||
bool should_synchronize_z = m_model->objects[volume_j->object_idx()]->instances[volume_j->instance_idx()]->auto_drop == false;
|
||||
if (should_synchronize_z && wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA)
|
||||
// Instances of the same object must remain at the same height. auto_drop
|
||||
// only controls snapping after the move, not the instance transform itself.
|
||||
if (wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA)
|
||||
new_inst_trafo_j.translation().z() = curr_inst_trafo_i.translation().z();
|
||||
|
||||
assert(is_rotation_xy_synchronized(curr_inst_trafo_i, new_inst_trafo_j));
|
||||
@@ -3136,9 +3128,7 @@ void Selection::ensure_on_bed()
|
||||
for (size_t i = 0; i < m_volumes->size(); ++i) {
|
||||
GLVolume* volume = (*m_volumes)[i];
|
||||
ModelObject* mo = m_model->objects[volume->object_idx()];
|
||||
ModelInstance* mi = mo->instances[volume->instance_idx()];
|
||||
|
||||
if (mi->auto_drop == false
|
||||
if (mo->auto_drop == false
|
||||
|| volume->is_wipe_tower
|
||||
|| volume->is_modifier
|
||||
|| std::find(m_cache.sinking_volumes.begin(), m_cache.sinking_volumes.end(), i) != m_cache.sinking_volumes.end())
|
||||
|
||||
Reference in New Issue
Block a user