Blender  V2.93
FX_shader_swirl.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2018, Blender Foundation
17  * This is a new part of Blender
18  */
19 
24 #include <stdio.h>
25 
26 #include "DNA_gpencil_types.h"
27 #include "DNA_object_types.h"
28 #include "DNA_scene_types.h"
29 #include "DNA_screen_types.h"
30 
31 #include "BLI_math_base.h"
32 #include "BLI_utildefines.h"
33 
34 #include "BKE_context.h"
35 #include "BKE_lib_query.h"
36 #include "BKE_modifier.h"
37 #include "BKE_screen.h"
38 #include "BKE_shader_fx.h"
39 
40 #include "UI_interface.h"
41 #include "UI_resources.h"
42 
43 #include "RNA_access.h"
44 
45 #include "FX_shader_types.h"
46 #include "FX_ui_common.h"
47 
48 #include "DEG_depsgraph.h"
49 #include "DEG_depsgraph_build.h"
50 
51 static void initData(ShaderFxData *md)
52 {
54  gpmd->radius = 100;
55  gpmd->angle = M_PI_2;
56 }
57 
58 static void copyData(const ShaderFxData *md, ShaderFxData *target)
59 {
61 }
62 
64 {
66  if (fxd->object != NULL) {
67  DEG_add_object_relation(ctx->node, fxd->object, DEG_OB_COMP_TRANSFORM, "Swirl ShaderFx");
68  }
69  DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Swirl ShaderFx");
70 }
71 
72 static bool isDisabled(ShaderFxData *fx, int UNUSED(userRenderParams))
73 {
75 
76  return !fxd->object;
77 }
78 
79 static void foreachIDLink(ShaderFxData *fx, Object *ob, IDWalkFunc walk, void *userData)
80 {
82 
83  walk(userData, ob, (ID **)&fxd->object, IDWALK_CB_NOP);
84 }
85 
86 static void panel_draw(const bContext *UNUSED(C), Panel *panel)
87 {
88  uiLayout *layout = panel->layout;
89 
91 
92  uiLayoutSetPropSep(layout, true);
93 
94  uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE);
95  uiItemR(layout, ptr, "radius", 0, NULL, ICON_NONE);
96  uiItemR(layout, ptr, "angle", 0, NULL, ICON_NONE);
97 
98  shaderfx_panel_end(layout, ptr);
99 }
100 
101 static void panelRegister(ARegionType *region_type)
102 {
104 }
105 
107  /* name */ "Swirl",
108  /* structName */ "SwirlShaderFxData",
109  /* structSize */ sizeof(SwirlShaderFxData),
110  /* type */ eShaderFxType_GpencilType,
111  /* flags */ 0,
112 
113  /* copyData */ copyData,
114 
115  /* initData */ initData,
116  /* freeData */ NULL,
117  /* isDisabled */ isDisabled,
118  /* updateDepsgraph */ updateDepsgraph,
119  /* dependsOnTime */ NULL,
120  /* foreachIDLink */ foreachIDLink,
121  /* panelRegister */ panelRegister,
122 };
@ IDWALK_CB_NOP
Definition: BKE_lib_query.h:47
void(* IDWalkFunc)(void *userData, struct Object *ob, struct ID **idpoin, int cb_flag)
Definition: BKE_modifier.h:120
@ eShaderFxType_GpencilType
Definition: BKE_shader_fx.h:49
void BKE_shaderfx_copydata_generic(const struct ShaderFxData *fx_src, struct ShaderFxData *fx_dst)
#define M_PI_2
Definition: BLI_math_base.h:41
#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:242
void shaderfx_panel_end(uiLayout *layout, PointerRNA *ptr)
Definition: FX_ui_common.c:99
PointerRNA * shaderfx_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
Definition: FX_ui_common.c:111
#define C
Definition: RandGen.cpp:39
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:273
struct DepsNodeHandle * node
Definition: BKE_modifier.h:147
struct uiLayout * layout
struct Object * object
PointerRNA * ptr
Definition: wm_files.c:3157