Blender V4.3
DNA_gpencil_legacy_types.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include "DNA_ID.h"
12#include "DNA_brush_types.h"
13#include "DNA_listBase.h"
14
15struct AnimData;
16struct Curve;
17struct Curve;
19struct MDeformVert;
20#ifdef __cplusplus
21namespace blender::gpu {
22class VertBuf;
23class Batch;
24} // namespace blender::gpu
25using GPUBatchHandle = blender::gpu::Batch;
27#else
30#endif
31
32#define GP_DEFAULT_PIX_FACTOR 1.0f
33#define GP_DEFAULT_GRID_LINES 4
34#define GP_MAX_INPUT_SAMPLES 10
35
36#define GP_DEFAULT_CURVE_RESOLUTION 32
37#define GP_DEFAULT_CURVE_ERROR 0.1f
38#define GP_DEFAULT_CURVE_EDIT_CORNER_ANGLE M_PI_2
39
40#define GPENCIL_MIN_FILL_FAC 0.05f
41#define GPENCIL_MAX_FILL_FAC 8.0f
42
43/* ***************************************** */
44/* GP Stroke Points */
45
46/* 'Control Point' data for primitives and curves */
47typedef struct bGPDcontrolpoint {
49 float x, y, z;
51 float color[4];
53 int size;
55
65
72typedef struct bGPDspoint {
74
75
76 float x, y, z;
78 float pressure;
80 float strength;
82 float time;
84 int flag;
85
87 float uv_fac;
89 float uv_rot;
91 float uv_fill[2];
92
94 float vert_color[4];
95
97 char _pad2[4];
98
101
103typedef enum eGPDspoint_Flag {
104 /* stroke point is selected (for editing) */
106
107 /* stroke point is tagged (for some editing operation) */
108 GP_SPOINT_TAG = (1 << 1),
109 /* stroke point is temp tagged (for some editing operation) */
111 /* stroke point is temp tagged (for some editing operation) */
114
115/* ***************************************** */
116/* GP Fill - Triangle Tessellation Data */
117
118/* Grease-Pencil Annotations - 'Triangle'
119 * -> A triangle contains the index of three vertices for filling the stroke
120 * This is only used if high quality fill is enabled
121 */
122typedef struct bGPDtriangle {
123 /* indices for tessellated triangle used for GP Fill */
124 unsigned int verts[3];
126
127/* ***************************************** */
128
129/* ***************************************** */
130/* GP Palettes (Deprecated - 2.78 - 2.79 only) */
131
132/* color of palettes */
133typedef struct bGPDpalettecolor {
135
136 struct bGPDpalettecolor *next, *prev;
138 char info[64];
139 float color[4];
141 float fill[4];
143 short flag;
145 char _pad[6];
147
150 /* color is active */
151 /* PC_COLOR_ACTIVE = (1 << 0), */ /* UNUSED */
152 /* don't display color */
153 PC_COLOR_HIDE = (1 << 1),
154 /* protected from further editing */
155 PC_COLOR_LOCKED = (1 << 2),
156 /* do onion skinning */
158 /* "volumetric" strokes */
161
162/* palette of colors */
163typedef struct bGPDpalette {
165
166 struct bGPDpalette *next, *prev;
167
169 ListBase colors;
171 char info[64];
172
173 short flag;
174 char _pad[6];
176
178typedef enum eGPDpalette_Flag {
179 /* palette is active */
182
183/* ***************************************** */
184/* GP Curve Point */
185
186typedef struct bGPDcurve_point {
190 float pressure;
192 float strength;
195
197 int flag;
198
200 float uv_fac;
202 float uv_rot;
204 float uv_fill[2];
205
207 float vert_color[4];
208 char _pad[4];
210
211/* bGPDcurve_point->flag */
215
216/* ***************************************** */
217/* GP Curve */
218
219/* Curve for Bezier Editing. */
220typedef struct bGPDcurve {
222
223
224 bGPDcurve_point *curve_points;
226 int tot_curve_points;
228 short flag;
229 char _pad[2];
231
232/* bGPDcurve_Flag->flag */
233typedef enum bGPDcurve_Flag {
234 /* Flag to indicated that the stroke data has been changed and the curve needs to be refitted */
236 /* Curve is selected */
237 GP_CURVE_SELECT = (1 << 1),
239
240/* ***************************************** */
241/* GP Strokes */
242
243/* Runtime temp data for bGPDstroke */
244typedef struct bGPDstroke_Runtime {
246
247
248 char tmp_layerinfo[128];
249
251 float multi_frame_falloff;
252
254 int stroke_start;
256 int fill_start;
258 int vertex_start;
260 int curve_start;
261 int _pad0;
262
264 struct bGPDstroke *gps_orig;
265 void *_pad2;
267
273typedef struct bGPDstroke {
275
276 struct bGPDstroke *next, *prev;
277
279 bGPDspoint *points;
281 bGPDtriangle *triangles;
283 int totpoints;
285 int tot_triangles;
286
288 short thickness;
290 short flag, _pad[2];
291
293 double inittime;
294
296 char colorname[128] DNA_DEPRECATED;
297
299 int mat_nr;
301 short caps[2];
302
304 float hardness;
306 float aspect_ratio[2];
307
309 float fill_opacity_fac;
310
312 float boundbox_min[3];
314 float boundbox_max[3];
315
317 float uv_rotation;
319 float uv_translation[2];
320 float uv_scale;
321
323 int select_index;
324 char _pad4[4];
325
327 struct MDeformVert *dvert;
328 void *_pad3;
329
331 float vert_color_fill[4];
332
334 struct bGPDcurve *editcurve;
335
337 void *_pad5;
339
341typedef enum eGPDstroke_Flag {
342 /* stroke is in 3d-space */
344 /* stroke is in 2d-space */
346 /* stroke is in 2d-space (but with special 'image' scaling) */
348 /* stroke is selected */
350 /* Flag used to indicate that stroke is closed and draw edge between last and first point */
352 /* Flag used to indicate that stroke is used for fill close and must use
353 * fill color for stroke and no fill area */
355 /* Flag to indicated that the editcurve has been changed and the stroke needs to be updated with
356 * the curve data */
358 /* Flag to indicate that a stroke is used only for help, and will not affect rendering or fill */
359 GP_STROKE_HELP = (1 << 10),
360 /* Flag to indicate that a extend stroke collide (fill tool) */
361 GP_STROKE_COLLIDE = (1 << 11),
362 /* only for use with stroke-buffer (while drawing arrows) */
364 /* only for use with stroke-buffer (while drawing arrows) */
366 /* Tag for update geometry */
367 GP_STROKE_TAG = (1 << 14),
368 /* only for use with stroke-buffer (while drawing eraser) */
369 GP_STROKE_ERASER = (1 << 15),
371
373typedef enum eGPDstroke_Caps {
374 /* type of extreme */
377
378 /* Keep last. */
381
382/* Arrows ----------------------- */
383
392
393/* ***************************************** */
394/* GP Frame */
395
396/* Runtime temp data for bGPDframe */
397typedef struct bGPDframe_Runtime {
399
400
401 int frameid;
403 int onion_id;
404
406 struct bGPDframe *gpf_orig;
408
413typedef struct bGPDframe {
415
416 struct bGPDframe *next, *prev;
417
419 ListBase strokes;
420
422 int framenum;
423
425 short flag;
427 short key_type;
428
431
432/* bGPDframe->flag */
433typedef enum eGPDframe_Flag {
434 /* frame is being painted on */
435 GP_FRAME_PAINT = (1 << 0),
436 /* for editing in Action Editor */
437 GP_FRAME_SELECT = (1 << 1),
438 /* Line Art generation */
441
442/* ***************************************** */
443/* GP Layer */
444
445/* List of masking layers. */
446typedef struct bGPDlayer_Mask {
448
449 struct bGPDlayer_Mask *next, *prev;
450 char name[128];
451 short flag;
453 short sort_index;
454 char _pad[4];
456
457/* bGPDlayer_Mask->flag */
459 /* Mask is hidden. */
460 GP_MASK_HIDE = (1 << 0),
461 /* Mask is inverted. */
462 GP_MASK_INVERT = (1 << 1),
464
466typedef struct bGPDlayer_Runtime {
468
469
470 int icon_id;
471 char _pad[4];
473 struct bGPDlayer *gpl_orig;
475
477typedef struct bGPDlayer {
479
480 struct bGPDlayer *next, *prev;
481
483 ListBase frames;
485 bGPDframe *actframe;
486
488 short flag;
490 short onion_flag;
491
494 float color[4];
496 float fill[4];
497
500 char info[128];
501
503 short thickness;
505 short pass_index;
506
508 struct Object *parent;
510 float inverse[4][4];
512 char parsubstr[64];
513 short partype;
514
516 short line_change;
518 float tintcolor[4];
520 float opacity;
522 char viewlayername[64];
523
525 int blend_mode;
527 float vertex_paint_opacity;
528
529 /* annotation onion skin */
534 short gstep;
539 short gstep_next;
540
542 float gcolor_prev[3];
544 float gcolor_next[3];
545 char _pad1[4];
546
548 ListBase mask_layers;
550 int act_mask;
551 char _pad2[4];
552
554 float location[3], rotation[3], scale[3];
555 float layer_mat[4][4], layer_invmat[4][4];
556 char _pad3[4];
557
560
561/* bGPDlayer->flag */
562typedef enum eGPDlayer_Flag {
563 /* don't display layer */
564 GP_LAYER_HIDE = (1 << 0),
565 /* protected from further editing */
566 GP_LAYER_LOCKED = (1 << 1),
567 /* layer is 'active' layer being edited */
568 GP_LAYER_ACTIVE = (1 << 2),
569 /* draw points of stroke for debugging purposes */
571 /* Flag used to display in Paint mode only layers with keyframe */
573 /* for editing in Action Editor */
574 GP_LAYER_SELECT = (1 << 5),
575 /* current frame for layer can't be changed */
577 /* Don't render X-ray (which is default). */
579 /* "volumetric" strokes */
581 /* Use Scene lights */
583 /* Unlock color */
585 /* Mask Layer */
586 GP_LAYER_USE_MASK = (1 << 13), /* TODO: DEPRECATED */
587 /* Ruler Layer */
588 GP_LAYER_IS_RULER = (1 << 14),
589 /* Disable masks in view-layer render */
592
595 /* do onion skinning */
599
609
610/* ***************************************** */
611/* GP Datablock */
612
613/* Runtime temp data for bGPdata */
614typedef struct bGPdata_Runtime {
616
617
618 void *sbuffer;
620 GPUVertBufHandle *sbuffer_position_buf;
621 GPUVertBufHandle *sbuffer_color_buf;
622 GPUBatchHandle *sbuffer_batch;
624 struct bGPDstroke *sbuffer_gps;
625
627 short playing;
628
630 short matid;
631
632 /* Stroke Buffer data (only used during paint-session)
633 * - buffer must be initialized before use, but freed after
634 * whole paint operation is over
635 */
637 short sbuffer_sflag;
638 char _pad1[2];
640 int sbuffer_used;
642 int sbuffer_size;
643
645 float vert_color_fill[4];
646
648 float fill_opacity_fac;
649
651 float arrow_start[8];
652 float arrow_end[8];
653 /* Arrow style for each corner */
654 int arrow_start_style;
655 int arrow_end_style;
656
658 int tot_cp_points;
662 Brush *sbuffer_brush;
663 struct GpencilBatchCache *gpencil_cache;
664 struct LineartCache *lineart_cache;
665
666 struct GPencilUpdateCache *update_cache;
668
669/* grid configuration */
670typedef struct bGPgrid {
671 float color[3];
672 float scale[2];
673 float offset[2];
674 char _pad1[4];
675
676 int lines;
677 char _pad[4];
679
681typedef struct bGPdata {
683
684
685 ID id;
687 struct AnimData *adt;
688
689 /* Grease-Pencil data */
691 ListBase layers;
693 int flag;
695 int curve_edit_resolution;
697 float curve_edit_threshold;
699 float curve_edit_corner_angle;
700
701 /* Palettes */
704
706 ListBase vertex_group_names;
707
708 /* 3D Viewport/Appearance Settings */
710 float pixfactor;
712 float line_color[4];
713
714 /* Onion skinning */
716 float onion_factor;
718 int onion_mode;
720 int onion_flag;
725 short gstep;
730 short gstep_next;
731
733 float gcolor_prev[3];
735 float gcolor_next[3];
736
738 float zdepth_offset;
740 struct Material **mat;
742 short totcol;
743
744 /* stats */
745 short totlayer;
746 short totframe;
747 char _pad2[6];
748 int totstroke;
749 int totpoint;
750
752 short draw_mode;
754 short onion_keytype;
755
757 int select_last_index;
758
759 int vertex_group_active_index;
760
762
765
773typedef enum eGPdata_Flag {
774 /* data-block is used for "annotations"
775 * NOTE: This flag used to be used in 2.4x, but should hardly ever have been set.
776 * We can use this freely now, as all GP data-blocks from pre-2.8 will get
777 * set on file load (as many old use cases are for "annotations" only)
778 */
780
781 /* show debugging info in viewport (i.e. status print) */
783 /* in Action Editor, show as expanded channel */
784 GP_DATA_EXPAND = (1 << 2),
785
786 /* is the block overriding all clicks? */
787 /* GP_DATA_EDITPAINT = (1 << 3), */
788
789 /* ------------------------------------------------ DEPRECATED */
790 /* new strokes are added in viewport space */
792
793 /* Project into the screen's Z values */
796
798 /* ------------------------------------------------ DEPRECATED */
799
800 /* Stroke Editing Mode - Toggle to enable alternative keymap
801 * for easier editing of stroke points */
803
804 /* Main flag to switch onion skinning on/off */
806
807 /* Batch drawing cache need to be recalculated */
809
810 /* Stroke Paint Mode - Toggle paint mode */
812 /* Stroke Editing Mode - Toggle sculpt mode */
814 /* Stroke Editing Mode - Toggle weight paint mode */
816
817 /* keep stroke thickness unchanged when zoom change */
819
820 /* Allow edit several frames at the same time */
822
823 /* Vertex Paint Mode - Toggle paint mode */
825
826 /* Auto-lock not active layers. */
828
829 /* Enable Bezier Editing Curve (a sub-mode of Edit mode). */
831 /* Use adaptive curve resolution */
834
835/* gpd->onion_flag */
836typedef enum eGPD_OnionFlag {
837 /* use custom color for ghosts before current frame */
839 /* use custom color for ghosts after current frame */
841 /* always show onion skins (i.e. even during renders/animation playback) */
843 /* use fade color in onion skin */
844 GP_ONION_FADE = (1 << 3),
845 /* Loop showing first frame after last frame */
846 GP_ONION_LOOP = (1 << 4),
848
849/* gpd->onion_mode */
855
856/* X-ray modes (Depth Ordering). */
861
862/* draw modes (Use 2D or 3D position) */
867
868/* ***************************************** */
869/* Mode Checking Macros */
870
871/* Check if 'multiedit sessions' is enabled */
872#define GPENCIL_MULTIEDIT_SESSIONS_ON(gpd) \
873 ((gpd) && \
874 ((gpd)->flag & \
875 (GP_DATA_STROKE_PAINTMODE | GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE | \
876 GP_DATA_STROKE_WEIGHTMODE | GP_DATA_STROKE_VERTEXMODE)) && \
877 ((gpd)->flag & GP_DATA_STROKE_MULTIEDIT))
878
879#define GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd) \
880 ((gpd) && ((gpd)->flag & (GP_DATA_STROKE_EDITMODE)) && ((gpd)->flag & GP_DATA_CURVE_EDIT_MODE))
881
882/* Macros to check grease pencil modes */
883#define GPENCIL_ANY_MODE(gpd) \
884 ((gpd) && ((gpd)->flag & \
885 (GP_DATA_STROKE_PAINTMODE | GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE | \
886 GP_DATA_STROKE_WEIGHTMODE | GP_DATA_STROKE_VERTEXMODE)))
887#define GPENCIL_EDIT_MODE(gpd) ((gpd) && ((gpd)->flag & GP_DATA_STROKE_EDITMODE))
888#define GPENCIL_ANY_EDIT_MODE(gpd) \
889 ((gpd) && ((gpd)->flag & \
890 (GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE | GP_DATA_STROKE_WEIGHTMODE)))
891#define GPENCIL_PAINT_MODE(gpd) ((gpd) && (gpd->flag & GP_DATA_STROKE_PAINTMODE))
892#define GPENCIL_SCULPT_MODE(gpd) ((gpd) && (gpd->flag & GP_DATA_STROKE_SCULPTMODE))
893#define GPENCIL_WEIGHT_MODE(gpd) ((gpd) && (gpd->flag & GP_DATA_STROKE_WEIGHTMODE))
894#define GPENCIL_VERTEX_MODE(gpd) ((gpd) && (gpd->flag & GP_DATA_STROKE_VERTEXMODE))
895#define GPENCIL_NONE_EDIT_MODE(gpd) \
896 ((gpd) && (((gpd)->flag & (GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE | \
897 GP_DATA_STROKE_WEIGHTMODE | GP_DATA_STROKE_VERTEXMODE)) == 0))
898#define GPENCIL_LAZY_MODE(brush, shift) \
899 (((brush) && \
900 (((brush)->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) && ((shift) == 0))) || \
901 ((((brush)->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) == 0) && ((shift) == 1)))
902
903#define GPENCIL_ANY_SCULPT_MASK(flag) \
904 ((flag & (GP_SCULPT_MASK_SELECTMODE_POINT | GP_SCULPT_MASK_SELECTMODE_STROKE | \
905 GP_SCULPT_MASK_SELECTMODE_SEGMENT)))
906
907#define GPENCIL_ANY_VERTEX_MASK(flag) \
908 ((flag & (GP_VERTEX_MASK_SELECTMODE_POINT | GP_VERTEX_MASK_SELECTMODE_STROKE | \
909 GP_VERTEX_MASK_SELECTMODE_SEGMENT)))
910
911#define GPENCIL_PLAY_ON(gpd) ((gpd) && ((gpd)->runtime.playing == 1))
ID and Library types, which are fundamental for SDNA.
enum eAnimEdit_AutoSnap DNA_DEPRECATED
struct GPUVertBufHandle GPUVertBufHandle
struct GPUBatchHandle GPUBatchHandle
#define DNA_DEFINE_CXX_METHODS(class_name)
Definition DNA_defs.h:66
@ GP_ONION_MODE_RELATIVE
@ GP_ONION_MODE_SELECTED
@ GP_ONION_MODE_ABSOLUTE
enum eGPDstroke_Caps GPDstroke_Caps
@ GP_CURVE_NEEDS_STROKE_UPDATE
@ GP_STROKE_ARROWSTYLE_NONE
@ GP_STROKE_ARROWSTYLE_SEGMENT
@ GP_STROKE_ARROWSTYLE_CLOSED
@ GP_STROKE_ARROWSTYLE_OPEN
@ GP_STROKE_ARROWSTYLE_SQUARE
struct GPUVertBufHandle GPUVertBufHandle
struct bGPDtriangle bGPDtriangle
@ GP_STROKE_USE_ARROW_END
@ GP_STROKE_NEEDS_CURVE_UPDATE
@ GP_STROKE_USE_ARROW_START
struct bGPDcontrolpoint bGPDcontrolpoint
enum eGPDspoint_Flag eGPSPoint_Flag
@ GP_LAYER_DISABLE_MASKS_IN_VIEWLAYER
@ GP_LAYER_UNLOCK_COLOR
@ GP_LAYER_ONIONSKIN_CUSTOM_COLOR
@ GP_ONION_GHOST_NEXTCOL
@ GP_ONION_GHOST_ALWAYS
@ GP_ONION_GHOST_PREVCOL
struct bGPDcurve_point bGPDcurve_point
struct GPUBatchHandle GPUBatchHandle
@ GP_DATA_SHOW_ONIONSKINS
@ GP_DATA_CURVE_ADAPTIVE_RESOLUTION
@ GP_DATA_STROKE_WEIGHTMODE
@ GP_DATA_DEPTH_STROKE_ENDPOINTS
@ GP_DATA_STROKE_VERTEXMODE
@ GP_DATA_CURVE_EDIT_MODE
@ GP_DATA_STROKE_MULTIEDIT
@ GP_DATA_CACHE_IS_DIRTY
@ GP_DATA_STROKE_PAINTMODE
@ GP_DATA_STROKE_SCULPTMODE
@ GP_DATA_AUTOLOCK_LAYERS
@ GP_DATA_STROKE_KEEPTHICKNESS
@ GP_DATA_STROKE_EDITMODE
@ GP_CURVE_POINT_SELECT
struct bGPgrid bGPgrid
@ eGplBlendMode_Regular
@ eGplBlendMode_Multiply
@ eGplBlendMode_Subtract
@ eGplBlendMode_HardLight
These structs are the foundation for all linked lists in the library system.
btMatrix3x3 inverse() const
Return the inverse of the matrix.
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
static float verts[][3]
static ulong * next
Definition DNA_ID.h:413
struct bGPDspoint * pt_orig
uint8_t flag
Definition wm_window.cc:138