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
4 changed files with 14 additions and 2 deletions
Showing only changes of commit a64920900c - Show all commits

View File

@ -7,6 +7,7 @@
#include "BKE_anim_data.h"
#include "BKE_curves.hh"
#include "BKE_customdata.h"
#include "BKE_grease_pencil.h"
#include "BKE_grease_pencil.hh"
#include "BKE_idtype.h"
#include "BKE_lib_id.h"
@ -52,6 +53,10 @@ static void grease_pencil_copy_data(Main * /*bmain*/,
GreasePencil *grease_pencil_dst = (GreasePencil *)id_dst;
const GreasePencil *grease_pencil_src = (GreasePencil *)id_src;
/* Duplicate material array. */

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

C++ cast here (and above, I'll stop writing it now)
grease_pencil_dst->material_array = static_cast<Material **>(

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.
MEM_dupallocN(grease_pencil_src->material_array));
/* Duplicate drawing array. */
grease_pencil_dst->drawing_array_size = grease_pencil_src->drawing_array_size;
grease_pencil_dst->drawing_array = MEM_cnew_array<GreasePencilDrawingOrReference *>(

View File

@ -384,7 +384,7 @@ short *BKE_object_material_len_p(Object *ob)
}
if (ob->type == OB_GREASE_PENCIL) {
GreasePencil *grease_pencil = static_cast<GreasePencil *>(ob->data);
return reinterpret_cast<short *>(&(grease_pencil->material_array_size));
return &(grease_pencil->material_array_size);
}
return nullptr;
}
@ -409,6 +409,8 @@ Material ***BKE_id_material_array_p(ID *id)
return &(((PointCloud *)id)->mat);
case ID_VO:
return &(((Volume *)id)->mat);
case ID_GP:
return &(((GreasePencil *)id)->material_array);
default:
break;
}
@ -435,6 +437,8 @@ short *BKE_id_material_len_p(ID *id)
return &(((PointCloud *)id)->totcol);
case ID_VO:
return &(((Volume *)id)->totcol);
case ID_GP:
return &(((GreasePencil *)id)->material_array_size);
default:
break;
}

View File

@ -3087,6 +3087,8 @@ static int object_convert_exec(bContext *C, wmOperator *op)
bke::gpencil::convert::legacy_gpencil_to_grease_pencil(*new_grease_pencil, *gpd);
BKE_id_materials_copy(bmain, &gpd->id, &new_grease_pencil->id);
BKE_object_free_derived_caches(newob);
BKE_object_free_modifiers(newob, 0);
}

View File

@ -181,7 +181,8 @@ typedef struct GreasePencil {
* An array of materials.
*/
struct Material **material_array;

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.
int material_array_size;
short material_array_size;
char _pad2[2];
/**
* Global flag on the data-block.