FIX: update_sequential_clearance may crash due to clipper's bug
offset may give empty results. The previous patch solved the issue that the studio crashes immediately when selecting by-object printing. This patch solves the issue that the studio crashes when moving objects with mouse after selecting by-object printing. Jira: STUDIO-2452 Change-Id: Iacd69e67386b0750f24e5af2799ff9c0da130e88 (cherry picked from commit 8ea4379d0b6d61e91bd6704e4b1e8309cb42b924)
This commit is contained in:
parent
f227a8f8da
commit
aebbe807f2
1 changed files with 9 additions and 7 deletions
|
@ -4964,17 +4964,19 @@ void GLCanvas3D::update_sequential_clearance()
|
|||
for (size_t i = 0; i < m_model->objects.size(); ++i) {
|
||||
ModelObject* model_object = m_model->objects[i];
|
||||
ModelInstance* model_instance0 = model_object->instances.front();
|
||||
Polygon hull_2d = offset(model_object->convex_hull_2d(Geometry::assemble_transform({ 0.0, 0.0, model_instance0->get_offset().z() }, model_instance0->get_rotation(),
|
||||
auto tmp = offset(model_object->convex_hull_2d(Geometry::assemble_transform({ 0.0, 0.0, model_instance0->get_offset().z() }, model_instance0->get_rotation(),
|
||||
model_instance0->get_scaling_factor(), model_instance0->get_mirror())),
|
||||
// Shrink the extruder_clearance_radius a tiny bit, so that if the object arrangement algorithm placed the objects
|
||||
// exactly by satisfying the extruder_clearance_radius, this test will not trigger collision.
|
||||
shrink_factor,
|
||||
jtRound, mitter_limit).front();
|
||||
|
||||
Pointf3s& cache_hull_2d = m_sequential_print_clearance.m_hull_2d_cache.emplace_back(Pointf3s());
|
||||
cache_hull_2d.reserve(hull_2d.points.size());
|
||||
for (const Point& p : hull_2d.points) {
|
||||
cache_hull_2d.emplace_back(unscale<double>(p.x()), unscale<double>(p.y()), 0.0);
|
||||
jtRound, mitter_limit);
|
||||
if (!tmp.empty()) { // tmp may be empty due to clipper's bug, see STUDIO-2452
|
||||
Polygon hull_2d = tmp.front();
|
||||
Pointf3s& cache_hull_2d = m_sequential_print_clearance.m_hull_2d_cache.emplace_back(Pointf3s());
|
||||
cache_hull_2d.reserve(hull_2d.points.size());
|
||||
for (const Point& p : hull_2d.points) {
|
||||
cache_hull_2d.emplace_back(unscale<double>(p.x()), unscale<double>(p.y()), 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_sequential_print_clearance_first_displacement = false;
|
||||
|
|
Loading…
Reference in a new issue