Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_info/info_stats.c
| Show All 24 Lines | |||||
| #include "DNA_armature_types.h" | #include "DNA_armature_types.h" | ||||
| #include "DNA_collection_types.h" | #include "DNA_collection_types.h" | ||||
| #include "DNA_curve_types.h" | #include "DNA_curve_types.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_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_modifier_types.h" | |||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_windowmanager_types.h" | #include "DNA_windowmanager_types.h" | ||||
| #include "BLF_api.h" | #include "BLF_api.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_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_editmesh.h" | #include "BKE_editmesh.h" | ||||
| #include "BKE_gpencil.h" | #include "BKE_gpencil.h" | ||||
| #include "BKE_key.h" | #include "BKE_key.h" | ||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_modifier.h" | |||||
| #include "BKE_multires.h" | |||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_particle.h" | #include "BKE_particle.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_subdiv_ccg.h" | #include "BKE_subdiv_ccg.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| ▲ Show 20 Lines • Show All 392 Lines • ▼ Show 20 Lines | void ED_info_stats_clear(ViewLayer *view_layer) | ||||
| } | } | ||||
| } | } | ||||
| const char *ED_info_footer_string(ViewLayer *view_layer) | const char *ED_info_footer_string(ViewLayer *view_layer) | ||||
| { | { | ||||
| return footer_string(view_layer); | return footer_string(view_layer); | ||||
| } | } | ||||
| static bool stats_get_multires_levels(Scene *scene, Object *ob, int *r_sculptlvl, int *r_totlvl) | |||||
campbellbarton: Return args should use `r_` prefix. | |||||
| { | |||||
| MultiresModifierData *mmd = get_multires_modifier(scene, ob, true); | |||||
| if (!mmd) { | |||||
| return false; | |||||
| } | |||||
| *r_sculptlvl = mmd->sculptlvl; | |||||
| *r_totlvl = mmd->totlvl; | |||||
Done Inline ActionsNo need for parenthesis on assignment. campbellbarton: No need for parenthesis on assignment. | |||||
| return true; | |||||
| } | |||||
| static void stats_row(int col1, | static void stats_row(int col1, | ||||
| const char *key, | const char *key, | ||||
| int col2, | int col2, | ||||
| const char *value1, | const char *value1, | ||||
| const char *value2, | const char *value2, | ||||
Done Inline ActionsNo need to duplicate logic of looking for a multires modifier. It is implemented in get_multires_modifier. sergey: No need to duplicate logic of looking for a multires modifier. It is implemented in… | |||||
| int *y, | int *y, | ||||
| int height) | int height) | ||||
| { | { | ||||
| *y -= height; | *y -= height; | ||||
| BLF_draw_default(col1, *y, 0.0f, key, 128); | BLF_draw_default(col1, *y, 0.0f, key, 128); | ||||
| char values[128]; | char values[128]; | ||||
| BLI_snprintf(values, sizeof(values), (value2) ? "%s / %s" : "%s", value1, value2); | BLI_snprintf(values, sizeof(values), (value2) ? "%s / %s" : "%s", value1, value2); | ||||
| BLF_draw_default(col2, *y, 0.0f, values, sizeof(values)); | BLF_draw_default(col2, *y, 0.0f, values, sizeof(values)); | ||||
| ▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | else if (stats_is_object_dynamic_topology_sculpt(ob, object_mode)) { | ||||
| stats_row(col1, labels[VERTS], col2, stats_fmt.totvert, NULL, y, height); | stats_row(col1, labels[VERTS], col2, stats_fmt.totvert, NULL, y, height); | ||||
| stats_row(col1, labels[TRIS], col2, stats_fmt.tottri, NULL, y, height); | stats_row(col1, labels[TRIS], col2, stats_fmt.tottri, NULL, y, height); | ||||
| } | } | ||||
| else { | else { | ||||
| stats_row(col1, labels[VERTS], col2, stats_fmt.totvert, NULL, y, height); | stats_row(col1, labels[VERTS], col2, stats_fmt.totvert, NULL, y, height); | ||||
| stats_row(col1, labels[EDGES], col2, stats_fmt.totedge, NULL, y, height); | stats_row(col1, labels[EDGES], col2, stats_fmt.totedge, NULL, y, height); | ||||
| stats_row(col1, labels[FACES], col2, stats_fmt.totface, NULL, y, height); | stats_row(col1, labels[FACES], col2, stats_fmt.totface, NULL, y, height); | ||||
| stats_row(col1, labels[TRIS], col2, stats_fmt.tottri, NULL, y, height); | stats_row(col1, labels[TRIS], col2, stats_fmt.tottri, NULL, y, height); | ||||
| if (ob && ob->mode & OB_MODE_SCULPT) { | |||||
| int sculptlvl, totlvl; | |||||
| char sculptlvl_str[MAX_INFO_NUM_LEN], totlvl_str[MAX_INFO_NUM_LEN]; | |||||
| if (stats_get_multires_levels(scene, ob, &sculptlvl, &totlvl)) { | |||||
| SNPRINTF(sculptlvl_str, "%d", sculptlvl); | |||||
| SNPRINTF(totlvl_str, "%d", totlvl); | |||||
Done Inline ActionsSNPRINTF can be used here. campbellbarton: `SNPRINTF` can be used here. | |||||
Done Inline ActionsBLI_snprintf sergey: `BLI_snprintf` | |||||
Done Inline ActionsSNPRINTF avoids redundant repetition here. campbellbarton: `SNPRINTF` avoids redundant repetition here. | |||||
| stats_row(col1, "Multires ", col2, sculptlvl_str, totlvl_str, y, height); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| BLF_disable(font_id, BLF_SHADOW); | BLF_disable(font_id, BLF_SHADOW); | ||||
| } | } | ||||
Return args should use r_ prefix.