Blender  V3.3
MOD_gpencilsubdiv.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2017 Blender Foundation. */
3 
8 #include <stdio.h>
9 #include <string.h> /* For #MEMCPY_STRUCT_AFTER. */
10 
11 #include "BLI_listbase.h"
12 #include "BLI_utildefines.h"
13 
14 #include "BLT_translation.h"
15 
16 #include "DNA_defaults.h"
18 #include "DNA_gpencil_types.h"
19 #include "DNA_object_types.h"
20 #include "DNA_screen_types.h"
21 
22 #include "BKE_context.h"
23 #include "BKE_gpencil_geom.h"
24 #include "BKE_gpencil_modifier.h"
25 #include "BKE_lib_query.h"
26 #include "BKE_modifier.h"
27 #include "BKE_screen.h"
28 
29 #include "DEG_depsgraph.h"
30 
31 #include "UI_interface.h"
32 #include "UI_resources.h"
33 
35 #include "MOD_gpencil_ui_common.h"
36 #include "MOD_gpencil_util.h"
37 
38 static void initData(GpencilModifierData *md)
39 {
41 
42  BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
43 
45 }
46 
47 static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
48 {
50 }
51 
52 /* subdivide stroke to get more control points */
55  Object *ob,
56  bGPDlayer *gpl,
57  bGPDframe *UNUSED(gpf),
58  bGPDstroke *gps)
59 {
61  bGPdata *gpd = ob->data;
62 
64  mmd->layername,
65  mmd->material,
66  mmd->pass_index,
67  mmd->layer_pass,
68  2,
69  gpl,
70  gps,
75  return;
76  }
77 
78  /* For strokes with less than 3 points, only the Simple Subdivision makes sense. */
79  short type = gps->totpoints < 3 ? GP_SUBDIV_SIMPLE : mmd->type;
80 
81  BKE_gpencil_stroke_subdivide(gpd, gps, mmd->level, type);
82 }
83 
84 static void bakeModifier(struct Main *UNUSED(bmain),
87  Object *ob)
88 {
90 }
91 
92 static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
93 {
95 
96  walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
97 }
98 
99 static void panel_draw(const bContext *UNUSED(C), Panel *panel)
100 {
101  uiLayout *layout = panel->layout;
102 
104 
105  uiLayoutSetPropSep(layout, true);
106 
107  uiItemR(layout, ptr, "subdivision_type", 0, NULL, ICON_NONE);
108  uiItemR(layout, ptr, "level", 0, IFACE_("Subdivisions"), ICON_NONE);
109 
111 }
112 
113 static void mask_panel_draw(const bContext *UNUSED(C), Panel *panel)
114 {
115  gpencil_modifier_masking_panel_draw(panel, true, false);
116 }
117 
118 static void panelRegister(ARegionType *region_type)
119 {
123  region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
124 }
125 
127  /* name */ N_("Subdivide"),
128  /* structName */ "SubdivGpencilModifierData",
129  /* structSize */ sizeof(SubdivGpencilModifierData),
132 
133  /* copyData */ copyData,
134 
135  /* deformStroke */ deformStroke,
136  /* generateStrokes */ NULL,
137  /* bakeModifier */ bakeModifier,
138  /* remapTime */ NULL,
139 
140  /* initData */ initData,
141  /* freeData */ NULL,
142  /* isDisabled */ NULL,
143  /* updateDepsgraph */ NULL,
144  /* dependsOnTime */ NULL,
145  /* foreachIDLink */ foreachIDLink,
146  /* foreachTexLink */ NULL,
147  /* panelRegister */ panelRegister,
148 };
void BKE_gpencil_stroke_subdivide(struct bGPdata *gpd, struct bGPDstroke *gps, int level, int type)
void BKE_gpencil_modifier_copydata_generic(const struct GpencilModifierData *md_src, struct GpencilModifierData *md_dst)
@ eGpencilModifierTypeFlag_SupportsEditmode
@ eGpencilModifierTypeType_Gpencil
@ IDWALK_CB_USER
Definition: BKE_lib_query.h:73
void(* IDWalkFunc)(void *userData, struct Object *ob, struct ID **idpoin, int cb_flag)
Definition: BKE_modifier.h:107
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define UNUSED(x)
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
#define IFACE_(msgid)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
#define DNA_struct_default_get(struct_name)
Definition: DNA_defaults.h:29
@ GP_SUBDIV_INVERT_MATERIAL
@ GP_SUBDIV_INVERT_LAYERPASS
@ GP_SUBDIV_INVERT_LAYER
struct SubdivGpencilModifierData SubdivGpencilModifierData
@ eGpencilModifierType_Subdiv
Object is a sort of wrapper for general info.
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
PointerRNA * gpencil_modifier_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
void gpencil_modifier_masking_panel_draw(Panel *panel, bool use_material, bool use_vertex)
void gpencil_modifier_panel_end(uiLayout *layout, PointerRNA *ptr)
PanelType * gpencil_modifier_subpanel_register(ARegionType *region_type, const char *name, const char *label, PanelDrawFn draw_header, PanelDrawFn draw, PanelType *parent)
PanelType * gpencil_modifier_panel_register(ARegionType *region_type, GpencilModifierType type, PanelDrawFn draw)
void generic_bake_deform_stroke(Depsgraph *depsgraph, GpencilModifierData *md, Object *ob, const bool retime, gpBakeCb bake_cb)
bool is_stroke_affected_by_modifier(Object *ob, char *mlayername, Material *material, const int mpassindex, const int gpl_passindex, const int minpoints, bGPDlayer *gpl, bGPDstroke *gps, const bool inv1, const bool inv2, const bool inv3, const bool inv4)
static void deformStroke(GpencilModifierData *md, Depsgraph *UNUSED(depsgraph), Object *ob, bGPDlayer *gpl, bGPDframe *UNUSED(gpf), bGPDstroke *gps)
static void bakeModifier(struct Main *UNUSED(bmain), Depsgraph *depsgraph, GpencilModifierData *md, Object *ob)
GpencilModifierTypeInfo modifierType_Gpencil_Subdiv
static void mask_panel_draw(const bContext *UNUSED(C), Panel *panel)
static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
static void panelRegister(ARegionType *region_type)
static void initData(GpencilModifierData *md)
#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)
const Depsgraph * depsgraph
Definition: DNA_ID.h:368
Definition: BKE_main.h:121
void * data
struct uiLayout * layout
#define N_(msgid)
PointerRNA * ptr
Definition: wm_files.c:3480