Blender  V3.3
FX_shader_swirl.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2018 Blender Foundation. */
3 
8 #include <stdio.h>
9 
10 #include "DNA_gpencil_types.h"
11 #include "DNA_object_types.h"
12 #include "DNA_scene_types.h"
13 #include "DNA_screen_types.h"
14 
15 #include "BLI_math_base.h"
16 #include "BLI_utildefines.h"
17 
18 #include "BLT_translation.h"
19 
20 #include "BKE_context.h"
21 #include "BKE_lib_query.h"
22 #include "BKE_modifier.h"
23 #include "BKE_screen.h"
24 #include "BKE_shader_fx.h"
25 
26 #include "UI_interface.h"
27 #include "UI_resources.h"
28 
29 #include "RNA_access.h"
30 
31 #include "FX_shader_types.h"
32 #include "FX_ui_common.h"
33 
34 #include "DEG_depsgraph.h"
35 #include "DEG_depsgraph_build.h"
36 
37 static void initData(ShaderFxData *md)
38 {
40  gpmd->radius = 100;
41  gpmd->angle = M_PI_2;
42 }
43 
44 static void copyData(const ShaderFxData *md, ShaderFxData *target)
45 {
47 }
48 
50 {
52  if (fxd->object != NULL) {
53  DEG_add_object_relation(ctx->node, fxd->object, DEG_OB_COMP_TRANSFORM, "Swirl ShaderFx");
54  }
55  DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Swirl ShaderFx");
56 }
57 
58 static bool isDisabled(ShaderFxData *fx, int UNUSED(userRenderParams))
59 {
61 
62  return !fxd->object;
63 }
64 
65 static void foreachIDLink(ShaderFxData *fx, Object *ob, IDWalkFunc walk, void *userData)
66 {
68 
69  walk(userData, ob, (ID **)&fxd->object, IDWALK_CB_NOP);
70 }
71 
72 static void panel_draw(const bContext *UNUSED(C), Panel *panel)
73 {
74  uiLayout *layout = panel->layout;
75 
77 
78  uiLayoutSetPropSep(layout, true);
79 
80  uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE);
81  uiItemR(layout, ptr, "radius", 0, NULL, ICON_NONE);
82  uiItemR(layout, ptr, "angle", 0, NULL, ICON_NONE);
83 
84  shaderfx_panel_end(layout, ptr);
85 }
86 
87 static void panelRegister(ARegionType *region_type)
88 {
90 }
91 
93  /* name */ N_("Swirl"),
94  /* structName */ "SwirlShaderFxData",
95  /* structSize */ sizeof(SwirlShaderFxData),
96  /* type */ eShaderFxType_GpencilType,
97  /* flags */ 0,
98 
99  /* copyData */ copyData,
100 
101  /* initData */ initData,
102  /* freeData */ NULL,
103  /* isDisabled */ isDisabled,
104  /* updateDepsgraph */ updateDepsgraph,
105  /* dependsOnTime */ NULL,
106  /* foreachIDLink */ foreachIDLink,
107  /* panelRegister */ panelRegister,
108 };
@ IDWALK_CB_NOP
Definition: BKE_lib_query.h:33
void(* IDWalkFunc)(void *userData, struct Object *ob, struct ID **idpoin, int cb_flag)
Definition: BKE_modifier.h:107
@ eShaderFxType_GpencilType
Definition: BKE_shader_fx.h:35
void BKE_shaderfx_copydata_generic(const struct ShaderFxData *fx_src, struct ShaderFxData *fx_dst)
#define M_PI_2
Definition: BLI_math_base.h:23
#define UNUSED(x)
void DEG_add_object_relation(struct DepsNodeHandle *node_handle, struct 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 initData(ShaderFxData *md)
static void updateDepsgraph(ShaderFxData *fx, const ModifierUpdateDepsgraphContext *ctx)
static bool isDisabled(ShaderFxData *fx, int UNUSED(userRenderParams))
ShaderFxTypeInfo shaderfx_Type_Swirl
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
static void panelRegister(ARegionType *region_type)
static void foreachIDLink(ShaderFxData *fx, Object *ob, IDWalkFunc walk, void *userData)
static void copyData(const ShaderFxData *md, ShaderFxData *target)
PanelType * shaderfx_panel_register(ARegionType *region_type, ShaderFxType type, PanelDrawFn draw)
Definition: FX_ui_common.c:223
void shaderfx_panel_end(uiLayout *layout, PointerRNA *ptr)
Definition: FX_ui_common.c:84
PointerRNA * shaderfx_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
Definition: FX_ui_common.c:93
#define C
Definition: RandGen.cpp:25
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
Definition: DNA_ID.h:368
struct DepsNodeHandle * node
Definition: BKE_modifier.h:134
struct uiLayout * layout
struct Object * object
#define N_(msgid)
PointerRNA * ptr
Definition: wm_files.c:3480