Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_info/info_stats.c
| Show First 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | static bool stats_mesheval(Mesh *me_eval, bool is_selected, SceneStats *stats) | ||||
| if (is_selected) { | if (is_selected) { | ||||
| stats->totvertsel += totvert; | stats->totvertsel += totvert; | ||||
| stats->totfacesel += totface; | stats->totfacesel += totface; | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| static void stats_object(Object *ob, SceneStats *stats) | static void stats_object(Object *ob, SceneStats *stats, GSet *objects_gset) | ||||
| { | { | ||||
| const bool is_selected = (ob->base_flag & BASE_SELECTED) != 0; | const bool is_selected = (ob->base_flag & BASE_SELECTED) != 0; | ||||
| stats->totobj++; | stats->totobj++; | ||||
| if (is_selected) { | if (is_selected) { | ||||
| stats->totobjsel++; | stats->totobjsel++; | ||||
| } | } | ||||
| switch (ob->type) { | switch (ob->type) { | ||||
| case OB_MESH: { | case OB_MESH: { | ||||
| /* we assume evaluated mesh is already built, this strictly does stats now. */ | /* we assume evaluated mesh is already built, this strictly does stats now. */ | ||||
| Mesh *me_eval = ob->runtime.mesh_eval; | Mesh *me_eval = ob->runtime.mesh_eval; | ||||
| if (!BLI_gset_add(objects_gset, me_eval)) { | |||||
| break; | |||||
| } | |||||
| stats_mesheval(me_eval, is_selected, stats); | stats_mesheval(me_eval, is_selected, stats); | ||||
| break; | break; | ||||
| } | } | ||||
| case OB_LAMP: | case OB_LAMP: | ||||
| stats->totlamp++; | stats->totlamp++; | ||||
| if (is_selected) { | if (is_selected) { | ||||
| stats->totlampsel++; | stats->totlampsel++; | ||||
| } | } | ||||
| break; | break; | ||||
| case OB_SURF: | case OB_SURF: | ||||
| case OB_CURVE: | case OB_CURVE: | ||||
| case OB_FONT: { | case OB_FONT: { | ||||
| Mesh *me_eval = ob->runtime.mesh_eval; | Mesh *me_eval = ob->runtime.mesh_eval; | ||||
| if ((me_eval != NULL) && !BLI_gset_add(objects_gset, me_eval)) { | |||||
| break; | |||||
| } | |||||
| if (stats_mesheval(me_eval, is_selected, stats)) { | if (stats_mesheval(me_eval, is_selected, stats)) { | ||||
| break; | break; | ||||
| } | } | ||||
| ATTR_FALLTHROUGH; /* Falltrough to displist. */ | ATTR_FALLTHROUGH; /* Falltrough to displist. */ | ||||
| } | } | ||||
| case OB_MBALL: { | case OB_MBALL: { | ||||
| int totv = 0, totf = 0, tottri = 0; | int totv = 0, totf = 0, tottri = 0; | ||||
| if (ob->runtime.curve_cache && ob->runtime.curve_cache->disp.first) { | if (ob->runtime.curve_cache && ob->runtime.curve_cache->disp.first) { | ||||
| /* Note: We only get the same curve_cache for instances of the same curve/font/... | |||||
| * For simple linked duplicated objects, each has its own dispList. */ | |||||
| if (!BLI_gset_add(objects_gset, ob->runtime.curve_cache)) { | |||||
| break; | |||||
| } | |||||
brecht: `ob->runtime.curve_cache` should get the same treatment here, so we don't count metaballs… | |||||
| BKE_displist_count(&ob->runtime.curve_cache->disp, &totv, &totf, &tottri); | BKE_displist_count(&ob->runtime.curve_cache->disp, &totv, &totf, &tottri); | ||||
| } | } | ||||
| stats->totvert += totv; | stats->totvert += totv; | ||||
| stats->totface += totf; | stats->totface += totf; | ||||
| stats->tottri += tottri; | stats->tottri += tottri; | ||||
| if (is_selected) { | if (is_selected) { | ||||
| stats->totvertsel += totv; | stats->totvertsel += totv; | ||||
| stats->totfacesel += totf; | stats->totfacesel += totf; | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case OB_GPENCIL: { | case OB_GPENCIL: { | ||||
| if (is_selected) { | if (is_selected) { | ||||
| bGPdata *gpd = (bGPdata *)ob->data; | bGPdata *gpd = (bGPdata *)ob->data; | ||||
| if (!BLI_gset_add(objects_gset, gpd)) { | |||||
| break; | |||||
| } | |||||
| /* GPXX Review if we can move to other place when object change | /* GPXX Review if we can move to other place when object change | ||||
| * maybe to depsgraph evaluation | * maybe to depsgraph evaluation | ||||
| */ | */ | ||||
| BKE_gpencil_stats_update(gpd); | BKE_gpencil_stats_update(gpd); | ||||
| stats->totgplayer += gpd->totlayer; | stats->totgplayer += gpd->totlayer; | ||||
| stats->totgpframe += gpd->totframe; | stats->totgpframe += gpd->totframe; | ||||
| stats->totgpstroke += gpd->totstroke; | stats->totgpstroke += gpd->totstroke; | ||||
| ▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | else if (ob && (ob->mode & OB_MODE_POSE)) { | ||||
| stats_object_pose(ob, &stats); | stats_object_pose(ob, &stats); | ||||
| } | } | ||||
| else if (ob && stats_is_object_dynamic_topology_sculpt(ob, ob->mode)) { | else if (ob && stats_is_object_dynamic_topology_sculpt(ob, ob->mode)) { | ||||
| /* Dynamic-topology sculpt mode */ | /* Dynamic-topology sculpt mode */ | ||||
| stats_object_sculpt_dynamic_topology(ob, &stats); | stats_object_sculpt_dynamic_topology(ob, &stats); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Objects */ | /* Objects */ | ||||
| GSet *objects_gset = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__); | |||||
| DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN (depsgraph, ob_iter) { | DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN (depsgraph, ob_iter) { | ||||
| stats_object(ob_iter, &stats); | stats_object(ob_iter, &stats, objects_gset); | ||||
| } | } | ||||
| DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END; | DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END; | ||||
| BLI_gset_free(objects_gset, NULL); | |||||
| } | } | ||||
| if (!view_layer->stats) { | if (!view_layer->stats) { | ||||
| view_layer->stats = MEM_callocN(sizeof(SceneStats), "SceneStats"); | view_layer->stats = MEM_callocN(sizeof(SceneStats), "SceneStats"); | ||||
| } | } | ||||
| *(view_layer->stats) = stats; | *(view_layer->stats) = stats; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 198 Lines • Show Last 20 Lines | |||||
ob->runtime.curve_cache should get the same treatment here, so we don't count metaballs multiple times.