Fix: unhandled empty Optional in 'bounds_min_max()'

Snap for meshes without vertices raised an error in debug build.
This commit is contained in:
Germano Cavalcante 2024-03-11 12:21:08 -03:00
parent f6f767b879
commit fcfce8f69f
1 changed files with 4 additions and 3 deletions

View File

@ -447,9 +447,10 @@ static eSnapMode snapMesh(SnapObjectContext *sctx,
SnapData_Mesh nearest2d(sctx, mesh_eval, obmat);
if (ob_eval->data == mesh_eval) {
const Bounds<float3> bounds = *mesh_eval->bounds_min_max();
if (!nearest2d.snap_boundbox(bounds.min, bounds.max)) {
return SCE_SNAP_TO_NONE;
if (std::optional<Bounds<float3>> bounds = mesh_eval->bounds_min_max()) {
if (!nearest2d.snap_boundbox(bounds->min, bounds->max)) {
return SCE_SNAP_TO_NONE;
}
}
}