Blender V4.5
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_utils.hh"
28#include "BLI_utildefines.h"
29
30#include "BLT_translation.hh"
31
32#include "BKE_colorband.hh"
33#include "BKE_colortools.hh"
34#include "BKE_context.hh"
35#include "BKE_freestyle.h"
36#include "BKE_idtype.hh"
37#include "BKE_lib_id.hh"
38#include "BKE_lib_query.hh"
39#include "BKE_linestyle.h"
40#include "BKE_node.hh"
43#include "BKE_texture.h"
44
45#include "BLO_read_write.hh"
46
48
59
60static void linestyle_copy_data(Main *bmain,
61 std::optional<Library *> owner_library,
62 ID *id_dst,
63 const ID *id_src,
64 const int flag)
65{
66 FreestyleLineStyle *linestyle_dst = (FreestyleLineStyle *)id_dst;
67 const FreestyleLineStyle *linestyle_src = (const FreestyleLineStyle *)id_src;
68
69 /* Never handle user-count here for own sub-data. */
70 const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
71 /* Always need allocation of the embedded ID data. */
72 const int flag_embedded_id_data = flag_subdata & ~LIB_ID_CREATE_NO_ALLOCATE;
73
74 for (int a = 0; a < MAX_MTEX; a++) {
75 if (linestyle_src->mtex[a]) {
76 linestyle_dst->mtex[a] = MEM_callocN<MTex>(__func__);
77 *linestyle_dst->mtex[a] = blender::dna::shallow_copy(*linestyle_src->mtex[a]);
78 }
79 }
80
81 if (linestyle_src->nodetree) {
83 owner_library,
84 &linestyle_src->nodetree->id,
85 &linestyle_dst->id,
86 reinterpret_cast<ID **>(&linestyle_dst->nodetree),
87 flag_embedded_id_data);
88 }
89
90 BLI_listbase_clear(&linestyle_dst->color_modifiers);
91 LISTBASE_FOREACH (LineStyleModifier *, linestyle_modifier, &linestyle_src->color_modifiers) {
92 BKE_linestyle_color_modifier_copy(linestyle_dst, linestyle_modifier, flag_subdata);
93 }
94
95 BLI_listbase_clear(&linestyle_dst->alpha_modifiers);
96 LISTBASE_FOREACH (LineStyleModifier *, linestyle_modifier, &linestyle_src->alpha_modifiers) {
97 BKE_linestyle_alpha_modifier_copy(linestyle_dst, linestyle_modifier, flag_subdata);
98 }
99
101 LISTBASE_FOREACH (LineStyleModifier *, linestyle_modifier, &linestyle_src->thickness_modifiers) {
102 BKE_linestyle_thickness_modifier_copy(linestyle_dst, linestyle_modifier, flag_subdata);
103 }
104
105 BLI_listbase_clear(&linestyle_dst->geometry_modifiers);
106 LISTBASE_FOREACH (LineStyleModifier *, linestyle_modifier, &linestyle_src->geometry_modifiers) {
107 BKE_linestyle_geometry_modifier_copy(linestyle_dst, linestyle_modifier, flag_subdata);
108 }
109}
110
111static void linestyle_free_data(ID *id)
112{
113 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
114 LineStyleModifier *linestyle_modifier;
115
116 for (int material_slot_index = 0; material_slot_index < MAX_MTEX; material_slot_index++) {
117 MEM_SAFE_FREE(linestyle->mtex[material_slot_index]);
118 }
119
120 /* is no lib link block, but linestyle extension */
121 if (linestyle->nodetree) {
123 MEM_freeN(linestyle->nodetree);
124 linestyle->nodetree = nullptr;
125 }
126
127 while ((linestyle_modifier = (LineStyleModifier *)linestyle->color_modifiers.first)) {
128 BKE_linestyle_color_modifier_remove(linestyle, linestyle_modifier);
129 }
130 while ((linestyle_modifier = (LineStyleModifier *)linestyle->alpha_modifiers.first)) {
131 BKE_linestyle_alpha_modifier_remove(linestyle, linestyle_modifier);
132 }
133 while ((linestyle_modifier = (LineStyleModifier *)linestyle->thickness_modifiers.first)) {
134 BKE_linestyle_thickness_modifier_remove(linestyle, linestyle_modifier);
135 }
136 while ((linestyle_modifier = (LineStyleModifier *)linestyle->geometry_modifiers.first)) {
137 BKE_linestyle_geometry_modifier_remove(linestyle, linestyle_modifier);
138 }
139}
140
142{
143 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
144
145 for (int i = 0; i < MAX_MTEX; i++) {
146 if (linestyle->mtex[i]) {
149 }
150 }
151 if (linestyle->nodetree) {
152 /* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
155 }
156
158 if (lsm->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
160 lsm;
162 }
163 }
165 if (lsm->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
167 lsm;
169 }
170 }
172 if (lsm->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
176 }
177 }
178}
179
181{
182 LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
183 int struct_nr;
184 switch (m->type) {
187 break;
190 break;
193 break;
196 break;
199 break;
202 break;
205 break;
208 break;
209 default:
210 struct_nr = sdna_struct_id_get<LineStyleModifier>(); /* this should not happen */
211 }
212 BLO_write_struct_by_id(writer, struct_nr, m);
213 }
214 LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
215 switch (m->type) {
218 break;
221 writer, ColorBand, ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp);
222 break;
225 writer, ColorBand, ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp);
226 break;
229 break;
231 BLO_write_struct(writer, ColorBand, ((LineStyleColorModifier_Tangent *)m)->color_ramp);
232 break;
234 BLO_write_struct(writer, ColorBand, ((LineStyleColorModifier_Noise *)m)->color_ramp);
235 break;
238 break;
241 writer, ColorBand, ((LineStyleColorModifier_Curvature_3D *)m)->color_ramp);
242 break;
243 }
244 }
245}
246
248{
249 LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
250 int struct_nr;
251 switch (m->type) {
254 break;
257 break;
260 break;
263 break;
266 break;
269 break;
272 break;
275 break;
276 default:
277 struct_nr = sdna_struct_id_get<LineStyleModifier>(); /* this should not happen */
278 }
279 BLO_write_struct_by_id(writer, struct_nr, m);
280 }
281 LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
282 switch (m->type) {
285 break;
289 break;
293 break;
296 break;
299 break;
302 break;
305 break;
308 break;
309 }
310 }
311}
312
314{
315 LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
316 int struct_nr;
317 switch (m->type) {
320 break;
323 break;
326 break;
329 break;
332 break;
335 break;
338 break;
341 break;
344 break;
345 default:
346 struct_nr = sdna_struct_id_get<LineStyleModifier>(); /* this should not happen */
347 }
348 BLO_write_struct_by_id(writer, struct_nr, m);
349 }
350 LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
351 switch (m->type) {
354 break;
358 break;
362 break;
365 break;
368 break;
371 break;
375 break;
376 }
377 }
378}
379
381{
382 LISTBASE_FOREACH (LineStyleModifier *, m, modifiers) {
383 int struct_nr;
384 switch (m->type) {
387 break;
390 break;
393 break;
396 break;
399 break;
402 break;
405 break;
408 break;
411 break;
414 break;
417 break;
420 break;
423 break;
426 break;
427 default:
428 struct_nr = sdna_struct_id_get<LineStyleModifier>(); /* this should not happen */
429 }
430 BLO_write_struct_by_id(writer, struct_nr, m);
431 }
432}
433
434static void linestyle_blend_write(BlendWriter *writer, ID *id, const void *id_address)
435{
436 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
437
438 BLO_write_id_struct(writer, FreestyleLineStyle, id_address, &linestyle->id);
439 BKE_id_blend_write(writer, &linestyle->id);
440
445 for (int a = 0; a < MAX_MTEX; a++) {
446 if (linestyle->mtex[a]) {
447 BLO_write_struct(writer, MTex, linestyle->mtex[a]);
448 }
449 }
450 if (linestyle->nodetree) {
451 BLO_Write_IDBuffer temp_embedded_id_buffer{linestyle->nodetree->id, writer};
453 writer, bNodeTree, linestyle->nodetree, temp_embedded_id_buffer.get());
455 writer, reinterpret_cast<bNodeTree *>(temp_embedded_id_buffer.get()));
456 }
457}
458
460 LineStyleModifier *modifier)
461{
462 switch (modifier->type) {
466 break;
467 }
470 modifier;
472 break;
473 }
476 modifier;
478 break;
479 }
483 break;
484 }
485 case LS_MODIFIER_TANGENT: {
488 break;
489 }
490 case LS_MODIFIER_NOISE: {
493 break;
494 }
498 break;
499 }
503 break;
504 }
505 }
506}
507
509 LineStyleModifier *modifier)
510{
511 switch (modifier->type) {
514 BLO_read_struct(reader, CurveMapping, &m->curve);
516 break;
517 }
520 modifier;
521 BLO_read_struct(reader, CurveMapping, &m->curve);
523 break;
524 }
527 modifier;
528 BLO_read_struct(reader, CurveMapping, &m->curve);
530 break;
531 }
534 BLO_read_struct(reader, CurveMapping, &m->curve);
536 break;
537 }
538 case LS_MODIFIER_TANGENT: {
540 BLO_read_struct(reader, CurveMapping, &m->curve);
542 break;
543 }
544 case LS_MODIFIER_NOISE: {
546 BLO_read_struct(reader, CurveMapping, &m->curve);
548 break;
549 }
552 BLO_read_struct(reader, CurveMapping, &m->curve);
554 break;
555 }
558 BLO_read_struct(reader, CurveMapping, &m->curve);
560 break;
561 }
562 }
563}
564
566 LineStyleModifier *modifier)
567{
568 switch (modifier->type) {
571 modifier;
572 BLO_read_struct(reader, CurveMapping, &m->curve);
574 break;
575 }
579 BLO_read_struct(reader, CurveMapping, &m->curve);
581 break;
582 }
586 BLO_read_struct(reader, CurveMapping, &m->curve);
588 break;
589 }
592 BLO_read_struct(reader, CurveMapping, &m->curve);
594 break;
595 }
596 case LS_MODIFIER_TANGENT: {
598 BLO_read_struct(reader, CurveMapping, &m->curve);
600 break;
601 }
604 modifier;
605 BLO_read_struct(reader, CurveMapping, &m->curve);
607 break;
608 }
611 modifier;
612 BLO_read_struct(reader, CurveMapping, &m->curve);
614 break;
615 }
616 }
617}
618
620 LineStyleModifier * /*modifier*/)
621{
622}
623
625{
626 FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
627
629 LISTBASE_FOREACH (LineStyleModifier *, modifier, &linestyle->color_modifiers) {
630 direct_link_linestyle_color_modifier(reader, modifier);
631 }
633 LISTBASE_FOREACH (LineStyleModifier *, modifier, &linestyle->alpha_modifiers) {
634 direct_link_linestyle_alpha_modifier(reader, modifier);
635 }
637 LISTBASE_FOREACH (LineStyleModifier *, modifier, &linestyle->thickness_modifiers) {
639 }
641 LISTBASE_FOREACH (LineStyleModifier *, modifier, &linestyle->geometry_modifiers) {
643 }
644 for (int a = 0; a < MAX_MTEX; a++) {
645 BLO_read_struct(reader, MTex, &linestyle->mtex[a]);
646 }
647}
648
650 /*id_code*/ FreestyleLineStyle::id_type,
651 /*id_filter*/ FILTER_ID_LS,
652 /*dependencies_id_types*/ FILTER_ID_TE | FILTER_ID_OB,
653 /*main_listbase_index*/ INDEX_ID_LS,
654 /*struct_size*/ sizeof(FreestyleLineStyle),
655 /*name*/ "FreestyleLineStyle",
656 /*name_plural*/ N_("linestyles"),
657 /*translation_context*/ BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE,
659 /*asset_type_info*/ nullptr,
660
661 /*init_data*/ linestyle_init_data,
662 /*copy_data*/ linestyle_copy_data,
663 /*free_data*/ linestyle_free_data,
664 /*make_local*/ nullptr,
665 /*foreach_id*/ linestyle_foreach_id,
666 /*foreach_cache*/ nullptr,
667 /*foreach_path*/ nullptr,
668 /*owner_pointer_get*/ nullptr,
669
670 /*blend_write*/ linestyle_blend_write,
671 /*blend_read_data*/ linestyle_blend_read_data,
672 /*blend_read_after_liblink*/ nullptr,
673
674 /*blend_read_undo_preserve*/ nullptr,
675
676 /*lib_override_apply_post*/ nullptr,
677};
678
679static const char *modifier_name[LS_MODIFIER_NUM] = {
680 nullptr, "Along Stroke", "Distance from Camera", "Distance from Object",
681 "Material", "Sampling", "Bézier Curve", "Sinus Displacement",
682 "Spatial Noise", "Perlin Noise 1D", "Perlin Noise 2D", "Backbone Stretcher",
683 "Tip Remover", "Calligraphy", "Polygonalization", "Guiding Lines",
684 "Blueprint", "2D Offset", "2D Transform", "Tangent",
685 "Noise", "Crease Angle", "Simplification", "Curvature 3D",
686};
687
689{
690 linestyle_init_data(&linestyle->id);
691}
692
693FreestyleLineStyle *BKE_linestyle_new(Main *bmain, const char *name)
694{
695 FreestyleLineStyle *linestyle;
696
697 linestyle = (FreestyleLineStyle *)BKE_libblock_alloc(bmain, ID_LS, name, 0);
698
699 BKE_linestyle_init(linestyle);
700
701 return linestyle;
702}
703
705{
706 FreestyleConfig *config = &view_layer->freestyle_config;
708 return (lineset) ? lineset->linestyle : nullptr;
709}
710
711static LineStyleModifier *new_modifier(const char *name, int type, size_t size)
712{
714
715 if (!name) {
716 name = modifier_name[type];
717 }
718 m = (LineStyleModifier *)MEM_callocN(size, "line style modifier");
719 m->type = type;
720 STRNCPY(m->name, DATA_(name));
721 m->influence = 1.0f;
723
724 return m;
725}
726
728{
729 BLI_addtail(lb, (void *)m);
731 lb, m, modifier_name[m->type], '.', offsetof(LineStyleModifier, name), sizeof(m->name));
732}
733
734static LineStyleModifier *alloc_color_modifier(const char *name, int type)
735{
736 size_t size;
737
738 switch (type) {
741 break;
744 break;
747 break;
750 break;
753 break;
756 break;
759 break;
762 break;
763 default:
764 return nullptr; /* unknown modifier type */
765 }
766
767 return new_modifier(name, type, size);
768}
769
771 const char *name,
772 int type)
773{
775
776 m = alloc_color_modifier(name, type);
777 if (UNLIKELY(m == nullptr)) {
778 return nullptr;
779 }
780 m->blend = MA_RAMP_BLEND;
781
782 switch (type) {
784 ((LineStyleColorModifier_AlongStroke *)m)->color_ramp = BKE_colorband_add(true);
785 break;
788 ((LineStyleColorModifier_DistanceFromCamera *)m)->range_min = 0.0f;
789 ((LineStyleColorModifier_DistanceFromCamera *)m)->range_max = 10000.0f;
790 break;
792 ((LineStyleColorModifier_DistanceFromObject *)m)->target = nullptr;
794 ((LineStyleColorModifier_DistanceFromObject *)m)->range_min = 0.0f;
795 ((LineStyleColorModifier_DistanceFromObject *)m)->range_max = 10000.0f;
796 break;
798 ((LineStyleColorModifier_Material *)m)->color_ramp = BKE_colorband_add(true);
800 break;
802 ((LineStyleColorModifier_Tangent *)m)->color_ramp = BKE_colorband_add(true);
803 break;
805 ((LineStyleColorModifier_Noise *)m)->color_ramp = BKE_colorband_add(true);
806 ((LineStyleColorModifier_Noise *)m)->amplitude = 10.0f;
807 ((LineStyleColorModifier_Noise *)m)->period = 10.0f;
808 ((LineStyleColorModifier_Noise *)m)->seed = 512;
809 break;
811 ((LineStyleColorModifier_CreaseAngle *)m)->color_ramp = BKE_colorband_add(true);
812 ((LineStyleColorModifier_CreaseAngle *)m)->min_angle = 0.0f;
813 ((LineStyleColorModifier_CreaseAngle *)m)->max_angle = DEG2RADF(180.0f);
814 break;
817 ((LineStyleColorModifier_Curvature_3D *)m)->min_curvature = 0.0f;
818 ((LineStyleColorModifier_Curvature_3D *)m)->max_curvature = 0.5f;
819 break;
820 default:
821 return nullptr; /* unknown modifier type */
822 }
824
825 return m;
826}
827
829 const LineStyleModifier *m,
830 const int flag)
831{
832 LineStyleModifier *new_m;
833
834 new_m = alloc_color_modifier(m->name, m->type);
835 if (UNLIKELY(new_m == nullptr)) {
836 return nullptr;
837 }
838 new_m->influence = m->influence;
839 new_m->flags = m->flags;
840 new_m->blend = m->blend;
841
842 switch (m->type) {
846 q->color_ramp = static_cast<ColorBand *>(MEM_dupallocN(p->color_ramp));
847 break;
848 }
851 m;
853 new_m;
854 q->color_ramp = static_cast<ColorBand *>(MEM_dupallocN(p->color_ramp));
855 q->range_min = p->range_min;
856 q->range_max = p->range_max;
857 break;
858 }
861 m;
863 new_m;
864 q->target = p->target;
866 id_us_plus((ID *)q->target);
867 }
868 q->color_ramp = static_cast<ColorBand *>(MEM_dupallocN(p->color_ramp));
869 q->range_min = p->range_min;
870 q->range_max = p->range_max;
871 break;
872 }
876 q->color_ramp = static_cast<ColorBand *>(MEM_dupallocN(p->color_ramp));
877 q->flags = p->flags;
878 q->mat_attr = p->mat_attr;
879 break;
880 }
881 case LS_MODIFIER_TANGENT: {
884 q->color_ramp = static_cast<ColorBand *>(MEM_dupallocN(p->color_ramp));
885 break;
886 }
887 case LS_MODIFIER_NOISE: {
890 q->color_ramp = static_cast<ColorBand *>(MEM_dupallocN(p->color_ramp));
891 q->amplitude = p->amplitude;
892 q->period = p->period;
893 q->seed = p->seed;
894 break;
895 }
899 q->color_ramp = static_cast<ColorBand *>(MEM_dupallocN(p->color_ramp));
900 q->min_angle = p->min_angle;
901 q->max_angle = p->max_angle;
902 break;
903 }
907 q->color_ramp = static_cast<ColorBand *>(MEM_dupallocN(p->color_ramp));
910 break;
911 }
912 default:
913 return nullptr; /* unknown modifier type */
914 }
915 add_to_modifier_list(&linestyle->color_modifiers, new_m);
916
917 return new_m;
918}
919
921{
922 if (BLI_findindex(&linestyle->color_modifiers, m) == -1) {
923 return -1;
924 }
925 switch (m->type) {
928 break;
931 break;
934 break;
936 MEM_freeN(((LineStyleColorModifier_Material *)m)->color_ramp);
937 break;
939 MEM_freeN(((LineStyleColorModifier_Tangent *)m)->color_ramp);
940 break;
942 MEM_freeN(((LineStyleColorModifier_Noise *)m)->color_ramp);
943 break;
946 break;
949 break;
950 }
951 BLI_freelinkN(&linestyle->color_modifiers, m);
952 return 0;
953}
954
955static LineStyleModifier *alloc_alpha_modifier(const char *name, int type)
956{
957 size_t size;
958
959 switch (type) {
962 break;
965 break;
968 break;
971 break;
974 break;
977 break;
980 break;
983 break;
984 default:
985 return nullptr; /* unknown modifier type */
986 }
987 return new_modifier(name, type, size);
988}
989
991 const char *name,
992 int type)
993{
995
996 m = alloc_alpha_modifier(name, type);
998
999 switch (type) {
1002 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1003 break;
1004 }
1007 m;
1008 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1009 p->range_min = 0.0f;
1010 p->range_max = 10000.0f;
1011 break;
1012 }
1015 m;
1016 p->target = nullptr;
1017 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1018 p->range_min = 0.0f;
1019 p->range_max = 10000.0f;
1020 break;
1021 }
1022 case LS_MODIFIER_MATERIAL: {
1024 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1026 break;
1027 }
1028 case LS_MODIFIER_TANGENT: {
1030 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1031 break;
1032 }
1033 case LS_MODIFIER_NOISE: {
1035 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1036 ((LineStyleAlphaModifier_Noise *)m)->amplitude = 10.0f;
1037 ((LineStyleAlphaModifier_Noise *)m)->period = 10.0f;
1038 ((LineStyleAlphaModifier_Noise *)m)->seed = 512;
1039 break;
1040 }
1043 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1044 ((LineStyleAlphaModifier_CreaseAngle *)m)->min_angle = 0.0f;
1045 ((LineStyleAlphaModifier_CreaseAngle *)m)->max_angle = DEG2RADF(180.0f);
1046 break;
1047 }
1050 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1051 ((LineStyleAlphaModifier_Curvature_3D *)m)->min_curvature = 0.0f;
1052 ((LineStyleAlphaModifier_Curvature_3D *)m)->max_curvature = 0.5f;
1053 break;
1054 }
1055 default:
1056 return nullptr; /* unknown modifier type */
1057 }
1058 add_to_modifier_list(&linestyle->alpha_modifiers, m);
1059
1060 return m;
1061}
1062
1064 const LineStyleModifier *m,
1065 const int /*flag*/)
1066{
1067 LineStyleModifier *new_m;
1068
1069 new_m = alloc_alpha_modifier(m->name, m->type);
1070 new_m->influence = m->influence;
1071 new_m->flags = m->flags;
1072 new_m->blend = m->blend;
1073
1074 switch (m->type) {
1079 q->flags = p->flags;
1080 break;
1081 }
1084 m;
1086 new_m;
1088 q->flags = p->flags;
1089 q->range_min = p->range_min;
1090 q->range_max = p->range_max;
1091 break;
1092 }
1095 m;
1097 new_m;
1098 if (p->target) {
1099 id_us_plus(&p->target->id);
1100 }
1101 q->target = p->target;
1103 q->flags = p->flags;
1104 q->range_min = p->range_min;
1105 q->range_max = p->range_max;
1106 break;
1107 }
1108 case LS_MODIFIER_MATERIAL: {
1112 q->flags = p->flags;
1113 q->mat_attr = p->mat_attr;
1114 break;
1115 }
1116 case LS_MODIFIER_TANGENT: {
1120 q->flags = p->flags;
1121 break;
1122 }
1123 case LS_MODIFIER_NOISE: {
1127 q->flags = p->flags;
1128 q->amplitude = p->amplitude;
1129 q->period = p->period;
1130 q->seed = p->seed;
1131 break;
1132 }
1137 q->flags = p->flags;
1138 q->min_angle = p->min_angle;
1139 q->max_angle = p->max_angle;
1140 break;
1141 }
1146 q->flags = p->flags;
1149 break;
1150 }
1151 default:
1152 return nullptr; /* unknown modifier type */
1153 }
1154 add_to_modifier_list(&linestyle->alpha_modifiers, new_m);
1155
1156 return new_m;
1157}
1158
1160{
1161 if (BLI_findindex(&linestyle->alpha_modifiers, m) == -1) {
1162 return -1;
1163 }
1164 switch (m->type) {
1167 break;
1170 break;
1173 break;
1176 break;
1179 break;
1180 case LS_MODIFIER_NOISE:
1182 break;
1185 break;
1188 break;
1189 }
1190 BLI_freelinkN(&linestyle->alpha_modifiers, m);
1191 return 0;
1192}
1193
1194static LineStyleModifier *alloc_thickness_modifier(const char *name, int type)
1195{
1196 size_t size;
1197
1198 switch (type) {
1201 break;
1204 break;
1207 break;
1210 break;
1213 break;
1216 break;
1217 case LS_MODIFIER_NOISE:
1219 break;
1222 break;
1225 break;
1226 default:
1227 return nullptr; /* unknown modifier type */
1228 }
1229
1230 return new_modifier(name, type, size);
1231}
1232
1234 const char *name,
1235 int type)
1236{
1238
1239 m = alloc_thickness_modifier(name, type);
1240 m->blend = LS_VALUE_BLEND;
1241
1242 switch (type) {
1245 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1246 p->value_min = 0.0f;
1247 p->value_max = 1.0f;
1248 break;
1249 }
1253 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1254 p->range_min = 0.0f;
1255 p->range_max = 1000.0f;
1256 p->value_min = 0.0f;
1257 p->value_max = 1.0f;
1258 break;
1259 }
1263 p->target = nullptr;
1264 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1265 p->range_min = 0.0f;
1266 p->range_max = 1000.0f;
1267 p->value_min = 0.0f;
1268 p->value_max = 1.0f;
1269 break;
1270 }
1271 case LS_MODIFIER_MATERIAL: {
1273 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1275 p->value_min = 0.0f;
1276 p->value_max = 1.0f;
1277 break;
1278 }
1281 p->min_thickness = 1.0f;
1282 p->max_thickness = 10.0f;
1283 p->orientation = DEG2RADF(60.0f);
1284 break;
1285 }
1286 case LS_MODIFIER_TANGENT: {
1288 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1289 p->min_thickness = 1.0f;
1290 p->max_thickness = 10.0f;
1291 break;
1292 }
1293 case LS_MODIFIER_NOISE: {
1295 p->period = 10.0f;
1296 p->amplitude = 10.0f;
1297 p->seed = 512;
1299 break;
1300 }
1303 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1304 p->min_angle = 0.0f;
1305 p->max_angle = DEG2RADF(180.0f);
1306 p->min_thickness = 1.0f;
1307 p->max_thickness = 10.0f;
1308 break;
1309 }
1312 p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
1313 p->min_curvature = 0.0f;
1314 p->max_curvature = 0.5f;
1315 p->min_thickness = 1.0f;
1316 p->max_thickness = 10.0f;
1317 break;
1318 }
1319 default:
1320 return nullptr; /* unknown modifier type */
1321 }
1323
1324 return m;
1325}
1326
1328 const LineStyleModifier *m,
1329 const int flag)
1330{
1331 LineStyleModifier *new_m;
1332
1333 new_m = alloc_thickness_modifier(m->name, m->type);
1334 if (!new_m) {
1335 return nullptr;
1336 }
1337 new_m->influence = m->influence;
1338 new_m->flags = m->flags;
1339 new_m->blend = m->blend;
1340
1341 switch (m->type) {
1346 q->flags = p->flags;
1347 q->value_min = p->value_min;
1348 q->value_max = p->value_max;
1349 break;
1350 }
1357 q->flags = p->flags;
1358 q->range_min = p->range_min;
1359 q->range_max = p->range_max;
1360 q->value_min = p->value_min;
1361 q->value_max = p->value_max;
1362 break;
1363 }
1369 q->target = p->target;
1370 if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
1371 id_us_plus((ID *)q->target);
1372 }
1374 q->flags = p->flags;
1375 q->range_min = p->range_min;
1376 q->range_max = p->range_max;
1377 q->value_min = p->value_min;
1378 q->value_max = p->value_max;
1379 break;
1380 }
1381 case LS_MODIFIER_MATERIAL: {
1385 q->flags = p->flags;
1386 q->mat_attr = p->mat_attr;
1387 q->value_min = p->value_min;
1388 q->value_max = p->value_max;
1389 break;
1390 }
1396 q->orientation = p->orientation;
1397 break;
1398 }
1399 case LS_MODIFIER_TANGENT: {
1403 q->flags = p->flags;
1406 break;
1407 }
1408 case LS_MODIFIER_NOISE: {
1411 q->amplitude = p->amplitude;
1412 q->period = p->period;
1413 q->seed = p->seed;
1414 q->flags = p->flags;
1415 break;
1416 }
1420 new_m;
1422 q->flags = p->flags;
1427 break;
1428 }
1433 q->flags = p->flags;
1434 q->min_angle = p->min_angle;
1435 q->max_angle = p->max_angle;
1438 break;
1439 }
1440 default:
1441 return nullptr; /* unknown modifier type */
1442 }
1443 add_to_modifier_list(&linestyle->thickness_modifiers, new_m);
1444
1445 return new_m;
1446}
1447
1449{
1450 if (BLI_findindex(&linestyle->thickness_modifiers, m) == -1) {
1451 return -1;
1452 }
1453 switch (m->type) {
1456 break;
1459 break;
1462 break;
1465 break;
1467 break;
1470 break;
1471 case LS_MODIFIER_NOISE:
1472 break;
1474 break;
1476 break;
1477 }
1478 BLI_freelinkN(&linestyle->thickness_modifiers, m);
1479 return 0;
1480}
1481
1482static LineStyleModifier *alloc_geometry_modifier(const char *name, int type)
1483{
1484 size_t size;
1485
1486 switch (type) {
1489 break;
1492 break;
1495 break;
1498 break;
1501 break;
1504 break;
1507 break;
1510 break;
1513 break;
1516 break;
1519 break;
1522 break;
1525 break;
1528 break;
1529 default:
1530 return nullptr; /* unknown modifier type */
1531 }
1532
1533 return new_modifier(name, type, size);
1534}
1535
1537 const char *name,
1538 int type)
1539{
1541
1542 m = alloc_geometry_modifier(name, type);
1543
1544 switch (type) {
1545 case LS_MODIFIER_SAMPLING: {
1547 p->sampling = 10.0f;
1548 break;
1549 }
1552 p->error = 10.0f;
1553 break;
1554 }
1558 p->wavelength = 20.0f;
1559 p->amplitude = 5.0f;
1560 p->phase = 0.0f;
1561 break;
1562 }
1565 p->amplitude = 5.0f;
1566 p->scale = 20.0f;
1567 p->octaves = 4;
1569 break;
1570 }
1573 p->frequency = 10.0f;
1574 p->amplitude = 10.0f;
1575 p->octaves = 4;
1576 p->angle = DEG2RADF(45.0f);
1577 break;
1578 }
1581 p->frequency = 10.0f;
1582 p->amplitude = 10.0f;
1583 p->octaves = 4;
1584 p->angle = DEG2RADF(45.0f);
1585 break;
1586 }
1590 p->backbone_length = 10.0f;
1591 break;
1592 }
1595 p->tip_length = 10.0f;
1596 break;
1597 }
1601 p->error = 10.0f;
1602 break;
1603 }
1606 p->offset = 0.0f;
1607 break;
1608 }
1609 case LS_MODIFIER_BLUEPRINT: {
1612 p->rounds = 1;
1613 p->backbone_length = 10.0f;
1614 p->random_radius = 3;
1615 p->random_center = 5;
1616 p->random_backbone = 5;
1617 break;
1618 }
1619 case LS_MODIFIER_2D_OFFSET: {
1621 p->start = 0.0f;
1622 p->end = 0.0f;
1623 p->x = 0.0f;
1624 p->y = 0.0f;
1625 break;
1626 }
1630 p->scale_x = 1.0f;
1631 p->scale_y = 1.0f;
1632 p->angle = DEG2RADF(0.0f);
1633 p->pivot_u = 0.5f;
1634 p->pivot_x = 0.0f;
1635 p->pivot_y = 0.0f;
1636 break;
1637 }
1640 p->tolerance = 0.1f;
1641 break;
1642 }
1643 default:
1644 return nullptr; /* unknown modifier type */
1645 }
1647
1648 return m;
1649}
1650
1652 const LineStyleModifier *m,
1653 const int /*flag*/)
1654{
1655 LineStyleModifier *new_m;
1656
1657 new_m = alloc_geometry_modifier(m->name, m->type);
1658 new_m->flags = m->flags;
1659
1660 switch (m->type) {
1661 case LS_MODIFIER_SAMPLING: {
1664 q->sampling = p->sampling;
1665 break;
1666 }
1670 q->error = p->error;
1671 break;
1672 }
1678 q->wavelength = p->wavelength;
1679 q->amplitude = p->amplitude;
1680 q->phase = p->phase;
1681 break;
1682 }
1686 q->amplitude = p->amplitude;
1687 q->scale = p->scale;
1688 q->octaves = p->octaves;
1689 q->flags = p->flags;
1690 break;
1691 }
1695 new_m;
1696 q->frequency = p->frequency;
1697 q->amplitude = p->amplitude;
1698 q->angle = p->angle;
1699 q->octaves = p->octaves;
1700 q->seed = p->seed;
1701 break;
1702 }
1706 new_m;
1707 q->frequency = p->frequency;
1708 q->amplitude = p->amplitude;
1709 q->angle = p->angle;
1710 q->octaves = p->octaves;
1711 q->seed = p->seed;
1712 break;
1713 }
1720 break;
1721 }
1725 q->tip_length = p->tip_length;
1726 break;
1727 }
1733 q->error = p->error;
1734 break;
1735 }
1739 q->offset = p->offset;
1740 break;
1741 }
1742 case LS_MODIFIER_BLUEPRINT: {
1745 q->flags = p->flags;
1746 q->rounds = p->rounds;
1751 break;
1752 }
1753 case LS_MODIFIER_2D_OFFSET: {
1756 q->start = p->start;
1757 q->end = p->end;
1758 q->x = p->x;
1759 q->y = p->y;
1760 break;
1761 }
1765 q->pivot = p->pivot;
1766 q->scale_x = p->scale_x;
1767 q->scale_y = p->scale_y;
1768 q->angle = p->angle;
1769 q->pivot_u = p->pivot_u;
1770 q->pivot_x = p->pivot_x;
1771 q->pivot_y = p->pivot_y;
1772 break;
1773 }
1777 new_m;
1778 q->tolerance = p->tolerance;
1779 break;
1780 }
1781 default:
1782 return nullptr; /* unknown modifier type */
1783 }
1784 add_to_modifier_list(&linestyle->geometry_modifiers, new_m);
1785
1786 return new_m;
1787}
1788
1790{
1791 if (BLI_findindex(&linestyle->geometry_modifiers, m) == -1) {
1792 return -1;
1793 }
1794 BLI_freelinkN(&linestyle->geometry_modifiers, m);
1795 return 0;
1796}
1797
1799 LineStyleModifier *modifier,
1800 int direction)
1801{
1802 return BLI_listbase_link_move(&linestyle->color_modifiers, modifier, direction);
1803}
1805 LineStyleModifier *modifier,
1806 int direction)
1807{
1808 return BLI_listbase_link_move(&linestyle->alpha_modifiers, modifier, direction);
1809}
1811 LineStyleModifier *modifier,
1812 int direction)
1813{
1814 return BLI_listbase_link_move(&linestyle->thickness_modifiers, modifier, direction);
1815}
1817 LineStyleModifier *modifier,
1818 int direction)
1819{
1820 return BLI_listbase_link_move(&linestyle->geometry_modifiers, modifier, direction);
1821}
1822
1824{
1825 ColorBand *color_ramp;
1826 LinkData *link;
1827
1828 BLI_listbase_clear(listbase);
1829
1831 switch (m->type) {
1833 color_ramp = ((LineStyleColorModifier_AlongStroke *)m)->color_ramp;
1834 break;
1836 color_ramp = ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp;
1837 break;
1839 color_ramp = ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp;
1840 break;
1842 color_ramp = ((LineStyleColorModifier_Material *)m)->color_ramp;
1843 break;
1844 default:
1845 continue;
1846 }
1847 link = MEM_callocN<LinkData>("link to color ramp");
1848 link->data = color_ramp;
1849 BLI_addtail(listbase, link);
1850 }
1851}
1852
1853std::optional<std::string> BKE_linestyle_path_to_color_ramp(FreestyleLineStyle *linestyle,
1854 const ColorBand *color_ramp)
1855{
1856 bool found = false;
1857
1859 switch (m->type) {
1861 if (color_ramp == ((LineStyleColorModifier_AlongStroke *)m)->color_ramp) {
1862 found = true;
1863 }
1864 break;
1866 if (color_ramp == ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp) {
1867 found = true;
1868 }
1869 break;
1871 if (color_ramp == ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp) {
1872 found = true;
1873 }
1874 break;
1876 if (color_ramp == ((LineStyleColorModifier_Material *)m)->color_ramp) {
1877 found = true;
1878 }
1879 break;
1881 if (color_ramp == ((LineStyleColorModifier_Tangent *)m)->color_ramp) {
1882 found = true;
1883 }
1884 break;
1885 case LS_MODIFIER_NOISE:
1886 if (color_ramp == ((LineStyleColorModifier_Noise *)m)->color_ramp) {
1887 found = true;
1888 }
1889 break;
1891 if (color_ramp == ((LineStyleColorModifier_CreaseAngle *)m)->color_ramp) {
1892 found = true;
1893 }
1894 break;
1896 if (color_ramp == ((LineStyleColorModifier_Curvature_3D *)m)->color_ramp) {
1897 found = true;
1898 }
1899 break;
1900 }
1901
1902 if (found) {
1903 char name_esc[sizeof(m->name) * 2];
1904 BLI_str_escape(name_esc, m->name, sizeof(name_esc));
1905 return fmt::format("color_modifiers[\"{}\"].color_ramp", name_esc);
1906 }
1907 }
1908 printf("BKE_linestyle_path_to_color_ramp: No color ramps correspond to the given pointer.\n");
1909 return std::nullopt;
1910}
1911
1912bool BKE_linestyle_use_textures(FreestyleLineStyle *linestyle, const bool use_shading_nodes)
1913{
1914 if (use_shading_nodes) {
1915 if (linestyle && linestyle->use_nodes && linestyle->nodetree) {
1916 LISTBASE_FOREACH (bNode *, node, &linestyle->nodetree->nodes) {
1917 if (node->typeinfo->nclass == NODE_CLASS_TEXTURE) {
1918 return true;
1919 }
1920 }
1921 }
1922 }
1923 else {
1924 if (linestyle && (linestyle->flag & LS_TEXTURE)) {
1925 return (linestyle->mtex[0] != nullptr);
1926 }
1927 }
1928 return false;
1929}
1930
1932{
1933 bNode *uv_along_stroke, *input_texture, *output_linestyle;
1934 bNodeSocket *fromsock, *tosock;
1935 bNodeTree *ntree;
1936
1937 BLI_assert(linestyle->nodetree == nullptr);
1938
1940 nullptr, &linestyle->id, "stroke_shader", "ShaderNodeTree");
1941
1943 uv_along_stroke->location[0] = -200.0f;
1944 uv_along_stroke->location[1] = 100.0f;
1945 uv_along_stroke->custom1 = 0; /* use_tips */
1946
1947 input_texture = blender::bke::node_add_static_node(C, *ntree, SH_NODE_TEX_IMAGE);
1948 input_texture->location[0] = 0.0f;
1949 input_texture->location[1] = 100.0f;
1950
1952 output_linestyle->location[0] = 300.0f;
1953 output_linestyle->location[1] = 100.0f;
1954 output_linestyle->custom1 = MA_RAMP_BLEND;
1955 output_linestyle->custom2 = 0; /* use_clamp */
1956
1957 blender::bke::node_set_active(*ntree, *input_texture);
1958
1959 fromsock = static_cast<bNodeSocket *>(BLI_findlink(&uv_along_stroke->outputs, 0)); /* UV */
1960 tosock = static_cast<bNodeSocket *>(BLI_findlink(&input_texture->inputs, 0)); /* UV */
1961 blender::bke::node_add_link(*ntree, *uv_along_stroke, *fromsock, *input_texture, *tosock);
1962
1963 fromsock = static_cast<bNodeSocket *>(BLI_findlink(&input_texture->outputs, 0)); /* Color */
1964 tosock = static_cast<bNodeSocket *>(BLI_findlink(&output_linestyle->inputs, 0)); /* Color */
1965 blender::bke::node_add_link(*ntree, *input_texture, *fromsock, *output_linestyle, *tosock);
1966
1968}
ColorBand * BKE_colorband_add(bool rangetype)
Definition colorband.cc:297
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:44
IDTypeInfo IDType_ID_LS
Definition linestyle.cc:649
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:663
void * BKE_libblock_alloc(Main *bmain, short type, const char *name, int flag) ATTR_WARN_UNUSED_RESULT
Definition lib_id.cc:1428
void id_us_plus(ID *id)
Definition lib_id.cc:353
@ LIB_ID_CREATE_NO_ALLOCATE
@ LIB_ID_CREATE_NO_USER_REFCOUNT
void BKE_id_blend_write(BlendWriter *writer, ID *id)
Definition lib_id.cc:2611
#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:443
#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:221
#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)
char * STRNCPY(char(&dst)[N], const char *src)
Definition BLI_string.h:688
size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
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)
@ INDEX_ID_LS
Definition DNA_ID.h:1222
@ ID_LS
#define DNA_struct_default_get(struct_name)
@ LS_THICKNESS_ASYMMETRIC
@ LS_MODIFIER_SPATIAL_NOISE_PURERANDOM
@ LS_MODIFIER_SPATIAL_NOISE_SMOOTH
@ LS_VALUE_BLEND
@ 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_2D_TRANSFORM_PIVOT_CENTER
@ LS_MODIFIER_MATERIAL_LINE
@ LS_MODIFIER_MATERIAL_LINE_A
@ LS_MODIFIER_EXPANDED
@ LS_MODIFIER_ENABLED
@ LS_MODIFIER_BLUEPRINT_CIRCLES
@ MA_RAMP_BLEND
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
#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(...)
#define FILTER_ID_OB
#define MEM_SAFE_FREE(v)
#define FILTER_ID_TE
#define FILTER_ID_LS
static void direct_link_linestyle_alpha_modifier(BlendDataReader *reader, LineStyleModifier *modifier)
Definition linestyle.cc:508
static void linestyle_free_data(ID *id)
Definition linestyle.cc:111
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:693
static void linestyle_init_data(ID *id)
Definition linestyle.cc:49
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:459
LineStyleModifier * BKE_linestyle_geometry_modifier_add(FreestyleLineStyle *linestyle, const char *name, int type)
void BKE_linestyle_init(FreestyleLineStyle *linestyle)
Definition linestyle.cc:688
static void write_linestyle_geometry_modifiers(BlendWriter *writer, ListBase *modifiers)
Definition linestyle.cc:380
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:247
LineStyleModifier * BKE_linestyle_color_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m, const int flag)
Definition linestyle.cc:828
static void direct_link_linestyle_thickness_modifier(BlendDataReader *reader, LineStyleModifier *modifier)
Definition linestyle.cc:565
LineStyleModifier * BKE_linestyle_alpha_modifier_add(FreestyleLineStyle *linestyle, const char *name, int type)
Definition linestyle.cc:990
static LineStyleModifier * alloc_geometry_modifier(const char *name, int type)
FreestyleLineStyle * BKE_linestyle_active_from_view_layer(ViewLayer *view_layer)
Definition linestyle.cc:704
LineStyleModifier * BKE_linestyle_color_modifier_add(FreestyleLineStyle *linestyle, const char *name, int type)
Definition linestyle.cc:770
static void write_linestyle_thickness_modifiers(BlendWriter *writer, ListBase *modifiers)
Definition linestyle.cc:313
int sdna_struct_id_get()
static void write_linestyle_color_modifiers(BlendWriter *writer, ListBase *modifiers)
Definition linestyle.cc:180
int BKE_linestyle_color_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *m)
Definition linestyle.cc:920
static void linestyle_blend_read_data(BlendDataReader *reader, ID *id)
Definition linestyle.cc:624
static LineStyleModifier * new_modifier(const char *name, int type, size_t size)
Definition linestyle.cc:711
static void linestyle_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Definition linestyle.cc:434
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:955
int BKE_linestyle_alpha_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *m)
static LineStyleModifier * alloc_color_modifier(const char *name, int type)
Definition linestyle.cc:734
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:141
static const char * modifier_name[LS_MODIFIER_NUM]
Definition linestyle.cc:679
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:60
int BKE_linestyle_geometry_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *m)
static void add_to_modifier_list(ListBase *lb, LineStyleModifier *m)
Definition linestyle.cc:727
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:619
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:4375
void node_tree_blend_write(BlendWriter *writer, bNodeTree *ntree)
Definition node.cc:1464
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
Definition node.cc:3804
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
Definition node.cc:4087
void node_set_active(bNodeTree &ntree, bNode &node)
Definition node.cc:4996
void node_tree_free_embedded_tree(bNodeTree *ntree)
Definition node.cc:4724
int sdna_struct_id_get()
struct FreestyleLineStyle * linestyle
struct bNodeTree * nodetree
struct MTex * mtex[18]
Definition DNA_ID.h:404
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:139