Keep non-sinking volumes on top of the printbed while scaling
This commit is contained in:
parent
097afc6598
commit
368cfedbc7
@ -838,8 +838,21 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type
|
||||
if (!m_valid)
|
||||
return;
|
||||
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
bool is_any_volume_sinking = false;
|
||||
#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA
|
||||
bool is_sla = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA;
|
||||
#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
|
||||
for (unsigned int i : m_list) {
|
||||
GLVolume &volume = *(*m_volumes)[i];
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA
|
||||
if (!is_sla)
|
||||
#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA
|
||||
is_any_volume_sinking |= !volume.is_modifier && std::find(m_cache.sinking_volumes.begin(), m_cache.sinking_volumes.end(), i) != m_cache.sinking_volumes.end();
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
if (is_single_full_instance()) {
|
||||
if (transformation_type.relative()) {
|
||||
Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), scale);
|
||||
@ -895,10 +908,10 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type
|
||||
synchronize_unselected_volumes();
|
||||
#endif // !DISABLE_INSTANCES_SYNCH
|
||||
|
||||
#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA
|
||||
if (wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA)
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
if (!is_any_volume_sinking)
|
||||
ensure_on_bed();
|
||||
#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
@ -1644,10 +1657,16 @@ void Selection::update_type()
|
||||
void Selection::set_caches()
|
||||
{
|
||||
m_cache.volumes_data.clear();
|
||||
for (unsigned int i = 0; i < (unsigned int)m_volumes->size(); ++i)
|
||||
{
|
||||
const GLVolume* v = (*m_volumes)[i];
|
||||
m_cache.volumes_data.emplace(i, VolumeCache(v->get_volume_transformation(), v->get_instance_transformation()));
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
m_cache.sinking_volumes.clear();
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
for (unsigned int i = 0; i < (unsigned int)m_volumes->size(); ++i) {
|
||||
const GLVolume& v = *(*m_volumes)[i];
|
||||
m_cache.volumes_data.emplace(i, VolumeCache(v.get_volume_transformation(), v.get_instance_transformation()));
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
if (v.is_sinking())
|
||||
m_cache.sinking_volumes.push_back(i);
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
}
|
||||
m_cache.dragging_center = get_bounding_box().center();
|
||||
}
|
||||
|
@ -186,6 +186,10 @@ private:
|
||||
// to a set of indices of ModelVolume instances in ModelObject::instances
|
||||
// Here the index means a position inside the respective std::vector, not ObjectID.
|
||||
ObjectIdxsToInstanceIdxsMap content;
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
// List of ids of the volumes which are sinking when starting dragging
|
||||
std::vector<unsigned int> sinking_volumes;
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
};
|
||||
|
||||
// Volumes owned by GLCanvas3D.
|
||||
|
Loading…
Reference in New Issue
Block a user