Blender V5.3
FX_shader_swirl.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2018 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLT_translation.hh"
10
11#include "BLI_math_base_c.hh"
12
13#include "BKE_context.hh"
14#include "BKE_lib_query.hh"
15#include "BKE_modifier.hh"
16#include "BKE_screen.hh"
17#include "BKE_shader_fx.hh"
18
19#include "DNA_screen_types.h"
20
22#include "UI_resources.hh"
23
24#include "RNA_access.hh"
25
26#include "FX_shader_types.hh"
27#include "FX_ui_common.hh"
28
30
31namespace blender {
32
33static void init_data(ShaderFxData *md)
34{
35 SwirlShaderFxData *gpmd = reinterpret_cast<SwirlShaderFxData *>(md);
36 gpmd->radius = 100;
37 gpmd->angle = M_PI_2;
38}
39
40static void copy_data(const ShaderFxData *md, ShaderFxData *target)
41{
43}
44
46{
47 SwirlShaderFxData *fxd = reinterpret_cast<SwirlShaderFxData *>(fx);
48 if (fxd->object != nullptr) {
49 DEG_add_object_relation(ctx->node, fxd->object, DEG_OB_COMP_TRANSFORM, "Swirl ShaderFx");
50 }
51 DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Swirl ShaderFx");
52}
53
54static bool is_disabled(ShaderFxData *fx, bool /*use_render_params*/)
55{
56 SwirlShaderFxData *fxd = reinterpret_cast<SwirlShaderFxData *>(fx);
57
58 return !fxd->object;
59}
60
61static void foreach_ID_link(ShaderFxData *fx, Object *ob, IDWalkFunc walk, void *user_data)
62{
63 SwirlShaderFxData *fxd = reinterpret_cast<SwirlShaderFxData *>(fx);
64
65 walk(user_data, ob, reinterpret_cast<ID **>(&fxd->object), IDWALK_CB_NOP);
66}
67
68static void panel_draw(const bContext * /*C*/, Panel *panel)
69{
70 ui::Layout &layout = *panel->layout;
71
73
74 layout.use_property_split_set(true);
75
76 layout.prop(ptr, "object", UI_ITEM_NONE, std::nullopt, ICON_NONE);
77 layout.prop(ptr, "radius", UI_ITEM_NONE, std::nullopt, ICON_NONE);
78 layout.prop(ptr, "angle", UI_ITEM_NONE, std::nullopt, ICON_NONE);
79
80 shaderfx_panel_end(layout, ptr);
81}
82
83static void panel_register(ARegionType *region_type)
84{
86}
87
89 /*name*/ N_("Swirl"),
90 /*struct_name*/ "SwirlShaderFxData",
91 /*struct_size*/ sizeof(SwirlShaderFxData),
93 /*flags*/ ShaderFxTypeFlag(0),
94
95 /*copy_data*/ copy_data,
96
97 /*init_data*/ init_data,
98 /*free_data*/ nullptr,
99 /*is_disabled*/ is_disabled,
100 /*update_depsgraph*/ update_depsgraph,
101 /*depends_on_time*/ nullptr,
102 /*foreach_ID_link*/ foreach_ID_link,
103 /*foreach_working_space_color*/ nullptr,
104 /*panel_register*/ panel_register,
105};
106
107} // namespace blender
#define M_PI_2
#define UI_ITEM_NONE
BMesh Iterators.
static void copy_data(const ModifierData *md, ModifierData *target, const int flag)
PanelType * shaderfx_panel_register(ARegionType *region_type, ShaderFxType type, PanelDrawFn draw)
static void init_data(ModifierData *md)
void(*)(void *user_data, Object *ob, ID **idpoin, LibraryForeachIDCallbackFlag cb_flag) IDWalkFunc
static void update_depsgraph(tGraphSliderOp *gso)
static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data)
void DEG_add_object_relation(DepsNodeHandle *node_handle, Object *object, eDepsObjectComponentType component, const char *description)
static void panel_register(ARegionType *region_type)
ShaderFxTypeInfo shaderfx_Type_Swirl
@ eShaderFxType_GpencilType
void shaderfx_panel_end(ui::Layout &layout, PointerRNA *ptr)
PointerRNA * shaderfx_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
static void panel_draw(const bContext *, Panel *panel)
void BKE_shaderfx_copydata_generic(const ShaderFxData *fx_src, ShaderFxData *fx_dst)
Definition shader_fx.cc:161
static bool is_disabled(const Scene *, ModifierData *md, bool)
ui::Layout * layout
void use_property_split_set(bool is_sep)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
#define N_(msgid)