Fix info header stats to iterator over layer instead of scene
Although this is working fine, there are two changes expected in the new future once depsgraph copy on write is implemented: 1) To call ED_info_stats_clear a callback from depsgraph, instead of the notifier system. (that would also allow us to clear only one SceneLayer). 2) To store/get stats from the evaluated SceneLayer, as well as iterate over the evaluated objects as well.
This commit is contained in:
parent
9619275729
commit
1e31127933
|
@ -69,7 +69,7 @@ class INFO_HT_header(Header):
|
|||
return
|
||||
|
||||
row.operator("wm.splash", text="", icon='BLENDER', emboss=False)
|
||||
row.label(text=scene.statistics(), translate=False)
|
||||
row.label(text=scene.statistics(context.render_layer), translate=False)
|
||||
|
||||
|
||||
class INFO_MT_editor_menus(Menu):
|
||||
|
|
|
@ -175,6 +175,8 @@ void BKE_scene_layer_free(SceneLayer *sl)
|
|||
IDP_FreeProperty(sl->properties_evaluated);
|
||||
MEM_freeN(sl->properties_evaluated);
|
||||
}
|
||||
|
||||
MEM_SAFE_FREE(sl->stats);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -254,7 +254,6 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
|
|||
scen->theDag = NULL;
|
||||
scen->depsgraph = NULL;
|
||||
scen->obedit = NULL;
|
||||
scen->stats = NULL;
|
||||
scen->fps_info = NULL;
|
||||
|
||||
if (sce->rigidbody_world)
|
||||
|
@ -317,6 +316,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
|
|||
BLI_duplicatelist(&scen->render_layers, &sce->render_layers);
|
||||
SceneLayer *new_sl = scen->render_layers.first;
|
||||
for (SceneLayer *sl = sce->render_layers.first; sl; sl = sl->next) {
|
||||
new_sl->stats = NULL;
|
||||
new_sl->properties = IDP_New(IDP_GROUP, (const IDPropertyTemplate *){0}, ROOT_PROP);
|
||||
new_sl->properties_evaluated = NULL;
|
||||
|
||||
|
@ -571,8 +571,7 @@ void BKE_scene_free(Scene *sce)
|
|||
DEG_scene_graph_free(sce);
|
||||
if (sce->depsgraph)
|
||||
DEG_graph_free(sce->depsgraph);
|
||||
|
||||
MEM_SAFE_FREE(sce->stats);
|
||||
|
||||
MEM_SAFE_FREE(sce->fps_info);
|
||||
|
||||
BKE_sound_destroy_scene(sce);
|
||||
|
|
|
@ -6049,7 +6049,6 @@ static void direct_link_scene(FileData *fd, Scene *sce)
|
|||
sce->theDag = NULL;
|
||||
sce->depsgraph = NULL;
|
||||
sce->obedit = NULL;
|
||||
sce->stats = NULL;
|
||||
sce->fps_info = NULL;
|
||||
sce->customdata_mask_modal = 0;
|
||||
sce->lay_updated = 0;
|
||||
|
@ -6309,6 +6308,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
|
|||
|
||||
link_list(fd, &sce->render_layers);
|
||||
for (sl = sce->render_layers.first; sl; sl = sl->next) {
|
||||
sl->stats = NULL;
|
||||
link_list(fd, &sl->object_bases);
|
||||
sl->basact = newdataadr(fd, sl->basact);
|
||||
direct_link_layer_collections(fd, &sl->layer_collections);
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#define __ED_INFO_H__
|
||||
|
||||
/* info_stats.c */
|
||||
void ED_info_stats_clear(struct Scene *scene);
|
||||
const char *ED_info_stats_string(struct Scene *scene);
|
||||
void ED_info_stats_clear(struct SceneLayer *sl);
|
||||
const char *ED_info_stats_string(struct Scene *scene, struct SceneLayer *sl);
|
||||
|
||||
#endif /* __ED_INFO_H__ */
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "BKE_displist.h"
|
||||
#include "BKE_DerivedMesh.h"
|
||||
#include "BKE_key.h"
|
||||
#include "BKE_layer.h"
|
||||
#include "BKE_paint.h"
|
||||
#include "BKE_particle.h"
|
||||
#include "BKE_editmesh.h"
|
||||
|
@ -269,9 +270,9 @@ static void stats_object_sculpt_dynamic_topology(Object *ob, SceneStats *stats)
|
|||
stats->tottri = ob->sculpt->bm->totface;
|
||||
}
|
||||
|
||||
static void stats_dupli_object(BaseLegacy *base, Object *ob, SceneStats *stats)
|
||||
static void stats_dupli_object(Base *base, Object *ob, SceneStats *stats)
|
||||
{
|
||||
if (base->flag_legacy & SELECT) stats->totobjsel++;
|
||||
if (base->flag & BASE_SELECTED) stats->totobjsel++;
|
||||
|
||||
if (ob->transflag & OB_DUPLIPARTS) {
|
||||
/* Dupli Particles */
|
||||
|
@ -344,11 +345,11 @@ static bool stats_is_object_dynamic_topology_sculpt(Object *ob)
|
|||
}
|
||||
|
||||
/* Statistics displayed in info header. Called regularly on scene changes. */
|
||||
static void stats_update(Scene *scene)
|
||||
static void stats_update(Scene *scene, SceneLayer *sl)
|
||||
{
|
||||
SceneStats stats = {0};
|
||||
Object *ob = (scene->basact) ? scene->basact->object : NULL;
|
||||
BaseLegacy *base;
|
||||
Object *ob = (sl->basact) ? sl->basact->object : NULL;
|
||||
Base *base;
|
||||
|
||||
if (scene->obedit) {
|
||||
/* Edit Mode */
|
||||
|
@ -364,23 +365,25 @@ static void stats_update(Scene *scene)
|
|||
}
|
||||
else {
|
||||
/* Objects */
|
||||
for (base = scene->base.first; base; base = base->next)
|
||||
if (scene->lay & base->lay)
|
||||
for (base = sl->object_bases.first; base; base = base->next)
|
||||
if (base->flag & BASE_VISIBLED) {
|
||||
stats_dupli_object(base, base->object, &stats);
|
||||
}
|
||||
}
|
||||
|
||||
if (!scene->stats)
|
||||
scene->stats = MEM_callocN(sizeof(SceneStats), "SceneStats");
|
||||
if (!sl->stats) {
|
||||
sl->stats = MEM_callocN(sizeof(SceneStats), "SceneStats");
|
||||
}
|
||||
|
||||
*(scene->stats) = stats;
|
||||
*(sl->stats) = stats;
|
||||
}
|
||||
|
||||
static void stats_string(Scene *scene)
|
||||
static void stats_string(Scene *scene, SceneLayer *sl)
|
||||
{
|
||||
#define MAX_INFO_MEM_LEN 64
|
||||
SceneStats *stats = scene->stats;
|
||||
SceneStats *stats = sl->stats;
|
||||
SceneStatsFmt stats_fmt;
|
||||
Object *ob = (scene->basact) ? scene->basact->object : NULL;
|
||||
Object *ob = (sl->basact) ? sl->basact->object : NULL;
|
||||
uintptr_t mem_in_use, mmap_in_use;
|
||||
char memstr[MAX_INFO_MEM_LEN];
|
||||
char gpumemstr[MAX_INFO_MEM_LEN] = "";
|
||||
|
@ -487,19 +490,20 @@ static void stats_string(Scene *scene)
|
|||
|
||||
#undef MAX_INFO_LEN
|
||||
|
||||
void ED_info_stats_clear(Scene *scene)
|
||||
void ED_info_stats_clear(SceneLayer *sl)
|
||||
{
|
||||
if (scene->stats) {
|
||||
MEM_freeN(scene->stats);
|
||||
scene->stats = NULL;
|
||||
if (sl->stats) {
|
||||
MEM_freeN(sl->stats);
|
||||
sl->stats = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const char *ED_info_stats_string(Scene *scene)
|
||||
const char *ED_info_stats_string(Scene *scene, SceneLayer *sl)
|
||||
{
|
||||
if (!scene->stats)
|
||||
stats_update(scene);
|
||||
stats_string(scene);
|
||||
if (!sl->stats) {
|
||||
stats_update(scene, sl);
|
||||
}
|
||||
stats_string(scene, sl);
|
||||
|
||||
return scene->stats->infostr;
|
||||
return sl->stats->infostr;
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ typedef struct SceneLayer {
|
|||
short flag;
|
||||
short pad[2];
|
||||
ListBase object_bases; /* ObjectBase */
|
||||
struct SceneStats *stats; /* default allocated now */
|
||||
struct Base *basact;
|
||||
ListBase layer_collections; /* LayerCollection */
|
||||
struct IDProperty *properties; /* overrides */
|
||||
|
|
|
@ -1689,7 +1689,7 @@ typedef struct Scene {
|
|||
struct Editing *ed; /* sequence editor data is allocated here */
|
||||
|
||||
struct ToolSettings *toolsettings; /* default allocated now */
|
||||
struct SceneStats *stats; /* default allocated now */
|
||||
void *pad2;
|
||||
struct DisplaySafeAreas safe_areas;
|
||||
|
||||
/* migrate or replace? depends on some internal things... */
|
||||
|
|
|
@ -9230,6 +9230,8 @@ void RNA_def_scene(BlenderRNA *brna)
|
|||
|
||||
/* Statistics */
|
||||
func = RNA_def_function(srna, "statistics", "ED_info_stats_string");
|
||||
parm = RNA_def_pointer(func, "scene_layer", "SceneLayer", "", "Active layer");
|
||||
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
||||
parm = RNA_def_string(func, "statistics", NULL, 0, "Statistics", "");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "BKE_context.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_layer.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_scene.h"
|
||||
|
@ -318,7 +319,8 @@ void wm_event_do_notifiers(bContext *C)
|
|||
}
|
||||
}
|
||||
if (ELEM(note->category, NC_SCENE, NC_OBJECT, NC_GEOM, NC_WM)) {
|
||||
ED_info_stats_clear(win->screen->scene);
|
||||
SceneLayer *sl = BKE_scene_layer_context_active(win->screen->scene);
|
||||
ED_info_stats_clear(sl);
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue