Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-06-16 10:13:09 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-06-16 10:17:15 +0300
commit1c0a490d0e76c56c2980bdf48b33b3e6bc981e5c (patch)
treee097d812bdd2dbf72b881bd0a8be3048fdf910fb
parentc3fa7b7e4fd773534e0a6d340256f3a25a86ff55 (diff)
Cleanup: minor simplification to status allocation
-rw-r--r--source/blender/editors/space_info/info_stats.c41
1 files changed, 16 insertions, 25 deletions
diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c
index 63ce7cb9d7a..50eb96824d7 100644
--- a/source/blender/editors/space_info/info_stats.c
+++ b/source/blender/editors/space_info/info_stats.c
@@ -393,19 +393,23 @@ static void stats_object_sculpt(const Object *ob, SceneStats *stats)
}
/* Statistics displayed in info header. Called regularly on scene changes. */
-static void stats_update(Depsgraph *depsgraph, ViewLayer *view_layer, View3D *v3d_local)
+static void stats_update(Depsgraph *depsgraph,
+ ViewLayer *view_layer,
+ View3D *v3d_local,
+ SceneStats *stats)
{
- SceneStats stats = {0};
const Object *ob = OBACT(view_layer);
const Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
+ memset(stats, 0x0, sizeof(*stats));
+
if (obedit) {
/* Edit Mode. */
FOREACH_OBJECT_BEGIN (view_layer, ob_iter) {
if (ob_iter->base_flag & BASE_VISIBLE_VIEWLAYER) {
if (ob_iter->mode & OB_MODE_EDIT) {
- stats_object_edit(ob_iter, &stats);
- stats.totobjsel++;
+ stats_object_edit(ob_iter, stats);
+ stats->totobjsel++;
}
else {
/* Skip hidden objects in local view that are not in edit-mode,
@@ -414,7 +418,7 @@ static void stats_update(Depsgraph *depsgraph, ViewLayer *view_layer, View3D *v3
continue;
}
}
- stats.totobj++;
+ stats->totobj++;
}
}
FOREACH_OBJECT_END;
@@ -424,8 +428,8 @@ static void stats_update(Depsgraph *depsgraph, ViewLayer *view_layer, View3D *v3
FOREACH_OBJECT_BEGIN (view_layer, ob_iter) {
if (ob_iter->base_flag & BASE_VISIBLE_VIEWLAYER) {
if (ob_iter->mode & OB_MODE_POSE) {
- stats_object_pose(ob_iter, &stats);
- stats.totobjsel++;
+ stats_object_pose(ob_iter, stats);
+ stats->totobjsel++;
}
else {
/* See comment for edit-mode. */
@@ -433,7 +437,7 @@ static void stats_update(Depsgraph *depsgraph, ViewLayer *view_layer, View3D *v3
continue;
}
}
- stats.totobj++;
+ stats->totobj++;
}
}
FOREACH_OBJECT_END;
@@ -446,32 +450,18 @@ static void stats_update(Depsgraph *depsgraph, ViewLayer *view_layer, View3D *v3
}
else {
/* When dynamic topology is not enabled both sculpt stats and scene stats are collected. */
- stats_object_sculpt(ob, &stats);
+ stats_object_sculpt(ob, stats);
}
}
else {
/* Objects. */
GSet *objects_gset = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN (depsgraph, ob_iter) {
- stats_object(ob_iter, v3d_local, &stats, objects_gset);
+ stats_object(ob_iter, v3d_local, stats, objects_gset);
}
DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END;
BLI_gset_free(objects_gset, NULL);
}
-
- if (v3d_local) {
- BLI_assert(v3d_local->localvd != NULL);
- if (v3d_local->runtime.local_stats == NULL) {
- v3d_local->runtime.local_stats = MEM_mallocN(sizeof(SceneStats), "LocalStats");
- }
- *v3d_local->runtime.local_stats = stats;
- }
- else {
- if (!view_layer->stats) {
- view_layer->stats = MEM_callocN(sizeof(SceneStats), "SceneStats");
- }
- *view_layer->stats = stats;
- }
}
void ED_info_stats_clear(wmWindowManager *wm, ViewLayer *view_layer)
@@ -510,7 +500,8 @@ static bool format_stats(
return false;
}
Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer);
- stats_update(depsgraph, view_layer, v3d_local);
+ *stats_p = MEM_mallocN(sizeof(SceneStats), __func__);
+ stats_update(depsgraph, view_layer, v3d_local, *stats_p);
}
SceneStats *stats = *stats_p;