15#include <fmt/format.h>
62 std::optional<Library *> owner_library,
76 if (linestyle_src->
mtex[a]) {
77 linestyle_dst->
mtex[a] = MEM_new<MTex>(__func__);
87 reinterpret_cast<ID **
>(&linestyle_dst->
nodetree),
88 flag_embedded_id_data);
117 for (
int material_slot_index = 0; material_slot_index <
MAX_MTEX; material_slot_index++) {
118 MEM_SAFE_DELETE(linestyle->
mtex[material_slot_index]);
146 for (
int i = 0; i <
MAX_MTEX; i++) {
147 if (linestyle->
mtex[i]) {
186 fn.single(&linestyle->
r);
190 ListBaseT<LineStyleModifier> *modifiers)
263 ListBaseT<LineStyleModifier> *modifiers)
338 ListBaseT<LineStyleModifier> *modifiers)
414 ListBaseT<LineStyleModifier> *modifiers)
479 for (
int a = 0; a <
MAX_MTEX; a++) {
480 if (linestyle->
mtex[a]) {
681 ListBaseT<LineStyleModifier> *modifiers,
711 for (
int a = 0; a <
MAX_MTEX; a++) {
717 .id_code = FreestyleLineStyle::id_type,
722 .name =
"FreestyleLineStyle",
723 .name_plural =
N_(
"linestyles"),
726 .asset_type_info =
nullptr,
731 .make_local =
nullptr,
733 .foreach_cache =
nullptr,
734 .foreach_path =
nullptr,
736 .foreach_asset_weak_reference =
nullptr,
737 .owner_pointer_get =
nullptr,
741 .blend_read_after_liblink =
nullptr,
743 .blend_read_undo_preserve =
nullptr,
745 .lib_override_apply_post =
nullptr,
749 nullptr,
"Along Stroke",
"Distance from Camera",
"Distance from Object",
750 "Material",
"Sampling",
"Bézier Curve",
"Sinus Displacement",
751 "Spatial Noise",
"Perlin Noise 1D",
"Perlin Noise 2D",
"Backbone Stretcher",
752 "Tip Remover",
"Calligraphy",
"Polygonalization",
"Guiding Lines",
753 "Blueprint",
"2D Offset",
"2D Transform",
"Tangent",
754 "Noise",
"Crease Angle",
"Simplification",
"Curvature 3D",
777 return (lineset) ? lineset->
linestyle :
nullptr;
843 if (m ==
nullptr) [[unlikely]] {
909 if (new_m ==
nullptr) [[unlikely]] {
1163 if (new_m ==
nullptr) [[unlikely]] {
1809 if (new_m ==
nullptr) [[unlikely]] {
2011 ListBaseT<LinkData> *listbase)
2016 listbase->clear_no_delete();
2038 link->
data = color_ramp;
2103 char name_esc[
sizeof(m.
name) * 2];
2105 return fmt::format(
"color_modifiers[\"{}\"].color_ramp", name_esc);
2108 printf(
"BKE_linestyle_path_to_color_ramp: No color ramps correspond to the given pointer.\n");
2109 return std::nullopt;
2114 if (use_shading_nodes) {
2125 return (linestyle->
mtex[0] !=
nullptr);
2133 bNode *uv_along_stroke, *input_texture, *output_linestyle;
2140 nullptr, &linestyle->
id,
"stroke_shader",
"ShaderNodeTree");
2143 uv_along_stroke->
location[0] = -200.0f;
2144 uv_along_stroke->
location[1] = 100.0f;
2149 input_texture->
location[1] = 100.0f;
2152 output_linestyle->
location[0] = 300.0f;
2153 output_linestyle->
location[1] = 100.0f;
2155 output_linestyle->
custom2 = 0;
#define BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data_, func_call_)
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
Blender kernel freestyle line style functionality.
#define NODE_CLASS_TEXTURE
#define SH_NODE_TEX_IMAGE
#define SH_NODE_UVALONGSTROKE
#define SH_NODE_OUTPUT_LINESTYLE
#define STRNCPY_UTF8(dst, src)
#define BLO_read_struct(reader, struct_name, ptr_p)
#define BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define INIT_DEFAULT_STRUCT_AFTER(struct_dst, member)
bNodeTree * node_tree_add_tree_embedded(Main *bmain, ID *owner_id, StringRefNull name, StringRefNull idname)
void node_tree_blend_write(BlendWriter *writer, bNodeTree *ntree)
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
void node_set_active(bNodeTree &ntree, bNode &node)
void node_tree_free_embedded_tree(bNodeTree *ntree)
internal::ShallowDataConstRef< T > shallow_copy(const T &other)
uint32_t struct_size(Span< shader::ShaderCreateInfo::PushConst > push_constants)
CurveMapping * BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy)
LineStyleModifier * BKE_linestyle_geometry_modifier_add(FreestyleLineStyle *linestyle, const char *name, eLineStyleModifier_Type type)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static void linestyle_blend_write(BlendWriter *writer, ID *id, const void *id_address)
static void add_to_modifier_list(ListBaseT< LineStyleModifier > *lb, LineStyleModifier *m)
void BKE_linestyle_init(struct FreestyleLineStyle *linestyle)
CurveMapping * BKE_curvemapping_copy(const CurveMapping *cumap)
void BKE_linestyle_modifier_list_color_ramps(FreestyleLineStyle *linestyle, ListBaseT< LinkData > *listbase)
LineStyleModifier * BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m, int flag)
static void direct_link_linestyle_color_modifier(BlendDataReader *reader, LineStyleModifier *modifier)
@ LS_MODIFIER_2D_TRANSFORM_PIVOT_CENTER
static void linestyle_blend_read_data(BlendDataReader *reader, ID *id)
static void write_linestyle_color_modifiers(BlendWriter *writer, ListBaseT< LineStyleModifier > *modifiers)
static void linestyle_copy_data(Main *bmain, std::optional< Library * > owner_library, ID *id_dst, const ID *id_src, const int flag)
int BKE_linestyle_thickness_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *modifier)
std::optional< std::string > BKE_linestyle_path_to_color_ramp(FreestyleLineStyle *linestyle, const struct ColorBand *color_ramp)
static void linestyle_foreach_working_space_color(ID *id, const IDTypeForeachColorFunctionCallback &fn)
static const char * modifier_name[LS_MODIFIER_NUM]
static size_t alpha_modifier_struct_size(eLineStyleModifier_Type type)
static LineStyleModifier * alloc_alpha_modifier(const char *name, eLineStyleModifier_Type type)
void BKE_curvemapping_blend_write(BlendWriter *writer, const CurveMapping *cumap)
static void write_linestyle_thickness_modifiers(BlendWriter *writer, ListBaseT< LineStyleModifier > *modifiers)
@ LS_MODIFIER_BLUEPRINT_CIRCLES
ColorBand * BKE_colorband_add(bool rangetype)
static void direct_link_linestyle_thickness_modifier(BlendDataReader *reader, LineStyleModifier *modifier)
void BKE_curvemapping_free(CurveMapping *cumap)
int BKE_linestyle_alpha_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *modifier)
void BKE_id_blend_write(BlendWriter *writer, ID *id)
@ LS_MODIFIER_MATERIAL_LINE_A
@ LS_MODIFIER_MATERIAL_LINE
static size_t geometry_modifier_struct_size(eLineStyleModifier_Type type)
@ LIB_ID_CREATE_NO_USER_REFCOUNT
@ LIB_ID_CREATE_NO_ALLOCATE
static void write_linestyle_geometry_modifiers(BlendWriter *writer, ListBaseT< LineStyleModifier > *modifiers)
LineStyleModifier * BKE_linestyle_color_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m, int flag)
bool BKE_linestyle_color_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_uniquename(const ListBase *list, void *vlink, const char *defname, char delim, int name_offset, size_t name_maxncpy) ATTR_NONNULL(1
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BKE_curvemapping_blend_read(BlendDataReader *reader, CurveMapping *cumap)
@ LS_MODIFIER_SPATIAL_NOISE_SMOOTH
@ LS_MODIFIER_SPATIAL_NOISE_PURERANDOM
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
BMesh const char void * data
struct FreestyleLineSet * BKE_freestyle_lineset_get_active(struct FreestyleConfig *config)
void BKE_library_foreach_ID_embedded(LibraryForeachIDData *data, ID **id_pp)
char char size_t BLI_str_escape(char *__restrict dst, StringRef src, size_t dst_maxncpy) ATTR_NONNULL(1)
static void linestyle_foreach_id(ID *id, LibraryForeachIDData *data)
static size_t color_modifier_struct_size(eLineStyleModifier_Type type)
void BKE_ntree_update_after_single_tree_change(Main &bmain, bNodeTree &modified_tree, const NodeTreeUpdateExtraParams ¶ms={})
@ LS_THICKNESS_ASYMMETRIC
void BLO_read_struct_list_with_type_size(BlendDataReader *reader, size_t base_size, ListBase *list, FunctionRef< size_t(const void *data)> type_size_fn)
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
FreestyleLineStyle * BKE_linestyle_new(struct Main *bmain, const char *name)
@ LS_MODIFIER_PERLIN_NOISE_2D
@ LS_MODIFIER_CALLIGRAPHY
@ LS_MODIFIER_BACKBONE_STRETCHER
@ LS_MODIFIER_PERLIN_NOISE_1D
@ LS_MODIFIER_2D_TRANSFORM
@ LS_MODIFIER_DISTANCE_FROM_CAMERA
@ LS_MODIFIER_BEZIER_CURVE
@ LS_MODIFIER_GUIDING_LINES
@ LS_MODIFIER_DISTANCE_FROM_OBJECT
@ LS_MODIFIER_SINUS_DISPLACEMENT
@ LS_MODIFIER_ALONG_STROKE
@ LS_MODIFIER_SPATIAL_NOISE
@ LS_MODIFIER_CURVATURE_3D
@ LS_MODIFIER_CREASE_ANGLE
@ LS_MODIFIER_SIMPLIFICATION
@ LS_MODIFIER_TIP_REMOVER
@ LS_MODIFIER_POLYGONIZATION
LineStyleModifier * BKE_linestyle_alpha_modifier_add(FreestyleLineStyle *linestyle, const char *name, eLineStyleModifier_Type type)
static void direct_link_linestyle_geometry_modifier(BlendDataReader *, LineStyleModifier *)
static void linestyle_modifiers_read(BlendDataReader *reader, ListBaseT< LineStyleModifier > *modifiers, size_t(*struct_size)(eLineStyleModifier_Type))
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
static LineStyleModifier * new_modifier(const char *name, eLineStyleModifier_Type type, size_t size)
Main * CTX_data_main(const bContext *C)
bool BKE_linestyle_thickness_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction)
LineStyleModifier * BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *linestyle, const char *name, eLineStyleModifier_Type type)
FreestyleLineStyle * BKE_linestyle_active_from_view_layer(struct ViewLayer *view_layer)
static void linestyle_init_data(ID *id)
static LineStyleModifier * alloc_thickness_modifier(const char *name, eLineStyleModifier_Type type)
void BKE_texture_mtex_foreach_id(struct LibraryForeachIDData *data, struct MTex *mtex)
static size_t thickness_modifier_struct_size(eLineStyleModifier_Type type)
static LineStyleModifier * alloc_geometry_modifier(const char *name, eLineStyleModifier_Type type)
bool BKE_linestyle_geometry_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction)
bool BKE_linestyle_alpha_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction)
LineStyleModifier * BKE_linestyle_color_modifier_add(FreestyleLineStyle *linestyle, const char *name, eLineStyleModifier_Type type)
int BKE_linestyle_color_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *modifier)
LineStyleModifier * BKE_linestyle_geometry_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m, int flag)
void BKE_linestyle_default_shader(const struct bContext *C, FreestyleLineStyle *linestyle)
LineStyleModifier * BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m, int flag)
static void linestyle_free_data(ID *id)
void * BKE_libblock_alloc(Main *bmain, short type, const char *name, int flag) ATTR_WARN_UNUSED_RESULT
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)
static void write_linestyle_alpha_modifiers(BlendWriter *writer, ListBaseT< LineStyleModifier > *modifiers)
static LineStyleModifier * alloc_color_modifier(const char *name, eLineStyleModifier_Type type)
bool BKE_linestyle_use_textures(FreestyleLineStyle *linestyle, bool use_shading_nodes)
static void direct_link_linestyle_alpha_modifier(BlendDataReader *reader, LineStyleModifier *modifier)
void void void bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step) ATTR_NONNULL()
int BKE_linestyle_geometry_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *modifier)
@ IDTYPE_FLAGS_APPEND_IS_REUSABLE
void write_struct_by_id(int struct_id, const void *data, BlendStructWriterFn fn=nullptr)
void write_embedded_id_struct(const void *id_address, const T *id, BlendStructWriterTypedFn< T > fn=nullptr)
void write_id_struct(const void *id_address, const T *id, BlendStructWriterTypedFn< T > fn=nullptr)
void write_struct(const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
struct FreestyleLineStyle * linestyle
ListBaseT< LineStyleModifier > color_modifiers
struct bNodeTree * nodetree
ListBaseT< LineStyleModifier > alpha_modifiers
ListBaseT< LineStyleModifier > thickness_modifiers
ListBaseT< LineStyleModifier > geometry_modifiers
struct CurveMapping * curve
eLineStyleAlphaThicknessModifier_Flag flags
eLineStyleAlphaThicknessModifier_Flag flags
struct CurveMapping * curve
struct CurveMapping * curve
eLineStyleAlphaThicknessModifier_Flag flags
struct CurveMapping * curve
eLineStyleAlphaThicknessModifier_Flag flags
eLineStyleAlphaThicknessModifier_Flag flags
struct CurveMapping * curve
eLineStyleMaterialAttr mat_attr
struct CurveMapping * curve
eLineStyleAlphaThicknessModifier_Flag flags
struct CurveMapping * curve
eLineStyleAlphaThicknessModifier_Flag flags
eLineStyleAlphaThicknessModifier_Flag flags
struct CurveMapping * curve
struct ColorBand * color_ramp
struct ColorBand * color_ramp
struct ColorBand * color_ramp
struct ColorBand * color_ramp
struct ColorBand * color_ramp
struct ColorBand * color_ramp
eLineStyleMaterialAttr mat_attr
eLineStyleColorModifier_Flag flags
struct ColorBand * color_ramp
struct ColorBand * color_ramp
unsigned int random_backbone
unsigned int random_center
unsigned int random_radius
eLineStyleGeomBlueprint_Flag flags
eLineStyleGeomSpatialNoise_Flag flags
eLineStyleModifier_Flag flags
eLineStyleModifier_Type type
eLineStyleAlphaThicknessModifier_Flag flags
struct CurveMapping * curve
struct CurveMapping * curve
eLineStyleAlphaThicknessModifier_Flag flags
struct CurveMapping * curve
eLineStyleAlphaThicknessModifier_Flag flags
eLineStyleAlphaThicknessModifier_Flag flags
struct CurveMapping * curve
eLineStyleAlphaThicknessModifier_Flag flags
struct CurveMapping * curve
struct CurveMapping * curve
eLineStyleMaterialAttr mat_attr
eLineStyleAlphaThicknessModifier_Flag flags
eLineStyleThicknessNoise_Flag flags
struct CurveMapping * curve
eLineStyleAlphaThicknessModifier_Flag flags
struct FreestyleConfig freestyle_config
ListBaseT< bNodeSocket > outputs
ListBaseT< bNodeSocket > inputs