Fix #132113: Grease Pencil: Sort cache before draw_scene early return

`GPENCIL_draw_scene` uses `pd->tobjects.first == nullptr` to determine
whether to early return (draw nothing). When there's only "In Front"
grease pencil objects in scene, `tobjects.first` can be `nullptr` but
`tobjects_infront.first` is valid, in which case no grease pencil would
be drawn. Becase `gpencil_object_cache_sort` will link those two command
lists both to `tobjects` and allow `infront` ones to draw after others,
thus move it before the early return to allow drawing to proceed
normally.

Pull Request: https://projects.blender.org/blender/blender/pulls/132155
This commit is contained in:
YimingWu 2025-01-21 06:54:21 +01:00 committed by YimingWu
parent d1e3db71a6
commit 932fa1b8bf

View file

@ -892,6 +892,9 @@ void GPENCIL_draw_scene(void *ved)
mul_v4_fl(clear_cols[1], pd->fade_3d_object_opacity);
}
/* Sort object by decreasing Z to avoid most of alpha ordering issues. */
gpencil_object_cache_sort(pd);
if (pd->tobjects.first == nullptr) {
return;
}
@ -911,9 +914,6 @@ void GPENCIL_draw_scene(void *ved)
blender::draw::View &view = blender::draw::View::default_get();
/* Sort object by decreasing Z to avoid most of alpha ordering issues. */
gpencil_object_cache_sort(pd);
LISTBASE_FOREACH (GPENCIL_tObject *, ob, &pd->tobjects) {
GPENCIL_draw_object(vedata, view, ob);
}