Blender V5.0
linestyle.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2010 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdio>
10#include <cstdlib>
11#include <cstring>
12#include <optional>
13
14#include <fmt/format.h>
15
16#include "MEM_guardedalloc.h"
17
18#include "DNA_defaults.h"
19#include "DNA_material_types.h" /* for ramp blend */
20#include "DNA_object_types.h"
21#include "DNA_sdna_type_ids.hh"
22#include "DNA_texture_types.h"
23
24#include "BLI_listbase.h"
25#include "BLI_math_rotation.h"
26#include "BLI_string.h"
27#include "BLI_string_utf8.h"
28#include "BLI_string_utils.hh"
29#include "BLI_utildefines.h"
30
31#include "BLT_translation.hh"
32
33#include "BKE_colorband.hh"
34#include "BKE_colortools.hh"
35#include "BKE_context.hh"
36#include "BKE_freestyle.h"
37#include "BKE_idtype.hh"
38#include "BKE_lib_id.hh"
39#include "BKE_lib_query.hh"
40#include "BKE_linestyle.h"
41#include "BKE_node.hh"
44#include "BKE_texture.h"
45
46#include "BLO_read_write.hh"
47
49
60
61static void linestyle_copy_data(Main *bmain,
62 std::optional<Library *> owner_library,
63 ID *id_dst,
64 const ID *id_src,
65 const int flag)
66{
67 FreestyleLineStyle *linestyle_dst = (FreestyleLineStyle *)id_dst;
68 const FreestyleLineStyle *linestyle_src = (const FreestyleLineStyle *)id_src;
69
70 /* Never handle user-count here for own sub-data. */
71 const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
72 /* Always need allocation of the embedded ID data. */
73 const int flag_embedded_id_data = flag_subdata & ~LIB_ID_CREATE_NO_ALLOCATE;
74
75 for (int a = 0; a < MAX_MTEX; a++) {
76 if (linestyle_src->mtex[a]) {
77 linestyle_dst->mtex[a] = MEM_callocN<MTex>(__func__);
78 *linestyle_dst->mtex[a] = blender::dna::shallow_copy(*linestyle_src->mtex[a]);
79 }
80 }
81
82 if (linestyle_src->nodetree) {
84 owner_library,
85 &linestyle_src->nodetree->id,
86 &linestyle_dst->id,
87 reinterpret_cast<ID **>(&linestyle_dst->nodetree),
88 flag_embedded_id_data);
89 }
90
91 BLI_listbase_clear(&linestyle_dst->color_modifiers);
92 LISTBASE_FOREACH (LineStyleModifier *, linestyle_modifier, &linestyle_src->color_modifiers) {
93 BKE_linestyle_color_modifier_copy(linestyle_dst, linestyle_modifier, flag_subdata);
94 }
95
96 BLI_listbase_clear(&linestyle_dst->alpha_modifiers);
97 LISTBASE_FOREACH (LineStyleModifier *, linestyle_modifier, &linestyle_src->alpha_modifiers) {
98 BKE_linestyle_alpha_modifier_copy(linestyle_dst, linestyle_modifier, flag_subdata);
99 }
100
102 LISTBASE_FOREACH (LineStyleModifier *, linestyle_modifier, &linestyle_src->thickness_modifiers) {
103 BKE_linestyle_thickness_modifier_copy(linestyle_dst, linestyle_modifier, flag_subdata);
104 }
105
106 BLI_listbase_clear(&linestyle_dst->geometry_modifiers);
107 LISTBASE_FOREACH (LineStyleModifier *, linestyle_modifier, &linestyle_src->geometry_modifiers) {
108 BKE_linestyle_geometry_modifier_copy(linestyle_dst, linestyle_modifier, flag_subdata);
109 }
110}
111
112static void linestyle_free_data(ID *id)
113{
114 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
115 LineStyleModifier *linestyle_modifier;
116
117 for (int material_slot_index = 0; material_slot_index < MAX_MTEX; material_slot_index++) {
118 MEM_SAFE_FREE(linestyle->mtex[material_slot_index]);
119 }
120
121 /* is no lib link block, but linestyle extension */
122 if (linestyle->nodetree) {
124 MEM_freeN(linestyle->nodetree);
125 linestyle->nodetree = nullptr;
126 }
127
128 while ((linestyle_modifier = (LineStyleModifier *)linestyle->color_modifiers.first)) {
129 BKE_linestyle_color_modifier_remove(linestyle, linestyle_modifier);
130 }
131 while ((linestyle_modifier = (LineStyleModifier *)linestyle->alpha_modifiers.first)) {
132 BKE_linestyle_alpha_modifier_remove(linestyle, linestyle_modifier);
133 }
134 while ((linestyle_modifier = (LineStyleModifier *)linestyle->thickness_modifiers.first)) {
135 BKE_linestyle_thickness_modifier_remove(linestyle, linestyle_modifier);
136 }
137 while ((linestyle_modifier = (LineStyleModifier *)linestyle->geometry_modifiers.first)) {
138 BKE_linestyle_geometry_modifier_remove(linestyle, linestyle_modifier);
139 }
140}
141
143{
144 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
145
146 for (int i = 0; i < MAX_MTEX; i++) {
147 if (linestyle->mtex[i]) {
150 }
151 }
152 if (linestyle->nodetree) {
153 /* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
156 }
157
159 if (lsm->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
161 lsm;
163 }
164 }
166 if (lsm->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
168 lsm;
170 }
171 }
173 if (lsm->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
177 }
178 }
179}
180
183{
184 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
185
186 fn.single(&linestyle->r);
187}
188
190{
191 LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
192 int struct_nr;
193 switch (m->type) {
196 break;
199 break;
202 break;
205 break;
208 break;
211 break;
214 break;
217 break;
218 default:
219 struct_nr = sdna_struct_id_get<LineStyleModifier>(); /* this should not happen */
220 }
221 BLO_write_struct_by_id(writer, struct_nr, m);
222 }
223 LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
224 switch (m->type) {
227 break;
230 writer, ColorBand, ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp);
231 break;
234 writer, ColorBand, ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp);
235 break;
238 break;
240 BLO_write_struct(writer, ColorBand, ((LineStyleColorModifier_Tangent *)m)->color_ramp);
241 break;
243 BLO_write_struct(writer, ColorBand, ((LineStyleColorModifier_Noise *)m)->color_ramp);
244 break;
247 break;
250 writer, ColorBand, ((LineStyleColorModifier_Curvature_3D *)m)->color_ramp);
251 break;
252 }
253 }
254}
255
257{
258 LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
259 int struct_nr;
260 switch (m->type) {
263 break;
266 break;
269 break;
272 break;
275 break;
278 break;
281 break;
284 break;
285 default:
286 struct_nr = sdna_struct_id_get<LineStyleModifier>(); /* this should not happen */
287 }
288 BLO_write_struct_by_id(writer, struct_nr, m);
289 }
290 LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
291 switch (m->type) {
294 break;
298 break;
302 break;
305 break;
308 break;
311 break;
314 break;
317 break;
318 }
319 }
320}
321
323{
324 LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
325 int struct_nr;
326 switch (m->type) {
329 break;
332 break;
335 break;
338 break;
341 break;
344 break;
347 break;
350 break;
353 break;
354 default:
355 struct_nr = sdna_struct_id_get<LineStyleModifier>(); /* this should not happen */
356 }
357 BLO_write_struct_by_id(writer, struct_nr, m);
358 }
359 LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
360 switch (m->type) {
363 break;
367 break;
371 break;
374 break;
377 break;
380 break;
384 break;
385 }
386 }
387}
388
390{
391 LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
392 int struct_nr;
393 switch (m->type) {
396 break;
399 break;
402 break;
405 break;
408 break;
411 break;
414 break;
417 break;
420 break;
423 break;
426 break;
429 break;
432 break;
435 break;
436 default:
437 struct_nr = sdna_struct_id_get<LineStyleModifier>(); /* this should not happen */
438 }
439 BLO_write_struct_by_id(writer, struct_nr, m);
440 }
441}
442
443static void linestyle_blend_write(BlendWriter *writer, ID *id, const void *id_address)
444{
445 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
446
447 BLO_write_id_struct(writer, FreestyleLineStyle, id_address, &linestyle->id);
448 BKE_id_blend_write(writer, &linestyle->id);
449
454 for (int a = 0; a < MAX_MTEX; a++) {
455 if (linestyle->mtex[a]) {
456 BLO_write_struct(writer, MTex, linestyle->mtex[a]);
457 }
458 }
459 if (linestyle->nodetree) {
460 BLO_Write_IDBuffer temp_embedded_id_buffer{linestyle->nodetree->id, writer};
462 writer, bNodeTree, linestyle->nodetree, temp_embedded_id_buffer.get());
464 writer, reinterpret_cast<bNodeTree *>(temp_embedded_id_buffer.get()));
465 }
466}
467
469 LineStyleModifier *modifier)
470{
471 switch (modifier->type) {
475 break;
476 }
479 modifier;
481 break;
482 }
485 modifier;
487 break;
488 }
492 break;
493 }
494 case LS_MODIFIER_TANGENT: {
497 break;
498 }
499 case LS_MODIFIER_NOISE: {
502 break;
503 }
507 break;
508 }
512 break;
513 }
514 }
515}
516
518 LineStyleModifier *modifier)
519{
520 switch (modifier->type) {
523 BLO_read_struct(reader, CurveMapping, &m->curve);
525 break;
526 }
529 modifier;
530 BLO_read_struct(reader, CurveMapping, &m->curve);
532 break;
533 }
536 modifier;
537 BLO_read_struct(reader, CurveMapping, &m->curve);
539 break;
540 }
543 BLO_read_struct(reader, CurveMapping, &m->curve);
545 break;
546 }
547 case LS_MODIFIER_TANGENT: {
549 BLO_read_struct(reader, CurveMapping, &m->curve);
551 break;
552 }
553 case LS_MODIFIER_NOISE: {
555 BLO_read_struct(reader, CurveMapping, &m->curve);
557 break;
558 }
561 BLO_read_struct(reader, CurveMapping, &m->curve);
563 break;
564 }
567 BLO_read_struct(reader, CurveMapping, &m->curve);
569 break;
570 }
571 }
572}
573
575 LineStyleModifier *modifier)
576{
577 switch (modifier->type) {
580 modifier;
581 BLO_read_struct(reader, CurveMapping, &m->curve);
583 break;
584 }
588 BLO_read_struct(reader, CurveMapping, &m->curve);
590 break;
591 }
595 BLO_read_struct(reader, CurveMapping, &m->curve);
597 break;
598 }
601 BLO_read_struct(reader, CurveMapping, &m->curve);
603 break;
604 }
605 case LS_MODIFIER_TANGENT: {
607 BLO_read_struct(reader, CurveMapping, &m->curve);
609 break;
610 }
613 modifier;
614 BLO_read_struct(reader, CurveMapping, &m->curve);
616 break;
617 }
620 modifier;
621 BLO_read_struct(reader, CurveMapping, &m->curve);
623 break;
624 }
625 }
626}
627
629 LineStyleModifier * /*modifier*/)
630{
631}
632
634{
635 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
636
638 LISTBASE_FOREACH (LineStyleModifier *, modifier, &linestyle->color_modifiers) {
639 direct_link_linestyle_color_modifier(reader, modifier);
640 }
642 LISTBASE_FOREACH (LineStyleModifier *, modifier, &linestyle->alpha_modifiers) {
643 direct_link_linestyle_alpha_modifier(reader, modifier);
644 }
646 LISTBASE_FOREACH (LineStyleModifier *, modifier, &linestyle->thickness_modifiers) {
648 }
650 LISTBASE_FOREACH (LineStyleModifier *, modifier, &linestyle->geometry_modifiers) {
652 }
653 for (int a = 0; a < MAX_MTEX; a++) {
654 BLO_read_struct(reader, MTex, &linestyle->mtex[a]);
655 }
656}
657
659 /*id_code*/ FreestyleLineStyle::id_type,
660 /*id_filter*/ FILTER_ID_LS,
661 /*dependencies_id_types*/ FILTER_ID_TE | FILTER_ID_OB,
662 /*main_listbase_index*/ INDEX_ID_LS,
663 /*struct_size*/ sizeof(FreestyleLineStyle),
664 /*name*/ "FreestyleLineStyle",
665 /*name_plural*/ N_("linestyles"),
666 /*translation_context*/ BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE,
668 /*asset_type_info*/ nullptr,
669
670 /*init_data*/ linestyle_init_data,
671 /*copy_data*/ linestyle_copy_data,
672 /*free_data*/ linestyle_free_data,
673 /*make_local*/ nullptr,
674 /*foreach_id*/ linestyle_foreach_id,
675 /*foreach_cache*/ nullptr,
676 /*foreach_path*/ nullptr,
677 /*foreach_working_space_color*/ linestyle_foreach_working_space_color,
678 /*owner_pointer_get*/ nullptr,
679
680 /*blend_write*/ linestyle_blend_write,
681 /*blend_read_data*/ linestyle_blend_read_data,
682 /*blend_read_after_liblink*/ nullptr,
683
684 /*blend_read_undo_preserve*/ nullptr,
685
686 /*lib_override_apply_post*/ nullptr,
687};
688
689static const char *modifier_name[LS_MODIFIER_NUM] = {
690 nullptr, "Along Stroke", "Distance from Camera", "Distance from Object",
691 "Material", "Sampling", "Bézier Curve", "Sinus Displacement",
692 "Spatial Noise", "Perlin Noise 1D", "Perlin Noise 2D", "Backbone Stretcher",
693 "Tip Remover", "Calligraphy", "Polygonalization", "Guiding Lines",
694 "Blueprint", "2D Offset", "2D Transform", "Tangent",
695 "Noise", "Crease Angle", "Simplification", "Curvature 3D",
696};
697
699{
700 linestyle_init_data(&linestyle->id);
701}
702
704{
705 FreestyleLineStyle *linestyle;
706
707 linestyle = (FreestyleLineStyle *)BKE_libblock_alloc(bmain, ID_LS, name, 0);
708
709 BKE_linestyle_init(linestyle);
710
711 return linestyle;
712}
713
715{
716 FreestyleConfig *config = &view_layer->freestyle_config;
718 return (lineset) ? lineset->linestyle : nullptr;
719}
720
721static LineStyleModifier *new_modifier(const char *name, int type, size_t size)
722{
724
725 if (!name) {
726 name = modifier_name[type];
727 }
728 m = (LineStyleModifier *)MEM_callocN(size, "line style modifier");
729 m->type = type;
731 m->influence = 1.0f;
733
734 return m;
735}
736
738{
739 BLI_addtail(lb, (void *)m);
741 lb, m, modifier_name[m->type], '.', offsetof(LineStyleModifier, name), sizeof(m->name));
742}
743
744static LineStyleModifier *alloc_color_modifier(const char *name, int type)
745{
746 size_t size;
747
748 switch (type) {
751 break;
754 break;
757 break;
760 break;
763 break;
766 break;
769 break;
772 break;
773 default:
774 return nullptr; /* unknown modifier type */
775 }
776
777 return new_modifier(name, type, size);
778}
779
781 const char *name,
782 int type)
783{
785
786 m = alloc_color_modifier(name, type);
787 if (UNLIKELY(m == nullptr)) {
788 return nullptr;
789 }
790 m->blend = MA_RAMP_BLEND;
791
792 switch (type) {
794 ((LineStyleColorModifier_AlongStroke *)m)->color_ramp = BKE_colorband_add(true);
795 break;
798 ((LineStyleColorModifier_DistanceFromCamera *)m)->range_min = 0.0f;
799 ((LineStyleColorModifier_DistanceFromCamera *)m)->range_max = 10000.0f;
800 break;
802 ((LineStyleColorModifier_DistanceFromObject *)m)->target = nullptr;
804 ((LineStyleColorModifier_DistanceFromObject *)m)->range_min = 0.0f;
805 ((LineStyleColorModifier_DistanceFromObject *)m)->range_max = 10000.0f;
806 break;
808 ((LineStyleColorModifier_Material *)m)->color_ramp = BKE_colorband_add(true);
810 break;
812 ((LineStyleColorModifier_Tangent *)m)->color_ramp = BKE_colorband_add(true);
813 break;
815 ((LineStyleColorModifier_Noise *)m)->color_ramp = BKE_colorband_add(true);
816 ((LineStyleColorModifier_Noise *)m)->amplitude = 10.0f;
817 ((LineStyleColorModifier_Noise *)m)->period = 10.0f;
818 ((LineStyleColorModifier_Noise *)m)->seed = 512;
819 break;
821 ((LineStyleColorModifier_CreaseAngle *)m)->color_ramp = BKE_colorband_add(true);
822 ((LineStyleColorModifier_CreaseAngle *)m)->min_angle = 0.0f;
823 ((LineStyleColorModifier_CreaseAngle *)m)->max_angle = DEG2RADF(180.0f);
824 break;
827 ((LineStyleColorModifier_Curvature_3D *)m)->min_curvature = 0.0f;
828 ((LineStyleColorModifier_Curvature_3D *)m)->max_curvature = 0.5f;
829 break;
830 default:
831 return nullptr; /* unknown modifier type */
832 }
834
835 return m;
836}
837
839 const LineStyleModifier *m,
840 const int flag)
841{
842 LineStyleModifier *new_m;
843
844 new_m = alloc_color_modifier(m->name, m->type);
845 if (UNLIKELY(new_m == nullptr)) {
846 return nullptr;
847 }
848 new_m->influence = m->influence;
849 new_m->flags = m->flags;
850 new_m->blend = m->blend;
851
852 switch (m->type) {
856 q->color_ramp = static_cast<ColorBand *>(MEM_dupallocN(p->color_ramp));
857 break;
858 }
861 m;
863 new_m;
864 q->color_ramp = static_cast<ColorBand *>(MEM_dupallocN(p->color_ramp));
865 q->range_min = p->range_min;
866 q->range_max = p->range_max;
867 break;
868 }
871 m;
873 new_m;
874 q->target = p->target;
876 id_us_plus((ID *)q->target);
877 }
878 q->color_ramp = static_cast<ColorBand *>(MEM_dupallocN(p->color_ramp));
879 q->range_min = p->range_min;
880 q->range_max = p->range_max;
881 break;
882 }
886 q->color_ramp = static_cast<ColorBand *>(MEM_dupallocN(p->color_ramp));
887 q->flags = p->flags;
888 q->mat_attr = p->mat_attr;
889 break;
890 }
891 case LS_MODIFIER_TANGENT: {
894 q->color_ramp = static_cast<ColorBand *>(MEM_dupallocN(p->color_ramp));
895 break;
896 }
897 case LS_MODIFIER_NOISE: {
900 q->color_ramp = static_cast<ColorBand *>(MEM_dupallocN(p->color_ramp));
901 q->amplitude = p->amplitude;
902 q->period = p->period;
903 q->seed = p->seed;
904 break;
905 }
909 q->color_ramp = static_cast<ColorBand *>(MEM_dupallocN(p->color_ramp));
910 q->min_angle = p->min_angle;
911 q->max_angle = p->max_angle;
912 break;
913 }
917 q->color_ramp = static_cast<ColorBand *>(MEM_dupallocN(p->color_ramp));
920 break;
921 }
922 default:
923 return nullptr; /* unknown modifier type */
924 }
925 add_to_modifier_list(&linestyle->color_modifiers, new_m);
926
927 return new_m;
928}
929
931{
932 if (BLI_findindex(&linestyle->color_modifiers, m) == -1) {
933 return -1;
934 }
935 switch (m->type) {
938 break;
941 break;
944 break;
946 MEM_freeN(((LineStyleColorModifier_Material *)m)->color_ramp);
947 break;
949 MEM_freeN(((LineStyleColorModifier_Tangent *)m)->color_ramp);
950 break;
952 MEM_freeN(((LineStyleColorModifier_Noise *)m)->color_ramp);
953 break;
956 break;
959 break;
960 }
961 BLI_freelinkN(&linestyle->color_modifiers, m);
962 return 0;
963}
964
965static LineStyleModifier *alloc_alpha_modifier(const char *name, int type)
966{
967 size_t size;
968
969 switch (type) {
972 break;
975 break;
978 break;
981 break;
984 break;
987 break;
990 break;
993 break;
994 default:
995 return nullptr; /* unknown modifier type */
996 }
997 return new_modifier(name, type, size);
998}
999
1001 const char *name,
1002 int type)
1003{
1005
1006 m = alloc_alpha_modifier(name, type);
1007 m->blend = LS_VALUE_BLEND;
1008
1009 switch (type) {
1012 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1013 break;
1014 }
1017 m;
1018 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1019 p->range_min = 0.0f;
1020 p->range_max = 10000.0f;
1021 break;
1022 }
1025 m;
1026 p->target = nullptr;
1027 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1028 p->range_min = 0.0f;
1029 p->range_max = 10000.0f;
1030 break;
1031 }
1032 case LS_MODIFIER_MATERIAL: {
1034 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1036 break;
1037 }
1038 case LS_MODIFIER_TANGENT: {
1040 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1041 break;
1042 }
1043 case LS_MODIFIER_NOISE: {
1045 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1046 ((LineStyleAlphaModifier_Noise *)m)->amplitude = 10.0f;
1047 ((LineStyleAlphaModifier_Noise *)m)->period = 10.0f;
1048 ((LineStyleAlphaModifier_Noise *)m)->seed = 512;
1049 break;
1050 }
1053 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1054 ((LineStyleAlphaModifier_CreaseAngle *)m)->min_angle = 0.0f;
1055 ((LineStyleAlphaModifier_CreaseAngle *)m)->max_angle = DEG2RADF(180.0f);
1056 break;
1057 }
1060 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1061 ((LineStyleAlphaModifier_Curvature_3D *)m)->min_curvature = 0.0f;
1062 ((LineStyleAlphaModifier_Curvature_3D *)m)->max_curvature = 0.5f;
1063 break;
1064 }
1065 default:
1066 return nullptr; /* unknown modifier type */
1067 }
1068 add_to_modifier_list(&linestyle->alpha_modifiers, m);
1069
1070 return m;
1071}
1072
1074 const LineStyleModifier *m,
1075 const int /*flag*/)
1076{
1077 LineStyleModifier *new_m;
1078
1079 new_m = alloc_alpha_modifier(m->name, m->type);
1080 new_m->influence = m->influence;
1081 new_m->flags = m->flags;
1082 new_m->blend = m->blend;
1083
1084 switch (m->type) {
1089 q->flags = p->flags;
1090 break;
1091 }
1094 m;
1096 new_m;
1098 q->flags = p->flags;
1099 q->range_min = p->range_min;
1100 q->range_max = p->range_max;
1101 break;
1102 }
1105 m;
1107 new_m;
1108 if (p->target) {
1109 id_us_plus(&p->target->id);
1110 }
1111 q->target = p->target;
1113 q->flags = p->flags;
1114 q->range_min = p->range_min;
1115 q->range_max = p->range_max;
1116 break;
1117 }
1118 case LS_MODIFIER_MATERIAL: {
1122 q->flags = p->flags;
1123 q->mat_attr = p->mat_attr;
1124 break;
1125 }
1126 case LS_MODIFIER_TANGENT: {
1130 q->flags = p->flags;
1131 break;
1132 }
1133 case LS_MODIFIER_NOISE: {
1137 q->flags = p->flags;
1138 q->amplitude = p->amplitude;
1139 q->period = p->period;
1140 q->seed = p->seed;
1141 break;
1142 }
1147 q->flags = p->flags;
1148 q->min_angle = p->min_angle;
1149 q->max_angle = p->max_angle;
1150 break;
1151 }
1156 q->flags = p->flags;
1159 break;
1160 }
1161 default:
1162 return nullptr; /* unknown modifier type */
1163 }
1164 add_to_modifier_list(&linestyle->alpha_modifiers, new_m);
1165
1166 return new_m;
1167}
1168
1170{
1171 if (BLI_findindex(&linestyle->alpha_modifiers, m) == -1) {
1172 return -1;
1173 }
1174 switch (m->type) {
1177 break;
1180 break;
1183 break;
1186 break;
1189 break;
1190 case LS_MODIFIER_NOISE:
1192 break;
1195 break;
1198 break;
1199 }
1200 BLI_freelinkN(&linestyle->alpha_modifiers, m);
1201 return 0;
1202}
1203
1205{
1206 size_t size;
1207
1208 switch (type) {
1211 break;
1214 break;
1217 break;
1220 break;
1223 break;
1226 break;
1227 case LS_MODIFIER_NOISE:
1229 break;
1232 break;
1235 break;
1236 default:
1237 return nullptr; /* unknown modifier type */
1238 }
1239
1240 return new_modifier(name, type, size);
1241}
1242
1244 const char *name,
1245 int type)
1246{
1248
1249 m = alloc_thickness_modifier(name, type);
1250 m->blend = LS_VALUE_BLEND;
1251
1252 switch (type) {
1255 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1256 p->value_min = 0.0f;
1257 p->value_max = 1.0f;
1258 break;
1259 }
1263 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1264 p->range_min = 0.0f;
1265 p->range_max = 1000.0f;
1266 p->value_min = 0.0f;
1267 p->value_max = 1.0f;
1268 break;
1269 }
1273 p->target = nullptr;
1274 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1275 p->range_min = 0.0f;
1276 p->range_max = 1000.0f;
1277 p->value_min = 0.0f;
1278 p->value_max = 1.0f;
1279 break;
1280 }
1281 case LS_MODIFIER_MATERIAL: {
1283 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1285 p->value_min = 0.0f;
1286 p->value_max = 1.0f;
1287 break;
1288 }
1291 p->min_thickness = 1.0f;
1292 p->max_thickness = 10.0f;
1293 p->orientation = DEG2RADF(60.0f);
1294 break;
1295 }
1296 case LS_MODIFIER_TANGENT: {
1298 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1299 p->min_thickness = 1.0f;
1300 p->max_thickness = 10.0f;
1301 break;
1302 }
1303 case LS_MODIFIER_NOISE: {
1305 p->period = 10.0f;
1306 p->amplitude = 10.0f;
1307 p->seed = 512;
1309 break;
1310 }
1313 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1314 p->min_angle = 0.0f;
1315 p->max_angle = DEG2RADF(180.0f);
1316 p->min_thickness = 1.0f;
1317 p->max_thickness = 10.0f;
1318 break;
1319 }
1322 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1323 p->min_curvature = 0.0f;
1324 p->max_curvature = 0.5f;
1325 p->min_thickness = 1.0f;
1326 p->max_thickness = 10.0f;
1327 break;
1328 }
1329 default:
1330 return nullptr; /* unknown modifier type */
1331 }
1333
1334 return m;
1335}
1336
1338 const LineStyleModifier *m,
1339 const int flag)
1340{
1341 LineStyleModifier *new_m;
1342
1343 new_m = alloc_thickness_modifier(m->name, m->type);
1344 if (!new_m) {
1345 return nullptr;
1346 }
1347 new_m->influence = m->influence;
1348 new_m->flags = m->flags;
1349 new_m->blend = m->blend;
1350
1351 switch (m->type) {
1356 q->flags = p->flags;
1357 q->value_min = p->value_min;
1358 q->value_max = p->value_max;
1359 break;
1360 }
1367 q->flags = p->flags;
1368 q->range_min = p->range_min;
1369 q->range_max = p->range_max;
1370 q->value_min = p->value_min;
1371 q->value_max = p->value_max;
1372 break;
1373 }
1379 q->target = p->target;
1380 if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
1381 id_us_plus((ID *)q->target);
1382 }
1384 q->flags = p->flags;
1385 q->range_min = p->range_min;
1386 q->range_max = p->range_max;
1387 q->value_min = p->value_min;
1388 q->value_max = p->value_max;
1389 break;
1390 }
1391 case LS_MODIFIER_MATERIAL: {
1395 q->flags = p->flags;
1396 q->mat_attr = p->mat_attr;
1397 q->value_min = p->value_min;
1398 q->value_max = p->value_max;
1399 break;
1400 }
1406 q->orientation = p->orientation;
1407 break;
1408 }
1409 case LS_MODIFIER_TANGENT: {
1413 q->flags = p->flags;
1416 break;
1417 }
1418 case LS_MODIFIER_NOISE: {
1421 q->amplitude = p->amplitude;
1422 q->period = p->period;
1423 q->seed = p->seed;
1424 q->flags = p->flags;
1425 break;
1426 }
1430 new_m;
1432 q->flags = p->flags;
1437 break;
1438 }
1443 q->flags = p->flags;
1444 q->min_angle = p->min_angle;
1445 q->max_angle = p->max_angle;
1448 break;
1449 }
1450 default:
1451 return nullptr; /* unknown modifier type */
1452 }
1453 add_to_modifier_list(&linestyle->thickness_modifiers, new_m);
1454
1455 return new_m;
1456}
1457
1459{
1460 if (BLI_findindex(&linestyle->thickness_modifiers, m) == -1) {
1461 return -1;
1462 }
1463 switch (m->type) {
1466 break;
1469 break;
1472 break;
1475 break;
1477 break;
1480 break;
1481 case LS_MODIFIER_NOISE:
1482 break;
1484 break;
1486 break;
1487 }
1488 BLI_freelinkN(&linestyle->thickness_modifiers, m);
1489 return 0;
1490}
1491
1492static LineStyleModifier *alloc_geometry_modifier(const char *name, int type)
1493{
1494 size_t size;
1495
1496 switch (type) {
1499 break;
1502 break;
1505 break;
1508 break;
1511 break;
1514 break;
1517 break;
1520 break;
1523 break;
1526 break;
1529 break;
1532 break;
1535 break;
1538 break;
1539 default:
1540 return nullptr; /* unknown modifier type */
1541 }
1542
1543 return new_modifier(name, type, size);
1544}
1545
1547 const char *name,
1548 int type)
1549{
1551
1552 m = alloc_geometry_modifier(name, type);
1553
1554 switch (type) {
1555 case LS_MODIFIER_SAMPLING: {
1557 p->sampling = 10.0f;
1558 break;
1559 }
1562 p->error = 10.0f;
1563 break;
1564 }
1568 p->wavelength = 20.0f;
1569 p->amplitude = 5.0f;
1570 p->phase = 0.0f;
1571 break;
1572 }
1575 p->amplitude = 5.0f;
1576 p->scale = 20.0f;
1577 p->octaves = 4;
1579 break;
1580 }
1583 p->frequency = 10.0f;
1584 p->amplitude = 10.0f;
1585 p->octaves = 4;
1586 p->angle = DEG2RADF(45.0f);
1587 break;
1588 }
1591 p->frequency = 10.0f;
1592 p->amplitude = 10.0f;
1593 p->octaves = 4;
1594 p->angle = DEG2RADF(45.0f);
1595 break;
1596 }
1600 p->backbone_length = 10.0f;
1601 break;
1602 }
1605 p->tip_length = 10.0f;
1606 break;
1607 }
1611 p->error = 10.0f;
1612 break;
1613 }
1616 p->offset = 0.0f;
1617 break;
1618 }
1619 case LS_MODIFIER_BLUEPRINT: {
1622 p->rounds = 1;
1623 p->backbone_length = 10.0f;
1624 p->random_radius = 3;
1625 p->random_center = 5;
1626 p->random_backbone = 5;
1627 break;
1628 }
1629 case LS_MODIFIER_2D_OFFSET: {
1631 p->start = 0.0f;
1632 p->end = 0.0f;
1633 p->x = 0.0f;
1634 p->y = 0.0f;
1635 break;
1636 }
1640 p->scale_x = 1.0f;
1641 p->scale_y = 1.0f;
1642 p->angle = DEG2RADF(0.0f);
1643 p->pivot_u = 0.5f;
1644 p->pivot_x = 0.0f;
1645 p->pivot_y = 0.0f;
1646 break;
1647 }
1650 p->tolerance = 0.1f;
1651 break;
1652 }
1653 default:
1654 return nullptr; /* unknown modifier type */
1655 }
1657
1658 return m;
1659}
1660
1662 const LineStyleModifier *m,
1663 const int /*flag*/)
1664{
1665 LineStyleModifier *new_m;
1666
1667 new_m = alloc_geometry_modifier(m->name, m->type);
1668 new_m->flags = m->flags;
1669
1670 switch (m->type) {
1671 case LS_MODIFIER_SAMPLING: {
1674 q->sampling = p->sampling;
1675 break;
1676 }
1680 q->error = p->error;
1681 break;
1682 }
1688 q->wavelength = p->wavelength;
1689 q->amplitude = p->amplitude;
1690 q->phase = p->phase;
1691 break;
1692 }
1696 q->amplitude = p->amplitude;
1697 q->scale = p->scale;
1698 q->octaves = p->octaves;
1699 q->flags = p->flags;
1700 break;
1701 }
1705 new_m;
1706 q->frequency = p->frequency;
1707 q->amplitude = p->amplitude;
1708 q->angle = p->angle;
1709 q->octaves = p->octaves;
1710 q->seed = p->seed;
1711 break;
1712 }
1716 new_m;
1717 q->frequency = p->frequency;
1718 q->amplitude = p->amplitude;
1719 q->angle = p->angle;
1720 q->octaves = p->octaves;
1721 q->seed = p->seed;
1722 break;
1723 }
1730 break;
1731 }
1735 q->tip_length = p->tip_length;
1736 break;
1737 }
1743 q->error = p->error;
1744 break;
1745 }
1749 q->offset = p->offset;
1750 break;
1751 }
1752 case LS_MODIFIER_BLUEPRINT: {
1755 q->flags = p->flags;
1756 q->rounds = p->rounds;
1761 break;
1762 }
1763 case LS_MODIFIER_2D_OFFSET: {
1766 q->start = p->start;
1767 q->end = p->end;
1768 q->x = p->x;
1769 q->y = p->y;
1770 break;
1771 }
1775 q->pivot = p->pivot;
1776 q->scale_x = p->scale_x;
1777 q->scale_y = p->scale_y;
1778 q->angle = p->angle;
1779 q->pivot_u = p->pivot_u;
1780 q->pivot_x = p->pivot_x;
1781 q->pivot_y = p->pivot_y;
1782 break;
1783 }
1787 new_m;
1788 q->tolerance = p->tolerance;
1789 break;
1790 }
1791 default:
1792 return nullptr; /* unknown modifier type */
1793 }
1794 add_to_modifier_list(&linestyle->geometry_modifiers, new_m);
1795
1796 return new_m;
1797}
1798
1800{
1801 if (BLI_findindex(&linestyle->geometry_modifiers, m) == -1) {
1802 return -1;
1803 }
1804 BLI_freelinkN(&linestyle->geometry_modifiers, m);
1805 return 0;
1806}
1807
1809 LineStyleModifier *modifier,
1810 int direction)
1811{
1812 return BLI_listbase_link_move(&linestyle->color_modifiers, modifier, direction);
1813}
1815 LineStyleModifier *modifier,
1816 int direction)
1817{
1818 return BLI_listbase_link_move(&linestyle->alpha_modifiers, modifier, direction);
1819}
1821 LineStyleModifier *modifier,
1822 int direction)
1823{
1824 return BLI_listbase_link_move(&linestyle->thickness_modifiers, modifier, direction);
1825}
1827 LineStyleModifier *modifier,
1828 int direction)
1829{
1830 return BLI_listbase_link_move(&linestyle->geometry_modifiers, modifier, direction);
1831}
1832
1834{
1835 ColorBand *color_ramp;
1836 LinkData *link;
1837
1838 BLI_listbase_clear(listbase);
1839
1841 switch (m->type) {
1843 color_ramp = ((LineStyleColorModifier_AlongStroke *)m)->color_ramp;
1844 break;
1846 color_ramp = ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp;
1847 break;
1849 color_ramp = ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp;
1850 break;
1852 color_ramp = ((LineStyleColorModifier_Material *)m)->color_ramp;
1853 break;
1854 default:
1855 continue;
1856 }
1857 link = MEM_callocN<LinkData>("link to color ramp");
1858 link->data = color_ramp;
1859 BLI_addtail(listbase, link);
1860 }
1861}
1862
1863std::optional<std::string> BKE_linestyle_path_to_color_ramp(FreestyleLineStyle *linestyle,
1864 const ColorBand *color_ramp)
1865{
1866 bool found = false;
1867
1869 switch (m->type) {
1871 if (color_ramp == ((LineStyleColorModifier_AlongStroke *)m)->color_ramp) {
1872 found = true;
1873 }
1874 break;
1876 if (color_ramp == ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp) {
1877 found = true;
1878 }
1879 break;
1881 if (color_ramp == ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp) {
1882 found = true;
1883 }
1884 break;
1886 if (color_ramp == ((LineStyleColorModifier_Material *)m)->color_ramp) {
1887 found = true;
1888 }
1889 break;
1891 if (color_ramp == ((LineStyleColorModifier_Tangent *)m)->color_ramp) {
1892 found = true;
1893 }
1894 break;
1895 case LS_MODIFIER_NOISE:
1896 if (color_ramp == ((LineStyleColorModifier_Noise *)m)->color_ramp) {
1897 found = true;
1898 }
1899 break;
1901 if (color_ramp == ((LineStyleColorModifier_CreaseAngle *)m)->color_ramp) {
1902 found = true;
1903 }
1904 break;
1906 if (color_ramp == ((LineStyleColorModifier_Curvature_3D *)m)->color_ramp) {
1907 found = true;
1908 }
1909 break;
1910 }
1911
1912 if (found) {
1913 char name_esc[sizeof(m->name) * 2];
1914 BLI_str_escape(name_esc, m->name, sizeof(name_esc));
1915 return fmt::format("color_modifiers[\"{}\"].color_ramp", name_esc);
1916 }
1917 }
1918 printf("BKE_linestyle_path_to_color_ramp: No color ramps correspond to the given pointer.\n");
1919 return std::nullopt;
1920}
1921
1922bool BKE_linestyle_use_textures(FreestyleLineStyle *linestyle, const bool use_shading_nodes)
1923{
1924 if (use_shading_nodes) {
1925 if (linestyle && linestyle->use_nodes && linestyle->nodetree) {
1926 LISTBASE_FOREACH (bNode *, node, &linestyle->nodetree->nodes) {
1927 if (node->typeinfo->nclass == NODE_CLASS_TEXTURE) {
1928 return true;
1929 }
1930 }
1931 }
1932 }
1933 else {
1934 if (linestyle && (linestyle->flag & LS_TEXTURE)) {
1935 return (linestyle->mtex[0] != nullptr);
1936 }
1937 }
1938 return false;
1939}
1940
1942{
1943 bNode *uv_along_stroke, *input_texture, *output_linestyle;
1944 bNodeSocket *fromsock, *tosock;
1945 bNodeTree *ntree;
1946
1947 BLI_assert(linestyle->nodetree == nullptr);
1948
1950 nullptr, &linestyle->id, "stroke_shader", "ShaderNodeTree");
1951
1953 uv_along_stroke->location[0] = -200.0f;
1954 uv_along_stroke->location[1] = 100.0f;
1955 uv_along_stroke->custom1 = 0; /* use_tips */
1956
1957 input_texture = blender::bke::node_add_static_node(C, *ntree, SH_NODE_TEX_IMAGE);
1958 input_texture->location[0] = 0.0f;
1959 input_texture->location[1] = 100.0f;
1960
1962 output_linestyle->location[0] = 300.0f;
1963 output_linestyle->location[1] = 100.0f;
1964 output_linestyle->custom1 = MA_RAMP_BLEND;
1965 output_linestyle->custom2 = 0; /* use_clamp */
1966
1967 blender::bke::node_set_active(*ntree, *input_texture);
1968
1969 fromsock = static_cast<bNodeSocket *>(BLI_findlink(&uv_along_stroke->outputs, 0)); /* UV */
1970 tosock = static_cast<bNodeSocket *>(BLI_findlink(&input_texture->inputs, 0)); /* UV */
1971 blender::bke::node_add_link(*ntree, *uv_along_stroke, *fromsock, *input_texture, *tosock);
1972
1973 fromsock = static_cast<bNodeSocket *>(BLI_findlink(&input_texture->outputs, 0)); /* Color */
1974 tosock = static_cast<bNodeSocket *>(BLI_findlink(&output_linestyle->inputs, 0)); /* Color */
1975 blender::bke::node_add_link(*ntree, *input_texture, *fromsock, *output_linestyle, *tosock);
1976
1978}
ColorBand * BKE_colorband_add(bool rangetype)
Definition colorband.cc:298
void BKE_curvemapping_blend_read(BlendDataReader *reader, CurveMapping *cumap)
CurveMapping * BKE_curvemapping_copy(const CurveMapping *cumap)
CurveMapping * BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy)
Definition colortools.cc:89
void BKE_curvemapping_free(CurveMapping *cumap)
void BKE_curvemapping_blend_write(BlendWriter *writer, const CurveMapping *cumap)
Main * CTX_data_main(const bContext *C)
struct FreestyleLineSet * BKE_freestyle_lineset_get_active(struct FreestyleConfig *config)
Definition freestyle.cc:212
@ IDTYPE_FLAGS_APPEND_IS_REUSABLE
Definition BKE_idtype.hh:47
IDTypeInfo IDType_ID_LS
Definition linestyle.cc:658
struct ID * BKE_id_copy_in_lib(Main *bmain, std::optional< Library * > owner_library, const ID *id, std::optional< const ID * > new_owner_id, ID **new_id_p, int flag)
Definition lib_id.cc:675
void * BKE_libblock_alloc(Main *bmain, short type, const char *name, int flag) ATTR_WARN_UNUSED_RESULT
Definition lib_id.cc:1447
void id_us_plus(ID *id)
Definition lib_id.cc:358
@ LIB_ID_CREATE_NO_ALLOCATE
@ LIB_ID_CREATE_NO_USER_REFCOUNT
void BKE_id_blend_write(BlendWriter *writer, ID *id)
Definition lib_id.cc:2631
#define BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data_, func_call_)
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
void BKE_library_foreach_ID_embedded(LibraryForeachIDData *data, ID **id_pp)
Definition lib_query.cc:172
@ IDWALK_CB_NOP
Blender kernel freestyle line style functionality.
#define NODE_CLASS_TEXTURE
Definition BKE_node.hh:457
#define SH_NODE_TEX_IMAGE
#define SH_NODE_UVALONGSTROKE
#define SH_NODE_OUTPUT_LINESTYLE
void BKE_ntree_update_after_single_tree_change(Main &bmain, bNodeTree &modified_tree, const NodeTreeUpdateExtraParams &params={})
void BKE_texture_mtex_foreach_id(struct LibraryForeachIDData *data, struct MTex *mtex)
Definition texture.cc:217
#define BLI_assert(a)
Definition BLI_assert.h:46
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:586
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:534
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE void BLI_listbase_clear(ListBase *lb)
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:270
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:111
void void void bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step) ATTR_NONNULL()
Definition listbase.cc:436
#define DEG2RADF(_deg)
size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define STRNCPY_UTF8(dst, src)
void BLI_uniquename(const struct ListBase *list, void *vlink, const char *defname, char delim, int name_offset, size_t name_maxncpy) ATTR_NONNULL(1
#define UNLIKELY(x)
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
#define BLO_write_id_struct(writer, struct_name, id_address, id)
#define BLO_write_struct(writer, struct_name, data_ptr)
#define BLO_read_struct_list(reader, struct_name, list)
#define BLO_read_struct(reader, struct_name, ptr_p)
void BLO_write_struct_by_id(BlendWriter *writer, int struct_id, const void *data_ptr)
#define BLO_write_struct_at_address(writer, struct_name, address, data_ptr)
#define BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE
#define DATA_(msgid)
#define FILTER_ID_OB
Definition DNA_ID.h:1214
#define FILTER_ID_TE
Definition DNA_ID.h:1220
#define FILTER_ID_LS
Definition DNA_ID.h:1206
@ INDEX_ID_LS
Definition DNA_ID.h:1313
@ ID_LS
#define DNA_struct_default_get(struct_name)
@ LS_MODIFIER_SPATIAL_NOISE_PURERANDOM
@ LS_MODIFIER_SPATIAL_NOISE_SMOOTH
@ LS_MODIFIER_SAMPLING
@ LS_MODIFIER_BEZIER_CURVE
@ LS_MODIFIER_NOISE
@ LS_MODIFIER_BACKBONE_STRETCHER
@ LS_MODIFIER_SPATIAL_NOISE
@ LS_MODIFIER_PERLIN_NOISE_2D
@ LS_MODIFIER_POLYGONIZATION
@ LS_MODIFIER_GUIDING_LINES
@ LS_MODIFIER_SIMPLIFICATION
@ LS_MODIFIER_TANGENT
@ LS_MODIFIER_CREASE_ANGLE
@ LS_MODIFIER_NUM
@ LS_MODIFIER_2D_TRANSFORM
@ LS_MODIFIER_DISTANCE_FROM_OBJECT
@ LS_MODIFIER_BLUEPRINT
@ LS_MODIFIER_CALLIGRAPHY
@ LS_MODIFIER_CURVATURE_3D
@ LS_MODIFIER_SINUS_DISPLACEMENT
@ LS_MODIFIER_ALONG_STROKE
@ LS_MODIFIER_MATERIAL
@ LS_MODIFIER_DISTANCE_FROM_CAMERA
@ LS_MODIFIER_PERLIN_NOISE_1D
@ LS_MODIFIER_2D_OFFSET
@ LS_MODIFIER_TIP_REMOVER
@ LS_MODIFIER_MATERIAL_LINE
@ LS_MODIFIER_MATERIAL_LINE_A
@ LS_MODIFIER_BLUEPRINT_CIRCLES
@ LS_MODIFIER_2D_TRANSFORM_PIVOT_CENTER
@ LS_THICKNESS_ASYMMETRIC
@ LS_VALUE_BLEND
@ LS_MODIFIER_EXPANDED
@ LS_MODIFIER_ENABLED
@ MA_RAMP_BLEND
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
#define C
Definition RandGen.cpp:29
#define MAX_MTEX
Definition Stroke.h:31
BMesh const char void * data
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
#define offsetof(t, d)
#define printf(...)
static void direct_link_linestyle_alpha_modifier(BlendDataReader *reader, LineStyleModifier *modifier)
Definition linestyle.cc:517
static void linestyle_free_data(ID *id)
Definition linestyle.cc:112
void BKE_linestyle_default_shader(const bContext *C, FreestyleLineStyle *linestyle)
bool BKE_linestyle_use_textures(FreestyleLineStyle *linestyle, const bool use_shading_nodes)
FreestyleLineStyle * BKE_linestyle_new(Main *bmain, const char *name)
Definition linestyle.cc:703
static void linestyle_init_data(ID *id)
Definition linestyle.cc:50
void BKE_linestyle_modifier_list_color_ramps(FreestyleLineStyle *linestyle, ListBase *listbase)
bool BKE_linestyle_thickness_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction)
static void direct_link_linestyle_color_modifier(BlendDataReader *reader, LineStyleModifier *modifier)
Definition linestyle.cc:468
LineStyleModifier * BKE_linestyle_geometry_modifier_add(FreestyleLineStyle *linestyle, const char *name, int type)
void BKE_linestyle_init(FreestyleLineStyle *linestyle)
Definition linestyle.cc:698
static void write_linestyle_geometry_modifiers(BlendWriter *writer, ListBase *modifiers)
Definition linestyle.cc:389
int BKE_linestyle_thickness_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *m)
bool BKE_linestyle_color_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction)
static void write_linestyle_alpha_modifiers(BlendWriter *writer, ListBase *modifiers)
Definition linestyle.cc:256
LineStyleModifier * BKE_linestyle_color_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m, const int flag)
Definition linestyle.cc:838
static void direct_link_linestyle_thickness_modifier(BlendDataReader *reader, LineStyleModifier *modifier)
Definition linestyle.cc:574
LineStyleModifier * BKE_linestyle_alpha_modifier_add(FreestyleLineStyle *linestyle, const char *name, int type)
static LineStyleModifier * alloc_geometry_modifier(const char *name, int type)
FreestyleLineStyle * BKE_linestyle_active_from_view_layer(ViewLayer *view_layer)
Definition linestyle.cc:714
LineStyleModifier * BKE_linestyle_color_modifier_add(FreestyleLineStyle *linestyle, const char *name, int type)
Definition linestyle.cc:780
static void write_linestyle_thickness_modifiers(BlendWriter *writer, ListBase *modifiers)
Definition linestyle.cc:322
int sdna_struct_id_get()
static void write_linestyle_color_modifiers(BlendWriter *writer, ListBase *modifiers)
Definition linestyle.cc:189
int BKE_linestyle_color_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *m)
Definition linestyle.cc:930
static void linestyle_blend_read_data(BlendDataReader *reader, ID *id)
Definition linestyle.cc:633
static LineStyleModifier * new_modifier(const char *name, int type, size_t size)
Definition linestyle.cc:721
static void linestyle_foreach_working_space_color(ID *id, const IDTypeForeachColorFunctionCallback &fn)
Definition linestyle.cc:181
static void linestyle_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Definition linestyle.cc:443
bool BKE_linestyle_alpha_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction)
bool BKE_linestyle_geometry_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction)
LineStyleModifier * BKE_linestyle_geometry_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m, const int)
static LineStyleModifier * alloc_alpha_modifier(const char *name, int type)
Definition linestyle.cc:965
int BKE_linestyle_alpha_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *m)
static LineStyleModifier * alloc_color_modifier(const char *name, int type)
Definition linestyle.cc:744
LineStyleModifier * BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *linestyle, const char *name, int type)
std::optional< std::string > BKE_linestyle_path_to_color_ramp(FreestyleLineStyle *linestyle, const ColorBand *color_ramp)
LineStyleModifier * BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m, const int flag)
static void linestyle_foreach_id(ID *id, LibraryForeachIDData *data)
Definition linestyle.cc:142
static const char * modifier_name[LS_MODIFIER_NUM]
Definition linestyle.cc:689
static LineStyleModifier * alloc_thickness_modifier(const char *name, int type)
static void linestyle_copy_data(Main *bmain, std::optional< Library * > owner_library, ID *id_dst, const ID *id_src, const int flag)
Definition linestyle.cc:61
int BKE_linestyle_geometry_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *m)
static void add_to_modifier_list(ListBase *lb, LineStyleModifier *m)
Definition linestyle.cc:737
LineStyleModifier * BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m, const int)
static void direct_link_linestyle_geometry_modifier(BlendDataReader *, LineStyleModifier *)
Definition linestyle.cc:628
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
void * MEM_dupallocN(const void *vmemh)
Definition mallocn.cc:143
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
bNodeTree * node_tree_add_tree_embedded(Main *bmain, ID *owner_id, StringRefNull name, StringRefNull idname)
Definition node.cc:4098
void node_tree_blend_write(BlendWriter *writer, bNodeTree *ntree)
Definition node.cc:1140
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
Definition node.cc:3500
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
Definition node.cc:3810
void node_set_active(bNodeTree &ntree, bNode &node)
Definition node.cc:4724
void node_tree_free_embedded_tree(bNodeTree *ntree)
Definition node.cc:4462
int sdna_struct_id_get()
const char * name
struct FreestyleLineStyle * linestyle
struct bNodeTree * nodetree
struct MTex * mtex[18]
const blender::FunctionRef< void(float rgb[3])> single
Definition DNA_ID.h:414
void * data
void * first
struct FreestyleConfig freestyle_config
ListBase nodes
float location[2]
int16_t custom1
ListBase inputs
ListBase outputs
int16_t custom2
i
Definition text_draw.cc:230
#define N_(msgid)
uint8_t flag
Definition wm_window.cc:145