Cycles: svn merge -r41531:41613 ^/trunk/blender
[blender.git] / source / blender / blenkernel / BKE_brush.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) 2001-2002 by NaN Holding BV.
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  * General operations for brushes.
27  */
28
29 #ifndef BKE_BRUSH_H
30 #define BKE_BRUSH_H
31
32 /** \file BKE_brush.h
33  *  \ingroup bke
34  */
35
36 struct ID;
37 struct Brush;
38 struct ImBuf;
39 struct Scene;
40 struct wmOperator;
41 // enum CurveMappingPreset;
42
43 /* datablock functions */
44 struct Brush *add_brush(const char *name);
45 struct Brush *copy_brush(struct Brush *brush);
46 void make_local_brush(struct Brush *brush);
47 void free_brush(struct Brush *brush);
48
49 void brush_reset_sculpt(struct Brush *brush);
50
51 /* image icon function */
52 struct ImBuf *get_brush_icon(struct Brush *brush);
53
54 /* brush library operations used by different paint panels */
55 int brush_delete(struct Brush **current_brush);
56 int brush_texture_set_nr(struct Brush *brush, int nr);
57 int brush_texture_delete(struct Brush *brush);
58 int brush_clone_image_set_nr(struct Brush *brush, int nr);
59 int brush_clone_image_delete(struct Brush *brush);
60
61 /* jitter */
62 void brush_jitter_pos(struct Brush *brush, float *pos, float *jitterpos);
63
64 /* brush curve */
65 void brush_curve_preset(struct Brush *b, /*enum CurveMappingPreset*/int preset);
66 float brush_curve_strength_clamp(struct Brush *br, float p, const float len);
67 float brush_curve_strength(struct Brush *br, float p, const float len); /* used for sculpt */
68
69 /* sampling */
70 void brush_sample_tex(struct Brush *brush, float *xy, float *rgba, const int thread);
71 void brush_imbuf_new(struct Brush *brush, short flt, short texfalloff, int size,
72         struct ImBuf **imbuf, int use_color_correction);
73
74 /* painting */
75 struct BrushPainter;
76 typedef struct BrushPainter BrushPainter;
77 typedef int (*BrushFunc)(void *user, struct ImBuf *ibuf, float *lastpos, float *pos);
78
79 BrushPainter *brush_painter_new(struct Brush *brush);
80 void brush_painter_require_imbuf(BrushPainter *painter, short flt,
81         short texonly, int size);
82 int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos,
83         double time, float pressure, void *user, int use_color_correction);
84 void brush_painter_break_stroke(BrushPainter *painter);
85 void brush_painter_free(BrushPainter *painter);
86
87 /* texture */
88 unsigned int *brush_gen_texture_cache(struct Brush *br, int half_side);
89
90 /* radial control */
91 struct ImBuf *brush_gen_radial_control_imbuf(struct Brush *br);
92
93 /* unified strength and size */
94
95 int  brush_size(struct Brush *brush);
96 void brush_set_size(struct Brush *brush, int value);
97
98 int  brush_use_locked_size(struct Brush *brush);
99 void brush_set_use_locked_size(struct Brush *brush, int value);
100
101 int  brush_use_alpha_pressure(struct Brush *brush);
102 void brush_set_use_alpha_pressure(struct Brush *brush, int value);
103
104 int  brush_use_size_pressure(struct Brush *brush);
105 void brush_set_use_size_pressure(struct Brush *brush, int value);
106
107 float brush_unprojected_radius(struct Brush *brush);
108 void  brush_set_unprojected_radius(struct Brush *brush, float value);
109
110 float brush_alpha(struct Brush *brush);
111 void  brush_set_alpha(struct Brush *brush, float value);
112
113 /* debugging only */
114 void brush_debug_print_state(struct Brush *br);
115
116 #endif
117