Cleanup: comment line length (editors)
[blender.git] / source / blender / makesdna / DNA_brush_types.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2005 Blender Foundation.
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Contributor(s): none yet.
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 /** \file DNA_brush_types.h
29  *  \ingroup DNA
30  */
31
32 #ifndef __DNA_BRUSH_TYPES_H__
33 #define __DNA_BRUSH_TYPES_H__
34
35
36 #include "DNA_ID.h"
37 #include "DNA_texture_types.h" /* for MTex */
38 #include "DNA_curve_types.h"
39
40 //#ifndef MAX_MTEX // XXX Not used?
41 //#define MAX_MTEX      18
42 //#endif
43
44 struct CurveMapping;
45 struct MTex;
46 struct Image;
47
48 typedef struct BrushClone {
49         struct Image *image;    /* image for clone tool */
50         float offset[2];        /* offset of clone image from canvas */
51         float alpha, pad;       /* transparency for drawing of clone image */
52 } BrushClone;
53
54 typedef struct Brush {
55         ID id;
56
57         struct BrushClone clone;
58         struct CurveMapping *curve; /* falloff curve */
59         struct MTex mtex;
60         struct MTex mask_mtex;
61
62         struct Brush *toggle_brush;
63
64         struct ImBuf *icon_imbuf;
65         PreviewImage *preview;
66         struct ColorBand *gradient;     /* color gradient */
67         struct PaintCurve *paint_curve;
68
69         char icon_filepath[1024]; /* 1024 = FILE_MAX */
70
71         float normal_weight;
72         float rake_factor;  /* rake actual data (not texture), used for sculpt */
73
74         short blend;        /* blend mode */
75         short ob_mode;      /* eObjectMode: to see if the brush is compatible, use for display only. */
76         float weight;       /* brush weight */
77         int size;           /* brush diameter */
78         int flag;           /* general purpose flag */
79         int mask_pressure;  /* pressure influence for mask */
80         float jitter;       /* jitter the position of the brush */
81         int jitter_absolute;    /* absolute jitter in pixels */
82         int overlay_flags;
83         int spacing;        /* spacing of paint operations */
84         int smooth_stroke_radius;   /* turning radius (in pixels) for smooth stroke */
85         float smooth_stroke_factor; /* higher values limit fast changes in the stroke direction */
86         float rate;         /* paint operations / second (airbrush) */
87
88         float rgb[3];           /* color */
89         float alpha;            /* opacity */
90
91         float secondary_rgb[3]; /* background color */
92
93         int sculpt_plane;       /* the direction of movement for sculpt vertices */
94
95         float plane_offset;     /* offset for plane brushes (clay, flatten, fill, scrape) */
96
97         int gradient_spacing;
98         char gradient_stroke_mode; /* source for stroke color gradient application */
99         char gradient_fill_mode;   /* source for fill tool color gradient application */
100
101         char pad;
102         char falloff_shape;     /* Projection shape (sphere, circle) */
103         float falloff_angle;
104
105         char sculpt_tool;       /* active sculpt tool */
106         char vertexpaint_tool;  /* active vertex/weight paint blend mode (poorly named) */
107         char imagepaint_tool;   /* active image paint tool */
108         char mask_tool;         /* enum eBrushMaskTool, only used if sculpt_tool is SCULPT_TOOL_MASK */
109
110         float autosmooth_factor;
111
112         float crease_pinch_factor;
113
114         float plane_trim;
115         float height;           /* affectable height of brush (layer height for layer tool, i.e.) */
116
117         float texture_sample_bias;
118
119         /* overlay */
120         int texture_overlay_alpha;
121         int mask_overlay_alpha;
122         int cursor_overlay_alpha;
123
124         float unprojected_radius;
125
126         /* soften/sharpen */
127         float sharp_threshold;
128         int blur_kernel_radius;
129         int blur_mode;
130
131         /* fill tool */
132         float fill_threshold;
133
134         float add_col[3];
135         float sub_col[3];
136
137         float stencil_pos[2];
138         float stencil_dimension[2];
139
140         float mask_stencil_pos[2];
141         float mask_stencil_dimension[2];
142 } Brush;
143
144 typedef struct PaletteColor {
145         struct PaletteColor *next, *prev;
146         /* two values, one to store rgb, other to store values for sculpt/weight */
147         float rgb[3];
148         float value;
149 } PaletteColor;
150
151 typedef struct Palette {
152         ID id;
153
154         /* pointer to individual colours */
155         ListBase colors;
156
157         int active_color;
158         int pad;
159 } Palette;
160
161 typedef struct PaintCurvePoint {
162         BezTriple bez; /* bezier handle */
163         float pressure; /* pressure on that point */
164 } PaintCurvePoint;
165
166 typedef struct PaintCurve {
167         ID id;
168         PaintCurvePoint *points; /* points of curve */
169         int tot_points;
170         int add_index; /* index where next point will be added */
171 } PaintCurve;
172
173 /* Brush.gradient_source */
174 typedef enum eBrushGradientSourceStroke {
175         BRUSH_GRADIENT_PRESSURE = 0, /* gradient from pressure */
176         BRUSH_GRADIENT_SPACING_REPEAT = 1, /* gradient from spacing */
177         BRUSH_GRADIENT_SPACING_CLAMP = 2 /* gradient from spacing */
178 } eBrushGradientSourceStroke;
179
180 typedef enum eBrushGradientSourceFill {
181         BRUSH_GRADIENT_LINEAR = 0, /* gradient from pressure */
182         BRUSH_GRADIENT_RADIAL = 1 /* gradient from spacing */
183 } eBrushGradientSourceFill;
184
185 /* Brush.flag */
186 typedef enum eBrushFlags {
187         BRUSH_AIRBRUSH = (1 << 0),
188         BRUSH_FLAG_DEPRECATED_1 = (1 << 1),
189         BRUSH_ALPHA_PRESSURE = (1 << 2),
190         BRUSH_SIZE_PRESSURE = (1 << 3),
191         BRUSH_JITTER_PRESSURE = (1 << 4),
192         BRUSH_SPACING_PRESSURE = (1 << 5),
193         BRUSH_FLAG_DEPRECATED_2 = (1 << 6),
194         BRUSH_FLAG_DEPRECATED_3 = (1 << 7),
195         BRUSH_ANCHORED = (1 << 8),
196         BRUSH_DIR_IN = (1 << 9),
197         BRUSH_SPACE = (1 << 10),
198         BRUSH_SMOOTH_STROKE = (1 << 11),
199         BRUSH_PERSISTENT = (1 << 12),
200         BRUSH_ACCUMULATE = (1 << 13),
201         BRUSH_LOCK_ALPHA = (1 << 14),
202         BRUSH_ORIGINAL_NORMAL = (1 << 15),
203         BRUSH_OFFSET_PRESSURE = (1 << 16),
204         BRUSH_FLAG_DEPRECATED_4 = (1 << 17),
205         BRUSH_SPACE_ATTEN = (1 << 18),
206         BRUSH_ADAPTIVE_SPACE = (1 << 19),
207         BRUSH_LOCK_SIZE = (1 << 20),
208         BRUSH_USE_GRADIENT = (1 << 21),
209         BRUSH_EDGE_TO_EDGE = (1 << 22),
210         BRUSH_DRAG_DOT = (1 << 23),
211         BRUSH_INVERSE_SMOOTH_PRESSURE = (1 << 24),
212         BRUSH_FRONTFACE_FALLOFF = (1 << 25),
213         BRUSH_PLANE_TRIM = (1 << 26),
214         BRUSH_FRONTFACE = (1 << 27),
215         BRUSH_CUSTOM_ICON = (1 << 28),
216         BRUSH_LINE = (1 << 29),
217         BRUSH_ABSOLUTE_JITTER = (1 << 30),
218         BRUSH_CURVE = (1u << 31)
219 } eBrushFlags;
220
221 typedef enum {
222         BRUSH_MASK_PRESSURE_RAMP = (1 << 1),
223         BRUSH_MASK_PRESSURE_CUTOFF = (1 << 2)
224 } BrushMaskPressureFlags;
225
226 /* Brush.overlay_flags */
227 typedef enum eOverlayFlags {
228         BRUSH_OVERLAY_CURSOR = (1),
229         BRUSH_OVERLAY_PRIMARY = (1 << 1),
230         BRUSH_OVERLAY_SECONDARY = (1 << 2),
231         BRUSH_OVERLAY_CURSOR_OVERRIDE_ON_STROKE = (1 << 3),
232         BRUSH_OVERLAY_PRIMARY_OVERRIDE_ON_STROKE = (1 << 4),
233         BRUSH_OVERLAY_SECONDARY_OVERRIDE_ON_STROKE = (1 << 5)
234 } eOverlayFlags;
235
236 #define BRUSH_OVERLAY_OVERRIDE_MASK (BRUSH_OVERLAY_CURSOR_OVERRIDE_ON_STROKE | \
237                                                                          BRUSH_OVERLAY_PRIMARY_OVERRIDE_ON_STROKE | \
238                                                                          BRUSH_OVERLAY_SECONDARY_OVERRIDE_ON_STROKE)
239
240 /* Brush.sculpt_tool */
241 typedef enum eBrushSculptTool {
242         SCULPT_TOOL_DRAW = 1,
243         SCULPT_TOOL_SMOOTH = 2,
244         SCULPT_TOOL_PINCH = 3,
245         SCULPT_TOOL_INFLATE = 4,
246         SCULPT_TOOL_GRAB = 5,
247         SCULPT_TOOL_LAYER = 6,
248         SCULPT_TOOL_FLATTEN = 7,
249         SCULPT_TOOL_CLAY = 8,
250         SCULPT_TOOL_FILL = 9,
251         SCULPT_TOOL_SCRAPE = 10,
252         SCULPT_TOOL_NUDGE = 11,
253         SCULPT_TOOL_THUMB = 12,
254         SCULPT_TOOL_SNAKE_HOOK = 13,
255         SCULPT_TOOL_ROTATE = 14,
256         SCULPT_TOOL_SIMPLIFY = 15,
257         SCULPT_TOOL_CREASE = 16,
258         SCULPT_TOOL_BLOB = 17,
259         SCULPT_TOOL_CLAY_STRIPS = 18,
260         SCULPT_TOOL_MASK = 19
261 } eBrushSculptTool;
262
263 /** When #BRUSH_ACCUMULATE is used */
264 #define SCULPT_TOOL_HAS_ACCUMULATE(t) ELEM(t, \
265         SCULPT_TOOL_DRAW, \
266         SCULPT_TOOL_CREASE, \
267         SCULPT_TOOL_BLOB, \
268         SCULPT_TOOL_LAYER, \
269         SCULPT_TOOL_INFLATE, \
270         SCULPT_TOOL_CLAY, \
271         SCULPT_TOOL_CLAY_STRIPS, \
272         SCULPT_TOOL_ROTATE, \
273         SCULPT_TOOL_FLATTEN \
274         )
275
276 #define SCULPT_TOOL_HAS_NORMAL_WEIGHT(t) ELEM(t, \
277         SCULPT_TOOL_GRAB, \
278         SCULPT_TOOL_SNAKE_HOOK \
279         )
280
281 #define SCULPT_TOOL_HAS_RAKE(t) ELEM(t, \
282         SCULPT_TOOL_SNAKE_HOOK \
283         )
284
285 #define SCULPT_TOOL_HAS_DYNTOPO(t) (ELEM(t, \
286         /* These brushes, as currently coded, cannot support dynamic topology */ \
287         SCULPT_TOOL_GRAB, \
288         SCULPT_TOOL_ROTATE, \
289         SCULPT_TOOL_THUMB, \
290         SCULPT_TOOL_LAYER, \
291         \
292         /* These brushes could handle dynamic topology, \
293          * but user feedback indicates it's better not to */ \
294         SCULPT_TOOL_SMOOTH, \
295         SCULPT_TOOL_MASK \
296         ) == 0)
297
298 /* ImagePaintSettings.tool */
299 typedef enum eBrushImagePaintTool {
300         PAINT_TOOL_DRAW = 0,
301         PAINT_TOOL_SOFTEN = 1,
302         PAINT_TOOL_SMEAR = 2,
303         PAINT_TOOL_CLONE = 3,
304         PAINT_TOOL_FILL = 4,
305         PAINT_TOOL_MASK = 5
306 } eBrushImagePaintTool;
307
308 /* direction that the brush displaces along */
309 enum {
310         SCULPT_DISP_DIR_AREA = 0,
311         SCULPT_DISP_DIR_VIEW = 1,
312         SCULPT_DISP_DIR_X = 2,
313         SCULPT_DISP_DIR_Y = 3,
314         SCULPT_DISP_DIR_Z = 4
315 };
316
317 enum {
318         PAINT_BLEND_MIX = 0,
319         PAINT_BLEND_ADD = 1,
320         PAINT_BLEND_SUB = 2,
321         PAINT_BLEND_MUL = 3,
322         PAINT_BLEND_BLUR = 4,
323         PAINT_BLEND_LIGHTEN = 5,
324         PAINT_BLEND_DARKEN = 6,
325         PAINT_BLEND_AVERAGE = 7,
326         PAINT_BLEND_SMEAR = 8,
327         PAINT_BLEND_COLORDODGE = 9,
328         PAINT_BLEND_DIFFERENCE = 10,
329         PAINT_BLEND_SCREEN = 11,
330         PAINT_BLEND_HARDLIGHT = 12,
331         PAINT_BLEND_OVERLAY = 13,
332         PAINT_BLEND_SOFTLIGHT = 14,
333         PAINT_BLEND_EXCLUSION = 15,
334         PAINT_BLEND_LUMINOCITY = 16,
335         PAINT_BLEND_SATURATION = 17,
336         PAINT_BLEND_HUE = 18,
337         PAINT_BLEND_ALPHA_SUB = 19,
338         PAINT_BLEND_ALPHA_ADD = 20,
339 };
340
341 typedef enum {
342         BRUSH_MASK_DRAW = 0,
343         BRUSH_MASK_SMOOTH = 1
344 } BrushMaskTool;
345
346 /* blur kernel types, Brush.blur_mode */
347 typedef enum eBlurKernelType {
348         KERNEL_GAUSSIAN,
349         KERNEL_BOX
350 } eBlurKernelType;
351
352 /* Brush.falloff_shape */
353 enum {
354         PAINT_FALLOFF_SHAPE_SPHERE = 0,
355         PAINT_FALLOFF_SHAPE_TUBE = 1,
356 };
357
358 #define MAX_BRUSH_PIXEL_RADIUS 500
359
360 #endif  /* __DNA_BRUSH_TYPES_H__ */