Blender V5.3
BKE_shader_fx.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4#pragma once
5
9
10#include "BLI_compiler_attrs.hh"
11#include "DNA_listBase.h"
12
13#include "DNA_shader_fx_types.h" /* Needed for all enum type definitions. */
14
15#include "BKE_lib_query.hh" /* For LibraryForeachIDCallbackFlag enum. */
16
17namespace blender {
18
19struct ARegionType;
20struct BlendDataReader;
21struct BlendWriter;
22struct ID;
25struct Object;
26struct ShaderFxData;
27
28#define SHADER_FX_ACTIVE(_fx, _is_render) \
29 ((((_fx)->mode & eShaderFxMode_Realtime) && (_is_render == false)) || \
30 (((_fx)->mode & eShaderFxMode_Render) && (_is_render == true)))
31#define SHADER_FX_EDIT(_fx, _is_edit) ((((_fx)->mode & eShaderFxMode_Editmode) == 0) && (_is_edit))
32
34 /* Should not be used, only for None type */
36
37 /* grease pencil effects */
39};
40
43
44 /* For effects that support editmode this determines if the
45 * effect should be enabled by default in editmode.
46 */
48
49 /* max one per type */
51
52 /* can't be added manually by user */
54};
55
56typedef void (*ShaderFxIDWalkFunc)(void *user_data,
57 Object *ob,
58 ID **idpoin,
60typedef void (*ShaderFxTexWalkFunc)(void *user_data,
61 Object *ob,
62 ShaderFxData *fx,
63 const char *propname);
64
66 /* The user visible name for this effect */
67 char name[32];
68
69 /* The DNA struct name for the effect data type, used to
70 * write the DNA data out.
71 */
72 char struct_name[32];
73
74 /* The size of the effect data type, used by allocation. */
76
79
80 /* Copy instance data for this effect type. Should copy all user
81 * level settings to the target effect.
82 */
83 void (*copy_data)(const ShaderFxData *fx, ShaderFxData *target);
84
85 /* Initialize new instance data for this effect type, this function
86 * should set effect variables to their default values.
87 *
88 * This function is optional.
89 */
90 void (*init_data)(ShaderFxData *fx);
91
92 /* Free internal effect data variables, this function should
93 * not free the fx variable itself.
94 *
95 * This function is optional.
96 */
97 void (*free_data)(ShaderFxData *fx);
98
99 /* Return a boolean value indicating if this effect is able to be
100 * calculated based on the effect data. This is *not* regarding the
101 * fx->flag, that is tested by the system, this is just if the data
102 * validates (for example, a lattice will return false if the lattice
103 * object is not defined).
104 *
105 * This function is optional (assumes never disabled if not present).
106 */
107 bool (*is_disabled)(ShaderFxData *fx, bool use_render_params);
108
109 /* Add the appropriate relations to the dependency graph.
110 *
111 * This function is optional.
112 */
114
115 /* Should return true if the effect needs to be recalculated on time
116 * changes.
117 *
118 * This function is optional (assumes false if not present).
119 */
121
122 /* Should call the given walk function with a pointer to each ID
123 * pointer (i.e. each data-block pointer) that the effect data
124 * stores. This is used for linking on file load and for
125 * unlinking data-blocks or forwarding data-block references.
126 *
127 * This function is optional.
128 */
129 void (*foreach_ID_link)(ShaderFxData *fx, Object *ob, ShaderFxIDWalkFunc walk, void *user_data);
130
131 /* Should iterate over every working space color. */
134
135 /* Register the panel types for the effect's UI. */
136 void (*panel_register)(ARegionType *region_type);
137};
138
139#define SHADERFX_TYPE_PANEL_PREFIX "FX_PT_"
140
144void BKE_shaderfx_init();
145
152void BKE_shaderfxType_panel_id(ShaderFxType type, char *r_idname);
153void BKE_shaderfx_panel_expand(ShaderFxData *fx);
154const ShaderFxTypeInfo *BKE_shaderfx_get_info(ShaderFxType type);
155ShaderFxData *BKE_shaderfx_new(ShaderFxType type);
156void BKE_shaderfx_free_ex(ShaderFxData *fx, int flag);
157void BKE_shaderfx_free(ShaderFxData *fx);
161void BKE_shaderfx_unique_name(ListBaseT<ShaderFxData> *shaders, ShaderFxData *fx);
162bool BKE_shaderfx_depends_ontime(ShaderFxData *fx);
169bool BKE_shaderfx_is_nonlocal_in_liboverride(const Object *ob, const ShaderFxData *shaderfx);
170ShaderFxData *BKE_shaderfx_findby_type(Object *ob, ShaderFxType type);
171ShaderFxData *BKE_shaderfx_findby_name(Object *ob, const char *name);
172void BKE_shaderfx_copydata_generic(const ShaderFxData *fx_src, ShaderFxData *fx_dst);
173void BKE_shaderfx_copydata(ShaderFxData *fx, ShaderFxData *target);
174void BKE_shaderfx_copydata_ex(ShaderFxData *fx, ShaderFxData *target, int flag);
175void BKE_shaderfx_copy(ListBaseT<ShaderFxData> *dst, const ListBaseT<ShaderFxData> *src);
176void BKE_shaderfx_foreach_ID_link(Object *ob, ShaderFxIDWalkFunc walk, void *user_data);
177
181bool BKE_shaderfx_has_gpencil(const Object *ob);
182
183void BKE_shaderfx_blend_write(BlendWriter *writer, ListBaseT<ShaderFxData> *fxbase);
184void BKE_shaderfx_blend_read_data(BlendDataReader *reader,
185 ListBaseT<ShaderFxData> *lb,
186 Object *ob);
187
188} // namespace blender
These structs are the foundation for all linked lists in the library system.
BMesh Iterators.
void BKE_shaderfx_foreach_ID_link(Object *ob, ShaderFxIDWalkFunc walk, void *user_data)
Definition shader_fx.cc:239
ShaderFxData * BKE_shaderfx_new(ShaderFxType type)
Definition shader_fx.cc:56
void BKE_shaderfx_blend_write(BlendWriter *writer, ListBaseT< ShaderFxData > *fxbase)
Definition shader_fx.cc:258
void BKE_shaderfx_blend_read_data(BlendDataReader *reader, ListBaseT< ShaderFxData > *lb, Object *ob)
Definition shader_fx.cc:274
void(*) ShaderFxTexWalkFunc(void *user_data, Object *ob, ShaderFxData *fx, const char *propname)
ShaderFxData * BKE_shaderfx_findby_type(Object *ob, ShaderFxType type)
Definition shader_fx.cc:226
void BKE_shaderfx_init()
Definition shader_fx.cc:50
bool BKE_shaderfx_depends_ontime(ShaderFxData *fx)
Definition shader_fx.cc:127
void BKE_shaderfx_copydata_ex(ShaderFxData *fx, ShaderFxData *target, int flag)
Definition shader_fx.cc:189
void BKE_shaderfx_unique_name(ListBaseT< ShaderFxData > *shaders, ShaderFxData *fx)
Definition shader_fx.cc:118
bool BKE_shaderfx_has_gpencil(const Object *ob)
Definition shader_fx.cc:39
@ eShaderFxType_NoneType
@ eShaderFxType_GpencilType
void BKE_shaderfx_free_ex(ShaderFxData *fx, int flag)
Definition shader_fx.cc:93
ShaderFxData * BKE_shaderfx_findby_name(Object *ob, const char *name)
Definition shader_fx.cc:252
void BKE_shaderfx_free(ShaderFxData *fx)
Definition shader_fx.cc:113
bool BKE_shaderfx_is_nonlocal_in_liboverride(const Object *ob, const ShaderFxData *shaderfx)
Definition shader_fx.cc:144
void BKE_shaderfx_panel_expand(ShaderFxData *fx)
Definition shader_fx.cc:156
@ eShaderFxTypeFlag_NoUserAdd
@ eShaderFxTypeFlag_SupportsEditmode
@ eShaderFxTypeFlag_Single
@ eShaderFxTypeFlag_EnableInEditmode
void BKE_shaderfx_copydata(ShaderFxData *fx, ShaderFxData *target)
Definition shader_fx.cc:208
void BKE_shaderfx_copydata_generic(const ShaderFxData *fx_src, ShaderFxData *fx_dst)
Definition shader_fx.cc:161
LibraryForeachIDCallbackFlag
void(*) ShaderFxIDWalkFunc(void *user_data, Object *ob, ID **idpoin, LibraryForeachIDCallbackFlag cb_flag)
void BKE_shaderfx_copy(ListBaseT< ShaderFxData > *dst, const ListBaseT< ShaderFxData > *src)
Definition shader_fx.cc:213
void BKE_shaderfxType_panel_id(ShaderFxType type, char *r_idname)
Definition shader_fx.cc:150
const ShaderFxTypeInfo * BKE_shaderfx_get_info(ShaderFxType type)
Definition shader_fx.cc:134
void(*) panel_register(ARegionType *region_type)
void(*) foreach_ID_link(ShaderFxData *fx, Object *ob, ShaderFxIDWalkFunc walk, void *user_data)
void(*) foreach_working_space_color(ShaderFxData *fx, const IDTypeForeachColorFunctionCallback &func)
void(*) update_depsgraph(ShaderFxData *fx, const ModifierUpdateDepsgraphContext *ctx)
bool(*) is_disabled(ShaderFxData *fx, bool use_render_params)
void(*) init_data(ShaderFxData *fx)
bool(*) depends_on_time(ShaderFxData *fx)
void(*) free_data(ShaderFxData *fx)
void(*) copy_data(const ShaderFxData *fx, ShaderFxData *target)