GPv3: Add statistics information #112573

Merged
Falk David merged 6 commits from PratikPB2123/blender:gpv3-stats into main 2023-09-21 12:42:48 +02:00
1 changed files with 28 additions and 3 deletions

View File

@ -15,6 +15,7 @@
#include "DNA_collection_types.h"
#include "DNA_curve_types.h"
#include "DNA_gpencil_legacy_types.h"
#include "DNA_grease_pencil_types.h"
#include "DNA_lattice_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
@ -30,6 +31,7 @@
#include "BLI_string_utf8.h"
#include "BLI_timecode.h"
#include "BLI_utildefines.h"
#include "BLI_span.hh"
#include "BLT_translation.h"
@ -38,9 +40,11 @@
#include "BKE_blender_version.h"
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_curves.hh"
#include "BKE_displist.h"
#include "BKE_editmesh.h"
#include "BKE_gpencil_legacy.h"
#include "BKE_grease_pencil.hh"
#include "BKE_key.h"
#include "BKE_layer.h"
#include "BKE_main.h"
@ -190,10 +194,31 @@ static void stats_object(Object *ob,
}
break;
}
case OB_GREASE_PENCIL: {
if (!is_selected) {
break;
}
filedescriptor marked this conversation as resolved
Review

Use const for the pointer variables here.

Use `const` for the pointer variables here.
filedescriptor marked this conversation as resolved Outdated

const for span too.

`const` for span too.
const GreasePencil *grease_pencil = static_cast<GreasePencil *>(ob->data);
for (const GreasePencilDrawingBase *drawing_base : grease_pencil->drawings()) {
const GreasePencilDrawing *drawing = reinterpret_cast<const GreasePencilDrawing *>(drawing_base);

range -> drawing_index

`range` -> `drawing_index`
const blender::bke::CurvesGeometry &curves = drawing->wrap().strokes();

This copies the geometry, since the variable isn't a reference.

This copies the geometry, since the variable isn't a reference.

We shouldn't ever access the geometry on the DNA directly. Use ->strokes().

We shouldn't ever access the `geometry` on the DNA directly. Use `->strokes()`.

These should be const pointers. I also updated main to make ->drawings(); return const pointers too.

These should be const pointers. I also updated main to make `->drawings();` return const pointers too.
filedescriptor marked this conversation as resolved Outdated

Use the .points_num() and .curves_num() accessors.

Use the `.points_num()` and `.curves_num()` accessors.
stats->totgppoint += curves.points_num();
stats->totgpstroke += curves.curves_num();
}
for (const blender::bke::greasepencil::Layer *layer : grease_pencil->layers()) {

This is not right. Number of drawings != number of keyframes.
This should iterate over the layers and count up their frames().size().

This is not right. Number of drawings != number of keyframes. This should iterate over the layers and count up their `frames().size()`.

I think new drawing is created for every frame so the count should be equal, no?
I might be wrong here. Updating the PR.

I think new drawing is created for every frame so the count should be equal, no? I might be wrong here. Updating the PR.

There will be the ability to link the data of one drawing for multiple keyframes (similar to how ALT+D works for object data linking).

There will be the ability to link the data of one drawing for multiple keyframes (similar to how `ALT`+`D` works for object data linking).
stats->totgpframe += layer->frames().size();
}

auto -> const bke::greasepencil::Layer *

`auto` -> `const bke::greasepencil::Layer *`
stats->totgplayer += grease_pencil->layers().size();
break;
}
case OB_CURVES:
case OB_POINTCLOUD:
case OB_VOLUME:
case OB_GREASE_PENCIL: {
case OB_VOLUME: {
break;
}
}
@ -835,7 +860,7 @@ void ED_info_draw_stats(
else if (ob && (object_mode & OB_MODE_POSE)) {
stats_row(col1, labels[BONES], col2, stats_fmt.totbonesel, stats_fmt.totbone, y, height);
}
else if ((ob) && (ob->type == OB_GPENCIL_LEGACY)) {
else if ((ob) && ELEM(ob->type, OB_GPENCIL_LEGACY, OB_GREASE_PENCIL)) {
stats_row(col1, labels[LAYERS], col2, stats_fmt.totgplayer, nullptr, y, height);
stats_row(col1, labels[FRAMES], col2, stats_fmt.totgpframe, nullptr, y, height);
stats_row(col1, labels[STROKES], col2, stats_fmt.totgpstroke, nullptr, y, height);