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
1 changed files with 6 additions and 9 deletions
Showing only changes of commit f616d9c237 - Show all commits

View File

@ -53,28 +53,25 @@ static void grease_pencil_copy_data(Main * /*bmain*/, ID *id_dst, const ID *id_s
grease_pencil_dst->drawing_array_size = grease_pencil_src->drawing_array_size;
grease_pencil_dst->drawing_array = MEM_cnew_array<GreasePencilDrawingOrReference *>(
grease_pencil_src->drawing_array_size, __func__);
for (int i = 0; i < grease_pencil_dst->drawing_array_size; i++) {
for (int i = 0; i < grease_pencil_src->drawing_array_size; i++) {

C++ cast here (and above, I'll stop writing it now)

C++ cast here (and above, I'll stop writing it now)
const GreasePencilDrawingOrReference *src_drawing_or_ref = grease_pencil_src->drawing_array[i];

Personally I find grease_pencil_dst a longer name than it needs to be, compared to something like gp_dst, where it's easier to see the logic when reading the function IMO. I understand that's subjective though

Personally I find `grease_pencil_dst` a longer name than it needs to be, compared to something like `gp_dst`, where it's easier to see the logic when reading the function IMO. I understand that's subjective though

This used to be the case in the old grease pencil code, but tbh I find it better when it's more explicit. We ended up with gpf,gpd,gps etc. and it's really unreadable imo.

This used to be the case in the old grease pencil code, but tbh I find it better when it's more explicit. We ended up with `gpf`,`gpd`,`gps` etc. and it's really unreadable imo.
GreasePencilDrawingOrReference *dst_drawing_or_ref = grease_pencil_dst->drawing_array[i];
switch (src_drawing_or_ref->type) {
case GREASE_PENCIL_DRAWING: {
const GreasePencilDrawing *src_drawing = reinterpret_cast<const GreasePencilDrawing *>(
src_drawing_or_ref);
grease_pencil_dst->drawing_array[i] = reinterpret_cast<GreasePencilDrawingOrReference *>(
MEM_cnew<GreasePencilDrawing>(__func__));
GreasePencilDrawing *dst_drawing = reinterpret_cast<GreasePencilDrawing *>(
dst_drawing_or_ref);
dst_drawing = MEM_cnew<GreasePencilDrawing>(__func__);
grease_pencil_dst->drawing_array[i]);
dst_drawing->base.type = src_drawing->base.type;
dst_drawing->base.flag = src_drawing->base.flag;
dst_drawing->geometry.runtime = MEM_new<bke::CurvesGeometryRuntime>(__func__);
dst_drawing->geometry.wrap() = src_drawing->geometry.wrap();
new (&dst_drawing->geometry) CurvesGeometry(src_drawing->geometry.wrap());
break;
}
case GREASE_PENCIL_DRAWING_REFERENCE: {
const GreasePencilDrawingReference *src_drawing_reference =
reinterpret_cast<const GreasePencilDrawingReference *>(src_drawing_or_ref);
GreasePencilDrawingReference *dst_drawing_reference =
reinterpret_cast<GreasePencilDrawingReference *>(dst_drawing_or_ref);
dst_drawing_reference = static_cast<GreasePencilDrawingReference *>(
grease_pencil_dst->drawing_array[i] = reinterpret_cast<GreasePencilDrawingOrReference *>(
MEM_dupallocN(src_drawing_reference));
break;
}