1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 * 16 * The Original Code is Copyright (C) 2008, Blender Foundation. 17 * This is a new part of Blender 18 */ 19 20 /** \file 21 * \ingroup DNA 22 */ 23 24 #pragma once 25 26 #include "DNA_ID.h" 27 #include "DNA_brush_types.h" 28 #include "DNA_listBase.h" 29 30 struct AnimData; 31 struct MDeformVert; 32 33 #define GP_DEFAULT_PIX_FACTOR 1.0f 34 #define GP_DEFAULT_GRID_LINES 4 35 #define GP_MAX_INPUT_SAMPLES 10 36 37 #define GP_MATERIAL_BUFFER_LEN 256 38 39 /* ***************************************** */ 40 /* GP Stroke Points */ 41 42 /* 'Control Point' data for primitives and curves */ 43 typedef struct bGPDcontrolpoint { 44 /** X and y coordinates of control point. */ 45 float x, y, z; 46 /** Point color. */ 47 float color[4]; 48 /** Radius. */ 49 int size; 50 } bGPDcontrolpoint; 51 52 typedef struct bGPDspoint_Runtime { 53 /** Original point (used to dereference evaluated data) */ 54 struct bGPDspoint *pt_orig; 55 /** Original index array position */ 56 int idx_orig; 57 char _pad0[4]; 58 } bGPDspoint_Runtime; 59 60 /* Grease-Pencil Annotations - 'Stroke Point' 61 * -> Coordinates may either be 2d or 3d depending on settings at the time 62 * -> Coordinates of point on stroke, in proportions of window size 63 * This assumes that the bottom-left corner is (0,0) 64 */ 65 typedef struct bGPDspoint { 66 /** Co-ordinates of point (usually 2d, but can be 3d as well). */ 67 float x, y, z; 68 /** Pressure of input device (from 0 to 1) at this point. */ 69 float pressure; 70 /** Color strength (used for alpha factor). */ 71 float strength; 72 /** Seconds since start of stroke. */ 73 float time; 74 /** Additional options. */ 75 int flag; 76 77 /** Factor of uv along the stroke. */ 78 float uv_fac; 79 /** Uv rotation for dot mode. */ 80 float uv_rot; 81 /** Uv for fill mode */ 82 float uv_fill[2]; 83 84 /** Vertex Color RGBA (A=mix factor). */ 85 float vert_color[4]; 86 87 /** Runtime data */ 88 char _pad2[4]; 89 90 bGPDspoint_Runtime runtime; 91 } bGPDspoint; 92 93 /* bGPDspoint->flag */ 94 typedef enum eGPDspoint_Flag { 95 /* stroke point is selected (for editing) */ 96 GP_SPOINT_SELECT = (1 << 0), 97 98 /* stroke point is tagged (for some editing operation) */ 99 GP_SPOINT_TAG = (1 << 1), 100 /* stroke point is temp tagged (for some editing operation) */ 101 GP_SPOINT_TEMP_TAG = (1 << 2), 102 } eGPSPoint_Flag; 103 104 /* ***************************************** */ 105 /* GP Fill - Triangle Tessellation Data */ 106 107 /* Grease-Pencil Annotations - 'Triangle' 108 * -> A triangle contains the index of three vertices for filling the stroke 109 * This is only used if high quality fill is enabled 110 */ 111 typedef struct bGPDtriangle { 112 /* indices for tessellated triangle used for GP Fill */ 113 unsigned int verts[3]; 114 } bGPDtriangle; 115 116 /* ***************************************** */ 117 118 /* ***************************************** */ 119 /* GP Palettes (Deprecated - 2.78 - 2.79 only) */ 120 121 /* color of palettes */ 122 typedef struct bGPDpalettecolor { 123 struct bGPDpalettecolor *next, *prev; 124 /** Color name. Must be unique. */ 125 char info[64]; 126 float color[4]; 127 /** Color that should be used for drawing "fills" for strokes. */ 128 float fill[4]; 129 /** Settings for palette color. */ 130 short flag; 131 /** Padding for compiler alignment error. */ 132 char _pad[6]; 133 } bGPDpalettecolor; 134 135 /* bGPDpalettecolor->flag */ 136 typedef enum eGPDpalettecolor_Flag { 137 /* color is active */ 138 /* PC_COLOR_ACTIVE = (1 << 0), */ /* UNUSED */ 139 /* don't display color */ 140 PC_COLOR_HIDE = (1 << 1), 141 /* protected from further editing */ 142 PC_COLOR_LOCKED = (1 << 2), 143 /* do onion skinning */ 144 PC_COLOR_ONIONSKIN = (1 << 3), 145 /* "volumetric" strokes */ 146 PC_COLOR_VOLUMETRIC = (1 << 4), 147 } eGPDpalettecolor_Flag; 148 149 /* palette of colors */ 150 typedef struct bGPDpalette { 151 struct bGPDpalette *next, *prev; 152 153 /** Pointer to individual colors. */ 154 ListBase colors; 155 /** Palette name. Must be unique. */ 156 char info[64]; 157 158 short flag; 159 char _pad[6]; 160 } bGPDpalette; 161 162 /* bGPDpalette->flag */ 163 typedef enum eGPDpalette_Flag { 164 /* palette is active */ 165 PL_PALETTE_ACTIVE = (1 << 0), 166 } eGPDpalette_Flag; 167 168 /* ***************************************** */ 169 /* GP Strokes */ 170 171 /* Runtime temp data for bGPDstroke */ 172 typedef struct bGPDstroke_Runtime { 173 /** temporary layer name only used during copy/paste to put the stroke in the original layer */ 174 char tmp_layerinfo[128]; 175 176 /** Runtime falloff factor (only for transform). */ 177 float multi_frame_falloff; 178 179 /** Vertex offset in the vbo where this stroke starts. */ 180 int stroke_start; 181 /** Triangle offset in the ibo where this fill starts. */ 182 int fill_start; 183 int _pad[1]; 184 185 /** Original stroke (used to dereference evaluated data) */ 186 struct bGPDstroke *gps_orig; 187 void *_pad2; 188 } bGPDstroke_Runtime; 189 190 /* Grease-Pencil Annotations - 'Stroke' 191 * -> A stroke represents a (simplified version) of the curve 192 * drawn by the user in one 'mouse-down'->'mouse-up' operation 193 */ 194 typedef struct bGPDstroke { 195 struct bGPDstroke *next, *prev; 196 197 /** Array of data-points for stroke. */ 198 bGPDspoint *points; 199 /** Tessellated triangles for GP Fill. */ 200 bGPDtriangle *triangles; 201 /** Number of data-points in array. */ 202 int totpoints; 203 /** Number of triangles in array. */ 204 int tot_triangles; 205 206 /** Thickness of stroke. */ 207 short thickness; 208 /** Various settings about this stroke. */ 209 short flag, _pad[2]; 210 211 /** Init time of stroke. */ 212 double inittime; 213 214 /** Color name. */ 215 char colorname[128] DNA_DEPRECATED; 216 217 /** Material index. */ 218 int mat_nr; 219 /** Caps mode for each stroke extreme */ 220 short caps[2]; 221 222 /** gradient control along y for color */ 223 float hardeness; 224 /** factor xy of shape for dots gradients */ 225 float aspect_ratio[2]; 226 227 /** Factor of opacity for Fill color (used by opacity modifier). */ 228 float fill_opacity_fac; 229 230 /** Min of the bound box used to speedup painting operators. */ 231 float boundbox_min[3]; 232 /** Max of the bound box used to speedup painting operators. */ 233 float boundbox_max[3]; 234 235 /** UV rotation */ 236 float uv_rotation; 237 /** UV translation (X and Y axis) */ 238 float uv_translation[2]; 239 float uv_scale; 240 241 /** Vertex weight data. */ 242 struct MDeformVert *dvert; 243 void *_pad3; 244 245 /** Vertex Color for Fill (one for all stroke, A=mix factor). */ 246 float vert_color_fill[4]; 247 248 bGPDstroke_Runtime runtime; 249 } bGPDstroke; 250 251 /* bGPDstroke->flag */ 252 typedef enum eGPDstroke_Flag { 253 /* stroke is in 3d-space */ 254 GP_STROKE_3DSPACE = (1 << 0), 255 /* stroke is in 2d-space */ 256 GP_STROKE_2DSPACE = (1 << 1), 257 /* stroke is in 2d-space (but with special 'image' scaling) */ 258 GP_STROKE_2DIMAGE = (1 << 2), 259 /* stroke is selected */ 260 GP_STROKE_SELECT = (1 << 3), 261 /* Flag used to indicate that stroke is closed and draw edge between last and first point */ 262 GP_STROKE_CYCLIC = (1 << 7), 263 /* Flag used to indicate that stroke is used for fill close and must use 264 * fill color for stroke and no fill area */ 265 GP_STROKE_NOFILL = (1 << 8), 266 /* only for use with stroke-buffer (while drawing arrows) */ 267 GP_STROKE_USE_ARROW_START = (1 << 12), 268 /* only for use with stroke-buffer (while drawing arrows) */ 269 GP_STROKE_USE_ARROW_END = (1 << 13), 270 /* Tag for update geometry */ 271 GP_STROKE_TAG = (1 << 14), 272 /* only for use with stroke-buffer (while drawing eraser) */ 273 GP_STROKE_ERASER = (1 << 15), 274 } eGPDstroke_Flag; 275 276 /* bGPDstroke->caps */ 277 typedef enum eGPDstroke_Caps { 278 /* type of extreme */ 279 GP_STROKE_CAP_ROUND = 0, 280 GP_STROKE_CAP_FLAT = 1, 281 282 /* Keeo last. */ 283 GP_STROKE_CAP_MAX, 284 } GPDstroke_Caps; 285 286 /* Arrows ----------------------- */ 287 288 /* bGPDataRuntime.arrowstyle */ 289 typedef enum eGPDstroke_Arrowstyle { 290 GP_STROKE_ARROWSTYLE_NONE = 0, 291 GP_STROKE_ARROWSTYLE_SEGMENT = 2, 292 GP_STROKE_ARROWSTYLE_OPEN = 3, 293 GP_STROKE_ARROWSTYLE_CLOSED = 4, 294 GP_STROKE_ARROWSTYLE_SQUARE = 6, 295 } eGPDstroke_Arrowstyle; 296 297 /* ***************************************** */ 298 /* GP Frame */ 299 300 /* Runtime temp data for bGPDframe */ 301 typedef struct bGPDframe_Runtime { 302 /** Index of this frame in the listbase of frames. */ 303 int frameid; 304 /** Onion offset from active frame. 0 if not onion. INT_MAX to bypass frame. */ 305 int onion_id; 306 307 /** Original frame (used to dereference evaluated data) */ 308 struct bGPDframe *gpf_orig; 309 } bGPDframe_Runtime; 310 311 /* Grease-Pencil Annotations - 'Frame' 312 * -> Acts as storage for the 'image' formed by strokes 313 */ 314 typedef struct bGPDframe { 315 struct bGPDframe *next, *prev; 316 317 /** List of the simplified 'strokes' that make up the frame's data. */ 318 ListBase strokes; 319 320 /** Frame number of this frame. */ 321 int framenum; 322 323 /** Temp settings. */ 324 short flag; 325 /** Keyframe type (eBezTriple_KeyframeType). */ 326 short key_type; 327 328 bGPDframe_Runtime runtime; 329 } bGPDframe; 330 331 /* bGPDframe->flag */ 332 typedef enum eGPDframe_Flag { 333 /* frame is being painted on */ 334 GP_FRAME_PAINT = (1 << 0), 335 /* for editing in Action Editor */ 336 GP_FRAME_SELECT = (1 << 1), 337 } eGPDframe_Flag; 338 339 /* ***************************************** */ 340 /* GP Layer */ 341 342 /* List of masking layers. */ 343 typedef struct bGPDlayer_Mask { 344 struct bGPDlayer_Mask *next, *prev; 345 char name[128]; 346 short flag; 347 /** Index for sorting. Only valid while sorting algorithm is running. */ 348 short sort_index; 349 char _pad[4]; 350 } bGPDlayer_Mask; 351 352 /* bGPDlayer_Mask->flag */ 353 typedef enum ebGPDlayer_Mask_Flag { 354 /* Mask is hidden. */ 355 GP_MASK_HIDE = (1 << 0), 356 /* Mask is inverted. */ 357 GP_MASK_INVERT = (1 << 1), 358 } ebGPDlayer_Mask_Flag; 359 360 /* Runtime temp data for bGPDlayer */ 361 typedef struct bGPDlayer_Runtime { 362 /** Id for dynamic icon used to show annotation color preview for layer. */ 363 int icon_id; 364 char _pad[4]; 365 /** Original layer (used to dereference evaluated data) */ 366 struct bGPDlayer *gpl_orig; 367 } bGPDlayer_Runtime; 368 369 /* Grease-Pencil Annotations - 'Layer' */ 370 typedef struct bGPDlayer { 371 struct bGPDlayer *next, *prev; 372 373 /** List of annotations to display for frames (bGPDframe list). */ 374 ListBase frames; 375 /** Active frame (should be the frame that is currently being displayed). */ 376 bGPDframe *actframe; 377 378 /** Settings for layer. */ 379 short flag; 380 /** Per-layer onion-skinning flags (eGPDlayer_OnionFlag). */ 381 short onion_flag; 382 383 /** Color for strokes in layers. Used for annotations, and for ruler 384 * (which uses GPencil internally). */ 385 float color[4]; 386 /** Fill color for strokes in layers. Not used anymore (was only for). */ 387 float fill[4]; 388 389 /** Name/reference info for this layer (i.e. "director's comments, 12/.3") 390 * needs to be kept unique, as it's used as the layer identifier */ 391 char info[128]; 392 393 /** Thickness to apply to strokes (Annotations). */ 394 short thickness; 395 /** Used to filter groups of layers in modifiers. */ 396 short pass_index; 397 398 /** Parent object. */ 399 struct Object *parent; 400 /** Inverse matrix (only used if parented). */ 401 float inverse[4][4]; 402 /** String describing subobject info, MAX_ID_NAME-2. */ 403 char parsubstr[64]; 404 short partype; 405 406 /** Thickness adjustment. */ 407 short line_change; 408 /** Color used to tint layer, alpha value is used as factor. */ 409 float tintcolor[4]; 410 /** Opacity of the layer. */ 411 float opacity; 412 /** Name of the layer used to filter render output. */ 413 char viewlayername[64]; 414 415 /** Blend modes. */ 416 int blend_mode; 417 /** Vertex Paint opacity by Layer. */ 418 float vertex_paint_opacity; 419 420 /* annotation onion skin */ 421 /** 422 * Ghosts Before: max number of ghost frames to show between 423 * active frame and the one before it (0 = only the ghost itself). 424 */ 425 short gstep; 426 /** 427 * Ghosts After: max number of ghost frames to show after 428 * active frame and the following it (0 = only the ghost itself). 429 */ 430 short gstep_next; 431 432 /** Color for ghosts before the active frame. */ 433 float gcolor_prev[3]; 434 /** Color for ghosts after the active frame. */ 435 float gcolor_next[3]; 436 char _pad1[4]; 437 438 /** Mask list (bGPDlayer_Mask). */ 439 ListBase mask_layers; 440 /** Current Mask index (noted base 1). */ 441 int act_mask; 442 char _pad2[4]; 443 444 bGPDlayer_Runtime runtime; 445 } bGPDlayer; 446 447 /* bGPDlayer->flag */ 448 typedef enum eGPDlayer_Flag { 449 /* don't display layer */ 450 GP_LAYER_HIDE = (1 << 0), 451 /* protected from further editing */ 452 GP_LAYER_LOCKED = (1 << 1), 453 /* layer is 'active' layer being edited */ 454 GP_LAYER_ACTIVE = (1 << 2), 455 /* draw points of stroke for debugging purposes */ 456 GP_LAYER_DRAWDEBUG = (1 << 3), 457 /* Flag used to display in Paint mode only layers with keyframe */ 458 GP_LAYER_SOLO_MODE = (1 << 4), 459 /* for editing in Action Editor */ 460 GP_LAYER_SELECT = (1 << 5), 461 /* current frame for layer can't be changed */ 462 GP_LAYER_FRAMELOCK = (1 << 6), 463 /* don't render xray (which is default) */ 464 GP_LAYER_NO_XRAY = (1 << 7), 465 /* "volumetric" strokes */ 466 GP_LAYER_VOLUMETRIC = (1 << 10), 467 /* Use Scene lights */ 468 GP_LAYER_USE_LIGHTS = (1 << 11), 469 /* Unlock color */ 470 GP_LAYER_UNLOCK_COLOR = (1 << 12), 471 /* Mask Layer */ 472 GP_LAYER_USE_MASK = (1 << 13), /*TODO: DEPRECATED */ 473 /* Ruler Layer */ 474 GP_LAYER_IS_RULER = (1 << 14), 475 } eGPDlayer_Flag; 476 477 /* bGPDlayer->onion_flag */ 478 typedef enum eGPDlayer_OnionFlag { 479 /* do onion skinning */ 480 GP_LAYER_ONIONSKIN = (1 << 0), 481 } eGPDlayer_OnionFlag; 482 483 /* layer blend_mode */ 484 typedef enum eGPLayerBlendModes { 485 eGplBlendMode_Regular = 0, 486 eGplBlendMode_HardLight = 1, 487 eGplBlendMode_Add = 2, 488 eGplBlendMode_Subtract = 3, 489 eGplBlendMode_Multiply = 4, 490 eGplBlendMode_Divide = 5, 491 } eGPLayerBlendModes; 492 493 /* ***************************************** */ 494 /* GP Datablock */ 495 496 /* Runtime temp data for bGPdata */ 497 typedef struct bGPdata_Runtime { 498 /** Stroke buffer. */ 499 void *sbuffer; 500 /** Temp batches cleared after drawing. */ 501 struct GPUBatch *sbuffer_stroke_batch; 502 struct GPUBatch *sbuffer_fill_batch; 503 /** Temp stroke used for drawing. */ 504 struct bGPDstroke *sbuffer_gps; 505 506 char _pad[2]; 507 /** Material index of the stroke. */ 508 short matid; 509 510 /* Stroke Buffer data (only used during paint-session) 511 * - buffer must be initialized before use, but freed after 512 * whole paint operation is over 513 */ 514 /** Flags for stroke that cache represents. */ 515 short sbuffer_sflag; 516 char _pad1[2]; 517 /** Number of elements currently used in cache. */ 518 int sbuffer_used; 519 /** Number of total elements available in cache. */ 520 int sbuffer_size; 521 522 /** Vertex Color applied to Fill (while drawing). */ 523 float vert_color_fill[4]; 524 525 /** Arrow points for stroke corners **/ 526 float arrow_start[8]; 527 float arrow_end[8]; 528 /* Arrow style for each corner */ 529 int arrow_start_style; 530 int arrow_end_style; 531 532 /** Number of control-points for stroke. */ 533 int tot_cp_points; 534 char _pad2[4]; 535 /** Array of control-points for stroke. */ 536 bGPDcontrolpoint *cp_points; 537 /** Brush pointer */ 538 Brush *sbuffer_brush; 539 struct GpencilBatchCache *gpencil_cache; 540 } bGPdata_Runtime; 541 542 /* grid configuration */ 543 typedef struct bGPgrid { 544 float color[3]; 545 float scale[2]; 546 float offset[2]; 547 char _pad1[4]; 548 549 int lines; 550 char _pad[4]; 551 } bGPgrid; 552 553 /* Grease-Pencil Annotations - 'DataBlock' */ 554 typedef struct bGPdata { 555 /** Grease Pencil data is a data-block. */ 556 ID id; 557 /** Animation data - for animating draw settings. */ 558 struct AnimData *adt; 559 560 /* Grease-Pencil data */ 561 /** bGPDlayer. */ 562 ListBase layers; 563 /** Settings for this data-block. */ 564 int flag; 565 char _pad1[4]; 566 567 /* Palettes */ 568 /** List of bGPDpalette's - Deprecated (2.78 - 2.79 only). */ 569 ListBase palettes DNA_DEPRECATED; 570 571 /* 3D Viewport/Appearance Settings */ 572 /** Factor to define pixel size conversion. */ 573 float pixfactor; 574 /** Color for edit line. */ 575 float line_color[4]; 576 577 /* Onion skinning */ 578 /** Onion alpha factor change. */ 579 float onion_factor; 580 /** Onion skinning range (eGP_OnionModes). */ 581 int onion_mode; 582 /** Onion skinning flags (eGPD_OnionFlag). */ 583 int onion_flag; 584 /** 585 * Ghosts Before: max number of ghost frames to show between 586 * active frame and the one before it (0 = only the ghost itself). 587 */ 588 short gstep; 589 /** Ghosts After: max number of ghost frames to show after 590 * active frame and the following it (0 = only the ghost itself). 591 */ 592 short gstep_next; 593 594 /** Optional color for ghosts before the active frame. */ 595 float gcolor_prev[3]; 596 /** Optional color for ghosts after the active frame. */ 597 float gcolor_next[3]; 598 599 /** Offset for drawing over surfaces to keep strokes on top. */ 600 float zdepth_offset; 601 /** Materials array. */ 602 struct Material **mat; 603 /** Total materials. */ 604 short totcol; 605 606 /* stats */ 607 short totlayer; 608 short totframe; 609 char _pad2[6]; 610 int totstroke; 611 int totpoint; 612 613 /** Draw mode for strokes (eGP_DrawMode). */ 614 short draw_mode; 615 /** Keyframe type for onion filter (eBezTriple_KeyframeType plus All option) */ 616 short onion_keytype; 617 618 bGPgrid grid; 619 620 bGPdata_Runtime runtime; 621 } bGPdata; 622 623 /* bGPdata->flag */ 624 /* NOTE: A few flags have been deprecated since early 2.5, 625 * since they have been made redundant by interaction 626 * changes made during the porting process. 627 */ 628 typedef enum eGPdata_Flag { 629 /* data-block is used for "annotations" 630 * NOTE: This flag used to be used in 2.4x, but should hardly ever have been set. 631 * We can use this freely now, as all GP data-blocks from pre-2.8 will get 632 * set on file load (as many old use cases are for "annotations" only) 633 */ 634 GP_DATA_ANNOTATIONS = (1 << 0), 635 636 /* show debugging info in viewport (i.e. status print) */ 637 GP_DATA_DISPINFO = (1 << 1), 638 /* in Action Editor, show as expanded channel */ 639 GP_DATA_EXPAND = (1 << 2), 640 641 /* is the block overriding all clicks? */ 642 /* GP_DATA_EDITPAINT = (1 << 3), */ 643 644 /* ------------------------------------------------ DEPRECATED */ 645 /* new strokes are added in viewport space */ 646 GP_DATA_VIEWALIGN = (1 << 4), 647 648 /* Project into the screen's Z values */ 649 GP_DATA_DEPTH_VIEW = (1 << 5), 650 GP_DATA_DEPTH_STROKE = (1 << 6), 651 652 GP_DATA_DEPTH_STROKE_ENDPOINTS = (1 << 7), 653 /* ------------------------------------------------ DEPRECATED */ 654 655 /* Stroke Editing Mode - Toggle to enable alternative keymap 656 * for easier editing of stroke points */ 657 GP_DATA_STROKE_EDITMODE = (1 << 8), 658 659 /* Main flag to switch onion skinning on/off */ 660 GP_DATA_SHOW_ONIONSKINS = (1 << 9), 661 662 /* Batch drawing cache need to be recalculated */ 663 GP_DATA_CACHE_IS_DIRTY = (1 << 11), 664 665 /* Stroke Paint Mode - Toggle paint mode */ 666 GP_DATA_STROKE_PAINTMODE = (1 << 12), 667 /* Stroke Editing Mode - Toggle sculpt mode */ 668 GP_DATA_STROKE_SCULPTMODE = (1 << 13), 669 /* Stroke Editing Mode - Toggle weight paint mode */ 670 GP_DATA_STROKE_WEIGHTMODE = (1 << 14), 671 672 /* keep stroke thickness unchanged when zoom change */ 673 GP_DATA_STROKE_KEEPTHICKNESS = (1 << 15), 674 675 /* Allow edit several frames at the same time */ 676 GP_DATA_STROKE_MULTIEDIT = (1 << 16), 677 678 /* Vertex Paint Mode - Toggle paint mode */ 679 GP_DATA_STROKE_VERTEXMODE = (1 << 18), 680 681 /* Autolock not active layers */ 682 GP_DATA_AUTOLOCK_LAYERS = (1 << 20), 683 } eGPdata_Flag; 684 685 /* gpd->onion_flag */ 686 typedef enum eGPD_OnionFlag { 687 /* use custom color for ghosts before current frame */ 688 GP_ONION_GHOST_PREVCOL = (1 << 0), 689 /* use custom color for ghosts after current frame */ 690 GP_ONION_GHOST_NEXTCOL = (1 << 1), 691 /* always show onion skins (i.e. even during renders/animation playback) */ 692 GP_ONION_GHOST_ALWAYS = (1 << 2), 693 /* use fade color in onion skin */ 694 GP_ONION_FADE = (1 << 3), 695 /* Loop showing first frame after last frame */ 696 GP_ONION_LOOP = (1 << 4), 697 } eGPD_OnionFlag; 698 699 /* gpd->onion_mode */ 700 typedef enum eGP_OnionModes { 701 GP_ONION_MODE_ABSOLUTE = 0, 702 GP_ONION_MODE_RELATIVE = 1, 703 GP_ONION_MODE_SELECTED = 2, 704 } eGP_OnionModes; 705 706 /* xray modes (Depth Ordering) */ 707 typedef enum eGP_DepthOrdering { 708 GP_XRAY_FRONT = 0, 709 GP_XRAY_3DSPACE = 1, 710 } eGP_DepthOrdering; 711 712 /* draw modes (Use 2D or 3D position) */ 713 typedef enum eGP_DrawMode { 714 GP_DRAWMODE_2D = 0, 715 GP_DRAWMODE_3D = 1, 716 } eGP_DrawMode; 717 718 /* ***************************************** */ 719 /* Mode Checking Macros */ 720 721 /* Check if 'multiedit sessions' is enabled */ 722 #define GPENCIL_MULTIEDIT_SESSIONS_ON(gpd) \ 723 ((gpd) && \ 724 ((gpd)->flag & (GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE | \ 725 GP_DATA_STROKE_WEIGHTMODE | GP_DATA_STROKE_VERTEXMODE)) && \ 726 ((gpd)->flag & GP_DATA_STROKE_MULTIEDIT)) 727 728 /* Macros to check grease pencil modes */ 729 #define GPENCIL_ANY_MODE(gpd) \ 730 ((gpd) && ((gpd)->flag & \ 731 (GP_DATA_STROKE_PAINTMODE | GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE | \ 732 GP_DATA_STROKE_WEIGHTMODE | GP_DATA_STROKE_VERTEXMODE))) 733 #define GPENCIL_EDIT_MODE(gpd) ((gpd) && ((gpd)->flag & GP_DATA_STROKE_EDITMODE)) 734 #define GPENCIL_ANY_EDIT_MODE(gpd) \ 735 ((gpd) && ((gpd)->flag & \ 736 (GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE | GP_DATA_STROKE_WEIGHTMODE))) 737 #define GPENCIL_PAINT_MODE(gpd) ((gpd) && (gpd->flag & GP_DATA_STROKE_PAINTMODE)) 738 #define GPENCIL_SCULPT_MODE(gpd) ((gpd) && (gpd->flag & GP_DATA_STROKE_SCULPTMODE)) 739 #define GPENCIL_WEIGHT_MODE(gpd) ((gpd) && (gpd->flag & GP_DATA_STROKE_WEIGHTMODE)) 740 #define GPENCIL_VERTEX_MODE(gpd) ((gpd) && (gpd->flag & GP_DATA_STROKE_VERTEXMODE)) 741 #define GPENCIL_SCULPT_OR_WEIGHT_MODE(gpd) \ 742 ((gpd) && ((gpd)->flag & (GP_DATA_STROKE_SCULPTMODE | GP_DATA_STROKE_WEIGHTMODE))) 743 #define GPENCIL_NONE_EDIT_MODE(gpd) \ 744 ((gpd) && (((gpd)->flag & (GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE | \ 745 GP_DATA_STROKE_WEIGHTMODE | GP_DATA_STROKE_VERTEXMODE)) == 0)) 746 #define GPENCIL_LAZY_MODE(brush, shift) \ 747 (((brush) && \ 748 (((brush)->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) && ((shift) == 0))) || \ 749 ((((brush)->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) == 0) && ((shift) == 1))) 750 751 #define GPENCIL_ANY_SCULPT_MASK(flag) \ 752 ((flag & (GP_SCULPT_MASK_SELECTMODE_POINT | GP_SCULPT_MASK_SELECTMODE_STROKE | \ 753 GP_SCULPT_MASK_SELECTMODE_SEGMENT))) 754 755 #define GPENCIL_ANY_VERTEX_MASK(flag) \ 756 ((flag & (GP_VERTEX_MASK_SELECTMODE_POINT | GP_VERTEX_MASK_SELECTMODE_STROKE | \ 757 GP_VERTEX_MASK_SELECTMODE_SEGMENT))) 758