GPv3: Empty grease pencil object crash #119690

Merged
Falk David merged 3 commits from PratikPB2123/blender:gpv3-empty-crash into main 2024-03-21 11:00:49 +01:00
Showing only changes of commit bf88bc42d4 - Show all commits

View File

@ -610,7 +610,8 @@ static GPENCIL_tObject *grease_pencil_object_cache_populate(GPENCIL_PrivateData
using namespace blender::bke::greasepencil;
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
const bool is_vertex_mode = (ob->mode & OB_MODE_VERTEX_PAINT) != 0;
const std::optional<blender::Bounds<float3>> bounds = grease_pencil.bounds_min_max_eval();
const std::optional<blender::Bounds<float3>> bounds =

Since you're using value_or now, this can just be const blender::Bounds<float3> bounds.

Since you're using `value_or` now, this can just be `const blender::Bounds<float3> bounds`.

Done. BTW bounds passed to gpencil_object_cache_add(), should I remove optional from function declaration?

Done. BTW `bounds` passed to `gpencil_object_cache_add()`, should I remove optional from function declaration?

Yes! It looks like GPv2 was already using value_or so that can be changed as well. So then gpencil_object_cache_add can just get Bounds<float3>.

Yes! It looks like GPv2 was already using `value_or` so that can be changed as well. So then `gpencil_object_cache_add` can just get `Bounds<float3>`.
grease_pencil.bounds_min_max_eval().value_or(blender::Bounds(float3(0)));
const bool use_stroke_order_3d = (grease_pencil.flag & GREASE_PENCIL_STROKE_ORDER_3D) != 0;
GPENCIL_tObject *tgp_ob = gpencil_object_cache_add(pd, ob, use_stroke_order_3d, bounds);