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 8 additions and 0 deletions
Showing only changes of commit 1de1e3e866 - Show all commits

View File

@ -67,6 +67,7 @@ static void grease_pencil_copy_data(Main * /*bmain*/,
grease_pencil_src->drawing_array_size, __func__);
for (int i = 0; i < grease_pencil_src->drawing_array_size; i++) {
const GreasePencilDrawingBase *src_drawing_base = grease_pencil_src->drawing_array[i];
grease_pencil_dst->drawing_array[i]->user_count = src_drawing_base->user_count;
switch (src_drawing_base->type) {
case GP_DRAWING: {
const GreasePencilDrawing *src_drawing = reinterpret_cast<const GreasePencilDrawing *>(
@ -1082,6 +1083,7 @@ void GreasePencil::add_empty_drawings(int n)
for (const int i : IndexRange(new_drawings.size())) {
new_drawings[i] = reinterpret_cast<GreasePencilDrawingBase *>(

IndexRange(new_drawings.size()) -> new_drawings.index_range()

Maybe regex this one? It's probably in this patch more than once

`IndexRange(new_drawings.size())` -> `new_drawings.index_range()` Maybe regex this one? It's probably in this patch more than once
MEM_new<GreasePencilDrawing>(__func__));
new_drawings[i]->user_count = 0;
GreasePencilDrawing *drawing = reinterpret_cast<GreasePencilDrawing *>(new_drawings[i]);
new (&drawing->geometry) bke::CurvesGeometry();
drawing->runtime = MEM_new<bke::GreasePencilDrawingRuntime>(__func__);

View File

@ -248,6 +248,7 @@ void legacy_gpencil_to_grease_pencil(Main &bmain, GreasePencil &grease_pencil, b
new_frame.type = gpf->key_type;
SET_FLAG_FROM_TEST(new_frame.flag, (gpf->flag & GP_FRAME_SELECT), GP_FRAME_SELECTED);
new_layer.insert_frame(gpf->framenum, std::move(new_frame));
drawing.base.user_count = 1;
i++;
}

View File

@ -79,6 +79,11 @@ typedef struct GreasePencilDrawingBase {
* Flag. Used to set e.g. the selection status. See `GreasePencilDrawingBaseFlag`.
*/
uint32_t flag;
/**
* Number of users of this drawing in the layer tree.
*/
int32_t user_count;

I wonder if this user count could be runtime data? Or if not, maybe it's worth mentioning why it isn't in a comment.

I wonder if this user count could be runtime data? Or if not, maybe it's worth mentioning why it isn't in a comment.

I thought about this, but I don't think it can be runtime data. Since there will be keyframe instances, we need to make the user count is saved.

I thought about this, but I don't think it can be runtime data. Since there will be keyframe instances, we need to make the user count is saved.

The connection between keyframe instances and saving the user count isn't super clear to me. Maybe a comment about what the user count is used for here would help?

The connection between keyframe instances and saving the user count isn't super clear to me. Maybe a comment about what the user count is used for here would help?

Maybe it's still better to have this as runtime data. If there is ever a bug where this doesn't get counted correctly, at least a file read could fix it. It should be possible to read this as zero, and increment it for every user?

This is easy to change afterwards though.

Maybe it's still better to have this as runtime data. If there is ever a bug where this doesn't get counted correctly, at least a file read could fix it. It should be possible to read this as zero, and increment it for every user? This is easy to change afterwards though.

I see, re-creating the user count when reading could work indeed.

I see, re-creating the user count when reading could work indeed.
char _pad2[4];
} GreasePencilDrawingBase;
/**