From 2df06a05ae680103c891b991c9336ade98635c03 Mon Sep 17 00:00:00 2001 From: Pratik Borhade Date: Thu, 21 Mar 2024 01:15:18 +0100 Subject: [PATCH] GPv3: Show stats in edit mode GPv3 uses `OB_MODE_EDIT` so it falsely shows empty mesh data in stats. This worked in legacy gp because it had special edit_mode type. To show correct grease pencil data in edit mode, rearrange if conditions and add special check for `OB_GREASE_PENCIL` Pull Request: https://projects.blender.org/blender/blender/pulls/119689 --- .../blender/editors/space_info/info_stats.cc | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index 3074cf397c2..de8aecbc98e 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -398,7 +398,7 @@ static void stats_update(Depsgraph *depsgraph, memset(stats, 0x0, sizeof(*stats)); - if (obedit) { + if (obedit && (ob->type != OB_GREASE_PENCIL)) { /* Edit Mode. */ FOREACH_OBJECT_BEGIN (scene, view_layer, ob_iter) { if (ob_iter->base_flag & BASE_ENABLED_AND_VISIBLE_IN_DEFAULT_VIEWPORT) { @@ -823,7 +823,26 @@ void ED_info_draw_stats( stats_row(col1, labels[OBJ], col2, stats_fmt.totobj, nullptr, y, height); } - if (obedit) { + if (!any_selected) { + if (any_objects) { + /* Show scene totals if nothing is selected. */ + stats_row(col1, labels[VERTS], col2, stats_fmt.totvert, nullptr, y, height); + stats_row(col1, labels[EDGES], col2, stats_fmt.totedge, nullptr, y, height); + stats_row(col1, labels[FACES], col2, stats_fmt.totface, nullptr, y, height); + stats_row(col1, labels[TRIS], col2, stats_fmt.tottri, nullptr, y, height); + } + else { + /* No objects in scene. */ + stats_row(col1, labels[OBJ], col2, stats_fmt.totobj, nullptr, y, height); + } + } + else if ((ob) && ELEM(ob->type, OB_GPENCIL_LEGACY, OB_GREASE_PENCIL)) { + stats_row(col1, labels[LAYERS], col2, stats_fmt.totgplayer, nullptr, y, height); + stats_row(col1, labels[FRAMES], col2, stats_fmt.totgpframe, nullptr, y, height); + stats_row(col1, labels[STROKES], col2, stats_fmt.totgpstroke, nullptr, y, height); + stats_row(col1, labels[POINTS], col2, stats_fmt.totgppoint, nullptr, y, height); + } + else if (obedit) { if (obedit->type == OB_MESH) { stats_row(col1, labels[VERTS], col2, stats_fmt.totvertsel, stats_fmt.totvert, y, height); stats_row(col1, labels[EDGES], col2, stats_fmt.totedgesel, stats_fmt.totedge, y, height); @@ -848,28 +867,9 @@ void ED_info_draw_stats( stats_row(col1, labels[FACES], col2, stats_fmt.totfacesculpt, nullptr, y, height); } } - else if (!any_selected) { - if (any_objects) { - /* Show scene totals if nothing is selected. */ - stats_row(col1, labels[VERTS], col2, stats_fmt.totvert, nullptr, y, height); - stats_row(col1, labels[EDGES], col2, stats_fmt.totedge, nullptr, y, height); - stats_row(col1, labels[FACES], col2, stats_fmt.totface, nullptr, y, height); - stats_row(col1, labels[TRIS], col2, stats_fmt.tottri, nullptr, y, height); - } - else { - /* No objects in scene. */ - stats_row(col1, labels[OBJ], col2, stats_fmt.totobj, nullptr, y, height); - } - } else if (ob && (object_mode & OB_MODE_POSE)) { stats_row(col1, labels[BONES], col2, stats_fmt.totbonesel, stats_fmt.totbone, y, height); } - else if ((ob) && ELEM(ob->type, OB_GPENCIL_LEGACY, OB_GREASE_PENCIL)) { - stats_row(col1, labels[LAYERS], col2, stats_fmt.totgplayer, nullptr, y, height); - stats_row(col1, labels[FRAMES], col2, stats_fmt.totgpframe, nullptr, y, height); - stats_row(col1, labels[STROKES], col2, stats_fmt.totgpstroke, nullptr, y, height); - stats_row(col1, labels[POINTS], col2, stats_fmt.totgppoint, nullptr, y, height); - } else if ((ob) && (ob->type == OB_LAMP)) { stats_row(col1, labels[LIGHTS], col2, stats_fmt.totlampsel, stats_fmt.totlamp, y, height); }