Initial Grease Pencil 3.0 stage #106848
|
@ -7,6 +7,7 @@
|
||||||
#include "BKE_anim_data.h"
|
#include "BKE_anim_data.h"
|
||||||
#include "BKE_curves.hh"
|
#include "BKE_curves.hh"
|
||||||
#include "BKE_customdata.h"
|
#include "BKE_customdata.h"
|
||||||
|
#include "BKE_grease_pencil.h"
|
||||||
#include "BKE_grease_pencil.hh"
|
#include "BKE_grease_pencil.hh"
|
||||||
#include "BKE_idtype.h"
|
#include "BKE_idtype.h"
|
||||||
#include "BKE_lib_id.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;
|
GreasePencil *grease_pencil_dst = (GreasePencil *)id_dst;
|
||||||
const GreasePencil *grease_pencil_src = (GreasePencil *)id_src;
|
const GreasePencil *grease_pencil_src = (GreasePencil *)id_src;
|
||||||
|
|
||||||
|
/* Duplicate material array. */
|
||||||
|
|||||||
|
grease_pencil_dst->material_array = static_cast<Material **>(
|
||||||
Hans Goudey
commented
Personally I find 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
Falk David
commented
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 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. */
|
/* Duplicate drawing array. */
|
||||||
grease_pencil_dst->drawing_array_size = grease_pencil_src->drawing_array_size;
|
grease_pencil_dst->drawing_array_size = grease_pencil_src->drawing_array_size;
|
||||||
grease_pencil_dst->drawing_array = MEM_cnew_array<GreasePencilDrawingOrReference *>(
|
grease_pencil_dst->drawing_array = MEM_cnew_array<GreasePencilDrawingOrReference *>(
|
||||||
|
|
|
@ -384,7 +384,7 @@ short *BKE_object_material_len_p(Object *ob)
|
||||||
}
|
}
|
||||||
if (ob->type == OB_GREASE_PENCIL) {
|
if (ob->type == OB_GREASE_PENCIL) {
|
||||||
GreasePencil *grease_pencil = static_cast<GreasePencil *>(ob->data);
|
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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -409,6 +409,8 @@ Material ***BKE_id_material_array_p(ID *id)
|
||||||
return &(((PointCloud *)id)->mat);
|
return &(((PointCloud *)id)->mat);
|
||||||
case ID_VO:
|
case ID_VO:
|
||||||
return &(((Volume *)id)->mat);
|
return &(((Volume *)id)->mat);
|
||||||
|
case ID_GP:
|
||||||
|
return &(((GreasePencil *)id)->material_array);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -435,6 +437,8 @@ short *BKE_id_material_len_p(ID *id)
|
||||||
return &(((PointCloud *)id)->totcol);
|
return &(((PointCloud *)id)->totcol);
|
||||||
case ID_VO:
|
case ID_VO:
|
||||||
return &(((Volume *)id)->totcol);
|
return &(((Volume *)id)->totcol);
|
||||||
|
case ID_GP:
|
||||||
|
return &(((GreasePencil *)id)->material_array_size);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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::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_derived_caches(newob);
|
||||||
BKE_object_free_modifiers(newob, 0);
|
BKE_object_free_modifiers(newob, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,8 @@ typedef struct GreasePencil {
|
||||||
* An array of materials.
|
* An array of materials.
|
||||||
*/
|
*/
|
||||||
struct Material **material_array;
|
struct Material **material_array;
|
||||||
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.
|
|||||||
int material_array_size;
|
short material_array_size;
|
||||||
|
char _pad2[2];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global flag on the data-block.
|
* Global flag on the data-block.
|
||||||
|
|
C++ cast here (and above, I'll stop writing it now)