Fixed manipulation of sinking multipart objects resulting in wrong object/parts positioning
This commit is contained in:
parent
a918314aab
commit
ca098d5763
3 changed files with 28 additions and 6 deletions
|
@ -959,7 +959,7 @@ void ModelObject::ensure_on_bed(bool allow_negative_z)
|
|||
double z_offset = 0.0;
|
||||
|
||||
if (allow_negative_z) {
|
||||
if (volumes.size() == 1)
|
||||
if (parts_count() == 1)
|
||||
z_offset = -get_min_z();
|
||||
else {
|
||||
const double max_z = get_max_z();
|
||||
|
@ -1127,6 +1127,15 @@ size_t ModelObject::facets_count() const
|
|||
return num;
|
||||
}
|
||||
|
||||
size_t ModelObject::parts_count() const
|
||||
{
|
||||
size_t num = 0;
|
||||
for (const ModelVolume* v : this->volumes)
|
||||
if (v->is_model_part())
|
||||
++num;
|
||||
return num;
|
||||
}
|
||||
|
||||
bool ModelObject::needed_repair() const
|
||||
{
|
||||
for (const ModelVolume *v : this->volumes)
|
||||
|
|
|
@ -347,6 +347,7 @@ public:
|
|||
|
||||
size_t materials_count() const;
|
||||
size_t facets_count() const;
|
||||
size_t parts_count() const;
|
||||
bool needed_repair() const;
|
||||
ModelObjectPtrs cut(size_t instance, coordf_t z, ModelObjectCutAttributes attributes);
|
||||
void split(ModelObjectPtrs* new_objects);
|
||||
|
|
|
@ -2154,11 +2154,23 @@ void Selection::ensure_not_below_bed()
|
|||
}
|
||||
}
|
||||
|
||||
for (GLVolume* volume : *m_volumes) {
|
||||
std::pair<int, int> instance = std::make_pair(volume->object_idx(), volume->instance_idx());
|
||||
InstancesToZMap::iterator it = instances_max_z.find(instance);
|
||||
if (it != instances_max_z.end() && it->second < SINKING_MIN_Z_THRESHOLD)
|
||||
volume->set_instance_offset(Z, volume->get_instance_offset(Z) + SINKING_MIN_Z_THRESHOLD - it->second);
|
||||
if (is_any_volume()) {
|
||||
for (unsigned int i : m_list) {
|
||||
GLVolume& volume = *(*m_volumes)[i];
|
||||
std::pair<int, int> instance = std::make_pair(volume.object_idx(), volume.instance_idx());
|
||||
InstancesToZMap::iterator it = instances_max_z.find(instance);
|
||||
double z_shift = SINKING_MIN_Z_THRESHOLD - it->second;
|
||||
if (it != instances_max_z.end() && z_shift > 0.0)
|
||||
volume.set_volume_offset(Z, volume.get_volume_offset(Z) + z_shift);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (GLVolume* volume : *m_volumes) {
|
||||
std::pair<int, int> instance = std::make_pair(volume->object_idx(), volume->instance_idx());
|
||||
InstancesToZMap::iterator it = instances_max_z.find(instance);
|
||||
if (it != instances_max_z.end() && it->second < SINKING_MIN_Z_THRESHOLD)
|
||||
volume->set_instance_offset(Z, volume->get_instance_offset(Z) + SINKING_MIN_Z_THRESHOLD - it->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue