Fixed crash when scaling to fit (SPE-2361):

the crash occured when scaling to fit on a circular bed with the object containing non-part volumes
This commit is contained in:
Lukas Matena 2024-07-10 17:09:34 +02:00
parent 1e035ee33d
commit 8dbf197e4e

View File

@ -1205,6 +1205,10 @@ void Selection::scale_to_fit_print_volume(const BuildVolume& volume)
double max_z = 0.0;
for (unsigned int i : m_list) {
const GLVolume& v = *(*m_volumes)[i];
if (v.convex_hull() == nullptr) {
// E.g. negative meshes do not have a convex hull... (hotfix for SPE-2361)
continue;
}
TriangleMesh hull_3d = *v.convex_hull();
hull_3d.transform(v.world_matrix());
max_z = std::max(max_z, hull_3d.bounding_box().size().z());
@ -1250,6 +1254,10 @@ void Selection::scale_to_fit_print_volume(const BuildVolume& volume)
remove_volumes(m_mode, to_remove);
}
// FIXME: It should really only account for the model parts when scaling to fit. Not for modifiers,
// support enforcers / blockers and negative meshes.
switch (volume.type())
{
case BuildVolume::Type::Rectangle: { undoredo_snapshot = fit_rectangle(volume, !undoredo_snapshot); break; }