mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-02 17:50:37 +08:00
Fixed shells of sinking volumes for preview
This commit is contained in:
parent
fbd7d14315
commit
ded5219719
@ -2259,13 +2259,39 @@ void GCodeViewer::load_shells(const Print& print)
|
|||||||
while (true) {
|
while (true) {
|
||||||
GLVolumePtrs::iterator it = std::find_if(m_shells.volumes.volumes.begin(), m_shells.volumes.volumes.end(), [](GLVolume* volume) { return volume->is_modifier; });
|
GLVolumePtrs::iterator it = std::find_if(m_shells.volumes.volumes.begin(), m_shells.volumes.volumes.end(), [](GLVolume* volume) { return volume->is_modifier; });
|
||||||
if (it != m_shells.volumes.volumes.end()) {
|
if (it != m_shells.volumes.volumes.end()) {
|
||||||
delete (*it);
|
delete *it;
|
||||||
m_shells.volumes.volumes.erase(it);
|
m_shells.volumes.volumes.erase(it);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// removes volumes which are completely below bed
|
||||||
|
int i = 0;
|
||||||
|
while (i < m_shells.volumes.volumes.size()) {
|
||||||
|
GLVolume* v = m_shells.volumes.volumes[i];
|
||||||
|
if (v->transformed_bounding_box().max.z() < SINKING_MIN_Z_THRESHOLD + EPSILON) {
|
||||||
|
delete v;
|
||||||
|
m_shells.volumes.volumes.erase(m_shells.volumes.volumes.begin() + i);
|
||||||
|
--i;
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
// search for sinking volumes and replace their mesh with the part of it with positive z
|
||||||
|
for (GLVolume* v : m_shells.volumes.volumes) {
|
||||||
|
if (v->is_sinking()) {
|
||||||
|
TriangleMesh mesh(wxGetApp().plater()->model().objects[v->object_idx()]->volumes[v->volume_idx()]->mesh());
|
||||||
|
mesh.transform(v->world_matrix(), true);
|
||||||
|
indexed_triangle_set upper_its;
|
||||||
|
cut_mesh(mesh.its, 0.0f, &upper_its, nullptr);
|
||||||
|
v->model.reset();
|
||||||
|
v->model.init_from(upper_its);
|
||||||
|
v->set_instance_transformation(Transform3d::Identity());
|
||||||
|
v->set_volume_transformation(Transform3d::Identity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (GLVolume* volume : m_shells.volumes.volumes) {
|
for (GLVolume* volume : m_shells.volumes.volumes) {
|
||||||
volume->zoom_to_volumes = false;
|
volume->zoom_to_volumes = false;
|
||||||
volume->color.a(0.25f);
|
volume->color.a(0.25f);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user