Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_info/info_stats.c
| Show All 26 Lines | |||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_armature_types.h" | #include "DNA_armature_types.h" | ||||
| #include "DNA_curve_types.h" | #include "DNA_curve_types.h" | ||||
| #include "DNA_gpencil_types.h" | |||||
| #include "DNA_group_types.h" | #include "DNA_group_types.h" | ||||
| #include "DNA_lattice_types.h" | #include "DNA_lattice_types.h" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_meta_types.h" | #include "DNA_meta_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "BKE_anim.h" | #include "BKE_anim.h" | ||||
| #include "BKE_blender_version.h" | #include "BKE_blender_version.h" | ||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| #include "BKE_displist.h" | #include "BKE_displist.h" | ||||
| #include "BKE_key.h" | #include "BKE_key.h" | ||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_particle.h" | #include "BKE_particle.h" | ||||
| #include "BKE_editmesh.h" | #include "BKE_editmesh.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_gpencil.h" | |||||
| #include "ED_info.h" | #include "ED_info.h" | ||||
| #include "ED_armature.h" | #include "ED_armature.h" | ||||
| #include "GPU_extensions.h" | #include "GPU_extensions.h" | ||||
| #define MAX_INFO_LEN 512 | #define MAX_INFO_LEN 512 | ||||
| #define MAX_INFO_NUM_LEN 16 | #define MAX_INFO_NUM_LEN 16 | ||||
| typedef struct SceneStats { | typedef struct SceneStats { | ||||
| int totvert, totvertsel; | int totvert, totvertsel; | ||||
| int totedge, totedgesel; | int totedge, totedgesel; | ||||
| int totface, totfacesel; | int totface, totfacesel; | ||||
| int totbone, totbonesel; | int totbone, totbonesel; | ||||
| int totobj, totobjsel; | int totobj, totobjsel; | ||||
| int totlamp, totlampsel; | int totlamp, totlampsel; | ||||
| int tottri; | int tottri; | ||||
| int totgplayer, totgpframe, totgpstroke, totgppoint; | |||||
| char infostr[MAX_INFO_LEN]; | char infostr[MAX_INFO_LEN]; | ||||
| } SceneStats; | } SceneStats; | ||||
| typedef struct SceneStatsFmt { | typedef struct SceneStatsFmt { | ||||
| /* Totals */ | /* Totals */ | ||||
| char totvert[MAX_INFO_NUM_LEN], totvertsel[MAX_INFO_NUM_LEN]; | char totvert[MAX_INFO_NUM_LEN], totvertsel[MAX_INFO_NUM_LEN]; | ||||
| char totface[MAX_INFO_NUM_LEN], totfacesel[MAX_INFO_NUM_LEN]; | char totface[MAX_INFO_NUM_LEN], totfacesel[MAX_INFO_NUM_LEN]; | ||||
| char totedge[MAX_INFO_NUM_LEN], totedgesel[MAX_INFO_NUM_LEN]; | char totedge[MAX_INFO_NUM_LEN], totedgesel[MAX_INFO_NUM_LEN]; | ||||
| char totbone[MAX_INFO_NUM_LEN], totbonesel[MAX_INFO_NUM_LEN]; | char totbone[MAX_INFO_NUM_LEN], totbonesel[MAX_INFO_NUM_LEN]; | ||||
| char totobj[MAX_INFO_NUM_LEN], totobjsel[MAX_INFO_NUM_LEN]; | char totobj[MAX_INFO_NUM_LEN], totobjsel[MAX_INFO_NUM_LEN]; | ||||
| char totlamp[MAX_INFO_NUM_LEN], totlampsel[MAX_INFO_NUM_LEN]; | char totlamp[MAX_INFO_NUM_LEN], totlampsel[MAX_INFO_NUM_LEN]; | ||||
| char tottri[MAX_INFO_NUM_LEN]; | char tottri[MAX_INFO_NUM_LEN]; | ||||
| char totgplayer[MAX_INFO_NUM_LEN], totgpframe[MAX_INFO_NUM_LEN]; | |||||
| char totgpstroke[MAX_INFO_NUM_LEN], totgppoint[MAX_INFO_NUM_LEN]; | |||||
| } SceneStatsFmt; | } SceneStatsFmt; | ||||
| static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) | static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) | ||||
| { | { | ||||
| 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. */ | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | case OB_MBALL: | ||||
| stats->tottri += tottri; | stats->tottri += tottri; | ||||
| if (sel) { | if (sel) { | ||||
| stats->totvertsel += totv; | stats->totvertsel += totv; | ||||
| stats->totfacesel += totf; | stats->totfacesel += totf; | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case OB_GPENCIL: | |||||
| { | |||||
| bGPdata *gpd = (bGPdata *)ob->data; | |||||
| /* GPXX Review if we can move to other place when object change | |||||
| * maybe to depsgraph evaluation | |||||
| */ | |||||
| BKE_gpencil_stats_update(gpd); | |||||
| stats->totgplayer = gpd->totlayer; | |||||
| stats->totgpframe = gpd->totframe; | |||||
| stats->totgpstroke = gpd->totstroke; | |||||
| stats->totgppoint = gpd->totpoint; | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| static void stats_object_edit(Object *obedit, SceneStats *stats) | static void stats_object_edit(Object *obedit, SceneStats *stats) | ||||
| { | { | ||||
| if (obedit->type == OB_MESH) { | if (obedit->type == OB_MESH) { | ||||
| BMEditMesh *em = BKE_editmesh_from_object(obedit); | BMEditMesh *em = BKE_editmesh_from_object(obedit); | ||||
| ▲ Show 20 Lines • Show All 282 Lines • ▼ Show 20 Lines | #define SCENE_STATS_FMT_INT(_id) \ | ||||
| SCENE_STATS_FMT_INT(totobj); | SCENE_STATS_FMT_INT(totobj); | ||||
| SCENE_STATS_FMT_INT(totobjsel); | SCENE_STATS_FMT_INT(totobjsel); | ||||
| SCENE_STATS_FMT_INT(totlamp); | SCENE_STATS_FMT_INT(totlamp); | ||||
| SCENE_STATS_FMT_INT(totlampsel); | SCENE_STATS_FMT_INT(totlampsel); | ||||
| SCENE_STATS_FMT_INT(tottri); | SCENE_STATS_FMT_INT(tottri); | ||||
| SCENE_STATS_FMT_INT(totgplayer); | |||||
| SCENE_STATS_FMT_INT(totgpframe); | |||||
| SCENE_STATS_FMT_INT(totgpstroke); | |||||
| SCENE_STATS_FMT_INT(totgppoint); | |||||
| #undef SCENE_STATS_FMT_INT | #undef SCENE_STATS_FMT_INT | ||||
| /* get memory statistics */ | /* get memory statistics */ | ||||
| BLI_str_format_byte_unit(formatted_mem, mem_in_use - mmap_in_use, true); | BLI_str_format_byte_unit(formatted_mem, mem_in_use - mmap_in_use, true); | ||||
| ofs = BLI_snprintf(memstr, MAX_INFO_MEM_LEN, IFACE_(" | Mem: %s"), formatted_mem); | ofs = BLI_snprintf(memstr, MAX_INFO_MEM_LEN, IFACE_(" | Mem: %s"), formatted_mem); | ||||
| if (mmap_in_use) { | if (mmap_in_use) { | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | if (obedit) { | ||||
| ofs += BLI_strncpy_rlen(s + ofs, memstr, MAX_INFO_LEN - ofs); | ofs += BLI_strncpy_rlen(s + ofs, memstr, MAX_INFO_LEN - ofs); | ||||
| ofs += BLI_strncpy_rlen(s + ofs, gpumemstr, MAX_INFO_LEN - ofs); | ofs += BLI_strncpy_rlen(s + ofs, gpumemstr, MAX_INFO_LEN - ofs); | ||||
| } | } | ||||
| else if (ob && (object_mode & OB_MODE_POSE)) { | else if (ob && (object_mode & OB_MODE_POSE)) { | ||||
| ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, IFACE_("Bones:%s/%s %s%s"), | ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, IFACE_("Bones:%s/%s %s%s"), | ||||
| stats_fmt.totbonesel, stats_fmt.totbone, memstr, gpumemstr); | stats_fmt.totbonesel, stats_fmt.totbone, memstr, gpumemstr); | ||||
| } | } | ||||
| else if ((ob) && (ob->type == OB_GPENCIL)) { | |||||
| ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, | |||||
| IFACE_("Layers:%s | Frames:%s | Strokes:%s | Points:%s"), | |||||
| stats_fmt.totgplayer, stats_fmt.totgpframe, stats_fmt.totgpstroke, stats_fmt.totgppoint); | |||||
| ofs += BLI_strncpy_rlen(s + ofs, memstr, MAX_INFO_LEN - ofs); | |||||
| ofs += BLI_strncpy_rlen(s + ofs, gpumemstr, MAX_INFO_LEN - ofs); | |||||
| } | |||||
| else if (stats_is_object_dynamic_topology_sculpt(ob, object_mode)) { | else if (stats_is_object_dynamic_topology_sculpt(ob, object_mode)) { | ||||
| ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, IFACE_("Verts:%s | Tris:%s%s"), stats_fmt.totvert, | ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, IFACE_("Verts:%s | Tris:%s%s"), stats_fmt.totvert, | ||||
| stats_fmt.tottri, gpumemstr); | stats_fmt.tottri, gpumemstr); | ||||
| } | } | ||||
| else { | else { | ||||
| ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, | ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, | ||||
| IFACE_("Verts:%s | Faces:%s | Tris:%s | Objects:%s/%s%s%s"), | IFACE_("Verts:%s | Faces:%s | Tris:%s | Objects:%s/%s%s%s"), | ||||
| stats_fmt.totvert, stats_fmt.totface, | stats_fmt.totvert, stats_fmt.totface, | ||||
| Show All 26 Lines | |||||