Fix of assertation from sinking contour

assertation at:
GLModel::init_from(Slic3r::GUI::GLModel::Geometry && data) Line 407
It is called from:
GLVolume::SinkingContours::update() Line 357
polygons(defined on line 344) are empty.  --> also init_data will be empty.
This commit is contained in:
Filip Sykala 2022-04-14 08:58:00 +02:00
parent af663a81e1
commit cbc138a525

View File

@ -324,9 +324,22 @@ void GLVolume::SinkingContours::update()
const int object_idx = m_parent.object_idx();
const Model& model = GUI::wxGetApp().plater()->model();
if (0 <= object_idx && object_idx < int(model.objects.size()) && m_parent.is_sinking() && !m_parent.is_below_printbed()) {
if (object_idx < 0 ||
object_idx >= int(model.objects.size()) ||
!m_parent.is_sinking() ||
m_parent.is_below_printbed()){
m_model.reset();
return;
}
const BoundingBoxf3& box = m_parent.transformed_convex_hull_bounding_box();
if (!m_old_box.size().isApprox(box.size()) || m_old_box.min.z() != box.min.z()) {
if (m_old_box.size().isApprox(box.size()) &&
m_old_box.min.z() == box.min.z()){
// Fix it !!! It is not working all the time
m_shift = box.center() - m_old_box.center();
return;
}
m_old_box = box;
m_shift = Vec3d::Zero();
@ -342,6 +355,8 @@ void GLVolume::SinkingContours::update()
MeshSlicingParams slicing_params;
slicing_params.trafo = m_parent.world_matrix();
const Polygons polygons = union_(slice_mesh(mesh.its, 0.0f, slicing_params));
if (polygons.empty()) return;
for (const ExPolygon& expoly : diff_ex(expand(polygons, float(scale_(HalfWidth))), shrink(polygons, float(scale_(HalfWidth))))) {
#if ENABLE_LEGACY_OPENGL_REMOVAL
const std::vector<Vec3d> triangulation = triangulate_expolygon_3d(expoly);
@ -376,12 +391,6 @@ void GLVolume::SinkingContours::update()
}
m_model.init_from(init_data);
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
}
else
m_shift = box.center() - m_old_box.center();
}
else
m_model.reset();
}
#if ENABLE_SHOW_NON_MANIFOLD_EDGES