mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-22 22:24:01 -06:00
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;
|
double z_offset = 0.0;
|
||||||
|
|
||||||
if (allow_negative_z) {
|
if (allow_negative_z) {
|
||||||
if (volumes.size() == 1)
|
if (parts_count() == 1)
|
||||||
z_offset = -get_min_z();
|
z_offset = -get_min_z();
|
||||||
else {
|
else {
|
||||||
const double max_z = get_max_z();
|
const double max_z = get_max_z();
|
||||||
|
@ -1127,6 +1127,15 @@ size_t ModelObject::facets_count() const
|
||||||
return num;
|
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
|
bool ModelObject::needed_repair() const
|
||||||
{
|
{
|
||||||
for (const ModelVolume *v : this->volumes)
|
for (const ModelVolume *v : this->volumes)
|
||||||
|
|
|
@ -347,6 +347,7 @@ public:
|
||||||
|
|
||||||
size_t materials_count() const;
|
size_t materials_count() const;
|
||||||
size_t facets_count() const;
|
size_t facets_count() const;
|
||||||
|
size_t parts_count() const;
|
||||||
bool needed_repair() const;
|
bool needed_repair() const;
|
||||||
ModelObjectPtrs cut(size_t instance, coordf_t z, ModelObjectCutAttributes attributes);
|
ModelObjectPtrs cut(size_t instance, coordf_t z, ModelObjectCutAttributes attributes);
|
||||||
void split(ModelObjectPtrs* new_objects);
|
void split(ModelObjectPtrs* new_objects);
|
||||||
|
|
|
@ -2154,11 +2154,23 @@ void Selection::ensure_not_below_bed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (GLVolume* volume : *m_volumes) {
|
if (is_any_volume()) {
|
||||||
std::pair<int, int> instance = std::make_pair(volume->object_idx(), volume->instance_idx());
|
for (unsigned int i : m_list) {
|
||||||
InstancesToZMap::iterator it = instances_max_z.find(instance);
|
GLVolume& volume = *(*m_volumes)[i];
|
||||||
if (it != instances_max_z.end() && it->second < SINKING_MIN_Z_THRESHOLD)
|
std::pair<int, int> instance = std::make_pair(volume.object_idx(), volume.instance_idx());
|
||||||
volume->set_instance_offset(Z, volume->get_instance_offset(Z) + SINKING_MIN_Z_THRESHOLD - it->second);
|
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…
Add table
Add a link
Reference in a new issue