Blender V5.0
DNA_grease_pencil_types.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "DNA_ID.h"
12#include "DNA_attribute_types.h"
13#include "DNA_curve_types.h"
14#include "DNA_curves_types.h"
15#include "DNA_listBase.h"
16
17#ifdef __cplusplus
18# include "BLI_bounds_types.hh"
19# include "BLI_function_ref.hh"
20# include "BLI_index_mask_fwd.hh"
21# include "BLI_map.hh"
24# include "BLI_span.hh"
25namespace blender::bke {
29class GreasePencilDrawingRuntime;
30namespace greasepencil {
31class DrawingRuntime;
32class Drawing;
34class TreeNode;
35class Layer;
36class LayerRuntime;
37class LayerGroup;
39} // namespace greasepencil
40} // namespace blender::bke
45#else
50#endif
51
52struct Main;
53struct GreasePencil;
54struct Object;
55
62
63#define GP_STROKE_MITER_ANGLE_ROUND 0.0f
64#define GP_STROKE_MITER_ANGLE_BEVEL DEG2RADF(180.0f)
65
75
83
92 int8_t type;
93 char _pad[3];
97 uint32_t flag;
99
119
133
139 /* When set, the frame is implicitly held until the next frame. E.g. it doesn't have a fixed
140 * duration. */
143
148typedef struct GreasePencilFrame {
156 uint32_t flag;
160 int8_t type;
161 char _pad[3];
162#ifdef __cplusplus
163 static GreasePencilFrame end();
164 bool is_end() const;
165 bool is_implicit_hold() const;
166 bool is_selected() const;
167#endif
169
173
179 /* Array of `frames` keys (sorted in ascending order). */
180 int *keys;
181 /* Array of `frames` values (order matches the keys array). */
183 /* Size of the map (number of key-value pairs). */
184 int num;
185 /* Flag for the status of the storage. */
186 int flag;
188
196
212
224
234
250
253 /* ListBase pointers. */
255 /* Parent pointer. Can be null. */
260 char *name;
265 int8_t type;
266 char _pad[7];
270 float color[3];
275 uint32_t flag;
276#ifdef __cplusplus
279#endif
281
331
343
364
373
382
384 /* Use custom colors (per object-data) for onion skinning. */
386 /* Fade the opacity of ghost frames further away from the current frame. */
388 /* Show looping frames in onion skinning. */
391
404
405#define GREASE_PENCIL_ONION_SKINNING_FILTER_ALL \
406 (GP_ONION_SKINNING_FILTER_KEYTYPE_KEYFRAME | GP_ONION_SKINNING_FILTER_KEYTYPE_EXTREME | \
407 GP_ONION_SKINNING_FILTER_KEYTYPE_BREAKDOWN | GP_ONION_SKINNING_FILTER_KEYTYPE_JITTER | \
408 GP_ONION_SKINNING_FILTER_KEYTYPE_MOVEHOLD)
409
417 float opacity;
418 /* #GreasePencilOnionSkinningMode. */
419 int8_t mode;
420 /* #GreasePencilOnionSkinningFlag. */
421 uint8_t flag;
422 /* #GreasePencilOnionSkinningFilter. */
423 uint8_t filter;
424 char _pad[1];
436 float color_before[3];
440 float color_after[3];
441 char _pad2[4];
443
447typedef struct GreasePencil {
448#ifdef __cplusplus
450 static constexpr ID_Type id_type = ID_GP;
451#endif
452
455 struct AnimData *adt;
456
464 char _pad[4];
465
466 /* Root group of the layer tree. */
468
471
476
483 char _pad2[4];
484
490
496 char _pad3[2];
500 uint32_t flag;
501
504 char _pad4[4];
505
514#ifdef __cplusplus
515 /* Root group. */
516 const blender::bke::greasepencil::LayerGroup &root_group() const;
518
519 /* Drawings read/write access. */
522 const GreasePencilDrawingBase *drawing(int64_t index) const;
523 GreasePencilDrawingBase *drawing(int64_t index);
524
525 /* Layers, layer groups and nodes read/write access. */
528 const blender::bke::greasepencil::Layer &layer(int64_t index) const;
530
533
536
537 /* Return the index of the layer if it's found, otherwise `std::nullopt`. */
538 std::optional<int> get_layer_index(const blender::bke::greasepencil::Layer &layer) const;
539
540 /* Active layer functions. */
541 bool has_active_layer() const;
542 const blender::bke::greasepencil::Layer *get_active_layer() const;
543 blender::bke::greasepencil::Layer *get_active_layer();
544 void set_active_layer(blender::bke::greasepencil::Layer *layer);
545 bool is_layer_active(const blender::bke::greasepencil::Layer *layer) const;
546 void autolock_inactive_layers();
547
548 /* Active group functions. */
549 bool has_active_group() const;
550 const blender::bke::greasepencil::LayerGroup *get_active_group() const;
551 blender::bke::greasepencil::LayerGroup *get_active_group();
552
553 /* Active node functions. */
554 const blender::bke::greasepencil::TreeNode *get_active_node() const;
555 blender::bke::greasepencil::TreeNode *get_active_node();
556 void set_active_node(blender::bke::greasepencil::TreeNode *node);
557
558 /* Adding layers and layer groups. */
561 bool check_name_is_unique = true);
566 bool check_name_is_unique = true);
568 blender::bke::greasepencil::Layer &duplicate_layer(
569 const blender::bke::greasepencil::Layer &duplicate_layer,
570 bool duplicate_frames = false,
571 bool duplicate_drawings = false);
573 blender::bke::greasepencil::Layer &duplicate_layer(
575 const blender::bke::greasepencil::Layer &duplicate_layer,
576 bool duplicate_frames = false,
577 bool duplicate_drawings = false);
580 bool check_name_is_unique = true);
584 bool check_name_is_unique = true);
585
590 void add_layers_for_eval(int num_new_layers);
591
592 /* Moving nodes. */
593 void move_node_up(blender::bke::greasepencil::TreeNode &node, int step = 1);
594 void move_node_down(blender::bke::greasepencil::TreeNode &node, int step = 1);
595 void move_node_top(blender::bke::greasepencil::TreeNode &node);
596 void move_node_bottom(blender::bke::greasepencil::TreeNode &node);
597
598 void move_node_after(blender::bke::greasepencil::TreeNode &node,
600 void move_node_before(blender::bke::greasepencil::TreeNode &node,
602 void move_node_into(blender::bke::greasepencil::TreeNode &node,
604
605 /* Search functions. */
606 const blender::bke::greasepencil::TreeNode *find_node_by_name(blender::StringRef name) const;
608 blender::IndexMask layer_selection_by_name(blender::StringRef name,
609 blender::IndexMaskMemory &memory) const;
610
611 void rename_node(Main &bmain,
613 blender::StringRef new_name);
614
615 void remove_layer(blender::bke::greasepencil::Layer &layer);
616 void remove_group(blender::bke::greasepencil::LayerGroup &group, bool keep_children = false);
617
618 std::string unique_layer_name(blender::StringRef name);
619
620 /* Frames API functions. */
621
634 int frame_number,
635 int duration = 0,
637
643 int frame_number,
644 int duration = 0,
650 bool remove_frames(blender::bke::greasepencil::Layer &layer, blender::Span<int> frame_numbers);
651
652 void copy_frames_from_layer(blender::bke::greasepencil::Layer &dst_layer,
653 const GreasePencil &src_grease_pencil,
654 const blender::bke::greasepencil::Layer &src_layer,
655 const std::optional<int> frame_select = std::nullopt);
660 void add_layers_with_empty_drawings_for_eval(int num);
661
666 void resize_drawings(int new_num);
668 void add_empty_drawings(int add_num);
669 void add_duplicate_drawings(int duplicate_num,
671 bool insert_duplicate_frame(blender::bke::greasepencil::Layer &layer,
672 int src_frame_number,
673 int dst_frame_number,
674 bool do_instance);
675
685 void move_frames(blender::bke::greasepencil::Layer &layer,
686 const blender::Map<int, int> &frame_number_destinations);
687
700 void move_duplicate_frames(blender::bke::greasepencil::Layer &layer,
701 const blender::Map<int, int> &frame_number_destinations,
702 const blender::Map<int, GreasePencilFrame> &duplicate_frames);
703
708 void remove_drawings_with_no_users();
712 void update_drawing_users_for_layer(const blender::bke::greasepencil::Layer &layer);
713
718 const blender::bke::greasepencil::Drawing *get_drawing_at(
719 const blender::bke::greasepencil::Layer &layer, int frame_number) const;
721 const blender::bke::greasepencil::Layer &layer, int frame_number);
726 blender::bke::greasepencil::Drawing *get_editable_drawing_at(
727 const blender::bke::greasepencil::Layer &layer, int frame_number);
728
733 const blender::bke::greasepencil::Drawing *get_eval_drawing(
734 const blender::bke::greasepencil::Layer &layer) const;
735 blender::bke::greasepencil::Drawing *get_eval_drawing(
737
738 std::optional<blender::Bounds<blender::float3>> bounds_min_max(int frame,
739 bool use_radius = true) const;
740 std::optional<blender::Bounds<blender::float3>> bounds_min_max_eval(
741 bool use_radius = true) const;
742
743 blender::bke::AttributeAccessor attributes() const;
744 blender::bke::MutableAttributeAccessor attributes_for_write();
745
749 std::optional<int> material_index_max_eval() const;
750
751 void count_memory(blender::MemoryCounter &memory) const;
752
757 blender::Array<int> count_frame_users_for_drawings() const;
758
759 /* For debugging purposes. */
760 void print_layer_tree();
761 void validate_drawing_user_counts();
762#endif
ATTR_WARN_UNUSED_RESULT const size_t num
ID and Library types, which are fundamental for SDNA.
ID_Type
@ ID_GP
eBezTriple_KeyframeType
@ BEZT_KEYTYPE_KEYFRAME
GreasePencilLayerBlendMode
@ GP_LAYER_BLEND_HARDLIGHT
@ GP_LAYER_BLEND_NONE
@ GP_LAYER_BLEND_MULTIPLY
@ GP_LAYER_BLEND_DIVIDE
@ GP_LAYER_BLEND_SUBTRACT
GreasePencilStrokeCapType
@ GP_STROKE_CAP_TYPE_FLAT
@ GP_STROKE_CAP_TYPE_ROUND
@ GP_STROKE_CAP_TYPE_MAX
GreasePencilLayerFramesMapStorageFlag
@ GP_LAYER_FRAMES_STORAGE_DIRTY
@ LAYERGROUP_COLOR_01
@ LAYERGROUP_COLOR_NONE
@ LAYERGROUP_COLOR_06
@ LAYERGROUP_COLOR_04
@ LAYERGROUP_COLOR_05
@ LAYERGROUP_COLOR_03
@ LAYERGROUP_COLOR_08
@ LAYERGROUP_COLOR_07
@ LAYERGROUP_COLOR_02
GreasePencilOnionSkinningMode
@ GP_ONION_SKINNING_MODE_ABSOLUTE
@ GP_ONION_SKINNING_MODE_SELECTED
@ GP_ONION_SKINNING_MODE_RELATIVE
GreasePencilDrawingBaseFlag
@ GreasePencilDrawingBaseFlag_TODO
GreasePencilLayerMaskFlag
@ GP_LAYER_MASK_INVERT
GreasePencilLayerTreeNodeType
@ GP_LAYER_TREE_GROUP
@ GP_FRAME_IMPLICIT_HOLD
GreasePencilLayerTreeNodeFlag
@ GP_LAYER_TREE_NODE_EXPANDED
@ GP_LAYER_TREE_NODE_IGNORE_LOCKED_MATERIALS
@ GP_LAYER_TREE_NODE_LOCKED
@ GP_LAYER_TREE_NODE_MUTE
@ GP_LAYER_TREE_NODE_HIDE
@ GP_LAYER_TREE_NODE_SELECT
@ GP_LAYER_TREE_NODE_HIDE_ONION_SKINNING
@ GP_LAYER_TREE_NODE_USE_LIGHTS
@ GP_LAYER_TREE_NODE_HIDE_MASKS
@ GP_LAYER_TREE_NODE_DISABLE_MASKS_IN_VIEWLAYER
GreasePencilDrawingType
@ GP_DRAWING_REFERENCE
struct GreasePencilRuntimeHandle GreasePencilRuntimeHandle
@ GREASE_PENCIL_AUTOLOCK_LAYERS
@ GREASE_PENCIL_ANIM_CHANNEL_EXPANDED
@ GREASE_PENCIL_STROKE_ORDER_3D
struct GreasePencilLayerRuntimeHandle GreasePencilLayerRuntimeHandle
GreasePencilOnionSkinningFlag
@ GP_ONION_SKINNING_USE_FADE
@ GP_ONION_SKINNING_SHOW_LOOP
@ GP_ONION_SKINNING_USE_CUSTOM_COLORS
GreasePencilOnionSkinningFilter
@ GP_ONION_SKINNING_FILTER_KEYTYPE_MOVEHOLD
@ GP_ONION_SKINNING_FILTER_KEYTYPE_JITTER
@ GP_ONION_SKINNING_FILTER_KEYTYPE_KEYFRAME
@ GP_ONION_SKINNING_FILTER_KEYTYPE_BREAKDOWN
@ GP_ONION_SKINNING_FILTER_KEYTYPE_EXTREME
struct GreasePencilLayerGroupRuntimeHandle GreasePencilLayerGroupRuntimeHandle
struct GreasePencilDrawingRuntimeHandle GreasePencilDrawingRuntimeHandle
These structs are the foundation for all linked lists in the library system.
long long int int64_t
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
float wrap(float value, float max, float min)
Definition node_math.h:103
const char * name
GreasePencilDrawingBase base
GreasePencilDrawingRuntimeHandle * runtime
struct GreasePencilLayerMask * next
struct GreasePencilLayerMask * prev
GreasePencilLayerTreeNode base
GreasePencilLayerGroupRuntimeHandle * runtime
struct GreasePencilLayerTreeNode * next
struct GreasePencilLayerTreeNode * prev
struct GreasePencilLayerTreeGroup * parent
GreasePencilLayerRuntimeHandle * runtime
GreasePencilLayerTreeNode base
GreasePencilLayerFramesMapStorage frames_storage
GreasePencilLayerTreeNode * active_node
struct Material ** material_array
GreasePencilLayerTreeGroup * root_group_ptr
GreasePencilRuntimeHandle * runtime
GreasePencilDrawingBase ** drawing_array
GreasePencilOnionSkinningSettings onion_skinning_settings
struct AnimData * adt
struct AttributeStorage attribute_storage
Definition DNA_ID.h:414