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 15 additions and 11 deletions
Showing only changes of commit 672069022d - Show all commits

View File

@ -13,7 +13,7 @@
namespace blender::bke {
class GreasePencilLayerRuntime {
private:
public:
Map<int, int> frames;
};
@ -46,12 +46,12 @@ class GreasePencil : ::GreasePencil {
* Accessors.
*/
Span<GreasePencilDrawing> drawings() const;
Span<GreasePencilDrawingOrReference> drawings() const;
};

Is defining these as constexpr helpful? I sort of doubt any real computation is done on these nodes at compile time. But maybe?

Is defining these as `constexpr` helpful? I sort of doubt any real computation is done on these nodes at compile time. But maybe?

The const in the const bool return type means nothing here

The `const` in the `const bool` return type means nothing here
} // namespace blender::bke
inline blender::Map<int, int> GreasePencilLayer::frames() const
inline const blender::Map<int, int> &GreasePencilLayer::frames() const
{
return this->runtime->frames;
}

View File

@ -4,10 +4,13 @@
* \ingroup bke
*/
#include "BKE_anim_data.h"
#include "BKE_grease_pencil.hh"
#include "BKE_idtype.h"
#include "BKE_lib_query.h"
#include "BLI_span.hh"
#include "BLO_read_write.h"
#include "BLT_translation.h"
@ -15,6 +18,7 @@
#include "DNA_ID.h"
#include "DNA_ID_enums.h"
#include "DNA_grease_pencil_types.h"
#include "DNA_material_types.h"
#include "MEM_guardedalloc.h"
@ -34,14 +38,14 @@ static void grease_pencil_free_data(ID *id)
// TODO: free drawing array
// TODO: free layer tree
MEM_SAFE_FREE(grease_pencil->mat);
MEM_SAFE_FREE(grease_pencil->material_array);
}
static void grease_pencil_foreach_id(ID *id, LibraryForeachIDData *data)
filedescriptor marked this conversation as resolved Outdated

Remove printfs.

Remove printfs.
{
GreasePencil *grease_pencil = (GreasePencil *)id;
for (int i = 0; i < grease_pencil->mat_num; i++) {
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, grease_pencil->mat[i], IDWALK_CB_USER);
for (int i = 0; i < grease_pencil->material_array_size; i++) {
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, grease_pencil->material_array[i], IDWALK_CB_USER);
}
// TODO: walk all the referenced drawings
}
@ -61,8 +65,8 @@ static void grease_pencil_blend_read_lib(BlendLibReader *reader, ID *id)
static void grease_pencil_blend_read_expand(BlendExpander *expander, ID *id)
{
GreasePencil *grease_pencil = (GreasePencil *)id;
for (int i = 0; i < grease_pencil->mat_num; i++) {
BLO_expand(expander, grease_pencil->mat[i]);
for (int i = 0; i < grease_pencil->material_array_size; i++) {
BLO_expand(expander, grease_pencil->material_array[i]);
}
}
@ -96,7 +100,7 @@ IDTypeInfo IDType_ID_GP = {
/*lib_override_apply_post*/ nullptr,
};
Span<GreasePencilDrawing> blender::bke::GreasePencil::drawings() const
blender::Span<GreasePencilDrawingOrReference> blender::bke::GreasePencil::drawings() const
{
return Span<GreasePencilDrawing>{this->drawing_array, this->drawing_array_size};
return blender::Span<GreasePencilDrawingOrReference>{this->drawing_array, this->drawing_array_size};
}

View File

@ -180,7 +180,7 @@ typedef struct GreasePencil {
* An array of GreasePencilDrawing's.
*/
GreasePencilDrawingOrReference *drawing_array;
int drawing_array_num;
int drawing_array_size;

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.
#ifdef __cplusplus
blender::Span<GreasePencilDrawingOrReference> drawings() const;
#endif