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
2 changed files with 33 additions and 29 deletions
Showing only changes of commit b1c7503067 - Show all commits

View File

@ -31,6 +31,7 @@ set(SRC_DNA_INC
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_genfile.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpencil_modifier_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpencil_legacy_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_grease_pencil_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpu_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_image_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_ipo_types.h

View File

@ -39,11 +39,12 @@ typedef struct GreasePencilDrawingOrReference {
* One of `GreasePencilDrawingType`.
* Indicates if this is an actual drawing or a drawing referenced from another object.
*/
char type;
uint8_t type;
char _pad[3];
/**
* Flag. Used to set e.g. the selection status.
*/
int flag;
uint32_t flag;
} GreasePencilDrawingOrReference;
/**
@ -68,6 +69,17 @@ typedef struct GreasePencilDrawingReference {
struct GreasePencil *id_reference;
filedescriptor marked this conversation as resolved Outdated

Move below runtime data pointer.

Move below runtime data pointer.
} GreasePencilDrawingReference;
/* Only used for storage in the .blend file. */
typedef struct GreasePencilLayerFramesMapStorage {
/* Array of `frames` keys (sorted in ascending order). */
int *keys;
int keys_num;
/* Array of `frames` values (order matches the keys array). */
int *values;
int values_num;
} GreasePencilLayerFramesMapStorage;
/**
* A grease pencil layer is a collection of drawings mapped to a specific time on the timeline.
*/

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.
@ -99,17 +111,7 @@ typedef struct GreasePencilLayer {
*/
const blender::Map<int, int> &frames() const;

What about a single function that returned std::optional rather than a separate "has_" function?

What about a single function that returned `std::optional` rather than a separate "has_" function?
#endif

Looks like stroke_buffer() can be const

Looks like `stroke_buffer()` can be `const`
/* Only used for storage in the .blend file. */
struct {
/* Array of `frames` keys (sorted in ascending order). */
int *keys;
int keys_num;
/* Array of `frames` values (order matches the keys array). */
int *values;
int values_num;
} frames_storage;
GreasePencilLayerFramesMapStorage frames_storage;
/**
* Runtime struct pointer.
@ -120,14 +122,19 @@ typedef struct GreasePencilLayer {
typedef enum GreasePencilLayerTreeNodeType {
GREASE_PENCIL_LAYER_TREE_LEAF = 0,
GREASE_PENCIL_LAYER_TREE_GROUP = 1,
} GreasePencilLayerTreeNode;
} GreasePencilLayerTreeNodeType;
typedef struct GreasePencilLayerTreeNode {
/**
* One of `GreasePencilLayerTreeNodeType`.
* Indicates the type of struct this element is.
*/
char type;
uint8_t type;
/**
* Color tag.
*/
uint8_t color[3];
/**
* Name of the layer/group. Dynamic length.
@ -137,12 +144,7 @@ typedef struct GreasePencilLayerTreeNode {
/**
* Flag. Used to set e.g. the selection, visibility, ... status.
*/
int flag;
/**
* Color tag.
*/
uchar color[3];
uint32_t flag;
} GreasePencilLayerTreeNode;
typedef struct GreasePencilLayerTreeGroup {
@ -155,6 +157,13 @@ typedef struct GreasePencilLayerTreeLeaf {
GreasePencilLayer layer;
} GreasePencilLayerTreeLeaf;
/* Only used for storage in the .blend file. */
typedef struct GreasePencilLayerTreeStorage {
/* Array of tree nodes. Pre-order serialization of the layer tree. */
GreasePencilLayerTreeNode **nodes;
int nodes_num;
} GreasePencilLayerTreeStorage;
/**
* The grease pencil data-block.
* It holds a set of grease pencil drawings, a tree of layer groups, and a set of layers whithin
@ -180,13 +189,7 @@ typedef struct GreasePencil {
*/
// const bke::gpencil::LayerTree &layer_tree() const;
#endif
/* Only used for storage in the .blend file. */
struct {
/* Array of tree nodes. Pre-order serialization of the layer tree. */
GreasePencilLayerTreeNode **nodes;
int nodes_num;
} layer_tree_storage;
GreasePencilLayerTreeStorage layer_tree_storage;
/**
* An array of materials.
@ -197,7 +200,7 @@ typedef struct GreasePencil {
/**
* Global flag on the data-block.
*/
int flag;
uint32_t flag;
/**
* Runtime struct pointer.