Initial Grease Pencil 3.0 stage #106848
|
@ -22,6 +22,8 @@ namespace gpencil::convert {
|
|||
|
||||
CurvesGeometry legacy_gpencil_frame_to_curves_geometry(bGPDframe &gpf);
|
||||
filedescriptor marked this conversation as resolved
Outdated
|
||||
|
||||
void legacy_gpencil_to_grease_pencil(bGPdata &gpd, GreasePencil &grease_pencil);
|
||||
|
||||
} // namespace gpencil::convert
|
||||
|
||||
} // namespace blender::bke
|
||||
|
|
|
@ -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
|
|
@ -181,9 +181,6 @@ typedef struct GreasePencil {
|
|||
*/
|
||||
GreasePencilDrawingOrReference **drawing_array;
|
||||
int drawing_array_size;
|
||||
Hans Goudey
commented
Pretty sure null-terminated goes without saying for Pretty sure null-terminated goes without saying for `char *` pointers in DNA, I don't think it's worth mentioning here
Sergey Sharybin
commented
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.
Hans Goudey
commented
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
|
||||
|
|
Loading…
Reference in New Issue
Decide on the namespace here. Should it maybe be just
gp
?