Fix: GPv3: Crash switching to draw mode for empty object

Crash occurs in debug mode after switching to draw mode if GP object is
empty (i.e. zero points)
This is due to accessing value which is empty i.e.`std::nullopt`

Pull Request: https://projects.blender.org/blender/blender/pulls/115795
This commit is contained in:
Pratik Borhade 2023-12-07 11:40:08 +01:00 committed by Falk David
parent cad81786d0
commit 5a2b8da619
1 changed files with 5 additions and 2 deletions

View File

@ -823,8 +823,11 @@ static blender::float3 paint_init_pivot_grease_pencil(Object *ob, const int fram
{
using namespace blender;
const GreasePencil &grease_pencil = *static_cast<const GreasePencil *>(ob->data);
const blender::Bounds<blender::float3> bounds = *grease_pencil.bounds_min_max(frame);
return blender::math::midpoint(bounds.min, bounds.max);
const std::optional<Bounds<float3>> bounds = grease_pencil.bounds_min_max(frame);
if (bounds.has_value()) {
return blender::math::midpoint(bounds->min, bounds->max);
}
return float3(0.0f);
}
void paint_init_pivot(Object *ob, Scene *scene)