From c8e331f45003352072789362241d2f5684737ec5 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Tue, 15 Jun 2021 19:01:53 -0700 Subject: UI - LOCAL View3D overlay stats This patch improves the 3DView statistics overlay to show LOCAL stats while in local view. This means the stats can vary between 3DViews and the statusbar when views are in local view, but this gives a much more accurate count of the objects, and their components, that you are directly working with rather than just scene values. Differential Revision: https://developer.blender.org/D8883 Reviewed by Campbell Barton --- source/blender/editors/space_view3d/space_view3d.c | 20 +++++++++++++++++++- source/blender/editors/space_view3d/view3d_draw.c | 4 +++- source/blender/editors/space_view3d/view3d_view.c | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/space_view3d') diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 36901141497..d560c1f9978 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -331,6 +331,8 @@ static void view3d_free(SpaceLink *sl) MEM_freeN(vd->localvd); } + MEM_SAFE_FREE(vd->runtime.local_stats); + if (vd->runtime.properties_storage) { MEM_freeN(vd->runtime.properties_storage); } @@ -346,6 +348,18 @@ static void view3d_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) { } +static void view3d_exit(wmWindowManager *UNUSED(wm), ScrArea *area) +{ + BLI_assert(area->spacetype == SPACE_VIEW3D); + View3D *v3d = area->spacedata.first; + /* Happens when freeing. */ + if (v3d == NULL) { + return; + } + + MEM_SAFE_FREE(v3d->runtime.local_stats); +} + static SpaceLink *view3d_duplicate(SpaceLink *sl) { View3D *v3do = (View3D *)sl; @@ -1581,7 +1595,7 @@ static void space_view3d_listener(const wmSpaceTypeListenerParams *params) } } -static void space_view3d_refresh(const bContext *C, ScrArea *UNUSED(area)) +static void space_view3d_refresh(const bContext *C, ScrArea *area) { Scene *scene = CTX_data_scene(C); LightCache *lcache = scene->eevee.light_cache_data; @@ -1590,6 +1604,9 @@ static void space_view3d_refresh(const bContext *C, ScrArea *UNUSED(area)) lcache->flag &= ~LIGHTCACHE_UPDATE_AUTO; view3d_lightcache_update((bContext *)C); } + + View3D *v3d = (View3D *)area->spacedata.first; + MEM_SAFE_FREE(v3d->runtime.local_stats); } const char *view3d_context_dir[] = { @@ -1697,6 +1714,7 @@ void ED_spacetype_view3d(void) st->create = view3d_create; st->free = view3d_free; st->init = view3d_init; + st->exit = view3d_exit; st->listener = space_view3d_listener; st->refresh = space_view3d_refresh; st->duplicate = view3d_duplicate; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 4a595c716b6..0bc19887118 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1537,7 +1537,9 @@ void view3d_draw_region_info(const bContext *C, ARegion *region) } if ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0 && (v3d->overlay.flag & V3D_OVERLAY_STATS)) { - ED_info_draw_stats(bmain, scene, view_layer, xoffset, &yoffset, VIEW3D_OVERLAY_LINEHEIGHT); + View3D *v3d_local = v3d->localvd ? v3d : NULL; + ED_info_draw_stats( + bmain, scene, view_layer, v3d_local, xoffset, &yoffset, VIEW3D_OVERLAY_LINEHEIGHT); } BLF_batch_draw_end(); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 21cb8560e9b..f49b94280d6 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1393,6 +1393,7 @@ static void view3d_localview_exit(const Depsgraph *depsgraph, MEM_freeN(v3d->localvd); v3d->localvd = NULL; + MEM_SAFE_FREE(v3d->runtime.local_stats); LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->regiontype == RGN_TYPE_WINDOW) { -- cgit v1.2.3