Blender V4.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
9#include <cstdio>
10
12#include "DNA_object_types.h"
13#include "DNA_scene_types.h"
14#include "DNA_screen_types.h"
15
16#include "BLI_math_base.h"
17#include "BLI_utildefines.h"
18
19#include "BLT_translation.hh"
20
21#include "BKE_context.hh"
22#include "BKE_lib_query.hh"
23#include "BKE_modifier.hh"
24#include "BKE_screen.hh"
25#include "BKE_shader_fx.h"
26
27#include "UI_interface.hh"
28#include "UI_resources.hh"
29
30#include "RNA_access.hh"
31
32#include "FX_shader_types.h"
33#include "FX_ui_common.h"
34
35#include "DEG_depsgraph.hh"
37
38static void init_data(ShaderFxData *md)
39{
41 gpmd->radius = 100;
42 gpmd->angle = M_PI_2;
43}
44
45static void copy_data(const ShaderFxData *md, ShaderFxData *target)
46{
48}
49
51{
53 if (fxd->object != nullptr) {
54 DEG_add_object_relation(ctx->node, fxd->object, DEG_OB_COMP_TRANSFORM, "Swirl ShaderFx");
55 }
56 DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Swirl ShaderFx");
57}
58
59static bool is_disabled(ShaderFxData *fx, bool /*use_render_params*/)
60{
62
63 return !fxd->object;
64}
65
66static void foreach_ID_link(ShaderFxData *fx, Object *ob, IDWalkFunc walk, void *user_data)
67{
69
70 walk(user_data, ob, (ID **)&fxd->object, IDWALK_CB_NOP);
71}
72
73static void panel_draw(const bContext * /*C*/, Panel *panel)
74{
75 uiLayout *layout = panel->layout;
76
78
79 uiLayoutSetPropSep(layout, true);
80
81 uiItemR(layout, ptr, "object", UI_ITEM_NONE, nullptr, ICON_NONE);
82 uiItemR(layout, ptr, "radius", UI_ITEM_NONE, nullptr, ICON_NONE);
83 uiItemR(layout, ptr, "angle", UI_ITEM_NONE, nullptr, ICON_NONE);
84
85 shaderfx_panel_end(layout, ptr);
86}
87
88static void panel_register(ARegionType *region_type)
89{
91}
92
94 /*name*/ N_("Swirl"),
95 /*struct_name*/ "SwirlShaderFxData",
96 /*struct_size*/ sizeof(SwirlShaderFxData),
98 /*flags*/ ShaderFxTypeFlag(0),
99
100 /*copy_data*/ copy_data,
101
102 /*init_data*/ init_data,
103 /*free_data*/ nullptr,
104 /*is_disabled*/ is_disabled,
105 /*update_depsgraph*/ update_depsgraph,
106 /*depends_on_time*/ nullptr,
107 /*foreach_ID_link*/ foreach_ID_link,
108 /*panel_register*/ panel_register,
109};
@ IDWALK_CB_NOP
void(*)(void *user_data, Object *ob, ID **idpoin, int cb_flag) IDWalkFunc
@ eShaderFxType_GpencilType
void BKE_shaderfx_copydata_generic(const struct ShaderFxData *fx_src, struct ShaderFxData *fx_dst)
ShaderFxTypeFlag
#define M_PI_2
void DEG_add_object_relation(DepsNodeHandle *node_handle, Object *object, eDepsObjectComponentType component, const char *description)
@ DEG_OB_COMP_TRANSFORM
Object is a sort of wrapper for general info.
struct SwirlShaderFxData SwirlShaderFxData
@ eShaderFxType_Swirl
static void panel_register(ARegionType *region_type)
static void foreach_ID_link(ShaderFxData *fx, Object *ob, IDWalkFunc walk, void *user_data)
static void update_depsgraph(ShaderFxData *fx, const ModifierUpdateDepsgraphContext *ctx)
static void panel_draw(const bContext *, Panel *panel)
ShaderFxTypeInfo shaderfx_Type_Swirl
static void init_data(ShaderFxData *md)
static void copy_data(const ShaderFxData *md, ShaderFxData *target)
PanelType * shaderfx_panel_register(ARegionType *region_type, ShaderFxType type, PanelDrawFn draw)
void shaderfx_panel_end(uiLayout *layout, PointerRNA *ptr)
PointerRNA * shaderfx_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
static bool is_disabled
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
#define UI_ITEM_NONE
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
Definition DNA_ID.h:413
struct uiLayout * layout
#define N_(msgid)
PointerRNA * ptr
Definition wm_files.cc:4126