Blender  V2.93
rna_gpencil.c
Go to the documentation of this file.
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 
21 #include <stdlib.h>
22 
23 #include "BLI_math.h"
24 
25 #include "DNA_brush_types.h"
26 #include "DNA_curve_types.h"
27 #include "DNA_gpencil_types.h"
28 #include "DNA_meshdata_types.h"
29 #include "DNA_object_types.h"
30 #include "DNA_scene_types.h"
31 
32 #include "MEM_guardedalloc.h"
33 
34 #include "BLI_utildefines.h"
35 
36 #include "BLT_translation.h"
37 
38 #include "RNA_access.h"
39 #include "RNA_define.h"
40 #include "RNA_enum_types.h"
41 
42 #include "rna_internal.h"
43 
44 #include "WM_types.h"
45 
46 /* parent type */
48  {PAROBJECT, "OBJECT", 0, "Object", "The layer is parented to an object"},
49  {PARSKEL, "ARMATURE", 0, "Armature", ""},
50  {PARBONE, "BONE", 0, "Bone", "The layer is parented to a bone"},
51  {0, NULL, 0, NULL, NULL},
52 };
53 
54 #ifndef RNA_RUNTIME
57  "2D",
58  0,
59  "2D Layers",
60  "Display strokes using grease pencil layers to define order"},
61  {GP_DRAWMODE_3D, "3D", 0, "3D Location", "Display strokes using real 3D position in 3D space"},
62  {0, NULL, 0, NULL, NULL},
63 };
64 
67  "ABSOLUTE",
68  0,
69  "Frames",
70  "Frames in absolute range of the scene frame"},
72  "RELATIVE",
73  0,
74  "Keyframes",
75  "Frames in relative range of the Grease Pencil keyframes"},
76  {GP_ONION_MODE_SELECTED, "SELECTED", 0, "Selected", "Only selected keyframes"},
77  {0, NULL, 0, NULL, NULL},
78 };
79 
82  "KEYFRAME",
83  ICON_KEYTYPE_KEYFRAME_VEC,
84  "Keyframe",
85  "Normal keyframe - e.g. for key poses"},
87  "BREAKDOWN",
88  ICON_KEYTYPE_BREAKDOWN_VEC,
89  "Breakdown",
90  "A breakdown pose - e.g. for transitions between key poses"},
92  "MOVING_HOLD",
93  ICON_KEYTYPE_MOVING_HOLD_VEC,
94  "Moving Hold",
95  "A keyframe that is part of a moving hold"},
97  "EXTREME",
98  ICON_KEYTYPE_EXTREME_VEC,
99  "Extreme",
100  "An 'extreme' pose, or some other purpose as needed"},
102  "JITTER",
103  ICON_KEYTYPE_JITTER_VEC,
104  "Jitter",
105  "A filler or baked keyframe for keying on ones, or some other purpose as needed"},
106  {0, NULL, 0, NULL, NULL},
107 };
108 
110  {-1, "ALL", 0, "All", "Include all Keyframe types"},
112  "KEYFRAME",
113  ICON_KEYTYPE_KEYFRAME_VEC,
114  "Keyframe",
115  "Normal keyframe - e.g. for key poses"},
117  "BREAKDOWN",
118  ICON_KEYTYPE_BREAKDOWN_VEC,
119  "Breakdown",
120  "A breakdown pose - e.g. for transitions between key poses"},
122  "MOVING_HOLD",
123  ICON_KEYTYPE_MOVING_HOLD_VEC,
124  "Moving Hold",
125  "A keyframe that is part of a moving hold"},
127  "EXTREME",
128  ICON_KEYTYPE_EXTREME_VEC,
129  "Extreme",
130  "An 'extreme' pose, or some other purpose as needed"},
132  "JITTER",
133  ICON_KEYTYPE_JITTER_VEC,
134  "Jitter",
135  "A filler or baked keyframe for keying on ones, or some other purpose as needed"},
136  {0, NULL, 0, NULL, NULL},
137 };
138 
140  {-1, "UP", 0, "Up", ""},
141  {1, "DOWN", 0, "Down", ""},
142  {0, NULL, 0, NULL, NULL},
143 };
144 
146  {eGplBlendMode_Regular, "REGULAR", 0, "Regular", ""},
147  {eGplBlendMode_HardLight, "HARDLIGHT", 0, "Hard Light", ""},
148  {eGplBlendMode_Add, "ADD", 0, "Add", ""},
149  {eGplBlendMode_Subtract, "SUBTRACT", 0, "Subtract", ""},
150  {eGplBlendMode_Multiply, "MULTIPLY", 0, "Multiply", ""},
151  {eGplBlendMode_Divide, "DIVIDE", 0, "Divide", ""},
152  {0, NULL, 0, NULL, NULL}};
153 
155  {GP_STROKE_CAP_ROUND, "ROUND", 0, "Rounded", ""},
156  {GP_STROKE_CAP_FLAT, "FLAT", 0, "Flat", ""},
157  {0, NULL, 0, NULL, NULL},
158 };
159 #endif
160 
161 #ifdef RNA_RUNTIME
162 
163 # include "BLI_ghash.h"
164 # include "BLI_listbase.h"
165 # include "BLI_string_utils.h"
166 
167 # include "WM_api.h"
168 
169 # include "BKE_action.h"
170 # include "BKE_animsys.h"
171 # include "BKE_deform.h"
172 # include "BKE_gpencil.h"
173 # include "BKE_gpencil_curve.h"
174 # include "BKE_gpencil_geom.h"
175 # include "BKE_icons.h"
176 
177 # include "DEG_depsgraph.h"
178 # include "DEG_depsgraph_build.h"
179 
180 static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
181 {
184 }
185 
186 static void rna_GpencilLayerMatrix_update(Main *bmain, Scene *scene, PointerRNA *ptr)
187 {
188  bGPDlayer *gpl = (bGPDlayer *)ptr->data;
189 
190  loc_eul_size_to_mat4(gpl->layer_mat, gpl->location, gpl->rotation, gpl->scale);
191  invert_m4_m4(gpl->layer_invmat, gpl->layer_mat);
192 
193  rna_GPencil_update(bmain, scene, ptr);
194 }
195 
196 static void rna_GPencil_curve_edit_mode_toggle(Main *bmain, Scene *scene, PointerRNA *ptr)
197 {
199  bGPdata *gpd = (bGPdata *)ptr->owner_id;
200 
201  /* Curve edit mode is turned on. */
203  /* If the current select mode is segment and the Bezier mode is on, change
204  * to Point because segment is not supported. */
207  }
208 
210  }
211  /* Curve edit mode is turned off. */
212  else {
214  }
215 
216  /* Standard update. */
217  rna_GPencil_update(bmain, scene, ptr);
218 }
219 
220 static void rna_GPencil_stroke_curve_update(Main *bmain, Scene *scene, PointerRNA *ptr)
221 {
222  bGPdata *gpd = (bGPdata *)ptr->owner_id;
223 
225  LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
226  if (gpl->actframe != NULL) {
227  bGPDframe *gpf = gpl->actframe;
228  LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
229  if (gps->editcurve != NULL) {
230  gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
232  }
233  }
234  }
235  }
236  }
237 
238  rna_GPencil_update(bmain, scene, ptr);
239 }
240 
241 static void rna_GPencil_stroke_curve_resolution_update(Main *bmain, Scene *scene, PointerRNA *ptr)
242 {
243  bGPdata *gpd = (bGPdata *)ptr->owner_id;
244 
246  LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
247  if (gpl->actframe != NULL) {
248  bGPDframe *gpf = gpl->actframe;
249  LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
250  if (gps->editcurve != NULL) {
251  gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
253  }
254  }
255  }
256  }
257  }
258  rna_GPencil_update(bmain, scene, ptr);
259 }
260 
261 static void rna_GPencil_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
262 {
266 
269 }
270 
271 static void rna_GPencil_uv_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
272 {
273  bGPdata *gpd = (bGPdata *)ptr->owner_id;
274  /* Force to recalc the UVs. */
275  bGPDstroke *gps = (bGPDstroke *)ptr->data;
276 
277  /* Calc geometry data. */
279 
282 }
283 
284 static void rna_GPencil_autolock(Main *bmain, Scene *scene, PointerRNA *ptr)
285 {
286  bGPdata *gpd = (bGPdata *)ptr->owner_id;
288 
289  /* standard update */
290  rna_GPencil_update(bmain, scene, ptr);
291 }
292 
293 static void rna_GPencil_editmode_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
294 {
295  bGPdata *gpd = (bGPdata *)ptr->owner_id;
297 
298  /* Notify all places where GPencil data lives that the editing state is different */
301 }
302 
303 /* Poll Callback to filter GP Datablocks to only show those for Annotations */
305 {
306  bGPdata *gpd = value.data;
307  return (gpd->flag & GP_DATA_ANNOTATIONS) != 0;
308 }
309 
310 /* Poll Callback to filter GP Datablocks to only show those for GP Objects */
312 {
313  bGPdata *gpd = value.data;
314  return (gpd->flag & GP_DATA_ANNOTATIONS) == 0;
315 }
316 
317 static char *rna_GPencilLayer_path(PointerRNA *ptr)
318 {
319  bGPDlayer *gpl = (bGPDlayer *)ptr->data;
320  char name_esc[sizeof(gpl->info) * 2];
321 
322  BLI_str_escape(name_esc, gpl->info, sizeof(name_esc));
323 
324  return BLI_sprintfN("layers[\"%s\"]", name_esc);
325 }
326 
327 static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr, const char **UNUSED(r_info))
328 {
329  bGPDlayer *gpl = (bGPDlayer *)ptr->data;
330 
331  /* surely there must be other criteria too... */
332  if (gpl->flag & GP_LAYER_LOCKED) {
333  return 0;
334  }
335  else {
336  return PROP_EDITABLE;
337  }
338 }
339 
340 /* set parent */
341 static void set_parent(bGPDlayer *gpl, Object *par, const int type, const char *substr)
342 {
343  if (type == PAROBJECT) {
344  invert_m4_m4(gpl->inverse, par->obmat);
345  gpl->parent = par;
346  gpl->partype |= PAROBJECT;
347  gpl->parsubstr[0] = 0;
348  }
349  else if (type == PARSKEL) {
350  invert_m4_m4(gpl->inverse, par->obmat);
351  gpl->parent = par;
352  gpl->partype |= PARSKEL;
353  gpl->parsubstr[0] = 0;
354  }
355  else if (type == PARBONE) {
356  bPoseChannel *pchan = BKE_pose_channel_find_name(par->pose, substr);
357  if (pchan) {
358  float tmp_mat[4][4];
359  mul_m4_m4m4(tmp_mat, par->obmat, pchan->pose_mat);
360 
361  invert_m4_m4(gpl->inverse, tmp_mat);
362  gpl->parent = par;
363  gpl->partype |= PARBONE;
364  BLI_strncpy(gpl->parsubstr, substr, sizeof(gpl->parsubstr));
365  }
366  }
367 }
368 
369 /* set parent object and inverse matrix */
370 static void rna_GPencilLayer_parent_set(PointerRNA *ptr,
371  PointerRNA value,
372  struct ReportList *UNUSED(reports))
373 {
374  bGPDlayer *gpl = (bGPDlayer *)ptr->data;
375  Object *par = (Object *)value.data;
376 
377  if (par != NULL) {
378  set_parent(gpl, par, gpl->partype, gpl->parsubstr);
379  }
380  else {
381  /* clear parent */
382  gpl->parent = NULL;
383  }
384 }
385 
386 /* set parent type */
387 static void rna_GPencilLayer_parent_type_set(PointerRNA *ptr, int value)
388 {
389  bGPDlayer *gpl = (bGPDlayer *)ptr->data;
390  Object *par = gpl->parent;
391  gpl->partype = value;
392 
393  if (par != NULL) {
394  set_parent(gpl, par, value, gpl->parsubstr);
395  }
396 }
397 
398 /* set parent bone */
399 static void rna_GPencilLayer_parent_bone_set(PointerRNA *ptr, const char *value)
400 {
401  bGPDlayer *gpl = (bGPDlayer *)ptr->data;
402 
403  Object *par = gpl->parent;
404  gpl->partype = PARBONE;
405 
406  if (par != NULL) {
407  set_parent(gpl, par, gpl->partype, value);
408  }
409 }
410 
411 static char *rna_GPencilLayerMask_path(PointerRNA *ptr)
412 {
413  bGPdata *gpd = (bGPdata *)ptr->owner_id;
416 
417  char gpl_info_esc[sizeof(gpl->info) * 2];
418  char mask_name_esc[sizeof(mask->name) * 2];
419 
420  BLI_str_escape(gpl_info_esc, gpl->info, sizeof(gpl_info_esc));
421  BLI_str_escape(mask_name_esc, mask->name, sizeof(mask_name_esc));
422 
423  return BLI_sprintfN("layers[\"%s\"].mask_layers[\"%s\"]", gpl_info_esc, mask_name_esc);
424 }
425 
426 static int rna_GPencil_active_mask_index_get(PointerRNA *ptr)
427 {
428  bGPDlayer *gpl = (bGPDlayer *)ptr->data;
429  return gpl->act_mask - 1;
430 }
431 
432 static void rna_GPencil_active_mask_index_set(PointerRNA *ptr, int value)
433 {
434  bGPDlayer *gpl = (bGPDlayer *)ptr->data;
435  gpl->act_mask = value + 1;
436 }
437 
438 static void rna_GPencil_active_mask_index_range(
439  PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
440 {
441  bGPDlayer *gpl = (bGPDlayer *)ptr->data;
442 
443  *min = 0;
444  *max = max_ii(0, BLI_listbase_count(&gpl->mask_layers) - 1);
445 }
446 
447 /* parent types enum */
448 static const EnumPropertyItem *rna_Object_parent_type_itemf(bContext *UNUSED(C),
449  PointerRNA *ptr,
450  PropertyRNA *UNUSED(prop),
451  bool *r_free)
452 {
453  bGPDlayer *gpl = (bGPDlayer *)ptr->data;
454  EnumPropertyItem *item = NULL;
455  int totitem = 0;
456 
458 
459  if (gpl->parent) {
460  Object *par = gpl->parent;
461 
462  if (par->type == OB_ARMATURE) {
463  /* special hack: prevents this being overridden */
464  RNA_enum_items_add_value(&item, &totitem, &parent_type_items[1], PARSKEL);
466  }
467  }
468 
469  RNA_enum_item_end(&item, &totitem);
470  *r_free = true;
471 
472  return item;
473 }
474 
475 static bool rna_GPencilLayer_is_parented_get(PointerRNA *ptr)
476 {
477  bGPDlayer *gpl = (bGPDlayer *)ptr->data;
478  return (gpl->parent != NULL);
479 }
480 
481 static PointerRNA rna_GPencil_active_layer_get(PointerRNA *ptr)
482 {
483  bGPdata *gpd = (bGPdata *)ptr->owner_id;
484 
485  if (GS(gpd->id.name) == ID_GD) { /* why would this ever be not GD */
486  bGPDlayer *gl;
487 
488  for (gl = gpd->layers.first; gl; gl = gl->next) {
489  if (gl->flag & GP_LAYER_ACTIVE) {
490  break;
491  }
492  }
493 
494  if (gl) {
496  }
497  }
498 
500 }
501 
502 static void rna_GPencil_active_layer_set(PointerRNA *ptr,
503  PointerRNA value,
504  struct ReportList *UNUSED(reports))
505 {
506  bGPdata *gpd = (bGPdata *)ptr->owner_id;
507 
508  /* Don't allow setting active layer to NULL if layers exist
509  * as this breaks various tools. Tools should be used instead
510  * if it's necessary to remove layers
511  */
512  if (value.data == NULL) {
513  printf("%s: Setting active layer to None is not allowed\n", __func__);
514  return;
515  }
516 
517  if (GS(gpd->id.name) == ID_GD) { /* why would this ever be not GD */
518  bGPDlayer *gl;
519 
520  for (gl = gpd->layers.first; gl; gl = gl->next) {
521  if (gl == value.data) {
522  gl->flag |= GP_LAYER_ACTIVE;
523  }
524  else {
525  gl->flag &= ~GP_LAYER_ACTIVE;
526  }
527  }
528 
530  }
531 }
532 
533 static int rna_GPencil_active_layer_index_get(PointerRNA *ptr)
534 {
535  bGPdata *gpd = (bGPdata *)ptr->owner_id;
537 
538  return BLI_findindex(&gpd->layers, gpl);
539 }
540 
541 static void rna_GPencil_active_layer_index_set(PointerRNA *ptr, int value)
542 {
543  bGPdata *gpd = (bGPdata *)ptr->owner_id;
544  bGPDlayer *gpl = BLI_findlink(&gpd->layers, value);
545 
547 
548  /* Now do standard updates... */
551 }
552 
553 static void rna_GPencil_active_layer_index_range(
554  PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
555 {
556  bGPdata *gpd = (bGPdata *)ptr->owner_id;
557 
558  *min = 0;
559  *max = max_ii(0, BLI_listbase_count(&gpd->layers) - 1);
560 
561  *softmin = *min;
562  *softmax = *max;
563 }
564 
565 static const EnumPropertyItem *rna_GPencil_active_layer_itemf(bContext *C,
566  PointerRNA *ptr,
567  PropertyRNA *UNUSED(prop),
568  bool *r_free)
569 {
570  bGPdata *gpd = (bGPdata *)ptr->owner_id;
571  bGPDlayer *gpl;
572  EnumPropertyItem *item = NULL, item_tmp = {0};
573  int totitem = 0;
574  int i = 0;
575 
576  if (ELEM(NULL, C, gpd)) {
577  return DummyRNA_NULL_items;
578  }
579 
580  /* Existing layers */
581  for (gpl = gpd->layers.first, i = 0; gpl; gpl = gpl->next, i++) {
582  item_tmp.identifier = gpl->info;
583  item_tmp.name = gpl->info;
584  item_tmp.value = i;
585 
586  item_tmp.icon = (gpd->flag & GP_DATA_ANNOTATIONS) ? BKE_icon_gplayer_color_ensure(gpl) :
587  ICON_GREASEPENCIL;
588 
589  RNA_enum_item_add(&item, &totitem, &item_tmp);
590  }
591 
592  RNA_enum_item_end(&item, &totitem);
593  *r_free = true;
594 
595  return item;
596 }
597 
598 static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value)
599 {
600  bGPdata *gpd = (bGPdata *)ptr->owner_id;
601  bGPDlayer *gpl = ptr->data;
602 
603  char oldname[128] = "";
604  BLI_strncpy(oldname, gpl->info, sizeof(oldname));
605 
606  /* copy the new name into the name slot */
607  BLI_strncpy_utf8(gpl->info, value, sizeof(gpl->info));
608 
610  &gpd->layers, gpl, DATA_("GP_Layer"), '.', offsetof(bGPDlayer, info), sizeof(gpl->info));
611 
612  /* now fix animation paths */
613  BKE_animdata_fix_paths_rename_all(&gpd->id, "layers", oldname, gpl->info);
614 
615  /* Fix mask layers. */
616  LISTBASE_FOREACH (bGPDlayer *, gpl_, &gpd->layers) {
617  LISTBASE_FOREACH (bGPDlayer_Mask *, mask, &gpl_->mask_layers) {
618  if (STREQ(mask->name, oldname)) {
619  BLI_strncpy(mask->name, gpl->info, sizeof(mask->name));
620  }
621  }
622  }
623 }
624 
625 static void rna_GPencilLayer_mask_info_set(PointerRNA *ptr, const char *value)
626 {
627  bGPdata *gpd = (bGPdata *)ptr->owner_id;
629  char oldname[128] = "";
630  BLI_strncpy(oldname, mask->name, sizeof(oldname));
631 
632  /* Really is changing the layer name. */
633  bGPDlayer *gpl = BKE_gpencil_layer_named_get(gpd, oldname);
634  if (gpl) {
635  /* copy the new name into the name slot */
636  BLI_strncpy_utf8(gpl->info, value, sizeof(gpl->info));
637 
639  &gpd->layers, gpl, DATA_("GP_Layer"), '.', offsetof(bGPDlayer, info), sizeof(gpl->info));
640 
641  /* now fix animation paths */
642  BKE_animdata_fix_paths_rename_all(&gpd->id, "layers", oldname, gpl->info);
643 
644  /* Fix mask layers. */
645  LISTBASE_FOREACH (bGPDlayer *, gpl_, &gpd->layers) {
646  LISTBASE_FOREACH (bGPDlayer_Mask *, mask_, &gpl_->mask_layers) {
647  if (STREQ(mask_->name, oldname)) {
648  BLI_strncpy(mask_->name, gpl->info, sizeof(mask_->name));
649  }
650  }
651  }
652  }
653 }
654 
655 static bGPDstroke *rna_GPencil_stroke_point_find_stroke(const bGPdata *gpd,
656  const bGPDspoint *pt,
657  bGPDlayer **r_gpl,
658  bGPDframe **r_gpf)
659 {
660  bGPDlayer *gpl;
661  bGPDstroke *gps;
662 
663  /* sanity checks */
664  if (ELEM(NULL, gpd, pt)) {
665  return NULL;
666  }
667 
668  if (r_gpl) {
669  *r_gpl = NULL;
670  }
671  if (r_gpf) {
672  *r_gpf = NULL;
673  }
674 
675  /* there's no faster alternative than just looping over everything... */
676  for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
677  if (gpl->actframe) {
678  for (gps = gpl->actframe->strokes.first; gps; gps = gps->next) {
679  if ((pt >= gps->points) && (pt < &gps->points[gps->totpoints])) {
680  /* found it */
681  if (r_gpl) {
682  *r_gpl = gpl;
683  }
684  if (r_gpf) {
685  *r_gpf = gpl->actframe;
686  }
687 
688  return gps;
689  }
690  }
691  }
692  }
693 
694  /* didn't find it */
695  return NULL;
696 }
697 
698 static void rna_GPencil_stroke_point_select_set(PointerRNA *ptr, const bool value)
699 {
700  bGPdata *gpd = (bGPdata *)ptr->owner_id;
701  bGPDspoint *pt = ptr->data;
702  bGPDstroke *gps = NULL;
703 
704  /* Ensure that corresponding stroke is set
705  * - Since we don't have direct access, we're going to have to search
706  * - We don't apply selection value unless we can find the corresponding
707  * stroke, so that they don't get out of sync
708  */
709  gps = rna_GPencil_stroke_point_find_stroke(gpd, pt, NULL, NULL);
710  if (gps) {
711  /* Set the new selection state for the point */
712  if (value) {
713  pt->flag |= GP_SPOINT_SELECT;
714  }
715  else {
716  pt->flag &= ~GP_SPOINT_SELECT;
717  }
718 
719  /* Check if the stroke should be selected or not... */
721  }
722 }
723 
724 static void rna_GPencil_stroke_point_add(
725  ID *id, bGPDstroke *stroke, int count, float pressure, float strength)
726 {
727  bGPdata *gpd = (bGPdata *)id;
728 
729  if (count > 0) {
730  /* create space at the end of the array for extra points */
731  stroke->points = MEM_recallocN_id(
732  stroke->points, sizeof(bGPDspoint) * (stroke->totpoints + count), "gp_stroke_points");
733  stroke->dvert = MEM_recallocN_id(
734  stroke->dvert, sizeof(MDeformVert) * (stroke->totpoints + count), "gp_stroke_weight");
735 
736  /* init the pressure and strength values so that old scripts won't need to
737  * be modified to give these initial values...
738  */
739  for (int i = 0; i < count; i++) {
740  bGPDspoint *pt = stroke->points + (stroke->totpoints + i);
741  MDeformVert *dvert = stroke->dvert + (stroke->totpoints + i);
742  pt->pressure = pressure;
743  pt->strength = strength;
744 
745  dvert->totweight = 0;
746  dvert->dw = NULL;
747  }
748 
749  stroke->totpoints += count;
750 
751  /* Calc geometry data. */
753 
754  DEG_id_tag_update(&gpd->id,
756 
758  }
759 }
760 
761 static void rna_GPencil_stroke_point_pop(ID *id,
762  bGPDstroke *stroke,
763  ReportList *reports,
764  int index)
765 {
766  bGPdata *gpd = (bGPdata *)id;
767  bGPDspoint *pt_tmp = stroke->points;
768  MDeformVert *pt_dvert = stroke->dvert;
769 
770  /* python style negative indexing */
771  if (index < 0) {
772  index += stroke->totpoints;
773  }
774 
775  if (stroke->totpoints <= index || index < 0) {
776  BKE_report(reports, RPT_ERROR, "GPencilStrokePoints.pop: index out of range");
777  return;
778  }
779 
780  stroke->totpoints--;
781 
782  stroke->points = MEM_callocN(sizeof(bGPDspoint) * stroke->totpoints, "gp_stroke_points");
783  if (pt_dvert != NULL) {
784  stroke->dvert = MEM_callocN(sizeof(MDeformVert) * stroke->totpoints, "gp_stroke_weights");
785  }
786 
787  if (index > 0) {
788  memcpy(stroke->points, pt_tmp, sizeof(bGPDspoint) * index);
789  /* verify weight data is available */
790  if (pt_dvert != NULL) {
791  memcpy(stroke->dvert, pt_dvert, sizeof(MDeformVert) * index);
792  }
793  }
794 
795  if (index < stroke->totpoints) {
796  memcpy(&stroke->points[index],
797  &pt_tmp[index + 1],
798  sizeof(bGPDspoint) * (stroke->totpoints - index));
799  if (pt_dvert != NULL) {
800  memcpy(&stroke->dvert[index],
801  &pt_dvert[index + 1],
802  sizeof(MDeformVert) * (stroke->totpoints - index));
803  }
804  }
805 
806  /* free temp buffer */
807  MEM_freeN(pt_tmp);
808  if (pt_dvert != NULL) {
809  MEM_freeN(pt_dvert);
810  }
811 
812  /* Calc geometry data. */
814 
816 
818 }
819 
820 static void rna_GPencil_stroke_point_update(ID *id, bGPDstroke *stroke)
821 {
822  bGPdata *gpd = (bGPdata *)id;
823 
824  /* Calc geometry data. */
825  if (stroke) {
827 
828  DEG_id_tag_update(&gpd->id,
830 
832  }
833 }
834 
835 static float rna_GPencilStrokePoints_weight_get(bGPDstroke *stroke,
836  ReportList *reports,
837  int vertex_group_index,
838  int point_index)
839 {
840  MDeformVert *dvert = stroke->dvert;
841  if (dvert == NULL) {
842  BKE_report(reports, RPT_ERROR, "Groups: No groups for this stroke");
843  return -1.0f;
844  }
845 
846  if (stroke->totpoints <= point_index || point_index < 0) {
847  BKE_report(reports, RPT_ERROR, "GPencilStrokePoints: index out of range");
848  return -1.0f;
849  }
850 
851  MDeformVert *pt_dvert = stroke->dvert + point_index;
852  if ((pt_dvert) && (pt_dvert->totweight <= vertex_group_index || vertex_group_index < 0)) {
853  BKE_report(reports, RPT_ERROR, "Groups: index out of range");
854  return -1.0f;
855  }
856 
857  MDeformWeight *dw = BKE_defvert_find_index(pt_dvert, vertex_group_index);
858  if (dw) {
859  return dw->weight;
860  }
861 
862  return -1.0f;
863 }
864 
865 static void rna_GPencilStrokePoints_weight_set(
866  bGPDstroke *stroke, ReportList *reports, int vertex_group_index, int point_index, float weight)
867 {
868  BKE_gpencil_dvert_ensure(stroke);
869 
870  MDeformVert *dvert = stroke->dvert;
871  if (dvert == NULL) {
872  BKE_report(reports, RPT_ERROR, "Groups: No groups for this stroke");
873  return;
874  }
875 
876  if (stroke->totpoints <= point_index || point_index < 0) {
877  BKE_report(reports, RPT_ERROR, "GPencilStrokePoints: index out of range");
878  return;
879  }
880 
881  MDeformVert *pt_dvert = stroke->dvert + point_index;
882  MDeformWeight *dw = BKE_defvert_ensure_index(pt_dvert, vertex_group_index);
883  if (dw) {
884  dw->weight = weight;
885  }
886 }
887 
888 static bGPDstroke *rna_GPencil_stroke_new(bGPDframe *frame)
889 {
890  bGPDstroke *stroke = BKE_gpencil_stroke_new(0, 0, 1.0f);
891  BLI_addtail(&frame->strokes, stroke);
892 
893  return stroke;
894 }
895 
896 static void rna_GPencil_stroke_remove(ID *id,
897  bGPDframe *frame,
898  ReportList *reports,
899  PointerRNA *stroke_ptr)
900 {
901  bGPdata *gpd = (bGPdata *)id;
902 
903  bGPDstroke *stroke = stroke_ptr->data;
904  if (BLI_findindex(&frame->strokes, stroke) == -1) {
905  BKE_report(reports, RPT_ERROR, "Stroke not found in grease pencil frame");
906  return;
907  }
908 
909  BLI_remlink(&frame->strokes, stroke);
910  BKE_gpencil_free_stroke(stroke);
911  RNA_POINTER_INVALIDATE(stroke_ptr);
912 
915 }
916 
917 static void rna_GPencil_stroke_close(ID *id,
918  bGPDframe *frame,
919  ReportList *reports,
920  PointerRNA *stroke_ptr)
921 {
922  bGPdata *gpd = (bGPdata *)id;
923  bGPDstroke *stroke = stroke_ptr->data;
924  if (BLI_findindex(&frame->strokes, stroke) == -1) {
925  BKE_report(reports, RPT_ERROR, "Stroke not found in grease pencil frame");
926  return;
927  }
928 
929  BKE_gpencil_stroke_close(stroke);
930 
933 }
934 
935 static void rna_GPencil_stroke_select_set(PointerRNA *ptr, const bool value)
936 {
937  bGPdata *gpd = (bGPdata *)ptr->owner_id;
938  bGPDstroke *gps = ptr->data;
939  bGPDspoint *pt;
940  int i;
941 
942  /* set new value */
943  if (value) {
944  gps->flag |= GP_STROKE_SELECT;
946  }
947  else {
948  gps->flag &= ~GP_STROKE_SELECT;
950  }
951 
952  /* ensure that the stroke's points are selected in the same way */
953  for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
954  if (value) {
955  pt->flag |= GP_SPOINT_SELECT;
956  }
957  else {
958  pt->flag &= ~GP_SPOINT_SELECT;
959  }
960  }
961 }
962 
963 static void rna_GPencil_curve_select_set(PointerRNA *ptr, const bool value)
964 {
965  bGPDcurve *gpc = ptr->data;
966 
967  /* Set new value. */
968  if (value) {
969  gpc->flag |= GP_CURVE_SELECT;
970  }
971  else {
972  gpc->flag &= ~GP_CURVE_SELECT;
973  }
974  /* Ensure that the curves's points are selected in the same way. */
975  for (int i = 0; i < gpc->tot_curve_points; i++) {
976  bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
977  BezTriple *bezt = &gpc_pt->bezt;
978  if (value) {
979  gpc_pt->flag |= GP_CURVE_POINT_SELECT;
980  BEZT_SEL_ALL(bezt);
981  }
982  else {
983  gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
984  BEZT_DESEL_ALL(bezt);
985  }
986  }
987 }
988 
989 static bGPDframe *rna_GPencil_frame_new(bGPDlayer *layer,
990  ReportList *reports,
991  int frame_number,
992  bool active)
993 {
994  bGPDframe *frame;
995 
996  if (BKE_gpencil_layer_frame_find(layer, frame_number)) {
997  BKE_reportf(reports, RPT_ERROR, "Frame already exists on this frame number %d", frame_number);
998  return NULL;
999  }
1000 
1001  frame = BKE_gpencil_frame_addnew(layer, frame_number);
1002  if (active) {
1003  layer->actframe = BKE_gpencil_layer_frame_get(layer, frame_number, GP_GETFRAME_USE_PREV);
1004  }
1006 
1007  return frame;
1008 }
1009 
1010 static void rna_GPencil_frame_remove(bGPDlayer *layer, ReportList *reports, PointerRNA *frame_ptr)
1011 {
1012  bGPDframe *frame = frame_ptr->data;
1013  if (BLI_findindex(&layer->frames, frame) == -1) {
1014  BKE_report(reports, RPT_ERROR, "Frame not found in grease pencil layer");
1015  return;
1016  }
1017 
1018  BKE_gpencil_layer_frame_delete(layer, frame);
1019  RNA_POINTER_INVALIDATE(frame_ptr);
1020 
1022 }
1023 
1024 static bGPDframe *rna_GPencil_frame_copy(bGPDlayer *layer, bGPDframe *src)
1025 {
1026  bGPDframe *frame = BKE_gpencil_frame_duplicate(src, true);
1027 
1028  while (BKE_gpencil_layer_frame_find(layer, frame->framenum)) {
1029  frame->framenum++;
1030  }
1031 
1032  BLI_addtail(&layer->frames, frame);
1033 
1035 
1036  return frame;
1037 }
1038 
1039 static bGPDlayer *rna_GPencil_layer_new(bGPdata *gpd, const char *name, bool setactive)
1040 {
1041  bGPDlayer *gpl = BKE_gpencil_layer_addnew(gpd, name, setactive != 0);
1042 
1044 
1045  return gpl;
1046 }
1047 
1048 static void rna_GPencil_layer_remove(bGPdata *gpd, ReportList *reports, PointerRNA *layer_ptr)
1049 {
1050  bGPDlayer *layer = layer_ptr->data;
1051  if (BLI_findindex(&gpd->layers, layer) == -1) {
1052  BKE_report(reports, RPT_ERROR, "Layer not found in grease pencil data");
1053  return;
1054  }
1055 
1056  BKE_gpencil_layer_delete(gpd, layer);
1057  RNA_POINTER_INVALIDATE(layer_ptr);
1058 
1060 }
1061 
1062 static void rna_GPencil_layer_move(bGPdata *gpd,
1063  ReportList *reports,
1064  PointerRNA *layer_ptr,
1065  int type)
1066 {
1067  bGPDlayer *gpl = layer_ptr->data;
1068  if (BLI_findindex(&gpd->layers, gpl) == -1) {
1069  BKE_report(reports, RPT_ERROR, "Layer not found in grease pencil data");
1070  return;
1071  }
1072 
1073  BLI_assert(ELEM(type, -1, 0, 1)); /* we use value below */
1074 
1075  const int direction = type * -1;
1076 
1077  if (BLI_listbase_link_move(&gpd->layers, gpl, direction)) {
1079  }
1080 
1082 }
1083 
1084 static void rna_GPencil_layer_mask_add(bGPDlayer *gpl, PointerRNA *layer_ptr)
1085 {
1086  bGPDlayer *gpl_mask = layer_ptr->data;
1087 
1088  BKE_gpencil_layer_mask_add(gpl, gpl_mask->info);
1089 
1091 }
1092 
1093 static void rna_GPencil_layer_mask_remove(bGPDlayer *gpl,
1094  ReportList *reports,
1095  PointerRNA *mask_ptr)
1096 {
1097  bGPDlayer_Mask *mask = mask_ptr->data;
1098  if (BLI_findindex(&gpl->mask_layers, mask) == -1) {
1099  BKE_report(reports, RPT_ERROR, "Mask not found in mask list");
1100  return;
1101  }
1102 
1104  RNA_POINTER_INVALIDATE(mask_ptr);
1105 
1107 }
1108 
1109 static void rna_GPencil_frame_clear(bGPDframe *frame)
1110 {
1111  BKE_gpencil_free_strokes(frame);
1112 
1114 }
1115 
1116 static void rna_GPencil_layer_clear(bGPDlayer *layer)
1117 {
1118  BKE_gpencil_free_frames(layer);
1119 
1121 }
1122 
1123 static void rna_GPencil_clear(bGPdata *gpd)
1124 {
1126 
1128 }
1129 
1130 static char *rna_GreasePencilGrid_path(PointerRNA *UNUSED(ptr))
1131 {
1132  return BLI_strdup("grid");
1133 }
1134 
1135 static void rna_GpencilCurvePoint_BezTriple_handle1_get(PointerRNA *ptr, float *values)
1136 {
1138  copy_v3_v3(values, cpt->bezt.vec[0]);
1139 }
1140 
1141 static void rna_GpencilCurvePoint_BezTriple_handle1_set(PointerRNA *ptr, const float *values)
1142 {
1144  copy_v3_v3(cpt->bezt.vec[0], values);
1145 }
1146 
1147 static bool rna_GpencilCurvePoint_BezTriple_handle1_select_get(PointerRNA *ptr)
1148 {
1150  return cpt->bezt.f1;
1151 }
1152 
1153 static void rna_GpencilCurvePoint_BezTriple_handle1_select_set(PointerRNA *ptr, const bool value)
1154 {
1156  cpt->bezt.f1 = value;
1157 }
1158 
1159 static void rna_GpencilCurvePoint_BezTriple_handle2_get(PointerRNA *ptr, float *values)
1160 {
1162  copy_v3_v3(values, cpt->bezt.vec[2]);
1163 }
1164 
1165 static void rna_GpencilCurvePoint_BezTriple_handle2_set(PointerRNA *ptr, const float *values)
1166 {
1168  copy_v3_v3(cpt->bezt.vec[2], values);
1169 }
1170 
1171 static bool rna_GpencilCurvePoint_BezTriple_handle2_select_get(PointerRNA *ptr)
1172 {
1174  return cpt->bezt.f3;
1175 }
1176 
1177 static void rna_GpencilCurvePoint_BezTriple_handle2_select_set(PointerRNA *ptr, const bool value)
1178 {
1180  cpt->bezt.f3 = value;
1181 }
1182 
1183 static void rna_GpencilCurvePoint_BezTriple_ctrlpoint_get(PointerRNA *ptr, float *values)
1184 {
1186  copy_v3_v3(values, cpt->bezt.vec[1]);
1187 }
1188 
1189 static void rna_GpencilCurvePoint_BezTriple_ctrlpoint_set(PointerRNA *ptr, const float *values)
1190 {
1192  copy_v3_v3(cpt->bezt.vec[1], values);
1193 }
1194 
1195 static bool rna_GpencilCurvePoint_BezTriple_ctrlpoint_select_get(PointerRNA *ptr)
1196 {
1198  return cpt->bezt.f2;
1199 }
1200 
1201 static void rna_GpencilCurvePoint_BezTriple_ctrlpoint_select_set(PointerRNA *ptr, const bool value)
1202 {
1204  cpt->bezt.f2 = value;
1205 }
1206 
1207 static bool rna_GpencilCurvePoint_BezTriple_hide_get(PointerRNA *ptr)
1208 {
1210  return (bool)cpt->bezt.hide;
1211 }
1212 
1213 static void rna_GpencilCurvePoint_BezTriple_hide_set(PointerRNA *ptr, const bool value)
1214 {
1216  cpt->bezt.hide = value;
1217 }
1218 
1219 static bool rna_stroke_has_edit_curve_get(PointerRNA *ptr)
1220 {
1221  bGPDstroke *gps = (bGPDstroke *)ptr->data;
1222  if (gps->editcurve != NULL) {
1223  return true;
1224  }
1225 
1226  return false;
1227 }
1228 
1229 #else
1230 
1232 {
1233  StructRNA *srna;
1234  PropertyRNA *prop;
1235 
1236  srna = RNA_def_struct(brna, "GPencilStrokePoint", NULL);
1237  RNA_def_struct_sdna(srna, "bGPDspoint");
1239  srna, "Grease Pencil Stroke Point", "Data point for freehand stroke curve");
1240 
1241  prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_XYZ);
1242  RNA_def_property_float_sdna(prop, NULL, "x");
1243  RNA_def_property_array(prop, 3);
1244  RNA_def_property_ui_text(prop, "Coordinates", "");
1245  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1246 
1247  prop = RNA_def_property(srna, "pressure", PROP_FLOAT, PROP_FACTOR);
1248  RNA_def_property_float_sdna(prop, NULL, "pressure");
1249  RNA_def_property_range(prop, 0.0f, FLT_MAX);
1250  RNA_def_property_ui_text(prop, "Pressure", "Pressure of tablet at point when drawing it");
1251  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1252 
1253  prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR);
1254  RNA_def_property_float_sdna(prop, NULL, "strength");
1255  RNA_def_property_range(prop, 0.0f, 1.0f);
1256  RNA_def_property_ui_text(prop, "Strength", "Color intensity (alpha factor)");
1257  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1258 
1259  prop = RNA_def_property(srna, "uv_factor", PROP_FLOAT, PROP_FACTOR);
1260  RNA_def_property_float_sdna(prop, NULL, "uv_fac");
1261  RNA_def_property_range(prop, 0.0f, 1.0f);
1262  RNA_def_property_ui_text(prop, "UV Factor", "Internal UV factor");
1263  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1264 
1265  prop = RNA_def_property(srna, "uv_rotation", PROP_FLOAT, PROP_ANGLE);
1266  RNA_def_property_float_sdna(prop, NULL, "uv_rot");
1268  RNA_def_property_ui_text(prop, "UV Rotation", "Internal UV factor for dot mode");
1269  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1270 
1271  prop = RNA_def_property(srna, "uv_fill", PROP_FLOAT, PROP_XYZ);
1272  RNA_def_property_float_sdna(prop, NULL, "uv_fill");
1273  RNA_def_property_array(prop, 2);
1274  RNA_def_property_ui_text(prop, "UV Fill", "Internal UV factor for filling");
1275  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1276 
1277  prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1279  RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencil_stroke_point_select_set");
1280  RNA_def_property_ui_text(prop, "Select", "Point is selected for viewport editing");
1281  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1282 
1283  /* Vertex color. */
1284  prop = RNA_def_property(srna, "vertex_color", PROP_FLOAT, PROP_COLOR);
1285  RNA_def_property_float_sdna(prop, NULL, "vert_color");
1286  RNA_def_property_array(prop, 4);
1287  RNA_def_property_range(prop, 0.0f, 1.0f);
1290  prop, "Vertex Color", "Color used to mix with point color to get final color");
1291  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1292 }
1293 
1295 {
1296  StructRNA *srna;
1297  FunctionRNA *func;
1298  PropertyRNA *parm;
1299 
1300  RNA_def_property_srna(cprop, "GPencilStrokePoints");
1301  srna = RNA_def_struct(brna, "GPencilStrokePoints", NULL);
1302  RNA_def_struct_sdna(srna, "bGPDstroke");
1304  srna, "Grease Pencil Stroke Points", "Collection of grease pencil stroke points");
1305 
1306  func = RNA_def_function(srna, "add", "rna_GPencil_stroke_point_add");
1307  RNA_def_function_ui_description(func, "Add a new grease pencil stroke point");
1309  parm = RNA_def_int(
1310  func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the stroke", 0, INT_MAX);
1312  RNA_def_float(func,
1313  "pressure",
1314  1.0f,
1315  0.0f,
1316  FLT_MAX,
1317  "Pressure",
1318  "Pressure for newly created points",
1319  0.0f,
1320  FLT_MAX);
1321  RNA_def_float(func,
1322  "strength",
1323  1.0f,
1324  0.0f,
1325  1.0f,
1326  "Strength",
1327  "Color intensity (alpha factor) for newly created points",
1328  0.0f,
1329  1.0f);
1330 
1331  func = RNA_def_function(srna, "pop", "rna_GPencil_stroke_point_pop");
1332  RNA_def_function_ui_description(func, "Remove a grease pencil stroke point");
1334  RNA_def_int(func, "index", -1, INT_MIN, INT_MAX, "Index", "point index", INT_MIN, INT_MAX);
1335 
1336  func = RNA_def_function(srna, "update", "rna_GPencil_stroke_point_update");
1337  RNA_def_function_ui_description(func, "Recalculate internal triangulation data");
1339 
1340  func = RNA_def_function(srna, "weight_get", "rna_GPencilStrokePoints_weight_get");
1341  RNA_def_function_ui_description(func, "Get vertex group point weight");
1343  RNA_def_int(func,
1344  "vertex_group_index",
1345  0,
1346  0,
1347  INT_MAX,
1348  "Vertex Group Index",
1349  "Index of Vertex Group in the array of groups",
1350  0,
1351  INT_MAX);
1352  RNA_def_int(func,
1353  "point_index",
1354  0,
1355  0,
1356  INT_MAX,
1357  "Point Index",
1358  "Index of the Point in the array",
1359  0,
1360  INT_MAX);
1361  parm = RNA_def_float(
1362  func, "weight", 0, -FLT_MAX, FLT_MAX, "Weight", "Point Weight", -FLT_MAX, FLT_MAX);
1363  RNA_def_function_return(func, parm);
1364 
1365  func = RNA_def_function(srna, "weight_set", "rna_GPencilStrokePoints_weight_set");
1366  RNA_def_function_ui_description(func, "Set vertex group point weight");
1368  RNA_def_int(func,
1369  "vertex_group_index",
1370  0,
1371  0,
1372  INT_MAX,
1373  "Vertex Group Index",
1374  "Index of Vertex Group in the array of groups",
1375  0,
1376  INT_MAX);
1377  RNA_def_int(func,
1378  "point_index",
1379  0,
1380  0,
1381  INT_MAX,
1382  "Point Index",
1383  "Index of the Point in the array",
1384  0,
1385  INT_MAX);
1386  RNA_def_float(func, "weight", 0, -FLT_MAX, FLT_MAX, "Weight", "Point Weight", -FLT_MAX, FLT_MAX);
1387 }
1388 
1389 /* This information is read only and it can be used by add-ons */
1391 {
1392  StructRNA *srna;
1393  PropertyRNA *prop;
1394 
1395  srna = RNA_def_struct(brna, "GPencilTriangle", NULL);
1396  RNA_def_struct_sdna(srna, "bGPDtriangle");
1397  RNA_def_struct_ui_text(srna, "Triangle", "Triangulation data for Grease Pencil fills");
1398 
1399  /* point v1 */
1400  prop = RNA_def_property(srna, "v1", PROP_INT, PROP_NONE);
1401  RNA_def_property_int_sdna(prop, NULL, "verts[0]");
1402  RNA_def_property_ui_text(prop, "v1", "First triangle vertex index");
1404 
1405  /* point v2 */
1406  prop = RNA_def_property(srna, "v2", PROP_INT, PROP_NONE);
1407  RNA_def_property_int_sdna(prop, NULL, "verts[1]");
1408  RNA_def_property_ui_text(prop, "v2", "Second triangle vertex index");
1410 
1411  /* point v3 */
1412  prop = RNA_def_property(srna, "v3", PROP_INT, PROP_NONE);
1413  RNA_def_property_int_sdna(prop, NULL, "verts[2]");
1414  RNA_def_property_ui_text(prop, "v3", "Third triangle vertex index");
1416 }
1417 
1419 {
1420  StructRNA *srna;
1421  PropertyRNA *prop;
1422 
1423  srna = RNA_def_struct(brna, "GPencilEditCurvePoint", NULL);
1424  RNA_def_struct_sdna(srna, "bGPDcurve_point");
1425  RNA_def_struct_ui_text(srna, "Bezier Curve Point", "Bezier curve point with two handles");
1426 
1427  /* Boolean values */
1428  prop = RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE);
1430  "rna_GpencilCurvePoint_BezTriple_handle1_select_get",
1431  "rna_GpencilCurvePoint_BezTriple_handle1_select_set");
1432  RNA_def_property_ui_text(prop, "Handle 1 selected", "Handle 1 selection status");
1433  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1434 
1435  prop = RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE);
1437  "rna_GpencilCurvePoint_BezTriple_handle2_select_get",
1438  "rna_GpencilCurvePoint_BezTriple_handle2_select_set");
1439  RNA_def_property_ui_text(prop, "Handle 2 selected", "Handle 2 selection status");
1440  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1441 
1442  prop = RNA_def_property(srna, "select_control_point", PROP_BOOLEAN, PROP_NONE);
1444  "rna_GpencilCurvePoint_BezTriple_ctrlpoint_select_get",
1445  "rna_GpencilCurvePoint_BezTriple_ctrlpoint_select_set");
1446  RNA_def_property_ui_text(prop, "Control Point selected", "Control point selection status");
1447  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1448 
1449  prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
1451  "rna_GpencilCurvePoint_BezTriple_hide_get",
1452  "rna_GpencilCurvePoint_BezTriple_hide_set");
1453  RNA_def_property_ui_text(prop, "Hide", "Visibility status");
1454  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1455 
1456  /* Vector values */
1457  prop = RNA_def_property(srna, "handle_left", PROP_FLOAT, PROP_TRANSLATION);
1458  RNA_def_property_array(prop, 3);
1460  "rna_GpencilCurvePoint_BezTriple_handle1_get",
1461  "rna_GpencilCurvePoint_BezTriple_handle1_set",
1462  NULL);
1464  RNA_def_property_ui_text(prop, "Handle 1", "Coordinates of the first handle");
1465  RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
1466  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
1467 
1468  prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
1469  RNA_def_property_array(prop, 3);
1471  "rna_GpencilCurvePoint_BezTriple_ctrlpoint_get",
1472  "rna_GpencilCurvePoint_BezTriple_ctrlpoint_set",
1473  NULL);
1475  RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point");
1476  RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
1477  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
1478 
1479  prop = RNA_def_property(srna, "handle_right", PROP_FLOAT, PROP_TRANSLATION);
1480  RNA_def_property_array(prop, 3);
1482  "rna_GpencilCurvePoint_BezTriple_handle2_get",
1483  "rna_GpencilCurvePoint_BezTriple_handle2_set",
1484  NULL);
1486  RNA_def_property_ui_text(prop, "Handle 2", "Coordinates of the second handle");
1487  RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
1488  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
1489 
1490  /* Pressure */
1491  prop = RNA_def_property(srna, "pressure", PROP_FLOAT, PROP_FACTOR);
1492  RNA_def_property_float_sdna(prop, NULL, "pressure");
1493  RNA_def_property_range(prop, 0.0f, FLT_MAX);
1496  RNA_def_property_ui_text(prop, "Pressure", "Pressure of the grease pencil stroke point");
1497  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
1498 
1499  /* Strength */
1500  prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR);
1501  RNA_def_property_float_sdna(prop, NULL, "strength");
1502  RNA_def_property_range(prop, 0.0f, 1.0f);
1505  prop, "Strength", "Color intensity (alpha factor) of the grease pencil stroke point");
1506  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
1507 
1508  /* read-only index */
1509  prop = RNA_def_property(srna, "point_index", PROP_INT, PROP_UNSIGNED);
1510  RNA_def_property_int_sdna(prop, NULL, "point_index");
1514  prop, "Point Index", "Index of the corresponding grease pencil stroke point");
1515 
1516  prop = RNA_def_property(srna, "uv_factor", PROP_FLOAT, PROP_FACTOR);
1517  RNA_def_property_float_sdna(prop, NULL, "uv_fac");
1518  RNA_def_property_range(prop, 0.0f, 1.0f);
1520  RNA_def_property_ui_text(prop, "UV Factor", "Internal UV factor");
1521  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
1522 
1523  prop = RNA_def_property(srna, "uv_rotation", PROP_FLOAT, PROP_ANGLE);
1524  RNA_def_property_float_sdna(prop, NULL, "uv_rot");
1527  RNA_def_property_ui_text(prop, "UV Rotation", "Internal UV factor for dot mode");
1528  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
1529 
1530  prop = RNA_def_property(srna, "vertex_color", PROP_FLOAT, PROP_COLOR);
1531  RNA_def_property_float_sdna(prop, NULL, "vert_color");
1532  RNA_def_property_array(prop, 4);
1533  RNA_def_property_range(prop, 0.0f, 1.0f);
1535  RNA_def_property_ui_text(prop, "Vertex Color", "Vertex color of the grease pencil stroke point");
1536  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
1537 }
1538 
1539 /* Editing Curve data. */
1541 {
1542  StructRNA *srna;
1543  PropertyRNA *prop;
1544 
1545  srna = RNA_def_struct(brna, "GPencilEditCurve", NULL);
1546  RNA_def_struct_sdna(srna, "bGPDcurve");
1547  RNA_def_struct_ui_text(srna, "Edit Curve", "Edition Curve");
1548 
1549  prop = RNA_def_property(srna, "curve_points", PROP_COLLECTION, PROP_NONE);
1550  RNA_def_property_collection_sdna(prop, NULL, "curve_points", "tot_curve_points");
1551  RNA_def_property_struct_type(prop, "GPencilEditCurvePoint");
1552  RNA_def_property_ui_text(prop, "Curve Points", "Curve data points");
1553 
1554  prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1556  RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencil_curve_select_set");
1557  RNA_def_property_ui_text(prop, "Select", "Curve is selected for viewport editing");
1558  RNA_def_property_update(prop, 0, "rna_GPencil_update");
1559 }
1560 
1562 {
1563  StructRNA *srna;
1564  PropertyRNA *prop;
1565 
1566  srna = RNA_def_struct(brna, "GpencilVertexGroupElement", NULL);
1567  RNA_def_struct_sdna(srna, "MDeformWeight");
1569  srna, "Vertex Group Element", "Weight value of a vertex in a vertex group");
1570  RNA_def_struct_ui_icon(srna, ICON_GROUP_VERTEX);
1571 
1572  /* we can't point to actual group, it is in the object and so
1573  * there is no unique group to point to, hence the index */
1574  prop = RNA_def_property(srna, "group", PROP_INT, PROP_UNSIGNED);
1575  RNA_def_property_int_sdna(prop, NULL, "def_nr");
1577  RNA_def_property_ui_text(prop, "Group Index", "");
1578  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1579 
1580  prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR);
1581  RNA_def_property_range(prop, 0.0f, 1.0f);
1582  RNA_def_property_ui_text(prop, "Weight", "Vertex Weight");
1583  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1584 }
1585 
1587 {
1588  StructRNA *srna;
1589  PropertyRNA *prop;
1590 
1591  static const EnumPropertyItem stroke_display_mode_items[] = {
1592  {0, "SCREEN", 0, "Screen", "Stroke is in screen-space"},
1593  {GP_STROKE_3DSPACE, "3DSPACE", 0, "3D Space", "Stroke is in 3D-space"},
1594  {GP_STROKE_2DSPACE, "2DSPACE", 0, "2D Space", "Stroke is in 2D-space"},
1596  "2DIMAGE",
1597  0,
1598  "2D Image",
1599  "Stroke is in 2D-space (but with special 'image' scaling)"},
1600  {0, NULL, 0, NULL, NULL},
1601  };
1602 
1603  srna = RNA_def_struct(brna, "GPencilStroke", NULL);
1604  RNA_def_struct_sdna(srna, "bGPDstroke");
1605  RNA_def_struct_ui_text(srna, "Grease Pencil Stroke", "Freehand curve defining part of a sketch");
1606 
1607  /* Points */
1608  prop = RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE);
1609  RNA_def_property_collection_sdna(prop, NULL, "points", "totpoints");
1610  RNA_def_property_struct_type(prop, "GPencilStrokePoint");
1611  RNA_def_property_ui_text(prop, "Stroke Points", "Stroke data points");
1613 
1614  /* Triangles */
1615  prop = RNA_def_property(srna, "triangles", PROP_COLLECTION, PROP_NONE);
1616  RNA_def_property_collection_sdna(prop, NULL, "triangles", "tot_triangles");
1617  RNA_def_property_struct_type(prop, "GPencilTriangle");
1618  RNA_def_property_ui_text(prop, "Triangles", "Triangulation data for HQ fill");
1619 
1620  /* Edit Curve. */
1621  prop = RNA_def_property(srna, "edit_curve", PROP_POINTER, PROP_NONE);
1622  RNA_def_property_pointer_sdna(prop, NULL, "editcurve");
1623  RNA_def_property_struct_type(prop, "GPencilEditCurve");
1624  RNA_def_property_ui_text(prop, "Edit Curve", "Temporary data for Edit Curve");
1625 
1626  /* Material Index */
1627  prop = RNA_def_property(srna, "material_index", PROP_INT, PROP_NONE);
1628  RNA_def_property_int_sdna(prop, NULL, "mat_nr");
1629  RNA_def_property_ui_text(prop, "Material Index", "Index of material used in this stroke");
1630  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1631 
1632  /* Settings */
1633  prop = RNA_def_property(srna, "display_mode", PROP_ENUM, PROP_NONE);
1635  RNA_def_property_enum_items(prop, stroke_display_mode_items);
1636  RNA_def_property_ui_text(prop, "Display Mode", "Coordinate space that stroke is in");
1637  RNA_def_property_update(prop, 0, "rna_GPencil_update");
1638 
1639  prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1641  RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencil_stroke_select_set");
1642  RNA_def_property_ui_text(prop, "Select", "Stroke is selected for viewport editing");
1643  RNA_def_property_update(prop, 0, "rna_GPencil_update");
1644 
1645  /* Cyclic: Draw a line from end to start point */
1646  prop = RNA_def_property(srna, "use_cyclic", PROP_BOOLEAN, PROP_NONE);
1648  RNA_def_property_ui_text(prop, "Cyclic", "Enable cyclic drawing, closing the stroke");
1649  RNA_def_property_update(prop, 0, "rna_GPencil_update");
1650 
1651  /* The stroke has Curve Edit data. */
1652  prop = RNA_def_property(srna, "has_edit_curve", PROP_BOOLEAN, PROP_NONE);
1653  RNA_def_property_boolean_funcs(prop, "rna_stroke_has_edit_curve_get", NULL);
1655  RNA_def_property_ui_text(prop, "Has Curve Data", "Stroke has Curve data to edit shape");
1656 
1657  /* Caps mode */
1658  prop = RNA_def_property(srna, "start_cap_mode", PROP_ENUM, PROP_NONE);
1659  RNA_def_property_enum_sdna(prop, NULL, "caps[0]");
1661  RNA_def_property_ui_text(prop, "Start Cap", "Stroke start extreme cap style");
1662  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1663 
1664  prop = RNA_def_property(srna, "end_cap_mode", PROP_ENUM, PROP_NONE);
1665  RNA_def_property_enum_sdna(prop, NULL, "caps[1]");
1667  RNA_def_property_ui_text(prop, "End Cap", "Stroke end extreme cap style");
1668  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1669 
1670  /* No fill: The stroke never must fill area and must use fill color as stroke color
1671  * (this is a special flag for fill brush). */
1672  prop = RNA_def_property(srna, "is_nofill_stroke", PROP_BOOLEAN, PROP_NONE);
1674  RNA_def_property_ui_text(prop, "No Fill", "Special stroke to use as boundary for filling areas");
1675  RNA_def_property_update(prop, 0, "rna_GPencil_update");
1676 
1677  /* Line Thickness */
1678  prop = RNA_def_property(srna, "line_width", PROP_INT, PROP_PIXEL);
1679  RNA_def_property_int_sdna(prop, NULL, "thickness");
1680  RNA_def_property_range(prop, 1, 1000);
1681  RNA_def_property_ui_range(prop, 1, 10, 1, 0);
1682  RNA_def_property_ui_text(prop, "Thickness", "Thickness of stroke (in pixels)");
1683  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1684 
1685  /* gradient control along y */
1686  prop = RNA_def_property(srna, "hardness", PROP_FLOAT, PROP_FACTOR);
1687  RNA_def_property_float_sdna(prop, NULL, "hardeness");
1688  RNA_def_property_range(prop, 0.001f, 1.0f);
1689  RNA_def_property_float_default(prop, 1.0f);
1690  RNA_def_property_ui_text(prop, "Hardness", "Amount of gradient along section of stroke");
1692  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1693 
1694  /* Stroke bound box */
1695  prop = RNA_def_property(srna, "bound_box_min", PROP_FLOAT, PROP_XYZ);
1696  RNA_def_property_float_sdna(prop, NULL, "boundbox_min");
1697  RNA_def_property_array(prop, 3);
1699  RNA_def_property_ui_text(prop, "Boundbox Min", "");
1700 
1701  prop = RNA_def_property(srna, "bound_box_max", PROP_FLOAT, PROP_XYZ);
1702  RNA_def_property_float_sdna(prop, NULL, "boundbox_max");
1703  RNA_def_property_array(prop, 3);
1705  RNA_def_property_ui_text(prop, "Boundbox Max", "");
1706 
1707  /* gradient shape ratio */
1708  prop = RNA_def_property(srna, "aspect", PROP_FLOAT, PROP_XYZ);
1709  RNA_def_property_float_sdna(prop, NULL, "aspect_ratio");
1710  RNA_def_property_array(prop, 2);
1711  RNA_def_property_range(prop, 0.01f, 1.0f);
1712  RNA_def_property_float_default(prop, 1.0f);
1713  RNA_def_property_ui_text(prop, "Aspect", "");
1714  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1715 
1716  /* UV translation. */
1717  prop = RNA_def_property(srna, "uv_translation", PROP_FLOAT, PROP_XYZ);
1718  RNA_def_property_float_sdna(prop, NULL, "uv_translation");
1719  RNA_def_property_array(prop, 2);
1720  RNA_def_property_float_default(prop, 0.0f);
1721  RNA_def_property_ui_text(prop, "UV Translation", "Translation of default UV position");
1723  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_uv_update");
1724 
1725  /* UV rotation. */
1726  prop = RNA_def_property(srna, "uv_rotation", PROP_FLOAT, PROP_ANGLE);
1727  RNA_def_property_float_sdna(prop, NULL, "uv_rotation");
1728  RNA_def_property_float_default(prop, 0.0f);
1729  RNA_def_property_ui_text(prop, "UV Rotation", "Rotation of the UV");
1731  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_uv_update");
1732 
1733  /* UV scale. */
1734  prop = RNA_def_property(srna, "uv_scale", PROP_FLOAT, PROP_NONE);
1735  RNA_def_property_float_sdna(prop, NULL, "uv_scale");
1736  RNA_def_property_float_default(prop, 1.0f);
1737  RNA_def_property_range(prop, 0.01f, 100.0f);
1738  RNA_def_property_ui_text(prop, "UV Scale", "Scale of the UV");
1740  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_uv_update");
1741 
1742  /* Vertex Color for Fill. */
1743  prop = RNA_def_property(srna, "vertex_color_fill", PROP_FLOAT, PROP_COLOR);
1744  RNA_def_property_float_sdna(prop, NULL, "vert_color_fill");
1745  RNA_def_property_array(prop, 4);
1746  RNA_def_property_range(prop, 0.0f, 1.0f);
1749  prop, "Vertex Fill Color", "Color used to mix with fill color to get final color");
1750  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1751 
1752  /* Selection Index */
1753  prop = RNA_def_property(srna, "select_index", PROP_INT, PROP_NONE);
1754  RNA_def_property_int_sdna(prop, NULL, "select_index");
1755  RNA_def_property_ui_text(prop, "Select Index", "Index of selection used for interpolation");
1756 }
1757 
1759 {
1760  StructRNA *srna;
1761 
1762  FunctionRNA *func;
1763  PropertyRNA *parm;
1764 
1765  RNA_def_property_srna(cprop, "GPencilStrokes");
1766  srna = RNA_def_struct(brna, "GPencilStrokes", NULL);
1767  RNA_def_struct_sdna(srna, "bGPDframe");
1768  RNA_def_struct_ui_text(srna, "Grease Pencil Frames", "Collection of grease pencil stroke");
1769 
1770  func = RNA_def_function(srna, "new", "rna_GPencil_stroke_new");
1771  RNA_def_function_ui_description(func, "Add a new grease pencil stroke");
1772  parm = RNA_def_pointer(func, "stroke", "GPencilStroke", "", "The newly created stroke");
1773  RNA_def_function_return(func, parm);
1774 
1775  func = RNA_def_function(srna, "remove", "rna_GPencil_stroke_remove");
1776  RNA_def_function_ui_description(func, "Remove a grease pencil stroke");
1778  parm = RNA_def_pointer(func, "stroke", "GPencilStroke", "Stroke", "The stroke to remove");
1781 
1782  func = RNA_def_function(srna, "close", "rna_GPencil_stroke_close");
1783  RNA_def_function_ui_description(func, "Close a grease pencil stroke adding geometry");
1785  parm = RNA_def_pointer(func, "stroke", "GPencilStroke", "Stroke", "The stroke to close");
1788 }
1789 
1791 {
1792  StructRNA *srna;
1793  PropertyRNA *prop;
1794 
1795  FunctionRNA *func;
1796 
1797  srna = RNA_def_struct(brna, "GPencilFrame", NULL);
1798  RNA_def_struct_sdna(srna, "bGPDframe");
1800  srna, "Grease Pencil Frame", "Collection of related sketches on a particular frame");
1801 
1802  /* Strokes */
1803  prop = RNA_def_property(srna, "strokes", PROP_COLLECTION, PROP_NONE);
1804  RNA_def_property_collection_sdna(prop, NULL, "strokes", NULL);
1805  RNA_def_property_struct_type(prop, "GPencilStroke");
1806  RNA_def_property_ui_text(prop, "Strokes", "Freehand curves defining the sketch on this frame");
1807  rna_def_gpencil_strokes_api(brna, prop);
1808 
1809  /* Frame Number */
1810  prop = RNA_def_property(srna, "frame_number", PROP_INT, PROP_NONE);
1811  RNA_def_property_int_sdna(prop, NULL, "framenum");
1812  /* XXX note: this cannot occur on the same frame as another sketch */
1814  RNA_def_property_ui_text(prop, "Frame Number", "The frame on which this sketch appears");
1815 
1816  prop = RNA_def_property(srna, "keyframe_type", PROP_ENUM, PROP_NONE);
1817  RNA_def_property_enum_sdna(prop, NULL, "key_type");
1820  RNA_def_property_ui_text(prop, "Keyframe Type", "Type of keyframe");
1821  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1822 
1823  /* Flags */
1824  prop = RNA_def_property(srna, "is_edited", PROP_BOOLEAN, PROP_NONE);
1826  prop, NULL, "flag", GP_FRAME_PAINT); /* XXX should it be editable? */
1827  RNA_def_property_ui_text(prop, "Paint Lock", "Frame is being edited (painted on)");
1828 
1829  prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1831  RNA_def_property_ui_text(prop, "Select", "Frame is selected for editing in the Dope Sheet");
1832 
1833  /* API */
1834  func = RNA_def_function(srna, "clear", "rna_GPencil_frame_clear");
1835  RNA_def_function_ui_description(func, "Remove all the grease pencil frame data");
1836 }
1837 
1839 {
1840  StructRNA *srna;
1841 
1842  FunctionRNA *func;
1843  PropertyRNA *parm;
1844 
1845  RNA_def_property_srna(cprop, "GPencilFrames");
1846  srna = RNA_def_struct(brna, "GPencilFrames", NULL);
1847  RNA_def_struct_sdna(srna, "bGPDlayer");
1848  RNA_def_struct_ui_text(srna, "Grease Pencil Frames", "Collection of grease pencil frames");
1849 
1850  func = RNA_def_function(srna, "new", "rna_GPencil_frame_new");
1851  RNA_def_function_ui_description(func, "Add a new grease pencil frame");
1853  parm = RNA_def_int(func,
1854  "frame_number",
1855  1,
1856  MINAFRAME,
1857  MAXFRAME,
1858  "Frame Number",
1859  "The frame on which this sketch appears",
1860  MINAFRAME,
1861  MAXFRAME);
1863  RNA_def_boolean(func, "active", 0, "Active", "");
1864  parm = RNA_def_pointer(func, "frame", "GPencilFrame", "", "The newly created frame");
1865  RNA_def_function_return(func, parm);
1866 
1867  func = RNA_def_function(srna, "remove", "rna_GPencil_frame_remove");
1868  RNA_def_function_ui_description(func, "Remove a grease pencil frame");
1870  parm = RNA_def_pointer(func, "frame", "GPencilFrame", "Frame", "The frame to remove");
1873 
1874  func = RNA_def_function(srna, "copy", "rna_GPencil_frame_copy");
1875  RNA_def_function_ui_description(func, "Copy a grease pencil frame");
1876  parm = RNA_def_pointer(func, "source", "GPencilFrame", "Source", "The source frame");
1878  parm = RNA_def_pointer(func, "copy", "GPencilFrame", "", "The newly copied frame");
1879  RNA_def_function_return(func, parm);
1880 }
1881 
1883 {
1884  StructRNA *srna;
1885  PropertyRNA *prop;
1886 
1887  FunctionRNA *func;
1888  PropertyRNA *parm;
1889 
1890  RNA_def_property_srna(cprop, "GreasePencilMaskLayers");
1891  srna = RNA_def_struct(brna, "GreasePencilMaskLayers", NULL);
1892  RNA_def_struct_sdna(srna, "bGPDlayer");
1894  srna, "Grease Pencil Mask Layers", "Collection of grease pencil masking layers");
1895 
1896  prop = RNA_def_property(srna, "active_mask_index", PROP_INT, PROP_UNSIGNED);
1899  "rna_GPencil_active_mask_index_get",
1900  "rna_GPencil_active_mask_index_set",
1901  "rna_GPencil_active_mask_index_range");
1902  RNA_def_property_ui_text(prop, "Active Layer Mask Index", "Active index in layer mask array");
1903 
1904  func = RNA_def_function(srna, "add", "rna_GPencil_layer_mask_add");
1905  RNA_def_function_ui_description(func, "Add a layer to mask list");
1906  parm = RNA_def_pointer(func, "layer", "GPencilLayer", "", "Layer to add as mask");
1909 
1910  func = RNA_def_function(srna, "remove", "rna_GPencil_layer_mask_remove");
1911  RNA_def_function_ui_description(func, "Remove a layer from mask list");
1913  parm = RNA_def_pointer(func, "mask", "GPencilLayerMask", "", "Mask to remove");
1916 }
1917 
1919 {
1920  StructRNA *srna;
1921  PropertyRNA *prop;
1922 
1923  srna = RNA_def_struct(brna, "GPencilLayerMask", NULL);
1924  RNA_def_struct_sdna(srna, "bGPDlayer_Mask");
1925  RNA_def_struct_ui_text(srna, "Grease Pencil Masking Layers", "List of Mask Layers");
1926  RNA_def_struct_path_func(srna, "rna_GPencilLayerMask_path");
1927 
1928  /* Name */
1929  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1930  RNA_def_property_ui_text(prop, "Layer", "Mask layer name");
1931  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GPencilLayer_mask_info_set");
1932  RNA_def_struct_name_property(srna, prop);
1935 
1936  /* Flags */
1937  prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
1939  RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1);
1940  RNA_def_property_ui_text(prop, "Hide", "Set mask Visibility");
1941  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1942 
1943  prop = RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE);
1945  RNA_def_property_ui_icon(prop, ICON_CLIPUV_HLT, -1);
1946  RNA_def_property_ui_text(prop, "Invert", "Invert mask");
1947  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1948 }
1949 
1951 {
1952  StructRNA *srna;
1953  PropertyRNA *prop;
1954 
1955  FunctionRNA *func;
1956  static const float default_onion_color_b[] = {0.302f, 0.851f, 0.302f};
1957  static const float default_onion_color_a[] = {0.250f, 0.1f, 1.0f};
1958 
1959  srna = RNA_def_struct(brna, "GPencilLayer", NULL);
1960  RNA_def_struct_sdna(srna, "bGPDlayer");
1961  RNA_def_struct_ui_text(srna, "Grease Pencil Layer", "Collection of related sketches");
1962  RNA_def_struct_path_func(srna, "rna_GPencilLayer_path");
1963 
1964  /* Name */
1965  prop = RNA_def_property(srna, "info", PROP_STRING, PROP_NONE);
1966  RNA_def_property_ui_text(prop, "Info", "Layer name");
1967  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GPencilLayer_info_set");
1968  RNA_def_struct_name_property(srna, prop);
1969  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_RENAME, "rna_GPencil_update");
1970 
1971  /* Frames */
1972  prop = RNA_def_property(srna, "frames", PROP_COLLECTION, PROP_NONE);
1973  RNA_def_property_collection_sdna(prop, NULL, "frames", NULL);
1974  RNA_def_property_struct_type(prop, "GPencilFrame");
1975  RNA_def_property_ui_text(prop, "Frames", "Sketches for this layer on different frames");
1976  rna_def_gpencil_frames_api(brna, prop);
1977 
1978  /* Mask Layers */
1979  prop = RNA_def_property(srna, "mask_layers", PROP_COLLECTION, PROP_NONE);
1980  RNA_def_property_collection_sdna(prop, NULL, "mask_layers", NULL);
1981  RNA_def_property_struct_type(prop, "GPencilLayerMask");
1982  RNA_def_property_ui_text(prop, "Masks", "List of Masking Layers");
1983  rna_def_gpencil_layers_mask_api(brna, prop);
1984 
1985  /* Active Frame */
1986  prop = RNA_def_property(srna, "active_frame", PROP_POINTER, PROP_NONE);
1987  RNA_def_property_pointer_sdna(prop, NULL, "actframe");
1988  RNA_def_property_ui_text(prop, "Active Frame", "Frame currently being displayed for this layer");
1989  RNA_def_property_editable_func(prop, "rna_GPencilLayer_active_frame_editable");
1991 
1992  /* Layer Opacity */
1993  prop = RNA_def_property(srna, "opacity", PROP_FLOAT, PROP_NONE);
1994  RNA_def_property_float_sdna(prop, NULL, "opacity");
1995  RNA_def_property_range(prop, 0.0, 1.0f);
1996  RNA_def_property_ui_text(prop, "Opacity", "Layer Opacity");
1997  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
1998 
1999  /* layer channel color (grease pencil) */
2000  prop = RNA_def_property(srna, "channel_color", PROP_FLOAT, PROP_COLOR_GAMMA);
2001  RNA_def_property_float_sdna(prop, NULL, "color");
2002  RNA_def_property_array(prop, 3);
2003  RNA_def_property_range(prop, 0.0f, 1.0f);
2006  prop, "Custom Channel Color", "Custom color for animation channel in Dopesheet");
2007  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2008 
2009  /* Stroke Drawing Color (Annotations) */
2010  prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
2011  RNA_def_property_array(prop, 3);
2012  RNA_def_property_range(prop, 0.0f, 1.0f);
2014  RNA_def_property_ui_text(prop, "Color", "Color for all strokes in this layer");
2015  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2016 
2017  /* Line Thickness (Annotations) */
2018  prop = RNA_def_property(srna, "thickness", PROP_INT, PROP_PIXEL);
2019  RNA_def_property_int_sdna(prop, NULL, "thickness");
2020  RNA_def_property_range(prop, 1, 10);
2022  RNA_def_property_ui_text(prop, "Thickness", "Thickness of annotation strokes");
2023  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2024 
2025  /* Tint Color */
2026  prop = RNA_def_property(srna, "tint_color", PROP_FLOAT, PROP_COLOR);
2027  RNA_def_property_float_sdna(prop, NULL, "tintcolor");
2028  RNA_def_property_array(prop, 3);
2029  RNA_def_property_range(prop, 0.0f, 1.0f);
2030  RNA_def_property_ui_text(prop, "Tint Color", "Color for tinting stroke colors");
2031  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2032 
2033  /* Tint factor */
2034  prop = RNA_def_property(srna, "tint_factor", PROP_FLOAT, PROP_FACTOR);
2035  RNA_def_property_float_sdna(prop, NULL, "tintcolor[3]");
2036  RNA_def_property_range(prop, 0.0, 1.0f);
2037  RNA_def_property_ui_text(prop, "Tint Factor", "Factor of tinting color");
2038  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2039 
2040  /* Vertex Paint opacity factor */
2041  prop = RNA_def_property(srna, "vertex_paint_opacity", PROP_FLOAT, PROP_FACTOR);
2042  RNA_def_property_float_sdna(prop, NULL, "vertex_paint_opacity");
2043  RNA_def_property_range(prop, 0.0f, 1.0f);
2044  RNA_def_property_float_default(prop, 1.0f);
2045  RNA_def_property_ui_text(prop, "Vertex Paint Opacity", "Vertex Paint mix factor");
2046  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2047 
2048  /* Line Thickness Change */
2049  prop = RNA_def_property(srna, "line_change", PROP_INT, PROP_PIXEL);
2050  RNA_def_property_int_sdna(prop, NULL, "line_change");
2051  RNA_def_property_range(prop, -300, 300);
2052  RNA_def_property_ui_range(prop, -100, 100, 1.0, 1);
2054  prop, "Thickness Change", "Thickness change to apply to current strokes (in pixels)");
2055  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2056 
2057  /* Onion-Skinning */
2058  prop = RNA_def_property(srna, "use_onion_skinning", PROP_BOOLEAN, PROP_NONE);
2061  prop, "Onion Skinning", "Display onion skins before and after the current frame");
2062  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2063 
2064  prop = RNA_def_property(srna, "use_annotation_onion_skinning", PROP_BOOLEAN, PROP_NONE);
2068  prop, "Onion Skinning", "Display annotation onion skins before and after the current frame");
2069  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2070 
2071  prop = RNA_def_property(srna, "annotation_onion_before_range", PROP_INT, PROP_NONE);
2072  RNA_def_property_int_sdna(prop, NULL, "gstep");
2073  RNA_def_property_range(prop, -1, 120);
2076  prop, "Frames Before", "Maximum number of frames to show before current frame");
2077  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2078 
2079  prop = RNA_def_property(srna, "annotation_onion_after_range", PROP_INT, PROP_NONE);
2080  RNA_def_property_int_sdna(prop, NULL, "gstep_next");
2081  RNA_def_property_range(prop, -1, 120);
2084  prop, "Frames After", "Maximum number of frames to show after current frame");
2085  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2086 
2087  prop = RNA_def_property(srna, "annotation_onion_before_color", PROP_FLOAT, PROP_COLOR_GAMMA);
2088  RNA_def_property_float_sdna(prop, NULL, "gcolor_prev");
2089  RNA_def_property_array(prop, 3);
2090  RNA_def_property_range(prop, 0.0f, 1.0f);
2091  RNA_def_property_float_array_default(prop, default_onion_color_b);
2093  RNA_def_property_ui_text(prop, "Before Color", "Base color for ghosts before the active frame");
2094  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2095 
2096  prop = RNA_def_property(srna, "annotation_onion_after_color", PROP_FLOAT, PROP_COLOR_GAMMA);
2097  RNA_def_property_float_sdna(prop, NULL, "gcolor_next");
2098  RNA_def_property_array(prop, 3);
2099  RNA_def_property_range(prop, 0.0f, 1.0f);
2100  RNA_def_property_float_array_default(prop, default_onion_color_a);
2102  RNA_def_property_ui_text(prop, "After Color", "Base color for ghosts after the active frame");
2103  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2104 
2105  /* pass index for compositing and modifiers */
2106  prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
2107  RNA_def_property_int_sdna(prop, NULL, "pass_index");
2108  RNA_def_property_ui_text(prop, "Pass Index", "Index number for the \"Layer Index\" pass");
2109  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2110 
2111  prop = RNA_def_property(srna, "viewlayer_render", PROP_STRING, PROP_NONE);
2112  RNA_def_property_string_sdna(prop, NULL, "viewlayername");
2114  prop,
2115  "ViewLayer",
2116  "Only include Layer in this View Layer render output (leave blank to include always)");
2117 
2118  /* blend mode */
2119  prop = RNA_def_property(srna, "blend_mode", PROP_ENUM, PROP_NONE);
2120  RNA_def_property_enum_sdna(prop, NULL, "blend_mode");
2122  RNA_def_property_ui_text(prop, "Blend Mode", "Blend mode");
2123  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2124 
2125  /* Layer transforms. */
2126  prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
2127  RNA_def_property_float_sdna(prop, NULL, "location");
2128  RNA_def_property_ui_text(prop, "Location", "Values for change location");
2129  RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
2130  RNA_def_property_update(prop, 0, "rna_GpencilLayerMatrix_update");
2131 
2132  prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_EULER);
2133  RNA_def_property_float_sdna(prop, NULL, "rotation");
2134  RNA_def_property_ui_text(prop, "Rotation", "Values for changes in rotation");
2135  RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
2136  RNA_def_property_update(prop, 0, "rna_GpencilLayerMatrix_update");
2137 
2138  prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
2139  RNA_def_property_float_sdna(prop, NULL, "scale");
2140  RNA_def_property_float_default(prop, 1.0f);
2141  RNA_def_property_ui_text(prop, "Scale", "Values for changes in scale");
2142  RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
2143  RNA_def_property_update(prop, 0, "rna_GpencilLayerMatrix_update");
2144 
2145  /* Layer matrix. */
2146  prop = RNA_def_property(srna, "matrix_layer", PROP_FLOAT, PROP_MATRIX);
2147  RNA_def_property_float_sdna(prop, NULL, "layer_mat");
2152  RNA_def_property_ui_text(prop, "Matrix Layer", "Local Layer transformation matrix");
2153 
2154  /* Layer inverse matrix. */
2155  prop = RNA_def_property(srna, "matrix_inverse_layer", PROP_FLOAT, PROP_MATRIX);
2156  RNA_def_property_float_sdna(prop, NULL, "layer_invmat");
2162  prop, "Matrix Layer Inverse", "Local Layer transformation inverse matrix");
2163 
2164  /* Flags */
2165  prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
2167  RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1);
2168  RNA_def_property_ui_text(prop, "Hide", "Set layer Visibility");
2169  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2170 
2171  prop = RNA_def_property(srna, "annotation_hide", PROP_BOOLEAN, PROP_NONE);
2173  RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1);
2175  RNA_def_property_ui_text(prop, "Hide", "Set annotation Visibility");
2176  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2177 
2178  prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
2180  RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2182  prop, "Locked", "Protect layer from further editing and/or frame changes");
2183  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2184 
2185  prop = RNA_def_property(srna, "lock_frame", PROP_BOOLEAN, PROP_NONE);
2187  RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2189  RNA_def_property_ui_text(prop, "Frame Locked", "Lock current frame displayed by layer");
2190  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2191 
2192  prop = RNA_def_property(srna, "lock_material", PROP_BOOLEAN, PROP_NONE);
2196  prop, "Disallow Locked Materials Editing", "Avoids editing locked materials in the layer");
2198 
2199  prop = RNA_def_property(srna, "use_mask_layer", PROP_BOOLEAN, PROP_NONE);
2202  prop,
2203  "Use Mask",
2204  "The visibility of drawings on this layer is affected by the layers in its masks list");
2205  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2206 
2207  prop = RNA_def_property(srna, "use_lights", PROP_BOOLEAN, PROP_NONE);
2210  prop, "Use Lights", "Enable the use of lights on stroke and fill materials");
2211  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2212 
2213  /* solo mode: Only display frames with keyframe */
2214  prop = RNA_def_property(srna, "use_solo_mode", PROP_BOOLEAN, PROP_NONE);
2217  prop, "Solo Mode", "In Paint mode display only layers with keyframe in current frame");
2218  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2219 
2220  /* Layer is used as Ruler. */
2221  prop = RNA_def_property(srna, "is_ruler", PROP_BOOLEAN, PROP_NONE);
2223  RNA_def_property_ui_text(prop, "Ruler", "This is a special ruler layer");
2225 
2226  prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
2228  RNA_def_property_ui_text(prop, "Select", "Layer is selected for editing in the Dope Sheet");
2229  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_SELECTED, "rna_GPencil_update");
2230 
2231  prop = RNA_def_property(srna, "show_points", PROP_BOOLEAN, PROP_NONE);
2234  prop, "Show Points", "Show the points which make up the strokes (for debugging purposes)");
2235  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2236 
2237  /* In Front */
2238  prop = RNA_def_property(srna, "show_in_front", PROP_BOOLEAN, PROP_NONE);
2240  RNA_def_property_ui_text(prop, "In Front", "Make the layer display in front of objects");
2241  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2242 
2243  /* Parent object */
2244  prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
2245  RNA_def_property_pointer_funcs(prop, NULL, "rna_GPencilLayer_parent_set", NULL, NULL);
2248  RNA_def_property_ui_text(prop, "Parent", "Parent object");
2249  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_dependency_update");
2250 
2251  /* parent type */
2252  prop = RNA_def_property(srna, "parent_type", PROP_ENUM, PROP_NONE);
2253  RNA_def_property_enum_bitflag_sdna(prop, NULL, "partype");
2256  prop, NULL, "rna_GPencilLayer_parent_type_set", "rna_Object_parent_type_itemf");
2257  RNA_def_property_ui_text(prop, "Parent Type", "Type of parent relation");
2258  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_dependency_update");
2259 
2260  /* parent bone */
2261  prop = RNA_def_property(srna, "parent_bone", PROP_STRING, PROP_NONE);
2262  RNA_def_property_string_sdna(prop, NULL, "parsubstr");
2263  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GPencilLayer_parent_bone_set");
2265  prop, "Parent Bone", "Name of parent bone in case of a bone parenting relation");
2266  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_dependency_update");
2267 
2268  /* matrix */
2269  prop = RNA_def_property(srna, "matrix_inverse", PROP_FLOAT, PROP_MATRIX);
2270  RNA_def_property_float_sdna(prop, NULL, "inverse");
2273  RNA_def_property_ui_text(prop, "Inverse Matrix", "Parent inverse transformation matrix");
2274  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2275 
2276  /* read only parented flag */
2277  prop = RNA_def_property(srna, "is_parented", PROP_BOOLEAN, PROP_NONE);
2278  RNA_def_property_boolean_funcs(prop, "rna_GPencilLayer_is_parented_get", NULL);
2280  RNA_def_property_ui_text(prop, "Is Parented", "True when the layer parent object is set");
2281 
2282  /* Layers API */
2283  func = RNA_def_function(srna, "clear", "rna_GPencil_layer_clear");
2284  RNA_def_function_ui_description(func, "Remove all the grease pencil layer data");
2285 }
2286 
2288 {
2289  StructRNA *srna;
2290  PropertyRNA *prop;
2291 
2292  FunctionRNA *func;
2293  PropertyRNA *parm;
2294 
2295  RNA_def_property_srna(cprop, "GreasePencilLayers");
2296  srna = RNA_def_struct(brna, "GreasePencilLayers", NULL);
2297  RNA_def_struct_sdna(srna, "bGPdata");
2298  RNA_def_struct_ui_text(srna, "Grease Pencil Layers", "Collection of grease pencil layers");
2299 
2300  func = RNA_def_function(srna, "new", "rna_GPencil_layer_new");
2301  RNA_def_function_ui_description(func, "Add a new grease pencil layer");
2302  parm = RNA_def_string(func, "name", "GPencilLayer", MAX_NAME, "Name", "Name of the layer");
2305  func, "set_active", true, "Set Active", "Set the newly created layer to the active layer");
2306  parm = RNA_def_pointer(func, "layer", "GPencilLayer", "", "The newly created layer");
2307  RNA_def_function_return(func, parm);
2308 
2309  func = RNA_def_function(srna, "remove", "rna_GPencil_layer_remove");
2310  RNA_def_function_ui_description(func, "Remove a grease pencil layer");
2312  parm = RNA_def_pointer(func, "layer", "GPencilLayer", "", "The layer to remove");
2315 
2316  func = RNA_def_function(srna, "move", "rna_GPencil_layer_move");
2317  RNA_def_function_ui_description(func, "Move a grease pencil layer in the layer stack");
2319  parm = RNA_def_pointer(func, "layer", "GPencilLayer", "", "The layer to move");
2322  parm = RNA_def_enum(
2323  func, "type", rna_enum_gplayer_move_type_items, 1, "", "Direction of movement");
2325 
2326  prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2327  RNA_def_property_struct_type(prop, "GPencilLayer");
2329  prop, "rna_GPencil_active_layer_get", "rna_GPencil_active_layer_set", NULL, NULL);
2331  RNA_def_property_ui_text(prop, "Active Layer", "Active grease pencil layer");
2333 
2334  prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
2336  "rna_GPencil_active_layer_index_get",
2337  "rna_GPencil_active_layer_index_set",
2338  "rna_GPencil_active_layer_index_range");
2339  RNA_def_property_ui_text(prop, "Active Layer Index", "Index of active grease pencil layer");
2341 
2342  /* Active Layer - As an enum (for selecting active layer for annotations) */
2343  prop = RNA_def_property(srna, "active_note", PROP_ENUM, PROP_NONE);
2345  "rna_GPencil_active_layer_index_get",
2346  "rna_GPencil_active_layer_index_set",
2347  "rna_GPencil_active_layer_itemf");
2349  prop, DummyRNA_DEFAULT_items); /* purely dynamic, as it maps to user-data */
2350  RNA_def_property_ui_text(prop, "Active Note", "Note/Layer to add annotation strokes to");
2351  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2352 }
2353 
2355 {
2356  StructRNA *srna;
2357  PropertyRNA *prop;
2358 
2359  static const float default_grid_color[] = {0.5f, 0.5f, 0.5f};
2360 
2361  srna = RNA_def_struct(brna, "GreasePencilGrid", NULL);
2362  RNA_def_struct_sdna(srna, "bGPgrid");
2363  RNA_def_struct_nested(brna, srna, "GreasePencil");
2364 
2365  RNA_def_struct_path_func(srna, "rna_GreasePencilGrid_path");
2367  srna, "Grid and Canvas Settings", "Settings for grid and canvas in 3D viewport");
2368 
2369  prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
2370  RNA_def_property_float_sdna(prop, NULL, "scale");
2371  RNA_def_property_range(prop, 0.01f, FLT_MAX);
2372  RNA_def_property_float_default(prop, 1.0f);
2373  RNA_def_property_ui_text(prop, "Grid Scale", "Grid scale");
2374  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2375 
2376  prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
2377  RNA_def_property_float_sdna(prop, NULL, "color");
2378  RNA_def_property_array(prop, 3);
2379  RNA_def_property_range(prop, 0.0f, 1.0f);
2380  RNA_def_property_float_array_default(prop, default_grid_color);
2381  RNA_def_property_ui_text(prop, "Grid Color", "Color for grid lines");
2382  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2383 
2384  prop = RNA_def_property(srna, "lines", PROP_INT, PROP_NONE);
2385  RNA_def_property_int_sdna(prop, NULL, "lines");
2386  RNA_def_property_range(prop, 0, SHRT_MAX);
2389  prop, "Grid Subdivisions", "Number of subdivisions in each side of symmetry line");
2390  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2391 
2392  prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_TRANSLATION);
2393  RNA_def_property_float_sdna(prop, NULL, "offset");
2394  RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
2395  RNA_def_property_array(prop, 2);
2396  RNA_def_property_ui_text(prop, "Offset", "Offset of the canvas");
2397  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2398 }
2399 
2401 {
2402  StructRNA *srna;
2403  PropertyRNA *prop;
2404  FunctionRNA *func;
2405 
2406  static float default_1[4] = {0.6f, 0.6f, 0.6f, 0.5f};
2407  static float onion_dft1[3] = {0.145098f, 0.419608f, 0.137255f}; /* green */
2408  static float onion_dft2[3] = {0.125490f, 0.082353f, 0.529412f}; /* blue */
2409 
2410  static const EnumPropertyItem stroke_thickness_items[] = {
2411  {0, "WORLDSPACE", 0, "World Space", "Set stroke thickness relative to the world space"},
2413  "SCREENSPACE",
2414  0,
2415  "Screen Space",
2416  "Set stroke thickness relative to the screen space"},
2417  {0, NULL, 0, NULL, NULL},
2418  };
2419 
2420  srna = RNA_def_struct(brna, "GreasePencil", "ID");
2421  RNA_def_struct_sdna(srna, "bGPdata");
2422  RNA_def_struct_ui_text(srna, "Grease Pencil", "Freehand annotation sketchbook");
2423  RNA_def_struct_ui_icon(srna, ICON_OUTLINER_DATA_GREASEPENCIL);
2424 
2425  /* Layers */
2426  prop = RNA_def_property(srna, "layers", PROP_COLLECTION, PROP_NONE);
2427  RNA_def_property_collection_sdna(prop, NULL, "layers", NULL);
2428  RNA_def_property_struct_type(prop, "GPencilLayer");
2429  RNA_def_property_ui_text(prop, "Layers", "");
2430  rna_def_gpencil_layers_api(brna, prop);
2431 
2432  /* Animation Data */
2434 
2435  /* materials */
2436  prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
2437  RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
2438  RNA_def_property_struct_type(prop, "Material");
2439  RNA_def_property_ui_text(prop, "Materials", "");
2440  RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
2442  prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int");
2443 
2444  /* Depth */
2445  prop = RNA_def_property(srna, "stroke_depth_order", PROP_ENUM, PROP_NONE);
2446  RNA_def_property_enum_sdna(prop, NULL, "draw_mode");
2449  prop,
2450  "Stroke Depth Order",
2451  "Defines how the strokes are ordered in 3D space (for objects not displayed 'In Front')");
2452  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2453 
2454  /* Flags */
2455  prop = RNA_def_property(srna, "use_stroke_edit_mode", PROP_BOOLEAN, PROP_NONE);
2458  prop, "Stroke Edit Mode", "Edit Grease Pencil strokes instead of viewport data");
2460  prop, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, "rna_GPencil_editmode_update");
2461 
2462  prop = RNA_def_property(srna, "is_stroke_paint_mode", PROP_BOOLEAN, PROP_NONE);
2464  RNA_def_property_ui_text(prop, "Stroke Paint Mode", "Draw Grease Pencil strokes on click/drag");
2467  prop, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, "rna_GPencil_editmode_update");
2468 
2469  prop = RNA_def_property(srna, "is_stroke_sculpt_mode", PROP_BOOLEAN, PROP_NONE);
2472  prop, "Stroke Sculpt Mode", "Sculpt Grease Pencil strokes instead of viewport data");
2475  prop, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, "rna_GPencil_editmode_update");
2476 
2477  prop = RNA_def_property(srna, "is_stroke_weight_mode", PROP_BOOLEAN, PROP_NONE);
2479  RNA_def_property_ui_text(prop, "Stroke Weight Paint Mode", "Grease Pencil weight paint");
2482  prop, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, "rna_GPencil_editmode_update");
2483 
2484  prop = RNA_def_property(srna, "is_stroke_vertex_mode", PROP_BOOLEAN, PROP_NONE);
2486  RNA_def_property_ui_text(prop, "Stroke Vertex Paint Mode", "Grease Pencil vertex paint");
2489  prop, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, "rna_GPencil_editmode_update");
2490 
2491  prop = RNA_def_property(srna, "use_onion_skinning", PROP_BOOLEAN, PROP_NONE);
2495  prop, "Onion Skins", "Show ghosts of the keyframes before and after the current frame");
2497  prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update");
2498 
2499  prop = RNA_def_property(srna, "stroke_thickness_space", PROP_ENUM, PROP_NONE); /* as an enum */
2501  RNA_def_property_enum_items(prop, stroke_thickness_items);
2503  prop, "Stroke Thickness", "Set stroke thickness in screen space or world space");
2504  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2505 
2506  prop = RNA_def_property(srna, "pixel_factor", PROP_FLOAT, PROP_NONE);
2507  RNA_def_property_float_sdna(prop, NULL, "pixfactor");
2508  RNA_def_property_range(prop, 0.1f, 30.0f);
2509  RNA_def_property_ui_range(prop, 0.1f, 30.0f, 1, 2);
2511  prop,
2512  "Scale",
2513  "Scale conversion factor for pixel size (use larger values for thicker lines)");
2514  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2515 
2516  prop = RNA_def_property(srna, "edit_curve_resolution", PROP_INT, PROP_NONE);
2517  RNA_def_property_int_sdna(prop, NULL, "curve_edit_resolution");
2518  RNA_def_property_range(prop, 1, 256);
2519  RNA_def_property_ui_range(prop, 1, 64, 1, 1);
2523  prop,
2524  "Curve Resolution",
2525  "Number of segments generated between control points when editing strokes in curve mode");
2527  prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_resolution_update");
2528 
2529  prop = RNA_def_property(srna, "use_adaptive_curve_resolution", PROP_BOOLEAN, PROP_NONE);
2533  "Adaptive Resolution",
2534  "Set the resolution of each editcurve segment dynamically depending on "
2535  "the length of the segment. The resolution is the number of points "
2536  "generated per unit distance");
2538  prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_resolution_update");
2539 
2540  /* Curve editing error threshold. */
2541  prop = RNA_def_property(srna, "curve_edit_threshold", PROP_FLOAT, PROP_FACTOR);
2542  RNA_def_property_float_sdna(prop, NULL, "curve_edit_threshold");
2543  RNA_def_property_range(prop, FLT_MIN, 10.0);
2545  RNA_def_property_ui_text(prop, "Threshold", "Curve conversion error threshold");
2546  RNA_def_property_ui_range(prop, FLT_MIN, 10.0, 2, 5);
2548 
2549  /* Curve editing corner angle. */
2550  prop = RNA_def_property(srna, "curve_edit_corner_angle", PROP_FLOAT, PROP_ANGLE);
2551  RNA_def_property_float_sdna(prop, NULL, "curve_edit_corner_angle");
2552  RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
2554  RNA_def_property_ui_text(prop, "Corner Angle", "Angle threshold to be treated as corners");
2556 
2557  prop = RNA_def_property(srna, "use_multiedit", PROP_BOOLEAN, PROP_NONE);
2560  "Multiframe",
2561  "Edit strokes from multiple grease pencil keyframes at the same time "
2562  "(keyframes must be selected to be included)");
2563  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2564 
2565  prop = RNA_def_property(srna, "use_curve_edit", PROP_BOOLEAN, PROP_NONE);
2567  RNA_def_property_ui_text(prop, "Curve Editing", "Edit strokes using curve handles");
2568  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_curve_edit_mode_toggle");
2569 
2570  prop = RNA_def_property(srna, "use_autolock_layers", PROP_BOOLEAN, PROP_NONE);
2573  prop,
2574  "Auto-Lock Layers",
2575  "Lock automatically all layers except active one to avoid accidental changes");
2576  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_autolock");
2577 
2578  prop = RNA_def_property(srna, "edit_line_color", PROP_FLOAT, PROP_COLOR_GAMMA);
2579  RNA_def_property_float_sdna(prop, NULL, "line_color");
2580  RNA_def_property_array(prop, 4);
2581  RNA_def_property_range(prop, 0.0f, 1.0f);
2582  RNA_def_property_float_array_default(prop, default_1);
2583  RNA_def_property_ui_text(prop, "Edit Line Color", "Color for editing line");
2584  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2585 
2586  /* onion skinning */
2587  prop = RNA_def_property(srna, "ghost_before_range", PROP_INT, PROP_NONE);
2588  RNA_def_property_int_sdna(prop, NULL, "gstep");
2589  RNA_def_property_range(prop, 0, 120);
2593  "Frames Before",
2594  "Maximum number of frames to show before current frame "
2595  "(0 = don't show any frames before current)");
2596  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2597 
2598  prop = RNA_def_property(srna, "ghost_after_range", PROP_INT, PROP_NONE);
2599  RNA_def_property_int_sdna(prop, NULL, "gstep_next");
2600  RNA_def_property_range(prop, 0, 120);
2604  "Frames After",
2605  "Maximum number of frames to show after current frame "
2606  "(0 = don't show any frames after current)");
2607  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2608 
2609  prop = RNA_def_property(srna, "use_ghost_custom_colors", PROP_BOOLEAN, PROP_NONE);
2611  prop, NULL, "onion_flag", GP_ONION_GHOST_PREVCOL | GP_ONION_GHOST_NEXTCOL);
2613  RNA_def_property_ui_text(prop, "Use Custom Ghost Colors", "Use custom colors for ghost frames");
2614  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2615 
2616  prop = RNA_def_property(srna, "before_color", PROP_FLOAT, PROP_COLOR);
2617  RNA_def_property_float_sdna(prop, NULL, "gcolor_prev");
2618  RNA_def_property_array(prop, 3);
2619  RNA_def_property_range(prop, 0.0f, 1.0f);
2620  RNA_def_property_float_array_default(prop, onion_dft1);
2622  RNA_def_property_ui_text(prop, "Before Color", "Base color for ghosts before the active frame");
2624  prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update");
2625 
2626  prop = RNA_def_property(srna, "after_color", PROP_FLOAT, PROP_COLOR);
2627  RNA_def_property_float_sdna(prop, NULL, "gcolor_next");
2628  RNA_def_property_array(prop, 3);
2629  RNA_def_property_range(prop, 0.0f, 1.0f);
2630  RNA_def_property_float_array_default(prop, onion_dft2);
2632  RNA_def_property_ui_text(prop, "After Color", "Base color for ghosts after the active frame");
2634  prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update");
2635 
2636  prop = RNA_def_property(srna, "use_ghosts_always", PROP_BOOLEAN, PROP_NONE);
2640  "Always Show Ghosts",
2641  "Ghosts are shown in renders and animation playback. Useful for "
2642  "special effects (e.g. motion blur)");
2643  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2644 
2645  prop = RNA_def_property(srna, "onion_mode", PROP_ENUM, PROP_NONE);
2646  RNA_def_property_enum_sdna(prop, NULL, "onion_mode");
2649  RNA_def_property_ui_text(prop, "Mode", "Mode to display frames");
2650  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2651 
2652  prop = RNA_def_property(srna, "onion_keyframe_type", PROP_ENUM, PROP_NONE);
2653  RNA_def_property_enum_sdna(prop, NULL, "onion_keytype");
2656  RNA_def_property_ui_text(prop, "Filter by Type", "Type of keyframe (for filtering)");
2657  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2658 
2659  prop = RNA_def_property(srna, "use_onion_fade", PROP_BOOLEAN, PROP_NONE);
2660  RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_ONION_FADE);
2663  prop, "Fade", "Display onion keyframes with a fade in color transparency");
2664  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2665 
2666  prop = RNA_def_property(srna, "use_onion_loop", PROP_BOOLEAN, PROP_NONE);
2667  RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_ONION_LOOP);
2670  prop, "Show Start Frame", "Display onion keyframes for looping animations");
2671  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2672 
2673  prop = RNA_def_property(srna, "onion_factor", PROP_FLOAT, PROP_NONE);
2674  RNA_def_property_float_sdna(prop, NULL, "onion_factor");
2675  RNA_def_property_float_default(prop, 0.5f);
2676  RNA_def_property_range(prop, 0.0, 1.0f);
2678  RNA_def_property_ui_text(prop, "Onion Opacity", "Change fade opacity of displayed onion frames");
2679  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2680 
2681  prop = RNA_def_property(srna, "zdepth_offset", PROP_FLOAT, PROP_NONE);
2682  RNA_def_property_float_sdna(prop, NULL, "zdepth_offset");
2683  RNA_def_property_range(prop, 0.0f, 1.0f);
2684  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1f, 3);
2685  RNA_def_property_float_default(prop, 0.150f);
2686  RNA_def_property_ui_text(prop, "Surface Offset", "Offset amount when drawing in surface mode");
2687  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
2688 
2689  prop = RNA_def_property(srna, "is_annotation", PROP_BOOLEAN, PROP_NONE);
2692  RNA_def_property_ui_text(prop, "Annotation", "Current data-block is an annotation");
2693 
2694  /* Nested Structs */
2695  prop = RNA_def_property(srna, "grid", PROP_POINTER, PROP_NONE);
2697  RNA_def_property_struct_type(prop, "GreasePencilGrid");
2699  prop, "Grid Settings", "Settings for grid and canvas in the 3D viewport");
2700 
2701  rna_def_gpencil_grid(brna);
2702 
2703  /* API Functions */
2704  func = RNA_def_function(srna, "clear", "rna_GPencil_clear");
2705  RNA_def_function_ui_description(func, "Remove all the Grease Pencil data");
2706 }
2707 
2708 /* --- */
2709 
2711 {
2712  rna_def_gpencil_data(brna);
2713 
2714  rna_def_gpencil_layer(brna);
2716  rna_def_gpencil_frame(brna);
2717 
2718  rna_def_gpencil_stroke(brna);
2721  rna_def_gpencil_curve(brna);
2723 
2725 }
2726 
2727 #endif
Blender kernel action and pose functionality.
struct bPoseChannel * BKE_pose_channel_find_name(const struct bPose *pose, const char *name)
void BKE_animdata_fix_paths_rename_all(struct ID *ref_id, const char *prefix, const char *oldName, const char *newName)
Definition: anim_data.c:1414
support for deformation groups and hooks.
struct MDeformWeight * BKE_defvert_ensure_index(struct MDeformVert *dv, const int defgroup)
Definition: deform.c:688
struct MDeformWeight * BKE_defvert_find_index(const struct MDeformVert *dv, const int defgroup)
bool BKE_gpencil_free_strokes(struct bGPDframe *gpf)
Definition: gpencil.c:425
void BKE_gpencil_stroke_select_index_set(struct bGPdata *gpd, struct bGPDstroke *gps)
Definition: gpencil.c:1203
struct bGPDframe * BKE_gpencil_frame_addnew(struct bGPDlayer *gpl, int cframe)
Definition: gpencil.c:539
void BKE_gpencil_layer_active_set(struct bGPdata *gpd, struct bGPDlayer *active)
Definition: gpencil.c:1698
struct bGPDlayer * BKE_gpencil_layer_active_get(struct bGPdata *gpd)
Definition: gpencil.c:1650
void BKE_gpencil_stroke_select_index_reset(struct bGPDstroke *gps)
Definition: gpencil.c:1210
void BKE_gpencil_free_frames(struct bGPDlayer *gpl)
Definition: gpencil.c:439
void BKE_gpencil_layer_mask_remove(struct bGPDlayer *gpl, struct bGPDlayer_Mask *mask)
Definition: gpencil.c:1540
struct bGPDlayer_Mask * BKE_gpencil_layer_mask_add(struct bGPDlayer *gpl, const char *name)
Definition: gpencil.c:1524
void BKE_gpencil_dvert_ensure(struct bGPDstroke *gps)
Definition: gpencil.c:2067
bool BKE_gpencil_layer_frame_delete(struct bGPDlayer *gpl, struct bGPDframe *gpf)
Definition: gpencil.c:1467
struct bGPDstroke * BKE_gpencil_stroke_new(int mat_idx, int totpoints, short thickness)
Definition: gpencil.c:826
struct bGPDlayer * BKE_gpencil_layer_named_get(struct bGPdata *gpd, const char *name)
Definition: gpencil.c:1496
struct bGPDframe * BKE_gpencil_layer_frame_find(struct bGPDlayer *gpl, int cframe)
Definition: gpencil.c:1281
void BKE_gpencil_free_stroke(struct bGPDstroke *gps)
Definition: gpencil.c:401
struct bGPDframe * BKE_gpencil_layer_frame_get(struct bGPDlayer *gpl, int cframe, eGP_GetFrame_Mode addnew)
Definition: gpencil.c:1307
struct bGPDframe * BKE_gpencil_frame_duplicate(const struct bGPDframe *gpf_src, const bool dup_strokes)
void BKE_gpencil_layer_delete(struct bGPdata *gpd, struct bGPDlayer *gpl)
Definition: gpencil.c:1760
void BKE_gpencil_free_layers(struct ListBase *list)
Definition: gpencil.c:469
struct bGPDlayer * BKE_gpencil_layer_addnew(struct bGPdata *gpd, const char *name, bool setactive)
Definition: gpencil.c:659
void BKE_gpencil_layer_autolock_set(struct bGPdata *gpd, const bool unlock)
Definition: gpencil.c:1725
@ GP_GETFRAME_USE_PREV
Definition: BKE_gpencil.h:187
void BKE_gpencil_stroke_sync_selection(struct bGPdata *gpd, struct bGPDstroke *gps)
Definition: gpencil.c:1139
void BKE_gpencil_strokes_selected_update_editcurve(struct bGPdata *gpd)
void BKE_gpencil_strokes_selected_sync_selection_editcurve(struct bGPdata *gpd)
void BKE_gpencil_stroke_geometry_update(struct bGPdata *gpd, struct bGPDstroke *gps)
bool BKE_gpencil_stroke_close(struct bGPDstroke *gps)
int BKE_icon_gplayer_color_ensure(struct bGPDlayer *gpl)
Definition: icons.cc:785
void BKE_report(ReportList *reports, ReportType type, const char *message)
Definition: report.c:104
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:110
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:133
void void void bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step) ATTR_NONNULL()
Definition: listbase.c:475
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
#define M_PI_2
Definition: BLI_math_base.h:41
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
Definition: math_matrix.c:262
bool invert_m4_m4(float R[4][4], const float A[4][4])
Definition: math_matrix.c:1278
void loc_eul_size_to_mat4(float R[4][4], const float loc[3], const float eul[3], const float size[3])
Definition: math_matrix.c:2653
#define DEG2RADF(_deg)
MINLINE void copy_v3_v3(float r[3], const float a[3])
size_t size_t char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
size_t size_t char size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, const size_t dst_maxncpy) ATTR_NONNULL()
Definition: string.c:333
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
Definition: string.c:70
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition: string.c:108
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string_utf8.c:258
bool BLI_uniquename(struct ListBase *list, void *vlink, const char *defname, char delim, int name_offset, size_t len)
Definition: string_utils.c:381
#define UNUSED(x)
#define ELEM(...)
#define STREQ(a, b)
#define DATA_(msgid)
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
@ ID_RECALC_TRANSFORM
Definition: DNA_ID.h:599
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:654
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:611
@ ID_GD
Definition: DNA_ID_enums.h:83
#define BEZT_SEL_ALL(bezt)
#define BEZT_DESEL_ALL(bezt)
@ BEZT_KEYTYPE_EXTREME
@ BEZT_KEYTYPE_JITTER
@ BEZT_KEYTYPE_BREAKDOWN
@ BEZT_KEYTYPE_MOVEHOLD
@ BEZT_KEYTYPE_KEYFRAME
#define MAX_NAME
Definition: DNA_defs.h:62
@ GP_ONION_MODE_RELATIVE
@ GP_ONION_MODE_SELECTED
@ GP_ONION_MODE_ABSOLUTE
@ GP_MASK_INVERT
@ GP_MASK_HIDE
@ GP_DRAWMODE_3D
@ GP_DRAWMODE_2D
@ GP_CURVE_SELECT
@ GP_STROKE_CAP_ROUND
@ GP_STROKE_CAP_FLAT
@ GP_STROKE_NOFILL
@ GP_STROKE_2DIMAGE
@ GP_STROKE_NEEDS_CURVE_UPDATE
@ GP_STROKE_SELECT
@ GP_STROKE_CYCLIC
@ GP_STROKE_2DSPACE
@ GP_STROKE_3DSPACE
#define GP_DEFAULT_CURVE_RESOLUTION
@ GP_LAYER_NO_XRAY
@ GP_LAYER_SOLO_MODE
@ GP_LAYER_IS_RULER
@ GP_LAYER_LOCKED
@ GP_LAYER_DRAWDEBUG
@ GP_LAYER_FRAMELOCK
@ GP_LAYER_ACTIVE
@ GP_LAYER_SELECT
@ GP_LAYER_USE_MASK
@ GP_LAYER_UNLOCK_COLOR
@ GP_LAYER_HIDE
@ GP_LAYER_USE_LIGHTS
#define GP_DEFAULT_GRID_LINES
@ GP_LAYER_ONIONSKIN
#define GP_DEFAULT_CURVE_ERROR
@ GP_ONION_GHOST_NEXTCOL
@ GP_ONION_GHOST_ALWAYS
@ GP_ONION_GHOST_PREVCOL
@ GP_ONION_FADE
@ GP_ONION_LOOP
@ GP_FRAME_SELECT
@ GP_FRAME_PAINT
@ GP_DATA_SHOW_ONIONSKINS
@ GP_DATA_CURVE_ADAPTIVE_RESOLUTION
@ GP_DATA_STROKE_WEIGHTMODE
@ GP_DATA_STROKE_VERTEXMODE
@ GP_DATA_CURVE_EDIT_MODE
@ GP_DATA_STROKE_MULTIEDIT
@ GP_DATA_STROKE_PAINTMODE
@ GP_DATA_STROKE_SCULPTMODE
@ GP_DATA_AUTOLOCK_LAYERS
@ GP_DATA_STROKE_KEEPTHICKNESS
@ GP_DATA_ANNOTATIONS
@ GP_DATA_STROKE_EDITMODE
#define GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)
@ GP_CURVE_POINT_SELECT
@ eGplBlendMode_Regular
@ eGplBlendMode_Add
@ eGplBlendMode_Multiply
@ eGplBlendMode_Divide
@ eGplBlendMode_Subtract
@ eGplBlendMode_HardLight
@ GP_SPOINT_SELECT
Object is a sort of wrapper for general info.
@ PARSKEL
@ PAROBJECT
@ PARBONE
@ OB_ARMATURE
#define MINAFRAME
@ GP_SELECTMODE_POINT
@ GP_SELECTMODE_SEGMENT
#define MAXFRAME
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Read Guarded memory(de)allocation.
#define RNA_POINTER_INVALIDATE(ptr)
Definition: RNA_access.h:1425
StructRNA RNA_GPencilLayer
@ PARM_RNAPTR
Definition: RNA_types.h:339
@ PARM_REQUIRED
Definition: RNA_types.h:337
@ FUNC_USE_REPORTS
Definition: RNA_types.h:578
@ FUNC_USE_SELF_ID
Definition: RNA_types.h:565
@ PROP_FLOAT
Definition: RNA_types.h:75
@ PROP_BOOLEAN
Definition: RNA_types.h:73
@ PROP_ENUM
Definition: RNA_types.h:77
@ PROP_INT
Definition: RNA_types.h:74
@ PROP_STRING
Definition: RNA_types.h:76
@ PROP_POINTER
Definition: RNA_types.h:78
@ PROP_COLLECTION
Definition: RNA_types.h:79
#define RNA_TRANSLATION_PREC_DEFAULT
Definition: RNA_types.h:104
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition: RNA_types.h:297
@ PROPOVERRIDE_NO_COMPARISON
Definition: RNA_types.h:305
@ PROP_THICK_WRAP
Definition: RNA_types.h:270
@ PROP_ANIMATABLE
Definition: RNA_types.h:188
@ PROP_EDITABLE
Definition: RNA_types.h:175
@ PROP_NEVER_NULL
Definition: RNA_types.h:225
@ PROP_ID_SELF_CHECK
Definition: RNA_types.h:218
@ PROP_MATRIX
Definition: RNA_types.h:144
@ PROP_XYZ
Definition: RNA_types.h:148
@ PROP_COLOR
Definition: RNA_types.h:139
@ PROP_PIXEL
Definition: RNA_types.h:128
@ PROP_ANGLE
Definition: RNA_types.h:132
@ PROP_EULER
Definition: RNA_types.h:145
@ PROP_NONE
Definition: RNA_types.h:113
@ PROP_FACTOR
Definition: RNA_types.h:131
@ PROP_COLOR_GAMMA
Definition: RNA_types.h:151
@ PROP_TRANSLATION
Definition: RNA_types.h:140
@ PROP_UNSIGNED
Definition: RNA_types.h:129
#define C
Definition: RandGen.cpp:39
#define ND_DATA
Definition: WM_types.h:408
#define ND_GPENCIL_EDITMODE
Definition: WM_types.h:403
#define NC_SCREEN
Definition: WM_types.h:278
#define NC_MOVIECLIP
Definition: WM_types.h:298
#define ND_MODE
Definition: WM_types.h:345
#define ND_SPACE_PROPERTIES
Definition: WM_types.h:424
#define NC_SCENE
Definition: WM_types.h:279
#define ND_TOOLSETTINGS
Definition: WM_types.h:349
#define NA_EDITED
Definition: WM_types.h:462
#define ND_PARENT
Definition: WM_types.h:368
#define NC_GPENCIL
Definition: WM_types.h:300
#define NA_RENAME
Definition: WM_types.h:466
#define NC_OBJECT
Definition: WM_types.h:280
#define NA_SELECTED
Definition: WM_types.h:467
return(oflags[bm->toolflag_index].f &oflag) !=0
Scene scene
int count
#define GS(x)
Definition: iris.c:241
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_recallocN_id)(void *vmemh, size_t len, const char *str)
Definition: mallocn.c:44
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
bool active
all scheduled work for the GPU.
PointerRNA rna_pointer_inherit_refine(PointerRNA *ptr, StructRNA *type, void *data)
Definition: rna_access.c:196
void rna_def_animdata_common(StructRNA *srna)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3825
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2762
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
Definition: rna_define.c:1212
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3481
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4159
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
Definition: rna_define.c:2257
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1555
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
Definition: rna_define.c:3312
void RNA_def_property_float_default(PropertyRNA *prop, float value)
Definition: rna_define.c:2042
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
Definition: rna_define.c:4302
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3153
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1676
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2717
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
Definition: rna_define.c:1684
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4262
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
Definition: rna_define.c:3462
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
Definition: rna_define.c:3408
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1259
void RNA_def_property_boolean_default(PropertyRNA *prop, bool value)
Definition: rna_define.c:1957
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
Definition: rna_define.c:2971
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
Definition: rna_define.c:1629
void RNA_def_property_int_default(PropertyRNA *prop, int value)
Definition: rna_define.c:1998
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
Definition: rna_define.c:1892
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
Definition: rna_define.c:1067
void RNA_def_property_array(PropertyRNA *prop, int length)
Definition: rna_define.c:1568
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
Definition: rna_define.c:1757
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
Definition: rna_define.c:1792
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
Definition: rna_define.c:2791
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4337
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
Definition: rna_define.c:2927
const int rna_matrix_dimsize_4x4[]
Definition: rna_define.c:1626
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
Definition: rna_define.c:3251
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
Definition: rna_define.c:2877
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1279
void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2691
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
Definition: rna_define.c:4470
void RNA_def_struct_name_property(struct StructRNA *srna, struct PropertyRNA *prop)
Definition: rna_define.c:1122
void RNA_def_function_flag(FunctionRNA *func, int flag)
Definition: rna_define.c:4332
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1517
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
Definition: rna_define.c:3373
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1047
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2623
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
Definition: rna_define.c:4416
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3055
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
Definition: rna_define.c:1267
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3675
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1512
void RNA_def_property_override_clear_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
Definition: rna_define.c:1530
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3585
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2515
void RNA_enum_items_add_value(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item, int value)
Definition: rna_define.c:4455
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
Definition: rna_define.c:1706
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3771
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2364
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
Definition: rna_define.c:2064
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
Definition: rna_define.c:2348
void RNA_def_struct_nested(BlenderRNA *brna, StructRNA *srna, const char *structname)
Definition: rna_define.c:1138
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
Definition: rna_define.c:1525
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1547
static void rna_def_gpencil_stroke(BlenderRNA *brna)
Definition: rna_gpencil.c:1586
static EnumPropertyItem rna_enum_gpencil_stroke_depth_order_items[]
Definition: rna_gpencil.c:55
static void rna_def_gpencil_layers_api(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_gpencil.c:2287
static void rna_def_gpencil_mvert_group(BlenderRNA *brna)
Definition: rna_gpencil.c:1561
static EnumPropertyItem rna_enum_gpencil_onion_modes_items[]
Definition: rna_gpencil.c:65
static void rna_def_gpencil_frames_api(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_gpencil.c:1838
static const EnumPropertyItem rna_enum_layer_blend_modes_items[]
Definition: rna_gpencil.c:145
static void rna_def_gpencil_grid(BlenderRNA *brna)
Definition: rna_gpencil.c:2354
static const EnumPropertyItem parent_type_items[]
Definition: rna_gpencil.c:47
static void rna_def_gpencil_layers_mask_api(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_gpencil.c:1882
static const EnumPropertyItem rna_enum_gpencil_caps_modes_items[]
Definition: rna_gpencil.c:154
void RNA_def_gpencil(BlenderRNA *brna)
Definition: rna_gpencil.c:2710
static void rna_def_gpencil_stroke_points_api(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_gpencil.c:1294
static const EnumPropertyItem rna_enum_gplayer_move_type_items[]
Definition: rna_gpencil.c:139
static void rna_def_gpencil_data(BlenderRNA *brna)
Definition: rna_gpencil.c:2400
static void rna_def_gpencil_strokes_api(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_gpencil.c:1758
static void rna_def_gpencil_stroke_point(BlenderRNA *brna)
Definition: rna_gpencil.c:1231
static void rna_def_gpencil_curve_point(BlenderRNA *brna)
Definition: rna_gpencil.c:1418
static void rna_def_gpencil_triangle(BlenderRNA *brna)
Definition: rna_gpencil.c:1390
static void rna_def_gpencil_layer(BlenderRNA *brna)
Definition: rna_gpencil.c:1950
static const EnumPropertyItem rna_enum_keyframe_type_items[]
Definition: rna_gpencil.c:80
static const EnumPropertyItem rna_enum_onion_keyframe_type_items[]
Definition: rna_gpencil.c:109
static void rna_def_gpencil_curve(BlenderRNA *brna)
Definition: rna_gpencil.c:1540
static void rna_def_gpencil_frame(BlenderRNA *brna)
Definition: rna_gpencil.c:1790
static void rna_def_gpencil_layer_mask(BlenderRNA *brna)
Definition: rna_gpencil.c:1918
bool rna_GPencil_datablocks_obdata_poll(struct PointerRNA *ptr, const struct PointerRNA value)
bool rna_GPencil_datablocks_annotations_poll(struct PointerRNA *ptr, const struct PointerRNA value)
const EnumPropertyItem DummyRNA_DEFAULT_items[]
Definition: rna_rna.c:45
const EnumPropertyItem DummyRNA_NULL_items[]
Definition: rna_rna.c:40
#define min(a, b)
Definition: sort.c:51
float vec[3][3]
const char * identifier
Definition: RNA_types.h:446
Definition: DNA_ID.h:273
char name[66]
Definition: DNA_ID.h:283
void * first
Definition: DNA_listBase.h:47
struct MDeformWeight * dw
Definition: BKE_main.h:116
struct bPose * pose
float obmat[4][4]
void * data
Definition: RNA_types.h:52
struct ID * owner_id
Definition: RNA_types.h:50
struct ToolSettings * toolsettings
char gpencil_selectmode_edit
bGPDcurve_point * curve_points
ListBase strokes
float inverse[4][4]
struct Object * parent
char info[128]
struct bGPDlayer * next
bGPDframe * actframe
float layer_mat[4][4]
char parsubstr[64]
float layer_invmat[4][4]
ListBase frames
ListBase mask_layers
float rotation[3]
float scale[3]
float location[3]
bGPDspoint * points
struct bGPDcurve * editcurve
struct MDeformVert * dvert
struct bGPDstroke * next
ListBase layers
float pose_mat[4][4]
float max
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
void WM_main_add_notifier(unsigned int type, void *reference)
PointerRNA * ptr
Definition: wm_files.c:3157