Initial Grease Pencil 3.0 stage #106848

Merged
Falk David merged 224 commits from filedescriptor/blender:grease-pencil-v3 into main 2023-05-30 11:14:22 +02:00
3 changed files with 33 additions and 3 deletions
Showing only changes of commit bf6134f7ad - Show all commits

View File

@ -22,6 +22,8 @@ namespace gpencil::convert {
CurvesGeometry legacy_gpencil_frame_to_curves_geometry(bGPDframe &gpf);
filedescriptor marked this conversation as resolved Outdated

Decide on the namespace here. Should it maybe be just gp?

Decide on the namespace here. Should it maybe be just `gp`?
void legacy_gpencil_to_grease_pencil(bGPdata &gpd, GreasePencil &grease_pencil);
} // namespace gpencil::convert
} // namespace blender::bke

View File

@ -91,4 +91,35 @@ CurvesGeometry legacy_gpencil_frame_to_curves_geometry(bGPDframe &gpf)
return curves;
}
void legacy_gpencil_to_grease_pencil(bGPdata &gpd, GreasePencil &grease_pencil)
{
int num_layers = 0;
int num_drawings = 0;
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd.layers) {
num_drawings += BLI_listbase_count(&gpl->frames);
num_layers++;
}
grease_pencil.drawing_array_size = num_drawings;
grease_pencil.drawing_array = reinterpret_cast<GreasePencilDrawingOrReference **>(
MEM_cnew_array<GreasePencilDrawing>(num_drawings, __func__));
int i = 0;
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd.layers) {
/* TODO: create a new layer here. */
LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
GreasePencilDrawing &drawing = *reinterpret_cast<GreasePencilDrawing *>(
grease_pencil.drawing_array[i]);
drawing.base.type = GREASE_PENCIL_DRAWING;
/* TODO: copy flag. */
/* Convert the frame to a drawing. */
drawing.geometry = legacy_gpencil_frame_to_curves_geometry(*gpf);
/* TODO: add drawing to layer. Using the gpf->framenum. */
i++;
}
}
}
} // namespace blender::bke::gpencil::convert

View File

@ -181,9 +181,6 @@ typedef struct GreasePencil {
*/
GreasePencilDrawingOrReference **drawing_array;
int drawing_array_size;

Pretty sure null-terminated goes without saying for char * pointers in DNA, I don't think it's worth mentioning here

Pretty sure null-terminated goes without saying for `char *` pointers in DNA, I don't think it's worth mentioning here

Not sure about dynamic names for strings. It is not something typically used in the DNA.

Not sure about dynamic names for strings. It is not something typically used in the DNA.

It's been done more recently I think. It's properly integrated with RNA now too, to avoid that boilerplate. It's nice not to have to worry about choosing a future-proof length.

It's been done more recently I think. It's properly integrated with RNA now too, to avoid that boilerplate. It's nice not to have to worry about choosing a future-proof length.
#ifdef __cplusplus
blender::Span<GreasePencilDrawingOrReference *> drawings() const;
#endif
char _pad[4];
#ifdef __cplusplus