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
17 /** \file
18 * \ingroup RNA
19 */
20
21 #include <stdio.h>
22 #include <stdlib.h>
23
24 #include "BLI_utildefines.h"
25
26 #include "RNA_define.h"
27 #include "RNA_enum_types.h"
28
29 #include "rna_internal.h"
30
31 #include "DNA_linestyle_types.h"
32 #include "DNA_material_types.h"
33 #include "DNA_texture_types.h"
34
35 #include "WM_api.h"
36 #include "WM_types.h"
37
38 const EnumPropertyItem rna_enum_linestyle_color_modifier_type_items[] = {
39 {LS_MODIFIER_ALONG_STROKE, "ALONG_STROKE", ICON_MODIFIER, "Along Stroke", ""},
40 {LS_MODIFIER_CREASE_ANGLE, "CREASE_ANGLE", ICON_MODIFIER, "Crease Angle", ""},
41 {LS_MODIFIER_CURVATURE_3D, "CURVATURE_3D", ICON_MODIFIER, "Curvature 3D", ""},
42 {LS_MODIFIER_DISTANCE_FROM_CAMERA,
43 "DISTANCE_FROM_CAMERA",
44 ICON_MODIFIER,
45 "Distance from Camera",
46 ""},
47 {LS_MODIFIER_DISTANCE_FROM_OBJECT,
48 "DISTANCE_FROM_OBJECT",
49 ICON_MODIFIER,
50 "Distance from Object",
51 ""},
52 {LS_MODIFIER_MATERIAL, "MATERIAL", ICON_MODIFIER, "Material", ""},
53 {LS_MODIFIER_NOISE, "NOISE", ICON_MODIFIER, "Noise", ""},
54 {LS_MODIFIER_TANGENT, "TANGENT", ICON_MODIFIER, "Tangent", ""},
55 {0, NULL, 0, NULL, NULL},
56 };
57
58 const EnumPropertyItem rna_enum_linestyle_alpha_modifier_type_items[] = {
59 {LS_MODIFIER_ALONG_STROKE, "ALONG_STROKE", ICON_MODIFIER, "Along Stroke", ""},
60 {LS_MODIFIER_CREASE_ANGLE, "CREASE_ANGLE", ICON_MODIFIER, "Crease Angle", ""},
61 {LS_MODIFIER_CURVATURE_3D, "CURVATURE_3D", ICON_MODIFIER, "Curvature 3D", ""},
62 {LS_MODIFIER_DISTANCE_FROM_CAMERA,
63 "DISTANCE_FROM_CAMERA",
64 ICON_MODIFIER,
65 "Distance from Camera",
66 ""},
67 {LS_MODIFIER_DISTANCE_FROM_OBJECT,
68 "DISTANCE_FROM_OBJECT",
69 ICON_MODIFIER,
70 "Distance from Object",
71 ""},
72 {LS_MODIFIER_MATERIAL, "MATERIAL", ICON_MODIFIER, "Material", ""},
73 {LS_MODIFIER_NOISE, "NOISE", ICON_MODIFIER, "Noise", ""},
74 {LS_MODIFIER_TANGENT, "TANGENT", ICON_MODIFIER, "Tangent", ""},
75 {0, NULL, 0, NULL, NULL},
76 };
77
78 const EnumPropertyItem rna_enum_linestyle_thickness_modifier_type_items[] = {
79 {LS_MODIFIER_ALONG_STROKE, "ALONG_STROKE", ICON_MODIFIER, "Along Stroke", ""},
80 {LS_MODIFIER_CALLIGRAPHY, "CALLIGRAPHY", ICON_MODIFIER, "Calligraphy", ""},
81 {LS_MODIFIER_CREASE_ANGLE, "CREASE_ANGLE", ICON_MODIFIER, "Crease Angle", ""},
82 {LS_MODIFIER_CURVATURE_3D, "CURVATURE_3D", ICON_MODIFIER, "Curvature 3D", ""},
83 {LS_MODIFIER_DISTANCE_FROM_CAMERA,
84 "DISTANCE_FROM_CAMERA",
85 ICON_MODIFIER,
86 "Distance from Camera",
87 ""},
88 {LS_MODIFIER_DISTANCE_FROM_OBJECT,
89 "DISTANCE_FROM_OBJECT",
90 ICON_MODIFIER,
91 "Distance from Object",
92 ""},
93 {LS_MODIFIER_MATERIAL, "MATERIAL", ICON_MODIFIER, "Material", ""},
94 {LS_MODIFIER_NOISE, "NOISE", ICON_MODIFIER, "Noise", ""},
95 {LS_MODIFIER_TANGENT, "TANGENT", ICON_MODIFIER, "Tangent", ""},
96 {0, NULL, 0, NULL, NULL},
97 };
98
99 const EnumPropertyItem rna_enum_linestyle_geometry_modifier_type_items[] = {
100 {LS_MODIFIER_2D_OFFSET, "2D_OFFSET", ICON_MODIFIER, "2D Offset", ""},
101 {LS_MODIFIER_2D_TRANSFORM, "2D_TRANSFORM", ICON_MODIFIER, "2D Transform", ""},
102 {LS_MODIFIER_BACKBONE_STRETCHER,
103 "BACKBONE_STRETCHER",
104 ICON_MODIFIER,
105 "Backbone Stretcher",
106 ""},
107 {LS_MODIFIER_BEZIER_CURVE, "BEZIER_CURVE", ICON_MODIFIER, "Bezier Curve", ""},
108 {LS_MODIFIER_BLUEPRINT, "BLUEPRINT", ICON_MODIFIER, "Blueprint", ""},
109 {LS_MODIFIER_GUIDING_LINES, "GUIDING_LINES", ICON_MODIFIER, "Guiding Lines", ""},
110 {LS_MODIFIER_PERLIN_NOISE_1D, "PERLIN_NOISE_1D", ICON_MODIFIER, "Perlin Noise 1D", ""},
111 {LS_MODIFIER_PERLIN_NOISE_2D, "PERLIN_NOISE_2D", ICON_MODIFIER, "Perlin Noise 2D", ""},
112 {LS_MODIFIER_POLYGONIZATION, "POLYGONIZATION", ICON_MODIFIER, "Polygonization", ""},
113 {LS_MODIFIER_SAMPLING, "SAMPLING", ICON_MODIFIER, "Sampling", ""},
114 {LS_MODIFIER_SIMPLIFICATION, "SIMPLIFICATION", ICON_MODIFIER, "Simplification", ""},
115 {LS_MODIFIER_SINUS_DISPLACEMENT,
116 "SINUS_DISPLACEMENT",
117 ICON_MODIFIER,
118 "Sinus Displacement",
119 ""},
120 {LS_MODIFIER_SPATIAL_NOISE, "SPATIAL_NOISE", ICON_MODIFIER, "Spatial Noise", ""},
121 {LS_MODIFIER_TIP_REMOVER, "TIP_REMOVER", ICON_MODIFIER, "Tip Remover", ""},
122 {0, NULL, 0, NULL, NULL},
123 };
124
125 #ifdef RNA_RUNTIME
126
127 # include "BLI_string_utils.h"
128
129 # include "BKE_linestyle.h"
130 # include "BKE_texture.h"
131
132 # include "DEG_depsgraph.h"
133
134 # include "ED_node.h"
135
136 # include "RNA_access.h"
137
rna_LineStyle_color_modifier_refine(struct PointerRNA * ptr)138 static StructRNA *rna_LineStyle_color_modifier_refine(struct PointerRNA *ptr)
139 {
140 LineStyleModifier *m = (LineStyleModifier *)ptr->data;
141
142 switch (m->type) {
143 case LS_MODIFIER_ALONG_STROKE:
144 return &RNA_LineStyleColorModifier_AlongStroke;
145 case LS_MODIFIER_DISTANCE_FROM_CAMERA:
146 return &RNA_LineStyleColorModifier_DistanceFromCamera;
147 case LS_MODIFIER_DISTANCE_FROM_OBJECT:
148 return &RNA_LineStyleColorModifier_DistanceFromObject;
149 case LS_MODIFIER_MATERIAL:
150 return &RNA_LineStyleColorModifier_Material;
151 case LS_MODIFIER_TANGENT:
152 return &RNA_LineStyleColorModifier_Tangent;
153 case LS_MODIFIER_NOISE:
154 return &RNA_LineStyleColorModifier_Noise;
155 case LS_MODIFIER_CREASE_ANGLE:
156 return &RNA_LineStyleColorModifier_CreaseAngle;
157 case LS_MODIFIER_CURVATURE_3D:
158 return &RNA_LineStyleColorModifier_Curvature_3D;
159 default:
160 return &RNA_LineStyleColorModifier;
161 }
162 }
163
rna_LineStyle_alpha_modifier_refine(struct PointerRNA * ptr)164 static StructRNA *rna_LineStyle_alpha_modifier_refine(struct PointerRNA *ptr)
165 {
166 LineStyleModifier *m = (LineStyleModifier *)ptr->data;
167
168 switch (m->type) {
169 case LS_MODIFIER_ALONG_STROKE:
170 return &RNA_LineStyleAlphaModifier_AlongStroke;
171 case LS_MODIFIER_DISTANCE_FROM_CAMERA:
172 return &RNA_LineStyleAlphaModifier_DistanceFromCamera;
173 case LS_MODIFIER_DISTANCE_FROM_OBJECT:
174 return &RNA_LineStyleAlphaModifier_DistanceFromObject;
175 case LS_MODIFIER_MATERIAL:
176 return &RNA_LineStyleAlphaModifier_Material;
177 case LS_MODIFIER_TANGENT:
178 return &RNA_LineStyleAlphaModifier_Tangent;
179 case LS_MODIFIER_NOISE:
180 return &RNA_LineStyleAlphaModifier_Noise;
181 case LS_MODIFIER_CREASE_ANGLE:
182 return &RNA_LineStyleAlphaModifier_CreaseAngle;
183 case LS_MODIFIER_CURVATURE_3D:
184 return &RNA_LineStyleAlphaModifier_Curvature_3D;
185 default:
186 return &RNA_LineStyleAlphaModifier;
187 }
188 }
189
rna_LineStyle_thickness_modifier_refine(struct PointerRNA * ptr)190 static StructRNA *rna_LineStyle_thickness_modifier_refine(struct PointerRNA *ptr)
191 {
192 LineStyleModifier *m = (LineStyleModifier *)ptr->data;
193
194 switch (m->type) {
195 case LS_MODIFIER_ALONG_STROKE:
196 return &RNA_LineStyleThicknessModifier_AlongStroke;
197 case LS_MODIFIER_DISTANCE_FROM_CAMERA:
198 return &RNA_LineStyleThicknessModifier_DistanceFromCamera;
199 case LS_MODIFIER_DISTANCE_FROM_OBJECT:
200 return &RNA_LineStyleThicknessModifier_DistanceFromObject;
201 case LS_MODIFIER_MATERIAL:
202 return &RNA_LineStyleThicknessModifier_Material;
203 case LS_MODIFIER_CALLIGRAPHY:
204 return &RNA_LineStyleThicknessModifier_Calligraphy;
205 case LS_MODIFIER_TANGENT:
206 return &RNA_LineStyleThicknessModifier_Tangent;
207 case LS_MODIFIER_NOISE:
208 return &RNA_LineStyleThicknessModifier_Noise;
209 case LS_MODIFIER_CREASE_ANGLE:
210 return &RNA_LineStyleThicknessModifier_CreaseAngle;
211 case LS_MODIFIER_CURVATURE_3D:
212 return &RNA_LineStyleThicknessModifier_Curvature_3D;
213 default:
214 return &RNA_LineStyleThicknessModifier;
215 }
216 }
217
rna_LineStyle_geometry_modifier_refine(struct PointerRNA * ptr)218 static StructRNA *rna_LineStyle_geometry_modifier_refine(struct PointerRNA *ptr)
219 {
220 LineStyleModifier *m = (LineStyleModifier *)ptr->data;
221
222 switch (m->type) {
223 case LS_MODIFIER_SAMPLING:
224 return &RNA_LineStyleGeometryModifier_Sampling;
225 case LS_MODIFIER_BEZIER_CURVE:
226 return &RNA_LineStyleGeometryModifier_BezierCurve;
227 case LS_MODIFIER_SINUS_DISPLACEMENT:
228 return &RNA_LineStyleGeometryModifier_SinusDisplacement;
229 case LS_MODIFIER_SPATIAL_NOISE:
230 return &RNA_LineStyleGeometryModifier_SpatialNoise;
231 case LS_MODIFIER_PERLIN_NOISE_1D:
232 return &RNA_LineStyleGeometryModifier_PerlinNoise1D;
233 case LS_MODIFIER_PERLIN_NOISE_2D:
234 return &RNA_LineStyleGeometryModifier_PerlinNoise2D;
235 case LS_MODIFIER_BACKBONE_STRETCHER:
236 return &RNA_LineStyleGeometryModifier_BackboneStretcher;
237 case LS_MODIFIER_TIP_REMOVER:
238 return &RNA_LineStyleGeometryModifier_TipRemover;
239 case LS_MODIFIER_POLYGONIZATION:
240 return &RNA_LineStyleGeometryModifier_Polygonalization;
241 case LS_MODIFIER_GUIDING_LINES:
242 return &RNA_LineStyleGeometryModifier_GuidingLines;
243 case LS_MODIFIER_BLUEPRINT:
244 return &RNA_LineStyleGeometryModifier_Blueprint;
245 case LS_MODIFIER_2D_OFFSET:
246 return &RNA_LineStyleGeometryModifier_2DOffset;
247 case LS_MODIFIER_2D_TRANSFORM:
248 return &RNA_LineStyleGeometryModifier_2DTransform;
249 case LS_MODIFIER_SIMPLIFICATION:
250 return &RNA_LineStyleGeometryModifier_Simplification;
251 default:
252 return &RNA_LineStyleGeometryModifier;
253 }
254 }
255
rna_LineStyle_color_modifier_path(PointerRNA * ptr)256 static char *rna_LineStyle_color_modifier_path(PointerRNA *ptr)
257 {
258 LineStyleModifier *m = (LineStyleModifier *)ptr->data;
259 char name_esc[sizeof(m->name) * 2];
260 BLI_strescape(name_esc, m->name, sizeof(name_esc));
261 return BLI_sprintfN("color_modifiers[\"%s\"]", name_esc);
262 }
263
rna_LineStyle_alpha_modifier_path(PointerRNA * ptr)264 static char *rna_LineStyle_alpha_modifier_path(PointerRNA *ptr)
265 {
266 LineStyleModifier *m = (LineStyleModifier *)ptr->data;
267 char name_esc[sizeof(m->name) * 2];
268 BLI_strescape(name_esc, m->name, sizeof(name_esc));
269 return BLI_sprintfN("alpha_modifiers[\"%s\"]", name_esc);
270 }
271
rna_LineStyle_thickness_modifier_path(PointerRNA * ptr)272 static char *rna_LineStyle_thickness_modifier_path(PointerRNA *ptr)
273 {
274 LineStyleModifier *m = (LineStyleModifier *)ptr->data;
275 char name_esc[sizeof(m->name) * 2];
276 BLI_strescape(name_esc, m->name, sizeof(name_esc));
277 return BLI_sprintfN("thickness_modifiers[\"%s\"]", name_esc);
278 }
279
rna_LineStyle_geometry_modifier_path(PointerRNA * ptr)280 static char *rna_LineStyle_geometry_modifier_path(PointerRNA *ptr)
281 {
282 LineStyleModifier *m = (LineStyleModifier *)ptr->data;
283 char name_esc[sizeof(m->name) * 2];
284 BLI_strescape(name_esc, m->name, sizeof(name_esc));
285 return BLI_sprintfN("geometry_modifiers[\"%s\"]", name_esc);
286 }
287
rna_LineStyleColorModifier_name_set(PointerRNA * ptr,const char * value)288 static void rna_LineStyleColorModifier_name_set(PointerRNA *ptr, const char *value)
289 {
290 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->owner_id;
291 LineStyleModifier *m = (LineStyleModifier *)ptr->data;
292
293 BLI_strncpy_utf8(m->name, value, sizeof(m->name));
294 BLI_uniquename(&linestyle->color_modifiers,
295 m,
296 "ColorModifier",
297 '.',
298 offsetof(LineStyleModifier, name),
299 sizeof(m->name));
300 }
301
rna_LineStyleAlphaModifier_name_set(PointerRNA * ptr,const char * value)302 static void rna_LineStyleAlphaModifier_name_set(PointerRNA *ptr, const char *value)
303 {
304 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->owner_id;
305 LineStyleModifier *m = (LineStyleModifier *)ptr->data;
306
307 BLI_strncpy_utf8(m->name, value, sizeof(m->name));
308 BLI_uniquename(&linestyle->alpha_modifiers,
309 m,
310 "AlphaModifier",
311 '.',
312 offsetof(LineStyleModifier, name),
313 sizeof(m->name));
314 }
315
rna_LineStyleThicknessModifier_name_set(PointerRNA * ptr,const char * value)316 static void rna_LineStyleThicknessModifier_name_set(PointerRNA *ptr, const char *value)
317 {
318 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->owner_id;
319 LineStyleModifier *m = (LineStyleModifier *)ptr->data;
320
321 BLI_strncpy_utf8(m->name, value, sizeof(m->name));
322 BLI_uniquename(&linestyle->thickness_modifiers,
323 m,
324 "ThicknessModifier",
325 '.',
326 offsetof(LineStyleModifier, name),
327 sizeof(m->name));
328 }
329
rna_LineStyleGeometryModifier_name_set(PointerRNA * ptr,const char * value)330 static void rna_LineStyleGeometryModifier_name_set(PointerRNA *ptr, const char *value)
331 {
332 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->owner_id;
333 LineStyleModifier *m = (LineStyleModifier *)ptr->data;
334
335 BLI_strncpy_utf8(m->name, value, sizeof(m->name));
336 BLI_uniquename(&linestyle->geometry_modifiers,
337 m,
338 "GeometryModifier",
339 '.',
340 offsetof(LineStyleModifier, name),
341 sizeof(m->name));
342 }
343
rna_LineStyle_mtex_begin(CollectionPropertyIterator * iter,PointerRNA * ptr)344 static void rna_LineStyle_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
345 {
346 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->owner_id;
347 rna_iterator_array_begin(iter, (void *)linestyle->mtex, sizeof(MTex *), MAX_MTEX, 0, NULL);
348 }
349
rna_LineStyle_active_texture_get(PointerRNA * ptr)350 static PointerRNA rna_LineStyle_active_texture_get(PointerRNA *ptr)
351 {
352 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->owner_id;
353 Tex *tex;
354
355 tex = give_current_linestyle_texture(linestyle);
356 return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex);
357 }
358
rna_LineStyle_active_texture_set(PointerRNA * ptr,PointerRNA value,struct ReportList * UNUSED (reports))359 static void rna_LineStyle_active_texture_set(PointerRNA *ptr,
360 PointerRNA value,
361 struct ReportList *UNUSED(reports))
362 {
363 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->owner_id;
364
365 set_current_linestyle_texture(linestyle, value.data);
366 }
367
rna_LineStyle_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)368 static void rna_LineStyle_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
369 {
370 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->owner_id;
371
372 DEG_id_tag_update(&linestyle->id, 0);
373 WM_main_add_notifier(NC_LINESTYLE, linestyle);
374 }
375
rna_LineStyle_use_nodes_update(bContext * C,PointerRNA * ptr)376 static void rna_LineStyle_use_nodes_update(bContext *C, PointerRNA *ptr)
377 {
378 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->data;
379
380 if (linestyle->use_nodes && linestyle->nodetree == NULL) {
381 BKE_linestyle_default_shader(C, linestyle);
382 }
383
384 rna_LineStyle_update(CTX_data_main(C), CTX_data_scene(C), ptr);
385 }
386
rna_LineStyle_color_modifier_add(FreestyleLineStyle * linestyle,ReportList * reports,const char * name,int type)387 static LineStyleModifier *rna_LineStyle_color_modifier_add(FreestyleLineStyle *linestyle,
388 ReportList *reports,
389 const char *name,
390 int type)
391 {
392 LineStyleModifier *modifier = BKE_linestyle_color_modifier_add(linestyle, name, type);
393
394 if (!modifier) {
395 BKE_report(reports, RPT_ERROR, "Failed to add the color modifier");
396 return NULL;
397 }
398
399 DEG_id_tag_update(&linestyle->id, 0);
400 WM_main_add_notifier(NC_LINESTYLE, linestyle);
401
402 return modifier;
403 }
404
rna_LineStyle_color_modifier_remove(FreestyleLineStyle * linestyle,ReportList * reports,PointerRNA * modifier_ptr)405 static void rna_LineStyle_color_modifier_remove(FreestyleLineStyle *linestyle,
406 ReportList *reports,
407 PointerRNA *modifier_ptr)
408 {
409 LineStyleModifier *modifier = modifier_ptr->data;
410
411 if (BKE_linestyle_color_modifier_remove(linestyle, modifier) == -1) {
412 BKE_reportf(reports, RPT_ERROR, "Color modifier '%s' could not be removed", modifier->name);
413 return;
414 }
415
416 RNA_POINTER_INVALIDATE(modifier_ptr);
417
418 DEG_id_tag_update(&linestyle->id, 0);
419 WM_main_add_notifier(NC_LINESTYLE, linestyle);
420 }
421
rna_LineStyle_alpha_modifier_add(FreestyleLineStyle * linestyle,ReportList * reports,const char * name,int type)422 static LineStyleModifier *rna_LineStyle_alpha_modifier_add(FreestyleLineStyle *linestyle,
423 ReportList *reports,
424 const char *name,
425 int type)
426 {
427 LineStyleModifier *modifier = BKE_linestyle_alpha_modifier_add(linestyle, name, type);
428
429 if (!modifier) {
430 BKE_report(reports, RPT_ERROR, "Failed to add the alpha modifier");
431 return NULL;
432 }
433
434 DEG_id_tag_update(&linestyle->id, 0);
435 WM_main_add_notifier(NC_LINESTYLE, linestyle);
436
437 return modifier;
438 }
439
rna_LineStyle_alpha_modifier_remove(FreestyleLineStyle * linestyle,ReportList * reports,PointerRNA * modifier_ptr)440 static void rna_LineStyle_alpha_modifier_remove(FreestyleLineStyle *linestyle,
441 ReportList *reports,
442 PointerRNA *modifier_ptr)
443 {
444 LineStyleModifier *modifier = modifier_ptr->data;
445
446 if (BKE_linestyle_alpha_modifier_remove(linestyle, modifier) == -1) {
447 BKE_reportf(reports, RPT_ERROR, "Alpha modifier '%s' could not be removed", modifier->name);
448 return;
449 }
450
451 RNA_POINTER_INVALIDATE(modifier_ptr);
452
453 DEG_id_tag_update(&linestyle->id, 0);
454 WM_main_add_notifier(NC_LINESTYLE, linestyle);
455 }
456
rna_LineStyle_thickness_modifier_add(FreestyleLineStyle * linestyle,ReportList * reports,const char * name,int type)457 static LineStyleModifier *rna_LineStyle_thickness_modifier_add(FreestyleLineStyle *linestyle,
458 ReportList *reports,
459 const char *name,
460 int type)
461 {
462 LineStyleModifier *modifier = BKE_linestyle_thickness_modifier_add(linestyle, name, type);
463
464 if (!modifier) {
465 BKE_report(reports, RPT_ERROR, "Failed to add the thickness modifier");
466 return NULL;
467 }
468
469 DEG_id_tag_update(&linestyle->id, 0);
470 WM_main_add_notifier(NC_LINESTYLE, linestyle);
471
472 return modifier;
473 }
474
rna_LineStyle_thickness_modifier_remove(FreestyleLineStyle * linestyle,ReportList * reports,PointerRNA * modifier_ptr)475 static void rna_LineStyle_thickness_modifier_remove(FreestyleLineStyle *linestyle,
476 ReportList *reports,
477 PointerRNA *modifier_ptr)
478 {
479 LineStyleModifier *modifier = modifier_ptr->data;
480
481 if (BKE_linestyle_thickness_modifier_remove(linestyle, modifier) == -1) {
482 BKE_reportf(
483 reports, RPT_ERROR, "Thickness modifier '%s' could not be removed", modifier->name);
484 return;
485 }
486
487 RNA_POINTER_INVALIDATE(modifier_ptr);
488
489 DEG_id_tag_update(&linestyle->id, 0);
490 WM_main_add_notifier(NC_LINESTYLE, linestyle);
491 }
492
rna_LineStyle_geometry_modifier_add(FreestyleLineStyle * linestyle,ReportList * reports,const char * name,int type)493 static LineStyleModifier *rna_LineStyle_geometry_modifier_add(FreestyleLineStyle *linestyle,
494 ReportList *reports,
495 const char *name,
496 int type)
497 {
498 LineStyleModifier *modifier = BKE_linestyle_geometry_modifier_add(linestyle, name, type);
499
500 if (!modifier) {
501 BKE_report(reports, RPT_ERROR, "Failed to add the geometry modifier");
502 return NULL;
503 }
504
505 DEG_id_tag_update(&linestyle->id, 0);
506 WM_main_add_notifier(NC_LINESTYLE, linestyle);
507
508 return modifier;
509 }
510
rna_LineStyle_geometry_modifier_remove(FreestyleLineStyle * linestyle,ReportList * reports,PointerRNA * modifier_ptr)511 static void rna_LineStyle_geometry_modifier_remove(FreestyleLineStyle *linestyle,
512 ReportList *reports,
513 PointerRNA *modifier_ptr)
514 {
515 LineStyleModifier *modifier = modifier_ptr->data;
516
517 if (BKE_linestyle_geometry_modifier_remove(linestyle, modifier) == -1) {
518 BKE_reportf(reports, RPT_ERROR, "Geometry modifier '%s' could not be removed", modifier->name);
519 return;
520 }
521
522 RNA_POINTER_INVALIDATE(modifier_ptr);
523
524 DEG_id_tag_update(&linestyle->id, 0);
525 WM_main_add_notifier(NC_LINESTYLE, linestyle);
526 }
527
528 #else
529
530 # include "BLI_math.h"
531
rna_def_linestyle_mtex(BlenderRNA * brna)532 static void rna_def_linestyle_mtex(BlenderRNA *brna)
533 {
534 StructRNA *srna;
535 PropertyRNA *prop;
536
537 static const EnumPropertyItem texco_items[] = {
538 {TEXCO_WINDOW, "WINDOW", 0, "Window", "Use screen coordinates as texture coordinates"},
539 {TEXCO_GLOB, "GLOBAL", 0, "Global", "Use global coordinates for the texture coordinates"},
540 {TEXCO_STROKE,
541 "ALONG_STROKE",
542 0,
543 "Along stroke",
544 "Use stroke length for texture coordinates"},
545 {TEXCO_ORCO,
546 "ORCO",
547 0,
548 "Generated",
549 "Use the original undeformed coordinates of the object"},
550 {0, NULL, 0, NULL, NULL},
551 };
552
553 static const EnumPropertyItem prop_mapping_items[] = {
554 {MTEX_FLAT, "FLAT", 0, "Flat", "Map X and Y coordinates directly"},
555 {MTEX_CUBE, "CUBE", 0, "Cube", "Map using the normal vector"},
556 {MTEX_TUBE, "TUBE", 0, "Tube", "Map with Z as central axis"},
557 {MTEX_SPHERE, "SPHERE", 0, "Sphere", "Map with Z as central axis"},
558 {0, NULL, 0, NULL, NULL},
559 };
560
561 static const EnumPropertyItem prop_x_mapping_items[] = {
562 {0, "NONE", 0, "None", ""},
563 {1, "X", 0, "X", ""},
564 {2, "Y", 0, "Y", ""},
565 {3, "Z", 0, "Z", ""},
566 {0, NULL, 0, NULL, NULL},
567 };
568
569 static const EnumPropertyItem prop_y_mapping_items[] = {
570 {0, "NONE", 0, "None", ""},
571 {1, "X", 0, "X", ""},
572 {2, "Y", 0, "Y", ""},
573 {3, "Z", 0, "Z", ""},
574 {0, NULL, 0, NULL, NULL},
575 };
576
577 static const EnumPropertyItem prop_z_mapping_items[] = {
578 {0, "NONE", 0, "None", ""},
579 {1, "X", 0, "X", ""},
580 {2, "Y", 0, "Y", ""},
581 {3, "Z", 0, "Z", ""},
582 {0, NULL, 0, NULL, NULL},
583 };
584
585 srna = RNA_def_struct(brna, "LineStyleTextureSlot", "TextureSlot");
586 RNA_def_struct_sdna(srna, "MTex");
587 RNA_def_struct_ui_text(
588 srna, "LineStyle Texture Slot", "Texture slot for textures in a LineStyle data-block");
589
590 prop = RNA_def_property(srna, "mapping_x", PROP_ENUM, PROP_NONE);
591 RNA_def_property_enum_sdna(prop, NULL, "projx");
592 RNA_def_property_enum_items(prop, prop_x_mapping_items);
593 RNA_def_property_ui_text(prop, "X Mapping", "");
594 RNA_def_property_update(prop, 0, "rna_LineStyle_update");
595
596 prop = RNA_def_property(srna, "mapping_y", PROP_ENUM, PROP_NONE);
597 RNA_def_property_enum_sdna(prop, NULL, "projy");
598 RNA_def_property_enum_items(prop, prop_y_mapping_items);
599 RNA_def_property_ui_text(prop, "Y Mapping", "");
600 RNA_def_property_update(prop, 0, "rna_LineStyle_update");
601
602 prop = RNA_def_property(srna, "mapping_z", PROP_ENUM, PROP_NONE);
603 RNA_def_property_enum_sdna(prop, NULL, "projz");
604 RNA_def_property_enum_items(prop, prop_z_mapping_items);
605 RNA_def_property_ui_text(prop, "Z Mapping", "");
606 RNA_def_property_update(prop, 0, "rna_LineStyle_update");
607
608 prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
609 RNA_def_property_enum_items(prop, prop_mapping_items);
610 RNA_def_property_ui_text(prop, "Mapping", "");
611 RNA_def_property_update(prop, 0, "rna_LineStyle_update");
612
613 /* map to */
614 prop = RNA_def_property(srna, "use_map_color_diffuse", PROP_BOOLEAN, PROP_NONE);
615 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_COL);
616 RNA_def_property_ui_text(prop, "Diffuse Color", "The texture affects basic color of the stroke");
617 RNA_def_property_update(prop, 0, "rna_LineStyle_update");
618
619 prop = RNA_def_property(srna, "use_map_alpha", PROP_BOOLEAN, PROP_NONE);
620 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_ALPHA);
621 RNA_def_property_ui_text(prop, "Alpha", "The texture affects the alpha value");
622 RNA_def_property_update(prop, 0, "rna_LineStyle_update");
623
624 prop = RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE);
625 RNA_def_property_enum_sdna(prop, NULL, "texco");
626 RNA_def_property_enum_items(prop, texco_items);
627 RNA_def_property_ui_text(prop,
628 "Texture Coordinates",
629 "Texture coordinates used to map the texture onto the background");
630 RNA_def_property_update(prop, 0, "rna_LineStyle_update");
631
632 prop = RNA_def_property(srna, "alpha_factor", PROP_FLOAT, PROP_NONE);
633 RNA_def_property_float_sdna(prop, NULL, "alphafac");
634 RNA_def_property_ui_range(prop, -1, 1, 10, 3);
635 RNA_def_property_ui_text(prop, "Alpha Factor", "Amount texture affects alpha");
636 RNA_def_property_update(prop, 0, "rna_LineStyle_update");
637
638 prop = RNA_def_property(srna, "diffuse_color_factor", PROP_FLOAT, PROP_NONE);
639 RNA_def_property_float_sdna(prop, NULL, "colfac");
640 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
641 RNA_def_property_ui_text(prop, "Diffuse Color Factor", "Amount texture affects diffuse color");
642 RNA_def_property_update(prop, 0, "rna_LineStyle_update");
643 }
644
rna_def_modifier_type_common(StructRNA * srna,const EnumPropertyItem * modifier_type_items,const char * set_name_func,const bool blend,const bool color)645 static void rna_def_modifier_type_common(StructRNA *srna,
646 const EnumPropertyItem *modifier_type_items,
647 const char *set_name_func,
648 const bool blend,
649 const bool color)
650 {
651 PropertyRNA *prop;
652
653 /* TODO: Check this is not already defined somewhere else, e.g. in nodes... */
654 static const EnumPropertyItem value_blend_items[] = {
655 {LS_VALUE_BLEND, "MIX", 0, "Mix", ""},
656 {LS_VALUE_ADD, "ADD", 0, "Add", ""},
657 {LS_VALUE_SUB, "SUBTRACT", 0, "Subtract", ""},
658 {LS_VALUE_MULT, "MULTIPLY", 0, "Multiply", ""},
659 {LS_VALUE_DIV, "DIVIDE", 0, "Divide", ""},
660 {LS_VALUE_DIFF, "DIFFERENCE", 0, "Difference", ""},
661 {LS_VALUE_MIN, "MINIMUM", 0, "Minimum", ""},
662 {LS_VALUE_MAX, "MAXIMUM", 0, "Maximum", ""},
663 {0, NULL, 0, NULL, NULL},
664 };
665
666 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
667 RNA_def_property_enum_sdna(prop, NULL, "modifier.type");
668 RNA_def_property_enum_items(prop, modifier_type_items);
669 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
670 RNA_def_property_ui_text(prop, "Modifier Type", "Type of the modifier");
671
672 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
673 RNA_def_property_string_sdna(prop, NULL, "modifier.name");
674 RNA_def_property_string_funcs(prop, NULL, NULL, set_name_func);
675 RNA_def_property_ui_text(prop, "Modifier Name", "Name of the modifier");
676 RNA_def_property_update(prop, NC_LINESTYLE, NULL);
677 RNA_def_struct_name_property(srna, prop);
678
679 if (blend) {
680 prop = RNA_def_property(srna, "blend", PROP_ENUM, PROP_NONE);
681 RNA_def_property_enum_sdna(prop, NULL, "modifier.blend");
682 RNA_def_property_enum_items(prop, (color) ? rna_enum_ramp_blend_items : value_blend_items);
683 RNA_def_property_ui_text(
684 prop, "Blend", "Specify how the modifier value is blended into the base value");
685 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
686
687 prop = RNA_def_property(srna, "influence", PROP_FLOAT, PROP_FACTOR);
688 RNA_def_property_float_sdna(prop, NULL, "modifier.influence");
689 RNA_def_property_range(prop, 0.0f, 1.0f);
690 RNA_def_property_ui_text(
691 prop, "Influence", "Influence factor by which the modifier changes the property");
692 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
693 }
694
695 prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
696 RNA_def_property_boolean_sdna(prop, NULL, "modifier.flags", LS_MODIFIER_ENABLED);
697 RNA_def_property_ui_text(prop, "Use", "Enable or disable this modifier during stroke rendering");
698 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
699
700 prop = RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE);
701 RNA_def_property_boolean_sdna(prop, NULL, "modifier.flags", LS_MODIFIER_EXPANDED);
702 RNA_def_property_ui_text(prop, "Expanded", "True if the modifier tab is expanded");
703 }
704
rna_def_color_modifier(StructRNA * srna)705 static void rna_def_color_modifier(StructRNA *srna)
706 {
707 rna_def_modifier_type_common(srna,
708 rna_enum_linestyle_color_modifier_type_items,
709 "rna_LineStyleColorModifier_name_set",
710 true,
711 true);
712 }
713
rna_def_alpha_modifier(StructRNA * srna)714 static void rna_def_alpha_modifier(StructRNA *srna)
715 {
716 rna_def_modifier_type_common(srna,
717 rna_enum_linestyle_alpha_modifier_type_items,
718 "rna_LineStyleAlphaModifier_name_set",
719 true,
720 false);
721 }
722
rna_def_thickness_modifier(StructRNA * srna)723 static void rna_def_thickness_modifier(StructRNA *srna)
724 {
725 rna_def_modifier_type_common(srna,
726 rna_enum_linestyle_thickness_modifier_type_items,
727 "rna_LineStyleThicknessModifier_name_set",
728 true,
729 false);
730 }
731
rna_def_geometry_modifier(StructRNA * srna)732 static void rna_def_geometry_modifier(StructRNA *srna)
733 {
734 rna_def_modifier_type_common(srna,
735 rna_enum_linestyle_geometry_modifier_type_items,
736 "rna_LineStyleGeometryModifier_name_set",
737 false,
738 false);
739 }
740
rna_def_modifier_color_ramp_common(StructRNA * srna,int range)741 static void rna_def_modifier_color_ramp_common(StructRNA *srna, int range)
742 {
743 PropertyRNA *prop;
744
745 prop = RNA_def_property(srna, "color_ramp", PROP_POINTER, PROP_NONE);
746 RNA_def_property_pointer_sdna(prop, NULL, "color_ramp");
747 RNA_def_property_struct_type(prop, "ColorRamp");
748 RNA_def_property_ui_text(prop, "Color Ramp", "Color ramp used to change line color");
749 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
750
751 if (range) {
752 prop = RNA_def_property(srna, "range_min", PROP_FLOAT, PROP_DISTANCE);
753 RNA_def_property_float_sdna(prop, NULL, "range_min");
754 RNA_def_property_ui_text(
755 prop, "Range Min", "Lower bound of the input range the mapping is applied");
756 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
757
758 prop = RNA_def_property(srna, "range_max", PROP_FLOAT, PROP_DISTANCE);
759 RNA_def_property_float_sdna(prop, NULL, "range_max");
760 RNA_def_property_ui_text(
761 prop, "Range Max", "Upper bound of the input range the mapping is applied");
762 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
763 }
764 }
765
rna_def_modifier_curve_common(StructRNA * srna,bool range,bool value)766 static void rna_def_modifier_curve_common(StructRNA *srna, bool range, bool value)
767 {
768 PropertyRNA *prop;
769
770 static const EnumPropertyItem mapping_items[] = {
771 {0, "LINEAR", 0, "Linear", "Use linear mapping"},
772 {LS_MODIFIER_USE_CURVE, "CURVE", 0, "Curve", "Use curve mapping"},
773 {0, NULL, 0, NULL, NULL},
774 };
775
776 prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
777 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
778 RNA_def_property_enum_items(prop, mapping_items);
779 RNA_def_property_ui_text(prop, "Mapping", "Select the mapping type");
780 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
781
782 prop = RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE);
783 RNA_def_property_boolean_sdna(prop, NULL, "flags", LS_MODIFIER_INVERT);
784 RNA_def_property_ui_text(prop, "Invert", "Invert the fade-out direction of the linear mapping");
785 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
786
787 prop = RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE);
788 RNA_def_property_pointer_sdna(prop, NULL, "curve");
789 RNA_def_property_struct_type(prop, "CurveMapping");
790 RNA_def_property_ui_text(prop, "Curve", "Curve used for the curve mapping");
791 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
792
793 if (range) {
794 prop = RNA_def_property(srna, "range_min", PROP_FLOAT, PROP_DISTANCE);
795 RNA_def_property_float_sdna(prop, NULL, "range_min");
796 RNA_def_property_ui_text(
797 prop, "Range Min", "Lower bound of the input range the mapping is applied");
798 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
799
800 prop = RNA_def_property(srna, "range_max", PROP_FLOAT, PROP_DISTANCE);
801 RNA_def_property_float_sdna(prop, NULL, "range_max");
802 RNA_def_property_ui_text(
803 prop, "Range Max", "Upper bound of the input range the mapping is applied");
804 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
805 }
806
807 if (value) {
808 prop = RNA_def_property(srna, "value_min", PROP_FLOAT, PROP_NONE);
809 RNA_def_property_float_sdna(prop, NULL, "value_min");
810 RNA_def_property_ui_text(prop, "Value Min", "Minimum output value of the mapping");
811 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
812
813 prop = RNA_def_property(srna, "value_max", PROP_FLOAT, PROP_NONE);
814 RNA_def_property_float_sdna(prop, NULL, "value_max");
815 RNA_def_property_ui_text(prop, "Value Max", "Maximum output value of the mapping");
816 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
817 }
818 }
819
rna_def_modifier_material_common(StructRNA * srna)820 static void rna_def_modifier_material_common(StructRNA *srna)
821 {
822 PropertyRNA *prop;
823
824 static const EnumPropertyItem mat_attr_items[] = {
825 {LS_MODIFIER_MATERIAL_LINE, "LINE", 0, "Line Color", ""},
826 {LS_MODIFIER_MATERIAL_LINE_R, "LINE_R", 0, "Line Color Red", ""},
827 {LS_MODIFIER_MATERIAL_LINE_G, "LINE_G", 0, "Line Color Green", ""},
828 {LS_MODIFIER_MATERIAL_LINE_B, "LINE_B", 0, "Line Color Blue", ""},
829 {LS_MODIFIER_MATERIAL_LINE_A, "LINE_A", 0, "Line Color Alpha", ""},
830 {LS_MODIFIER_MATERIAL_DIFF, "DIFF", 0, "Diffuse Color", ""},
831 {LS_MODIFIER_MATERIAL_DIFF_R, "DIFF_R", 0, "Diffuse Color Red", ""},
832 {LS_MODIFIER_MATERIAL_DIFF_G, "DIFF_G", 0, "Diffuse Color Green", ""},
833 {LS_MODIFIER_MATERIAL_DIFF_B, "DIFF_B", 0, "Diffuse Color Blue", ""},
834 {LS_MODIFIER_MATERIAL_SPEC, "SPEC", 0, "Specular Color", ""},
835 {LS_MODIFIER_MATERIAL_SPEC_R, "SPEC_R", 0, "Specular Color Red", ""},
836 {LS_MODIFIER_MATERIAL_SPEC_G, "SPEC_G", 0, "Specular Color Green", ""},
837 {LS_MODIFIER_MATERIAL_SPEC_B, "SPEC_B", 0, "Specular Color Blue", ""},
838 {LS_MODIFIER_MATERIAL_SPEC_HARD, "SPEC_HARD", 0, "Specular Hardness", ""},
839 {LS_MODIFIER_MATERIAL_ALPHA, "ALPHA", 0, "Alpha Transparency", ""},
840 {0, NULL, 0, NULL, NULL},
841 };
842
843 prop = RNA_def_property(srna, "material_attribute", PROP_ENUM, PROP_NONE);
844 RNA_def_property_enum_sdna(prop, NULL, "mat_attr");
845 RNA_def_property_enum_items(prop, mat_attr_items);
846 RNA_def_property_ui_text(prop, "Material Attribute", "Specify which material attribute is used");
847 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
848 }
849
rna_def_linestyle_modifiers(BlenderRNA * brna)850 static void rna_def_linestyle_modifiers(BlenderRNA *brna)
851 {
852 StructRNA *srna;
853 PropertyRNA *prop;
854
855 static const EnumPropertyItem blueprint_shape_items[] = {
856 {LS_MODIFIER_BLUEPRINT_CIRCLES,
857 "CIRCLES",
858 0,
859 "Circles",
860 "Draw a blueprint using circular contour strokes"},
861 {LS_MODIFIER_BLUEPRINT_ELLIPSES,
862 "ELLIPSES",
863 0,
864 "Ellipses",
865 "Draw a blueprint using elliptic contour strokes"},
866 {LS_MODIFIER_BLUEPRINT_SQUARES,
867 "SQUARES",
868 0,
869 "Squares",
870 "Draw a blueprint using square contour strokes"},
871 {0, NULL, 0, NULL, NULL},
872 };
873
874 static const EnumPropertyItem transform_pivot_items[] = {
875 {LS_MODIFIER_2D_TRANSFORM_PIVOT_CENTER, "CENTER", 0, "Stroke Center", ""},
876 {LS_MODIFIER_2D_TRANSFORM_PIVOT_START, "START", 0, "Stroke Start", ""},
877 {LS_MODIFIER_2D_TRANSFORM_PIVOT_END, "END", 0, "Stroke End", ""},
878 {LS_MODIFIER_2D_TRANSFORM_PIVOT_PARAM, "PARAM", 0, "Stroke Point Parameter", ""},
879 {LS_MODIFIER_2D_TRANSFORM_PIVOT_ABSOLUTE, "ABSOLUTE", 0, "Absolute 2D Point", ""},
880 {0, NULL, 0, NULL, NULL},
881 };
882
883 srna = RNA_def_struct(brna, "LineStyleModifier", NULL);
884 RNA_def_struct_ui_text(srna, "Line Style Modifier", "Base type to define modifiers");
885
886 /* line color modifiers */
887
888 srna = RNA_def_struct(brna, "LineStyleColorModifier", "LineStyleModifier");
889 RNA_def_struct_sdna(srna, "LineStyleModifier");
890 RNA_def_struct_refine_func(srna, "rna_LineStyle_color_modifier_refine");
891 RNA_def_struct_path_func(srna, "rna_LineStyle_color_modifier_path");
892 RNA_def_struct_ui_text(
893 srna, "Line Style Color Modifier", "Base type to define line color modifiers");
894
895 srna = RNA_def_struct(brna, "LineStyleColorModifier_AlongStroke", "LineStyleColorModifier");
896 RNA_def_struct_ui_text(srna, "Along Stroke", "Change line color along stroke");
897 rna_def_color_modifier(srna);
898 rna_def_modifier_color_ramp_common(srna, false);
899
900 srna = RNA_def_struct(
901 brna, "LineStyleColorModifier_DistanceFromCamera", "LineStyleColorModifier");
902 RNA_def_struct_ui_text(
903 srna, "Distance from Camera", "Change line color based on the distance from the camera");
904 rna_def_color_modifier(srna);
905 rna_def_modifier_color_ramp_common(srna, true);
906
907 srna = RNA_def_struct(
908 brna, "LineStyleColorModifier_DistanceFromObject", "LineStyleColorModifier");
909 RNA_def_struct_ui_text(
910 srna, "Distance from Object", "Change line color based on the distance from an object");
911 rna_def_color_modifier(srna);
912 rna_def_modifier_color_ramp_common(srna, true);
913
914 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
915 RNA_def_property_pointer_sdna(prop, NULL, "target");
916 RNA_def_property_struct_type(prop, "Object");
917 RNA_def_property_flag(prop, PROP_EDITABLE);
918 RNA_def_property_ui_text(prop, "Target", "Target object from which the distance is measured");
919 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
920
921 srna = RNA_def_struct(brna, "LineStyleColorModifier_Material", "LineStyleColorModifier");
922 RNA_def_struct_ui_text(srna, "Material", "Change line color based on a material attribute");
923 rna_def_color_modifier(srna);
924 rna_def_modifier_material_common(srna);
925 rna_def_modifier_color_ramp_common(srna, false);
926
927 prop = RNA_def_property(srna, "use_ramp", PROP_BOOLEAN, PROP_NONE);
928 RNA_def_property_boolean_sdna(prop, NULL, "flags", LS_MODIFIER_USE_RAMP);
929 RNA_def_property_ui_text(prop, "Ramp", "Use color ramp to map the BW average into an RGB color");
930 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
931
932 srna = RNA_def_struct(brna, "LineStyleColorModifier_Tangent", "LineStyleColorModifier");
933 RNA_def_struct_ui_text(srna, "Tangent", "Change line color based on the direction of a stroke");
934 rna_def_color_modifier(srna);
935 rna_def_modifier_color_ramp_common(srna, false);
936
937 srna = RNA_def_struct(brna, "LineStyleColorModifier_Noise", "LineStyleColorModifier");
938 RNA_def_struct_ui_text(srna, "Noise", "Change line color based on random noise");
939 rna_def_color_modifier(srna);
940 rna_def_modifier_color_ramp_common(srna, false);
941
942 prop = RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
943 RNA_def_property_float_sdna(prop, NULL, "amplitude");
944 RNA_def_property_ui_text(prop, "Amplitude", "Amplitude of the noise");
945 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
946
947 prop = RNA_def_property(srna, "period", PROP_FLOAT, PROP_NONE);
948 RNA_def_property_float_sdna(prop, NULL, "period");
949 RNA_def_property_ui_text(prop, "Period", "Period of the noise");
950 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
951
952 prop = RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
953 RNA_def_property_int_sdna(prop, NULL, "seed");
954 RNA_def_property_ui_text(prop, "Seed", "Seed for the noise generation");
955 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
956
957 srna = RNA_def_struct(brna, "LineStyleColorModifier_CreaseAngle", "LineStyleColorModifier");
958 RNA_def_struct_ui_text(
959 srna, "Crease Angle", "Change line color based on the underlying crease angle");
960 rna_def_color_modifier(srna);
961 rna_def_modifier_color_ramp_common(srna, false);
962
963 prop = RNA_def_property(srna, "angle_min", PROP_FLOAT, PROP_ANGLE);
964 RNA_def_property_float_sdna(prop, NULL, "min_angle");
965 RNA_def_property_ui_text(prop, "Min Angle", "Minimum angle to modify thickness");
966 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
967
968 prop = RNA_def_property(srna, "angle_max", PROP_FLOAT, PROP_ANGLE);
969 RNA_def_property_float_sdna(prop, NULL, "max_angle");
970 RNA_def_property_ui_text(prop, "Max Angle", "Maximum angle to modify thickness");
971 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
972
973 srna = RNA_def_struct(brna, "LineStyleColorModifier_Curvature_3D", "LineStyleColorModifier");
974 RNA_def_struct_ui_text(
975 srna, "Curvature 3D", "Change line color based on the radial curvature of 3D mesh surfaces");
976 rna_def_color_modifier(srna);
977 rna_def_modifier_color_ramp_common(srna, false);
978
979 prop = RNA_def_property(srna, "curvature_min", PROP_FLOAT, PROP_NONE);
980 RNA_def_property_float_sdna(prop, NULL, "min_curvature");
981 RNA_def_property_ui_text(prop, "Min Curvature", "Minimum Curvature");
982 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
983
984 prop = RNA_def_property(srna, "curvature_max", PROP_FLOAT, PROP_NONE);
985 RNA_def_property_float_sdna(prop, NULL, "max_curvature");
986 RNA_def_property_ui_text(prop, "Max Curvature", "Maximum Curvature");
987 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
988
989 /* alpha transparency modifiers */
990
991 srna = RNA_def_struct(brna, "LineStyleAlphaModifier", "LineStyleModifier");
992 RNA_def_struct_sdna(srna, "LineStyleModifier");
993 RNA_def_struct_refine_func(srna, "rna_LineStyle_alpha_modifier_refine");
994 RNA_def_struct_path_func(srna, "rna_LineStyle_alpha_modifier_path");
995 RNA_def_struct_ui_text(
996 srna, "Line Style Alpha Modifier", "Base type to define alpha transparency modifiers");
997
998 srna = RNA_def_struct(brna, "LineStyleAlphaModifier_AlongStroke", "LineStyleAlphaModifier");
999 RNA_def_struct_ui_text(srna, "Along Stroke", "Change alpha transparency along stroke");
1000 rna_def_alpha_modifier(srna);
1001 rna_def_modifier_curve_common(srna, false, false);
1002
1003 srna = RNA_def_struct(
1004 brna, "LineStyleAlphaModifier_DistanceFromCamera", "LineStyleAlphaModifier");
1005 RNA_def_struct_ui_text(srna,
1006 "Distance from Camera",
1007 "Change alpha transparency based on the distance from the camera");
1008 rna_def_alpha_modifier(srna);
1009 rna_def_modifier_curve_common(srna, true, false);
1010
1011 srna = RNA_def_struct(
1012 brna, "LineStyleAlphaModifier_DistanceFromObject", "LineStyleAlphaModifier");
1013 RNA_def_struct_ui_text(srna,
1014 "Distance from Object",
1015 "Change alpha transparency based on the distance from an object");
1016 rna_def_alpha_modifier(srna);
1017 rna_def_modifier_curve_common(srna, true, false);
1018
1019 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
1020 RNA_def_property_pointer_sdna(prop, NULL, "target");
1021 RNA_def_property_struct_type(prop, "Object");
1022 RNA_def_property_flag(prop, PROP_EDITABLE);
1023 RNA_def_property_ui_text(prop, "Target", "Target object from which the distance is measured");
1024 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1025
1026 srna = RNA_def_struct(brna, "LineStyleAlphaModifier_Material", "LineStyleAlphaModifier");
1027 RNA_def_struct_ui_text(
1028 srna, "Material", "Change alpha transparency based on a material attribute");
1029 rna_def_alpha_modifier(srna);
1030 rna_def_modifier_material_common(srna);
1031 rna_def_modifier_curve_common(srna, false, false);
1032
1033 srna = RNA_def_struct(brna, "LineStyleAlphaModifier_Tangent", "LineStyleAlphaModifier");
1034 RNA_def_struct_ui_text(
1035 srna, "Tangent", "Alpha transparency based on the direction of the stroke");
1036 rna_def_alpha_modifier(srna);
1037 rna_def_modifier_curve_common(srna, false, false);
1038
1039 srna = RNA_def_struct(brna, "LineStyleAlphaModifier_Noise", "LineStyleAlphaModifier");
1040 RNA_def_struct_ui_text(srna, "Noise", "Alpha transparency based on random noise");
1041 rna_def_alpha_modifier(srna);
1042 rna_def_modifier_curve_common(srna, false, false);
1043
1044 prop = RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
1045 RNA_def_property_float_sdna(prop, NULL, "amplitude");
1046 RNA_def_property_ui_text(prop, "Amplitude", "Amplitude of the noise");
1047 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1048
1049 prop = RNA_def_property(srna, "period", PROP_FLOAT, PROP_NONE);
1050 RNA_def_property_float_sdna(prop, NULL, "period");
1051 RNA_def_property_ui_text(prop, "Period", "Period of the noise");
1052 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1053
1054 prop = RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
1055 RNA_def_property_int_sdna(prop, NULL, "seed");
1056 RNA_def_property_ui_text(prop, "Seed", "Seed for the noise generation");
1057 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1058
1059 srna = RNA_def_struct(brna, "LineStyleAlphaModifier_CreaseAngle", "LineStyleAlphaModifier");
1060 RNA_def_struct_ui_text(
1061 srna, "Crease Angle", "Alpha transparency based on the angle between two adjacent faces");
1062 rna_def_alpha_modifier(srna);
1063 rna_def_modifier_curve_common(srna, false, false);
1064
1065 prop = RNA_def_property(srna, "angle_min", PROP_FLOAT, PROP_ANGLE);
1066 RNA_def_property_float_sdna(prop, NULL, "min_angle");
1067 RNA_def_property_ui_text(prop, "Min Angle", "Minimum angle to modify thickness");
1068 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1069
1070 prop = RNA_def_property(srna, "angle_max", PROP_FLOAT, PROP_ANGLE);
1071 RNA_def_property_float_sdna(prop, NULL, "max_angle");
1072 RNA_def_property_ui_text(prop, "Max Angle", "Maximum angle to modify thickness");
1073 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1074
1075 srna = RNA_def_struct(brna, "LineStyleAlphaModifier_Curvature_3D", "LineStyleAlphaModifier");
1076 RNA_def_struct_ui_text(srna,
1077 "Curvature 3D",
1078 "Alpha transparency based on the radial curvature of 3D mesh surfaces");
1079 rna_def_alpha_modifier(srna);
1080 rna_def_modifier_curve_common(srna, false, false);
1081
1082 prop = RNA_def_property(srna, "curvature_min", PROP_FLOAT, PROP_NONE);
1083 RNA_def_property_float_sdna(prop, NULL, "min_curvature");
1084 RNA_def_property_range(prop, 0.0f, 10000.0f);
1085 RNA_def_property_ui_text(prop, "Min Curvature", "Minimum Curvature");
1086 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1087
1088 prop = RNA_def_property(srna, "curvature_max", PROP_FLOAT, PROP_NONE);
1089 RNA_def_property_float_sdna(prop, NULL, "max_curvature");
1090 RNA_def_property_range(prop, 0.0f, 10000.0f);
1091 RNA_def_property_ui_text(prop, "Max Curvature", "Maximum Curvature");
1092 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1093
1094 /* line thickness modifiers */
1095 srna = RNA_def_struct(brna, "LineStyleThicknessModifier", "LineStyleModifier");
1096 RNA_def_struct_sdna(srna, "LineStyleModifier");
1097 RNA_def_struct_refine_func(srna, "rna_LineStyle_thickness_modifier_refine");
1098 RNA_def_struct_path_func(srna, "rna_LineStyle_thickness_modifier_path");
1099 RNA_def_struct_ui_text(
1100 srna, "Line Style Thickness Modifier", "Base type to define line thickness modifiers");
1101
1102 srna = RNA_def_struct(brna, "LineStyleThicknessModifier_Tangent", "LineStyleThicknessModifier");
1103 RNA_def_struct_ui_text(srna, "Tangent", "Thickness based on the direction of the stroke");
1104 rna_def_thickness_modifier(srna);
1105 rna_def_modifier_curve_common(srna, false, false);
1106
1107 prop = RNA_def_property(srna, "thickness_min", PROP_FLOAT, PROP_NONE);
1108 RNA_def_property_float_sdna(prop, NULL, "min_thickness");
1109 RNA_def_property_range(prop, 0.0f, 10000.0f);
1110 RNA_def_property_ui_text(prop, "Min Thickness", "Minimum thickness");
1111 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1112
1113 prop = RNA_def_property(srna, "thickness_max", PROP_FLOAT, PROP_NONE);
1114 RNA_def_property_float_sdna(prop, NULL, "max_thickness");
1115 RNA_def_property_range(prop, 0.0f, 10000.0f);
1116 RNA_def_property_ui_text(prop, "Max Thickness", "Maximum thickness");
1117 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1118
1119 srna = RNA_def_struct(
1120 brna, "LineStyleThicknessModifier_AlongStroke", "LineStyleThicknessModifier");
1121 RNA_def_struct_ui_text(srna, "Along Stroke", "Change line thickness along stroke");
1122 rna_def_thickness_modifier(srna);
1123 rna_def_modifier_curve_common(srna, false, true);
1124
1125 srna = RNA_def_struct(
1126 brna, "LineStyleThicknessModifier_DistanceFromCamera", "LineStyleThicknessModifier");
1127 RNA_def_struct_ui_text(
1128 srna, "Distance from Camera", "Change line thickness based on the distance from the camera");
1129 rna_def_thickness_modifier(srna);
1130 rna_def_modifier_curve_common(srna, true, true);
1131
1132 srna = RNA_def_struct(
1133 brna, "LineStyleThicknessModifier_DistanceFromObject", "LineStyleThicknessModifier");
1134 RNA_def_struct_ui_text(
1135 srna, "Distance from Object", "Change line thickness based on the distance from an object");
1136 rna_def_thickness_modifier(srna);
1137 rna_def_modifier_curve_common(srna, true, true);
1138
1139 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
1140 RNA_def_property_pointer_sdna(prop, NULL, "target");
1141 RNA_def_property_struct_type(prop, "Object");
1142 RNA_def_property_flag(prop, PROP_EDITABLE);
1143 RNA_def_property_ui_text(prop, "Target", "Target object from which the distance is measured");
1144 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1145
1146 srna = RNA_def_struct(brna, "LineStyleThicknessModifier_Material", "LineStyleThicknessModifier");
1147 RNA_def_struct_ui_text(srna, "Material", "Change line thickness based on a material attribute");
1148 rna_def_thickness_modifier(srna);
1149 rna_def_modifier_material_common(srna);
1150 rna_def_modifier_curve_common(srna, false, true);
1151
1152 srna = RNA_def_struct(
1153 brna, "LineStyleThicknessModifier_Calligraphy", "LineStyleThicknessModifier");
1154 RNA_def_struct_ui_text(
1155 srna,
1156 "Calligraphy",
1157 "Change line thickness so that stroke looks like made with a calligraphic pen");
1158 rna_def_thickness_modifier(srna);
1159
1160 prop = RNA_def_property(srna, "orientation", PROP_FLOAT, PROP_ANGLE);
1161 RNA_def_property_float_sdna(prop, NULL, "orientation");
1162 RNA_def_property_ui_text(prop, "Orientation", "Angle of the main direction");
1163 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1164
1165 prop = RNA_def_property(srna, "thickness_min", PROP_FLOAT, PROP_NONE);
1166 RNA_def_property_float_sdna(prop, NULL, "min_thickness");
1167 RNA_def_property_range(prop, 0.0f, 10000.0f);
1168 RNA_def_property_ui_text(
1169 prop,
1170 "Min Thickness",
1171 "Minimum thickness in the direction perpendicular to the main direction");
1172 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1173
1174 prop = RNA_def_property(srna, "thickness_max", PROP_FLOAT, PROP_NONE);
1175 RNA_def_property_float_sdna(prop, NULL, "max_thickness");
1176 RNA_def_property_range(prop, 0.0f, 10000.0f);
1177 RNA_def_property_ui_text(prop, "Max Thickness", "Maximum thickness in the main direction");
1178 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1179
1180 srna = RNA_def_struct(brna, "LineStyleThicknessModifier_Noise", "LineStyleThicknessModifier");
1181 RNA_def_struct_ui_text(srna, "Noise", "Line thickness based on random noise");
1182 rna_def_thickness_modifier(srna);
1183
1184 prop = RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
1185 RNA_def_property_float_sdna(prop, NULL, "amplitude");
1186 RNA_def_property_ui_text(prop, "Amplitude", "Amplitude of the noise");
1187 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1188
1189 prop = RNA_def_property(srna, "period", PROP_FLOAT, PROP_NONE);
1190 RNA_def_property_float_sdna(prop, NULL, "period");
1191 RNA_def_property_ui_text(prop, "Period", "Period of the noise");
1192 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1193
1194 prop = RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
1195 RNA_def_property_int_sdna(prop, NULL, "seed");
1196 RNA_def_property_ui_text(prop, "Seed", "Seed for the noise generation");
1197 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1198
1199 prop = RNA_def_property(srna, "use_asymmetric", PROP_BOOLEAN, PROP_NONE);
1200 RNA_def_property_boolean_sdna(prop, NULL, "flags", LS_THICKNESS_ASYMMETRIC);
1201 RNA_def_property_ui_text(prop, "Asymmetric", "Allow thickness to be assigned asymmetrically");
1202 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1203
1204 srna = RNA_def_struct(
1205 brna, "LineStyleThicknessModifier_Curvature_3D", "LineStyleThicknessModifier");
1206 RNA_def_struct_ui_text(
1207 srna, "Curvature 3D", "Line thickness based on the radial curvature of 3D mesh surfaces");
1208 rna_def_thickness_modifier(srna);
1209 rna_def_modifier_curve_common(srna, false, false);
1210
1211 prop = RNA_def_property(srna, "thickness_min", PROP_FLOAT, PROP_NONE);
1212 RNA_def_property_float_sdna(prop, NULL, "min_thickness");
1213 RNA_def_property_range(prop, 0.0f, 10000.0f);
1214 RNA_def_property_ui_text(prop, "Min Thickness", "Minimum thickness");
1215 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1216
1217 prop = RNA_def_property(srna, "thickness_max", PROP_FLOAT, PROP_NONE);
1218 RNA_def_property_float_sdna(prop, NULL, "max_thickness");
1219 RNA_def_property_range(prop, 0.0f, 10000.0f);
1220 RNA_def_property_ui_text(prop, "Max Thickness", "Maximum thickness");
1221 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1222
1223 prop = RNA_def_property(srna, "curvature_min", PROP_FLOAT, PROP_NONE);
1224 RNA_def_property_float_sdna(prop, NULL, "min_curvature");
1225 RNA_def_property_range(prop, 0.0f, 10000.0f);
1226 RNA_def_property_ui_text(prop, "Min Curvature", "Minimum Curvature");
1227 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1228
1229 prop = RNA_def_property(srna, "curvature_max", PROP_FLOAT, PROP_NONE);
1230 RNA_def_property_float_sdna(prop, NULL, "max_curvature");
1231 RNA_def_property_range(prop, 0.0f, 10000.0f);
1232 RNA_def_property_ui_text(prop, "Max Curvature", "Maximum Curvature");
1233 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1234
1235 srna = RNA_def_struct(
1236 brna, "LineStyleThicknessModifier_CreaseAngle", "LineStyleThicknessModifier");
1237 RNA_def_struct_ui_text(
1238 srna, "Crease Angle", "Line thickness based on the angle between two adjacent faces");
1239 rna_def_thickness_modifier(srna);
1240 rna_def_modifier_curve_common(srna, false, false);
1241
1242 prop = RNA_def_property(srna, "angle_min", PROP_FLOAT, PROP_ANGLE);
1243 RNA_def_property_float_sdna(prop, NULL, "min_angle");
1244 RNA_def_property_ui_text(prop, "Min Angle", "Minimum angle to modify thickness");
1245 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1246
1247 prop = RNA_def_property(srna, "angle_max", PROP_FLOAT, PROP_ANGLE);
1248 RNA_def_property_float_sdna(prop, NULL, "max_angle");
1249 RNA_def_property_ui_text(prop, "Max Angle", "Maximum angle to modify thickness");
1250 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1251
1252 prop = RNA_def_property(srna, "thickness_min", PROP_FLOAT, PROP_NONE);
1253 RNA_def_property_float_sdna(prop, NULL, "min_thickness");
1254 RNA_def_property_range(prop, 0.0f, 10000.0f);
1255 RNA_def_property_ui_text(prop, "Min Thickness", "Minimum thickness");
1256 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1257
1258 prop = RNA_def_property(srna, "thickness_max", PROP_FLOAT, PROP_NONE);
1259 RNA_def_property_float_sdna(prop, NULL, "max_thickness");
1260 RNA_def_property_range(prop, 0.0f, 10000.0f);
1261 RNA_def_property_ui_text(prop, "Max Thickness", "Maximum thickness");
1262 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1263
1264 /* geometry modifiers */
1265
1266 srna = RNA_def_struct(brna, "LineStyleGeometryModifier", "LineStyleModifier");
1267 RNA_def_struct_sdna(srna, "LineStyleModifier");
1268 RNA_def_struct_refine_func(srna, "rna_LineStyle_geometry_modifier_refine");
1269 RNA_def_struct_path_func(srna, "rna_LineStyle_geometry_modifier_path");
1270 RNA_def_struct_ui_text(
1271 srna, "Line Style Geometry Modifier", "Base type to define stroke geometry modifiers");
1272
1273 srna = RNA_def_struct(brna, "LineStyleGeometryModifier_Sampling", "LineStyleGeometryModifier");
1274 RNA_def_struct_ui_text(
1275 srna,
1276 "Sampling",
1277 "Specify a new sampling value that determines the resolution of stroke polylines");
1278 rna_def_geometry_modifier(srna);
1279
1280 prop = RNA_def_property(srna, "sampling", PROP_FLOAT, PROP_NONE);
1281 RNA_def_property_float_sdna(prop, NULL, "sampling");
1282 RNA_def_property_range(prop, 0.0f, 10000.0f);
1283 RNA_def_property_ui_text(
1284 prop, "Sampling", "New sampling value to be used for subsequent modifiers");
1285 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1286
1287 srna = RNA_def_struct(
1288 brna, "LineStyleGeometryModifier_BezierCurve", "LineStyleGeometryModifier");
1289 RNA_def_struct_ui_text(srna,
1290 "Bezier Curve",
1291 "Replace stroke backbone geometry by a Bezier curve approximation of the "
1292 "original backbone geometry");
1293 rna_def_geometry_modifier(srna);
1294
1295 prop = RNA_def_property(srna, "error", PROP_FLOAT, PROP_NONE);
1296 RNA_def_property_float_sdna(prop, NULL, "error");
1297 RNA_def_property_ui_text(prop,
1298 "Error",
1299 "Maximum distance allowed between the new Bezier curve and the "
1300 "original backbone geometry");
1301 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1302
1303 srna = RNA_def_struct(
1304 brna, "LineStyleGeometryModifier_SinusDisplacement", "LineStyleGeometryModifier");
1305 RNA_def_struct_ui_text(
1306 srna, "Sinus Displacement", "Add sinus displacement to stroke backbone geometry");
1307 rna_def_geometry_modifier(srna);
1308
1309 prop = RNA_def_property(srna, "wavelength", PROP_FLOAT, PROP_NONE);
1310 RNA_def_property_float_sdna(prop, NULL, "wavelength");
1311 RNA_def_property_ui_text(prop, "Wavelength", "Wavelength of the sinus displacement");
1312 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1313
1314 prop = RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
1315 RNA_def_property_float_sdna(prop, NULL, "amplitude");
1316 RNA_def_property_ui_text(prop, "Amplitude", "Amplitude of the sinus displacement");
1317 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1318
1319 prop = RNA_def_property(srna, "phase", PROP_FLOAT, PROP_NONE);
1320 RNA_def_property_float_sdna(prop, NULL, "phase");
1321 RNA_def_property_ui_text(prop, "Phase", "Phase of the sinus displacement");
1322 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1323
1324 srna = RNA_def_struct(
1325 brna, "LineStyleGeometryModifier_SpatialNoise", "LineStyleGeometryModifier");
1326 RNA_def_struct_ui_text(srna, "Spatial Noise", "Add spatial noise to stroke backbone geometry");
1327 rna_def_geometry_modifier(srna);
1328
1329 prop = RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
1330 RNA_def_property_float_sdna(prop, NULL, "amplitude");
1331 RNA_def_property_ui_text(prop, "Amplitude", "Amplitude of the spatial noise");
1332 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1333
1334 prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
1335 RNA_def_property_float_sdna(prop, NULL, "scale");
1336 RNA_def_property_ui_text(prop, "Scale", "Scale of the spatial noise");
1337 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1338
1339 prop = RNA_def_property(srna, "octaves", PROP_INT, PROP_UNSIGNED);
1340 RNA_def_property_int_sdna(prop, NULL, "octaves");
1341 RNA_def_property_ui_text(
1342 prop, "Octaves", "Number of octaves (i.e., the amount of detail of the spatial noise)");
1343 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1344
1345 prop = RNA_def_property(srna, "smooth", PROP_BOOLEAN, PROP_NONE);
1346 RNA_def_property_boolean_sdna(prop, NULL, "flags", LS_MODIFIER_SPATIAL_NOISE_SMOOTH);
1347 RNA_def_property_ui_text(prop, "Smooth", "If true, the spatial noise is smooth");
1348 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1349
1350 prop = RNA_def_property(srna, "use_pure_random", PROP_BOOLEAN, PROP_NONE);
1351 RNA_def_property_boolean_sdna(prop, NULL, "flags", LS_MODIFIER_SPATIAL_NOISE_PURERANDOM);
1352 RNA_def_property_ui_text(
1353 prop, "Pure Random", "If true, the spatial noise does not show any coherence");
1354 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1355
1356 srna = RNA_def_struct(
1357 brna, "LineStyleGeometryModifier_PerlinNoise1D", "LineStyleGeometryModifier");
1358 RNA_def_struct_ui_text(
1359 srna, "Perlin Noise 1D", "Add one-dimensional Perlin noise to stroke backbone geometry");
1360 rna_def_geometry_modifier(srna);
1361
1362 prop = RNA_def_property(srna, "frequency", PROP_FLOAT, PROP_NONE);
1363 RNA_def_property_float_sdna(prop, NULL, "frequency");
1364 RNA_def_property_ui_text(prop, "Frequency", "Frequency of the Perlin noise");
1365 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1366
1367 prop = RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
1368 RNA_def_property_float_sdna(prop, NULL, "amplitude");
1369 RNA_def_property_ui_text(prop, "Amplitude", "Amplitude of the Perlin noise");
1370 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1371
1372 prop = RNA_def_property(srna, "octaves", PROP_INT, PROP_UNSIGNED);
1373 RNA_def_property_int_sdna(prop, NULL, "octaves");
1374 RNA_def_property_ui_text(
1375 prop, "Octaves", "Number of octaves (i.e., the amount of detail of the Perlin noise)");
1376 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1377
1378 prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
1379 RNA_def_property_float_sdna(prop, NULL, "angle");
1380 RNA_def_property_ui_text(prop, "Angle", "Displacement direction");
1381 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1382
1383 prop = RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
1384 RNA_def_property_int_sdna(prop, NULL, "seed");
1385 RNA_def_property_ui_text(
1386 prop,
1387 "Seed",
1388 "Seed for random number generation (if negative, time is used as a seed instead)");
1389 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1390
1391 srna = RNA_def_struct(
1392 brna, "LineStyleGeometryModifier_PerlinNoise2D", "LineStyleGeometryModifier");
1393 RNA_def_struct_ui_text(
1394 srna, "Perlin Noise 2D", "Add two-dimensional Perlin noise to stroke backbone geometry");
1395 rna_def_geometry_modifier(srna);
1396
1397 prop = RNA_def_property(srna, "frequency", PROP_FLOAT, PROP_NONE);
1398 RNA_def_property_float_sdna(prop, NULL, "frequency");
1399 RNA_def_property_ui_text(prop, "Frequency", "Frequency of the Perlin noise");
1400 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1401
1402 prop = RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
1403 RNA_def_property_float_sdna(prop, NULL, "amplitude");
1404 RNA_def_property_ui_text(prop, "Amplitude", "Amplitude of the Perlin noise");
1405 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1406
1407 prop = RNA_def_property(srna, "octaves", PROP_INT, PROP_UNSIGNED);
1408 RNA_def_property_int_sdna(prop, NULL, "octaves");
1409 RNA_def_property_ui_text(
1410 prop, "Octaves", "Number of octaves (i.e., the amount of detail of the Perlin noise)");
1411 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1412
1413 prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
1414 RNA_def_property_float_sdna(prop, NULL, "angle");
1415 RNA_def_property_ui_text(prop, "Angle", "Displacement direction");
1416 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1417
1418 prop = RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
1419 RNA_def_property_int_sdna(prop, NULL, "seed");
1420 RNA_def_property_ui_text(
1421 prop,
1422 "Seed",
1423 "Seed for random number generation (if negative, time is used as a seed instead)");
1424 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1425
1426 srna = RNA_def_struct(
1427 brna, "LineStyleGeometryModifier_BackboneStretcher", "LineStyleGeometryModifier");
1428 RNA_def_struct_ui_text(
1429 srna, "Backbone Stretcher", "Stretch the beginning and the end of stroke backbone");
1430 rna_def_geometry_modifier(srna);
1431
1432 prop = RNA_def_property(srna, "backbone_length", PROP_FLOAT, PROP_NONE);
1433 RNA_def_property_float_sdna(prop, NULL, "backbone_length");
1434 RNA_def_property_ui_text(prop, "Backbone Length", "Amount of backbone stretching");
1435 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1436
1437 srna = RNA_def_struct(brna, "LineStyleGeometryModifier_TipRemover", "LineStyleGeometryModifier");
1438 RNA_def_struct_ui_text(
1439 srna,
1440 "Tip Remover",
1441 "Remove a piece of stroke at the beginning and the end of stroke backbone");
1442 rna_def_geometry_modifier(srna);
1443
1444 prop = RNA_def_property(srna, "tip_length", PROP_FLOAT, PROP_NONE);
1445 RNA_def_property_float_sdna(prop, NULL, "tip_length");
1446 RNA_def_property_ui_text(prop, "Tip Length", "Length of tips to be removed");
1447 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1448
1449 srna = RNA_def_struct(
1450 brna, "LineStyleGeometryModifier_Polygonalization", "LineStyleGeometryModifier");
1451 RNA_def_struct_ui_text(
1452 srna, "Polygonalization", "Modify the stroke geometry so that it looks more 'polygonal'");
1453 rna_def_geometry_modifier(srna);
1454
1455 prop = RNA_def_property(srna, "error", PROP_FLOAT, PROP_NONE);
1456 RNA_def_property_float_sdna(prop, NULL, "error");
1457 RNA_def_property_ui_text(
1458 prop,
1459 "Error",
1460 "Maximum distance between the original stroke and its polygonal approximation");
1461 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1462
1463 srna = RNA_def_struct(
1464 brna, "LineStyleGeometryModifier_GuidingLines", "LineStyleGeometryModifier");
1465 RNA_def_struct_ui_text(
1466 srna,
1467 "Guiding Lines",
1468 "Modify the stroke geometry so that it corresponds to its main direction line");
1469 rna_def_geometry_modifier(srna);
1470
1471 prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
1472 RNA_def_property_float_sdna(prop, NULL, "offset");
1473 RNA_def_property_ui_text(
1474 prop, "Offset", "Displacement that is applied to the main direction line along its normal");
1475 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1476
1477 srna = RNA_def_struct(brna, "LineStyleGeometryModifier_Blueprint", "LineStyleGeometryModifier");
1478 RNA_def_struct_ui_text(
1479 srna,
1480 "Blueprint",
1481 "Produce a blueprint using circular, elliptic, and square contour strokes");
1482 rna_def_geometry_modifier(srna);
1483
1484 prop = RNA_def_property(srna, "shape", PROP_ENUM, PROP_NONE);
1485 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
1486 RNA_def_property_enum_items(prop, blueprint_shape_items);
1487 RNA_def_property_ui_text(prop, "Shape", "Select the shape of blueprint contour strokes");
1488 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1489
1490 prop = RNA_def_property(srna, "rounds", PROP_INT, PROP_UNSIGNED);
1491 RNA_def_property_int_sdna(prop, NULL, "rounds");
1492 RNA_def_property_range(prop, 1, 1000);
1493 RNA_def_property_ui_text(prop, "Rounds", "Number of rounds in contour strokes");
1494 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1495
1496 prop = RNA_def_property(srna, "backbone_length", PROP_FLOAT, PROP_NONE);
1497 RNA_def_property_float_sdna(prop, NULL, "backbone_length");
1498 RNA_def_property_ui_text(prop, "Backbone Length", "Amount of backbone stretching");
1499 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1500
1501 prop = RNA_def_property(srna, "random_radius", PROP_INT, PROP_UNSIGNED);
1502 RNA_def_property_int_sdna(prop, NULL, "random_radius");
1503 RNA_def_property_ui_text(prop, "Random Radius", "Randomness of the radius");
1504 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1505
1506 prop = RNA_def_property(srna, "random_center", PROP_INT, PROP_UNSIGNED);
1507 RNA_def_property_int_sdna(prop, NULL, "random_center");
1508 RNA_def_property_ui_text(prop, "Random Center", "Randomness of the center");
1509 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1510
1511 prop = RNA_def_property(srna, "random_backbone", PROP_INT, PROP_UNSIGNED);
1512 RNA_def_property_int_sdna(prop, NULL, "random_backbone");
1513 RNA_def_property_ui_text(prop, "Random Backbone", "Randomness of the backbone stretching");
1514 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1515
1516 srna = RNA_def_struct(brna, "LineStyleGeometryModifier_2DOffset", "LineStyleGeometryModifier");
1517 RNA_def_struct_ui_text(
1518 srna, "2D Offset", "Add two-dimensional offsets to stroke backbone geometry");
1519 rna_def_geometry_modifier(srna);
1520
1521 prop = RNA_def_property(srna, "start", PROP_FLOAT, PROP_NONE);
1522 RNA_def_property_float_sdna(prop, NULL, "start");
1523 RNA_def_property_ui_text(
1524 prop, "Start", "Displacement that is applied from the beginning of the stroke");
1525 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1526
1527 prop = RNA_def_property(srna, "end", PROP_FLOAT, PROP_NONE);
1528 RNA_def_property_float_sdna(prop, NULL, "end");
1529 RNA_def_property_ui_text(prop, "End", "Displacement that is applied from the end of the stroke");
1530 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1531
1532 prop = RNA_def_property(srna, "x", PROP_FLOAT, PROP_NONE);
1533 RNA_def_property_float_sdna(prop, NULL, "x");
1534 RNA_def_property_ui_text(
1535 prop, "X", "Displacement that is applied to the X coordinates of stroke vertices");
1536 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1537
1538 prop = RNA_def_property(srna, "y", PROP_FLOAT, PROP_NONE);
1539 RNA_def_property_float_sdna(prop, NULL, "y");
1540 RNA_def_property_ui_text(
1541 prop, "Y", "Displacement that is applied to the Y coordinates of stroke vertices");
1542 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1543
1544 srna = RNA_def_struct(
1545 brna, "LineStyleGeometryModifier_2DTransform", "LineStyleGeometryModifier");
1546 RNA_def_struct_ui_text(srna,
1547 "2D Transform",
1548 "Apply two-dimensional scaling and rotation to stroke backbone geometry");
1549 rna_def_geometry_modifier(srna);
1550
1551 prop = RNA_def_property(srna, "pivot", PROP_ENUM, PROP_NONE);
1552 RNA_def_property_enum_sdna(prop, NULL, "pivot");
1553 RNA_def_property_enum_items(prop, transform_pivot_items);
1554 RNA_def_property_ui_text(prop, "Pivot", "Pivot of scaling and rotation operations");
1555 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1556
1557 prop = RNA_def_property(srna, "scale_x", PROP_FLOAT, PROP_NONE);
1558 RNA_def_property_float_sdna(prop, NULL, "scale_x");
1559 RNA_def_property_flag(prop, PROP_PROPORTIONAL);
1560 RNA_def_property_ui_text(prop, "Scale X", "Scaling factor that is applied along the X axis");
1561 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1562
1563 prop = RNA_def_property(srna, "scale_y", PROP_FLOAT, PROP_NONE);
1564 RNA_def_property_float_sdna(prop, NULL, "scale_y");
1565 RNA_def_property_flag(prop, PROP_PROPORTIONAL);
1566 RNA_def_property_ui_text(prop, "Scale Y", "Scaling factor that is applied along the Y axis");
1567 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1568
1569 prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
1570 RNA_def_property_float_sdna(prop, NULL, "angle");
1571 RNA_def_property_ui_text(prop, "Rotation Angle", "Rotation angle");
1572 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1573
1574 prop = RNA_def_property(srna, "pivot_u", PROP_FLOAT, PROP_FACTOR);
1575 RNA_def_property_float_sdna(prop, NULL, "pivot_u");
1576 RNA_def_property_range(prop, 0.f, 1.f);
1577 RNA_def_property_ui_text(prop,
1578 "Stroke Point Parameter",
1579 "Pivot in terms of the stroke point parameter u (0 <= u <= 1)");
1580 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1581
1582 prop = RNA_def_property(srna, "pivot_x", PROP_FLOAT, PROP_NONE);
1583 RNA_def_property_float_sdna(prop, NULL, "pivot_x");
1584 RNA_def_property_ui_text(prop, "Pivot X", "2D X coordinate of the absolute pivot");
1585 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1586
1587 prop = RNA_def_property(srna, "pivot_y", PROP_FLOAT, PROP_NONE);
1588 RNA_def_property_float_sdna(prop, NULL, "pivot_y");
1589 RNA_def_property_ui_text(prop, "Pivot Y", "2D Y coordinate of the absolute pivot");
1590 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1591
1592 srna = RNA_def_struct(
1593 brna, "LineStyleGeometryModifier_Simplification", "LineStyleGeometryModifier");
1594 RNA_def_struct_ui_text(srna, "Simplification", "Simplify the stroke set");
1595 rna_def_geometry_modifier(srna);
1596
1597 prop = RNA_def_property(srna, "tolerance", PROP_FLOAT, PROP_NONE);
1598 RNA_def_property_float_sdna(prop, NULL, "tolerance");
1599 RNA_def_property_ui_text(prop, "Tolerance", "Distance below which segments will be merged");
1600 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1601 }
1602
rna_def_freestyle_color_modifiers(BlenderRNA * brna,PropertyRNA * cprop)1603 static void rna_def_freestyle_color_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
1604 {
1605 StructRNA *srna;
1606 FunctionRNA *func;
1607 PropertyRNA *parm;
1608
1609 RNA_def_property_srna(cprop, "LineStyleColorModifiers");
1610 srna = RNA_def_struct(brna, "LineStyleColorModifiers", NULL);
1611 RNA_def_struct_sdna(srna, "FreestyleLineStyle");
1612 RNA_def_struct_ui_text(srna, "Color Modifiers", "Color modifiers for changing line colors");
1613
1614 func = RNA_def_function(srna, "new", "rna_LineStyle_color_modifier_add");
1615 RNA_def_function_ui_description(func, "Add a color modifier to line style");
1616 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1617 parm = RNA_def_string(
1618 func, "name", "ColorModifier", 0, "", "New name for the color modifier (not unique)");
1619 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1620 parm = RNA_def_enum(func,
1621 "type",
1622 rna_enum_linestyle_color_modifier_type_items,
1623 0,
1624 "",
1625 "Color modifier type to add");
1626 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1627 parm = RNA_def_pointer(
1628 func, "modifier", "LineStyleColorModifier", "", "Newly added color modifier");
1629 RNA_def_function_return(func, parm);
1630
1631 func = RNA_def_function(srna, "remove", "rna_LineStyle_color_modifier_remove");
1632 RNA_def_function_ui_description(func, "Remove a color modifier from line style");
1633 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1634 parm = RNA_def_pointer(
1635 func, "modifier", "LineStyleColorModifier", "", "Color modifier to remove");
1636 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1637 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1638 }
1639
rna_def_freestyle_alpha_modifiers(BlenderRNA * brna,PropertyRNA * cprop)1640 static void rna_def_freestyle_alpha_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
1641 {
1642 StructRNA *srna;
1643 FunctionRNA *func;
1644 PropertyRNA *parm;
1645
1646 RNA_def_property_srna(cprop, "LineStyleAlphaModifiers");
1647 srna = RNA_def_struct(brna, "LineStyleAlphaModifiers", NULL);
1648 RNA_def_struct_sdna(srna, "FreestyleLineStyle");
1649 RNA_def_struct_ui_text(srna, "Alpha Modifiers", "Alpha modifiers for changing line alphas");
1650
1651 func = RNA_def_function(srna, "new", "rna_LineStyle_alpha_modifier_add");
1652 RNA_def_function_ui_description(func, "Add a alpha modifier to line style");
1653 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1654 parm = RNA_def_string(
1655 func, "name", "AlphaModifier", 0, "", "New name for the alpha modifier (not unique)");
1656 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1657 parm = RNA_def_enum(func,
1658 "type",
1659 rna_enum_linestyle_alpha_modifier_type_items,
1660 0,
1661 "",
1662 "Alpha modifier type to add");
1663 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1664 parm = RNA_def_pointer(
1665 func, "modifier", "LineStyleAlphaModifier", "", "Newly added alpha modifier");
1666 RNA_def_function_return(func, parm);
1667
1668 func = RNA_def_function(srna, "remove", "rna_LineStyle_alpha_modifier_remove");
1669 RNA_def_function_ui_description(func, "Remove a alpha modifier from line style");
1670 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1671 parm = RNA_def_pointer(
1672 func, "modifier", "LineStyleAlphaModifier", "", "Alpha modifier to remove");
1673 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1674 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1675 }
1676
rna_def_freestyle_thickness_modifiers(BlenderRNA * brna,PropertyRNA * cprop)1677 static void rna_def_freestyle_thickness_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
1678 {
1679 StructRNA *srna;
1680 FunctionRNA *func;
1681 PropertyRNA *parm;
1682
1683 RNA_def_property_srna(cprop, "LineStyleThicknessModifiers");
1684 srna = RNA_def_struct(brna, "LineStyleThicknessModifiers", NULL);
1685 RNA_def_struct_sdna(srna, "FreestyleLineStyle");
1686 RNA_def_struct_ui_text(
1687 srna, "Thickness Modifiers", "Thickness modifiers for changing line thickness");
1688
1689 func = RNA_def_function(srna, "new", "rna_LineStyle_thickness_modifier_add");
1690 RNA_def_function_ui_description(func, "Add a thickness modifier to line style");
1691 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1692 parm = RNA_def_string(func,
1693 "name",
1694 "ThicknessModifier",
1695 0,
1696 "",
1697 "New name for the thickness modifier (not unique)");
1698 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1699 parm = RNA_def_enum(func,
1700 "type",
1701 rna_enum_linestyle_thickness_modifier_type_items,
1702 0,
1703 "",
1704 "Thickness modifier type to add");
1705 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1706 parm = RNA_def_pointer(
1707 func, "modifier", "LineStyleThicknessModifier", "", "Newly added thickness modifier");
1708 RNA_def_function_return(func, parm);
1709
1710 func = RNA_def_function(srna, "remove", "rna_LineStyle_thickness_modifier_remove");
1711 RNA_def_function_ui_description(func, "Remove a thickness modifier from line style");
1712 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1713 parm = RNA_def_pointer(
1714 func, "modifier", "LineStyleThicknessModifier", "", "Thickness modifier to remove");
1715 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1716 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1717 }
1718
rna_def_freestyle_geometry_modifiers(BlenderRNA * brna,PropertyRNA * cprop)1719 static void rna_def_freestyle_geometry_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
1720 {
1721 StructRNA *srna;
1722 FunctionRNA *func;
1723 PropertyRNA *parm;
1724
1725 RNA_def_property_srna(cprop, "LineStyleGeometryModifiers");
1726 srna = RNA_def_struct(brna, "LineStyleGeometryModifiers", NULL);
1727 RNA_def_struct_sdna(srna, "FreestyleLineStyle");
1728 RNA_def_struct_ui_text(
1729 srna, "Geometry Modifiers", "Geometry modifiers for changing line geometries");
1730
1731 func = RNA_def_function(srna, "new", "rna_LineStyle_geometry_modifier_add");
1732 RNA_def_function_ui_description(func, "Add a geometry modifier to line style");
1733 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1734 parm = RNA_def_string(
1735 func, "name", "GeometryModifier", 0, "", "New name for the geometry modifier (not unique)");
1736 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1737 parm = RNA_def_enum(func,
1738 "type",
1739 rna_enum_linestyle_geometry_modifier_type_items,
1740 0,
1741 "",
1742 "Geometry modifier type to add");
1743 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1744 parm = RNA_def_pointer(
1745 func, "modifier", "LineStyleGeometryModifier", "", "Newly added geometry modifier");
1746 RNA_def_function_return(func, parm);
1747
1748 func = RNA_def_function(srna, "remove", "rna_LineStyle_geometry_modifier_remove");
1749 RNA_def_function_ui_description(func, "Remove a geometry modifier from line style");
1750 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1751 parm = RNA_def_pointer(
1752 func, "modifier", "LineStyleGeometryModifier", "", "Geometry modifier to remove");
1753 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1754 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1755 }
1756
rna_def_linestyle(BlenderRNA * brna)1757 static void rna_def_linestyle(BlenderRNA *brna)
1758 {
1759 StructRNA *srna;
1760 PropertyRNA *prop;
1761
1762 static const EnumPropertyItem panel_items[] = {
1763 {LS_PANEL_STROKES, "STROKES", 0, "Strokes", "Show the panel for stroke construction"},
1764 {LS_PANEL_COLOR, "COLOR", 0, "Color", "Show the panel for line color options"},
1765 {LS_PANEL_ALPHA, "ALPHA", 0, "Alpha", "Show the panel for alpha transparency options"},
1766 {LS_PANEL_THICKNESS, "THICKNESS", 0, "Thickness", "Show the panel for line thickness options"},
1767 {LS_PANEL_GEOMETRY, "GEOMETRY", 0, "Geometry", "Show the panel for stroke geometry options"},
1768 {LS_PANEL_TEXTURE, "TEXTURE", 0, "Texture", "Show the panel for stroke texture options"},
1769 # if 0 /* hidden for now */
1770 {LS_PANEL_MISC, "MISC", 0, "Misc", "Show the panel for miscellaneous options"},
1771 # endif
1772 {0, NULL, 0, NULL, NULL},
1773 };
1774 static const EnumPropertyItem chaining_items[] = {
1775 {LS_CHAINING_PLAIN, "PLAIN", 0, "Plain", "Plain chaining"},
1776 {LS_CHAINING_SKETCHY, "SKETCHY", 0, "Sketchy", "Sketchy chaining with a multiple touch"},
1777 {0, NULL, 0, NULL, NULL},
1778 };
1779 static const EnumPropertyItem cap_items[] = {
1780 {LS_CAPS_BUTT, "BUTT", 0, "Butt", "Butt cap (flat)"},
1781 {LS_CAPS_ROUND, "ROUND", 0, "Round", "Round cap (half-circle)"},
1782 {LS_CAPS_SQUARE, "SQUARE", 0, "Square", "Square cap (flat and extended)"},
1783 {0, NULL, 0, NULL, NULL},
1784 };
1785 static const EnumPropertyItem thickness_position_items[] = {
1786 {LS_THICKNESS_CENTER,
1787 "CENTER",
1788 0,
1789 "Center",
1790 "Silhouettes and border edges are centered along stroke geometry"},
1791 {LS_THICKNESS_INSIDE,
1792 "INSIDE",
1793 0,
1794 "Inside",
1795 "Silhouettes and border edges are drawn inside of stroke geometry"},
1796 {LS_THICKNESS_OUTSIDE,
1797 "OUTSIDE",
1798 0,
1799 "Outside",
1800 "Silhouettes and border edges are drawn outside of stroke geometry"},
1801 {LS_THICKNESS_RELATIVE,
1802 "RELATIVE",
1803 0,
1804 "Relative",
1805 "Silhouettes and border edges are shifted by a user-defined ratio"},
1806 {0, NULL, 0, NULL, NULL},
1807 };
1808 static const EnumPropertyItem sort_key_items[] = {
1809 {LS_SORT_KEY_DISTANCE_FROM_CAMERA,
1810 "DISTANCE_FROM_CAMERA",
1811 0,
1812 "Distance from Camera",
1813 "Sort by distance from camera (closer lines lie on top of further lines)"},
1814 {LS_SORT_KEY_2D_LENGTH,
1815 "2D_LENGTH",
1816 0,
1817 "2D Length",
1818 "Sort by curvilinear 2D length (longer lines lie on top of shorter lines)"},
1819 {LS_SORT_KEY_PROJECTED_X,
1820 "PROJECTED_X",
1821 0,
1822 "Projected X",
1823 "Sort by the projected X value in the image coordinate system"},
1824 {LS_SORT_KEY_PROJECTED_Y,
1825 "PROJECTED_Y",
1826 0,
1827 "Projected Y",
1828 "Sort by the projected Y value in the image coordinate system"},
1829 {0, NULL, 0, NULL, NULL},
1830 };
1831 static const EnumPropertyItem sort_order_items[] = {
1832 {0, "DEFAULT", 0, "Default", "Default order of the sort key"},
1833 {LS_REVERSE_ORDER, "REVERSE", 0, "Reverse", "Reverse order"},
1834 {0, NULL, 0, NULL, NULL},
1835 };
1836 static const EnumPropertyItem integration_type_items[] = {
1837 {LS_INTEGRATION_MEAN,
1838 "MEAN",
1839 0,
1840 "Mean",
1841 "The value computed for the chain is the mean of the values obtained for chain vertices"},
1842 {LS_INTEGRATION_MIN,
1843 "MIN",
1844 0,
1845 "Min",
1846 "The value computed for the chain is the minimum of the values obtained for chain "
1847 "vertices"},
1848 {LS_INTEGRATION_MAX,
1849 "MAX",
1850 0,
1851 "Max",
1852 "The value computed for the chain is the maximum of the values obtained for chain "
1853 "vertices"},
1854 {LS_INTEGRATION_FIRST,
1855 "FIRST",
1856 0,
1857 "First",
1858 "The value computed for the chain is the value obtained for the first chain vertex"},
1859 {LS_INTEGRATION_LAST,
1860 "LAST",
1861 0,
1862 "Last",
1863 "The value computed for the chain is the value obtained for the last chain vertex"},
1864 {0, NULL, 0, NULL, NULL},
1865 };
1866
1867 srna = RNA_def_struct(brna, "FreestyleLineStyle", "ID");
1868 RNA_def_struct_ui_text(
1869 srna, "Freestyle Line Style", "Freestyle line style, reusable by multiple line sets");
1870 RNA_def_struct_ui_icon(srna, ICON_LINE_DATA);
1871
1872 rna_def_mtex_common(brna,
1873 srna,
1874 "rna_LineStyle_mtex_begin",
1875 "rna_LineStyle_active_texture_get",
1876 "rna_LineStyle_active_texture_set",
1877 NULL,
1878 "LineStyleTextureSlot",
1879 "LineStyleTextureSlots",
1880 "rna_LineStyle_update",
1881 "rna_LineStyle_update");
1882
1883 prop = RNA_def_property(srna, "panel", PROP_ENUM, PROP_NONE);
1884 RNA_def_property_enum_bitflag_sdna(prop, NULL, "panel");
1885 RNA_def_property_enum_items(prop, panel_items);
1886 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1887 RNA_def_property_ui_text(prop, "Panel", "Select the property panel to be shown");
1888
1889 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
1890 RNA_def_property_float_sdna(prop, NULL, "r");
1891 RNA_def_property_array(prop, 3);
1892 RNA_def_property_ui_text(
1893 prop, "Color", "Base line color, possibly modified by line color modifiers");
1894 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1895
1896 prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_FACTOR);
1897 RNA_def_property_float_sdna(prop, NULL, "alpha");
1898 RNA_def_property_range(prop, 0.0f, 1.0f);
1899 RNA_def_property_ui_text(
1900 prop,
1901 "Alpha Transparency",
1902 "Base alpha transparency, possibly modified by alpha transparency modifiers");
1903 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1904
1905 prop = RNA_def_property(srna, "thickness", PROP_FLOAT, PROP_NONE);
1906 RNA_def_property_float_sdna(prop, NULL, "thickness");
1907 RNA_def_property_range(prop, 0.0f, 10000.0f);
1908 RNA_def_property_ui_text(
1909 prop, "Thickness", "Base line thickness, possibly modified by line thickness modifiers");
1910 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1911
1912 prop = RNA_def_property(srna, "thickness_position", PROP_ENUM, PROP_NONE);
1913 RNA_def_property_enum_bitflag_sdna(prop, NULL, "thickness_position");
1914 RNA_def_property_enum_items(prop, thickness_position_items);
1915 RNA_def_property_ui_text(prop,
1916 "Thickness Position",
1917 "Thickness position of silhouettes and border edges (applicable when "
1918 "plain chaining is used with the Same Object option)");
1919 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1920
1921 prop = RNA_def_property(srna, "thickness_ratio", PROP_FLOAT, PROP_FACTOR);
1922 RNA_def_property_float_sdna(prop, NULL, "thickness_ratio");
1923 RNA_def_property_range(prop, 0.f, 1.f);
1924 RNA_def_property_ui_text(
1925 prop,
1926 "Thickness Ratio",
1927 "A number between 0 (inside) and 1 (outside) specifying the relative position of "
1928 "stroke thickness");
1929 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1930
1931 prop = RNA_def_property(srna, "color_modifiers", PROP_COLLECTION, PROP_NONE);
1932 RNA_def_property_collection_sdna(prop, NULL, "color_modifiers", NULL);
1933 RNA_def_property_struct_type(prop, "LineStyleColorModifier");
1934 RNA_def_property_ui_text(prop, "Color Modifiers", "List of line color modifiers");
1935 rna_def_freestyle_color_modifiers(brna, prop);
1936
1937 prop = RNA_def_property(srna, "alpha_modifiers", PROP_COLLECTION, PROP_NONE);
1938 RNA_def_property_collection_sdna(prop, NULL, "alpha_modifiers", NULL);
1939 RNA_def_property_struct_type(prop, "LineStyleAlphaModifier");
1940 RNA_def_property_ui_text(prop, "Alpha Modifiers", "List of alpha transparency modifiers");
1941 rna_def_freestyle_alpha_modifiers(brna, prop);
1942
1943 prop = RNA_def_property(srna, "thickness_modifiers", PROP_COLLECTION, PROP_NONE);
1944 RNA_def_property_collection_sdna(prop, NULL, "thickness_modifiers", NULL);
1945 RNA_def_property_struct_type(prop, "LineStyleThicknessModifier");
1946 RNA_def_property_ui_text(prop, "Thickness Modifiers", "List of line thickness modifiers");
1947 rna_def_freestyle_thickness_modifiers(brna, prop);
1948
1949 prop = RNA_def_property(srna, "geometry_modifiers", PROP_COLLECTION, PROP_NONE);
1950 RNA_def_property_collection_sdna(prop, NULL, "geometry_modifiers", NULL);
1951 RNA_def_property_struct_type(prop, "LineStyleGeometryModifier");
1952 RNA_def_property_ui_text(prop, "Geometry Modifiers", "List of stroke geometry modifiers");
1953 rna_def_freestyle_geometry_modifiers(brna, prop);
1954
1955 prop = RNA_def_property(srna, "use_chaining", PROP_BOOLEAN, PROP_NONE);
1956 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", LS_NO_CHAINING);
1957 RNA_def_property_ui_text(prop, "Chaining", "Enable chaining of feature edges");
1958 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1959
1960 prop = RNA_def_property(srna, "chaining", PROP_ENUM, PROP_NONE);
1961 RNA_def_property_enum_sdna(prop, NULL, "chaining");
1962 RNA_def_property_enum_items(prop, chaining_items);
1963 RNA_def_property_ui_text(
1964 prop, "Chaining Method", "Select the way how feature edges are jointed to form chains");
1965 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1966
1967 prop = RNA_def_property(srna, "rounds", PROP_INT, PROP_UNSIGNED);
1968 RNA_def_property_int_sdna(prop, NULL, "rounds");
1969 RNA_def_property_range(prop, 1, 1000);
1970 RNA_def_property_ui_text(prop, "Rounds", "Number of rounds in a sketchy multiple touch");
1971 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1972
1973 prop = RNA_def_property(srna, "use_same_object", PROP_BOOLEAN, PROP_NONE);
1974 RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_SAME_OBJECT);
1975 RNA_def_property_ui_text(
1976 prop, "Same Object", "If true, only feature edges of the same object are joined");
1977 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1978
1979 prop = RNA_def_property(srna, "use_split_length", PROP_BOOLEAN, PROP_NONE);
1980 RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_SPLIT_LENGTH);
1981 RNA_def_property_ui_text(
1982 prop, "Use Split Length", "Enable chain splitting by curvilinear 2D length");
1983 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1984
1985 prop = RNA_def_property(srna, "split_length", PROP_FLOAT, PROP_NONE);
1986 RNA_def_property_float_sdna(prop, NULL, "split_length");
1987 RNA_def_property_range(prop, 0.0f, 10000.0f);
1988 RNA_def_property_ui_text(prop, "Split Length", "Curvilinear 2D length for chain splitting");
1989 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1990
1991 prop = RNA_def_property(srna, "use_angle_min", PROP_BOOLEAN, PROP_NONE);
1992 RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_MIN_2D_ANGLE);
1993 RNA_def_property_ui_text(prop,
1994 "Use Min 2D Angle",
1995 "Split chains at points with angles smaller than the minimum 2D angle");
1996 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
1997
1998 prop = RNA_def_property(srna, "angle_min", PROP_FLOAT, PROP_ANGLE);
1999 RNA_def_property_float_sdna(prop, NULL, "min_angle");
2000 RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
2001 RNA_def_property_ui_text(prop, "Min 2D Angle", "Minimum 2D angle for splitting chains");
2002 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2003
2004 prop = RNA_def_property(srna, "use_angle_max", PROP_BOOLEAN, PROP_NONE);
2005 RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_MAX_2D_ANGLE);
2006 RNA_def_property_ui_text(prop,
2007 "Use Max 2D Angle",
2008 "Split chains at points with angles larger than the maximum 2D angle");
2009 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2010
2011 prop = RNA_def_property(srna, "angle_max", PROP_FLOAT, PROP_ANGLE);
2012 RNA_def_property_float_sdna(prop, NULL, "max_angle");
2013 RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
2014 RNA_def_property_ui_text(prop, "Max 2D Angle", "Maximum 2D angle for splitting chains");
2015 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2016
2017 prop = RNA_def_property(srna, "use_length_min", PROP_BOOLEAN, PROP_NONE);
2018 RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_MIN_2D_LENGTH);
2019 RNA_def_property_ui_text(
2020 prop, "Use Min 2D Length", "Enable the selection of chains by a minimum 2D length");
2021 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2022
2023 prop = RNA_def_property(srna, "length_min", PROP_FLOAT, PROP_NONE);
2024 RNA_def_property_float_sdna(prop, NULL, "min_length");
2025 RNA_def_property_range(prop, 0.0f, 10000.0f);
2026 RNA_def_property_ui_text(
2027 prop, "Min 2D Length", "Minimum curvilinear 2D length for the selection of chains");
2028 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2029
2030 prop = RNA_def_property(srna, "use_length_max", PROP_BOOLEAN, PROP_NONE);
2031 RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_MAX_2D_LENGTH);
2032 RNA_def_property_ui_text(
2033 prop, "Use Max 2D Length", "Enable the selection of chains by a maximum 2D length");
2034 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2035
2036 prop = RNA_def_property(srna, "length_max", PROP_FLOAT, PROP_NONE);
2037 RNA_def_property_float_sdna(prop, NULL, "max_length");
2038 RNA_def_property_range(prop, 0.0f, 10000.0f);
2039 RNA_def_property_ui_text(
2040 prop, "Max 2D Length", "Maximum curvilinear 2D length for the selection of chains");
2041 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2042
2043 prop = RNA_def_property(srna, "use_chain_count", PROP_BOOLEAN, PROP_NONE);
2044 RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_CHAIN_COUNT);
2045 RNA_def_property_ui_text(prop, "Use Chain Count", "Enable the selection of first N chains");
2046 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2047
2048 prop = RNA_def_property(srna, "chain_count", PROP_INT, PROP_UNSIGNED);
2049 RNA_def_property_int_sdna(prop, NULL, "chain_count");
2050 RNA_def_property_ui_text(prop, "Chain Count", "Chain count for the selection of first N chains");
2051 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2052
2053 prop = RNA_def_property(srna, "use_split_pattern", PROP_BOOLEAN, PROP_NONE);
2054 RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_SPLIT_PATTERN);
2055 RNA_def_property_ui_text(
2056 prop, "Use Split Pattern", "Enable chain splitting by dashed line patterns");
2057 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2058
2059 prop = RNA_def_property(srna, "split_dash1", PROP_INT, PROP_UNSIGNED);
2060 RNA_def_property_int_sdna(prop, NULL, "split_dash1");
2061 RNA_def_property_range(prop, 0, USHRT_MAX);
2062 RNA_def_property_ui_text(prop, "Split Dash 1", "Length of the 1st dash for splitting");
2063 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2064
2065 prop = RNA_def_property(srna, "split_gap1", PROP_INT, PROP_UNSIGNED);
2066 RNA_def_property_int_sdna(prop, NULL, "split_gap1");
2067 RNA_def_property_range(prop, 0, USHRT_MAX);
2068 RNA_def_property_ui_text(prop, "Split Gap 1", "Length of the 1st gap for splitting");
2069 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2070
2071 prop = RNA_def_property(srna, "split_dash2", PROP_INT, PROP_UNSIGNED);
2072 RNA_def_property_int_sdna(prop, NULL, "split_dash2");
2073 RNA_def_property_range(prop, 0, USHRT_MAX);
2074 RNA_def_property_ui_text(prop, "Split Dash 2", "Length of the 2nd dash for splitting");
2075 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2076
2077 prop = RNA_def_property(srna, "split_gap2", PROP_INT, PROP_UNSIGNED);
2078 RNA_def_property_int_sdna(prop, NULL, "split_gap2");
2079 RNA_def_property_range(prop, 0, USHRT_MAX);
2080 RNA_def_property_ui_text(prop, "Split Gap 2", "Length of the 2nd gap for splitting");
2081 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2082
2083 prop = RNA_def_property(srna, "split_dash3", PROP_INT, PROP_UNSIGNED);
2084 RNA_def_property_int_sdna(prop, NULL, "split_dash3");
2085 RNA_def_property_range(prop, 0, USHRT_MAX);
2086 RNA_def_property_ui_text(prop, "Split Dash 3", "Length of the 3rd dash for splitting");
2087 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2088
2089 prop = RNA_def_property(srna, "split_gap3", PROP_INT, PROP_UNSIGNED);
2090 RNA_def_property_int_sdna(prop, NULL, "split_gap3");
2091 RNA_def_property_range(prop, 0, USHRT_MAX);
2092 RNA_def_property_ui_text(prop, "Split Gap 3", "Length of the 3rd gap for splitting");
2093 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2094
2095 prop = RNA_def_property(srna, "material_boundary", PROP_BOOLEAN, PROP_NONE);
2096 RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_MATERIAL_BOUNDARY);
2097 RNA_def_property_ui_text(prop,
2098 "Material Boundary",
2099 "If true, chains of feature edges are split at material boundaries");
2100 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2101
2102 prop = RNA_def_property(srna, "use_sorting", PROP_BOOLEAN, PROP_NONE);
2103 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", LS_NO_SORTING);
2104 RNA_def_property_ui_text(prop, "Sorting", "Arrange the stacking order of strokes");
2105 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2106
2107 prop = RNA_def_property(srna, "sort_key", PROP_ENUM, PROP_NONE);
2108 RNA_def_property_enum_sdna(prop, NULL, "sort_key");
2109 RNA_def_property_enum_items(prop, sort_key_items);
2110 RNA_def_property_ui_text(
2111 prop, "Sort Key", "Select the sort key to determine the stacking order of chains");
2112 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2113
2114 prop = RNA_def_property(srna, "sort_order", PROP_ENUM, PROP_NONE);
2115 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
2116 RNA_def_property_enum_items(prop, sort_order_items);
2117 RNA_def_property_ui_text(prop, "Sort Order", "Select the sort order");
2118 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2119
2120 prop = RNA_def_property(srna, "integration_type", PROP_ENUM, PROP_NONE);
2121 RNA_def_property_enum_sdna(prop, NULL, "integration_type");
2122 RNA_def_property_enum_items(prop, integration_type_items);
2123 RNA_def_property_ui_text(
2124 prop, "Integration Type", "Select the way how the sort key is computed for each chain");
2125 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2126
2127 prop = RNA_def_property(srna, "use_dashed_line", PROP_BOOLEAN, PROP_NONE);
2128 RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_DASHED_LINE);
2129 RNA_def_property_ui_text(prop, "Dashed Line", "Enable or disable dashed line");
2130 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2131
2132 prop = RNA_def_property(srna, "caps", PROP_ENUM, PROP_NONE);
2133 RNA_def_property_enum_bitflag_sdna(prop, NULL, "caps");
2134 RNA_def_property_enum_items(prop, cap_items);
2135 RNA_def_property_ui_text(prop, "Caps", "Select the shape of both ends of strokes");
2136 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2137
2138 prop = RNA_def_property(srna, "dash1", PROP_INT, PROP_UNSIGNED);
2139 RNA_def_property_int_sdna(prop, NULL, "dash1");
2140 RNA_def_property_range(prop, 0, USHRT_MAX);
2141 RNA_def_property_ui_text(prop, "Dash 1", "Length of the 1st dash for dashed lines");
2142 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2143
2144 prop = RNA_def_property(srna, "gap1", PROP_INT, PROP_UNSIGNED);
2145 RNA_def_property_int_sdna(prop, NULL, "gap1");
2146 RNA_def_property_range(prop, 0, USHRT_MAX);
2147 RNA_def_property_ui_text(prop, "Gap 1", "Length of the 1st gap for dashed lines");
2148 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2149
2150 prop = RNA_def_property(srna, "dash2", PROP_INT, PROP_UNSIGNED);
2151 RNA_def_property_int_sdna(prop, NULL, "dash2");
2152 RNA_def_property_range(prop, 0, USHRT_MAX);
2153 RNA_def_property_ui_text(prop, "Dash 2", "Length of the 2nd dash for dashed lines");
2154 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2155
2156 prop = RNA_def_property(srna, "gap2", PROP_INT, PROP_UNSIGNED);
2157 RNA_def_property_int_sdna(prop, NULL, "gap2");
2158 RNA_def_property_range(prop, 0, USHRT_MAX);
2159 RNA_def_property_ui_text(prop, "Gap 2", "Length of the 2nd gap for dashed lines");
2160 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2161
2162 prop = RNA_def_property(srna, "dash3", PROP_INT, PROP_UNSIGNED);
2163 RNA_def_property_int_sdna(prop, NULL, "dash3");
2164 RNA_def_property_range(prop, 0, USHRT_MAX);
2165 RNA_def_property_ui_text(prop, "Dash 3", "Length of the 3rd dash for dashed lines");
2166 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2167
2168 prop = RNA_def_property(srna, "gap3", PROP_INT, PROP_UNSIGNED);
2169 RNA_def_property_int_sdna(prop, NULL, "gap3");
2170 RNA_def_property_range(prop, 0, USHRT_MAX);
2171 RNA_def_property_ui_text(prop, "Gap 3", "Length of the 3rd gap for dashed lines");
2172 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2173
2174 prop = RNA_def_property(srna, "use_texture", PROP_BOOLEAN, PROP_NONE);
2175 RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_TEXTURE);
2176 RNA_def_property_ui_text(prop, "Use Textures", "Enable or disable textured strokes");
2177 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2178
2179 prop = RNA_def_property(srna, "texture_spacing", PROP_FLOAT, PROP_FACTOR);
2180 RNA_def_property_float_sdna(prop, NULL, "texstep");
2181 RNA_def_property_range(prop, 0.01f, 100.0f);
2182 RNA_def_property_ui_text(prop, "Texture Spacing", "Spacing for textures along stroke length");
2183 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update");
2184
2185 /* anim */
2186 rna_def_animdata_common(srna);
2187
2188 /* nodes */
2189 prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
2190 RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
2191 RNA_def_property_clear_flag(prop, PROP_PTR_NO_OWNERSHIP);
2192 RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node-based shaders");
2193
2194 prop = RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE);
2195 RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1);
2196 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2197 RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
2198 RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes for the line style");
2199 RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_use_nodes_update");
2200 }
2201
RNA_def_linestyle(BlenderRNA * brna)2202 void RNA_def_linestyle(BlenderRNA *brna)
2203 {
2204 rna_def_linestyle_modifiers(brna);
2205 rna_def_linestyle(brna);
2206 rna_def_linestyle_mtex(brna);
2207 }
2208
2209 #endif
2210