4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * Contributor(s): Campbell Barton
22 * ***** END GPL LICENSE BLOCK *****
27 #include "RNA_define.h"
28 #include "RNA_types.h"
30 #include "rna_internal.h"
32 #include "DNA_scene_types.h"
34 #include "BKE_paint.h"
38 static PointerRNA rna_ParticleEdit_brush_get(PointerRNA *ptr)
40 ParticleEditSettings *pset= (ParticleEditSettings*)ptr->data;
41 ParticleBrushData *brush= NULL;;
43 if(pset->brushtype != PE_BRUSH_NONE)
44 brush= &pset->brush[pset->brushtype];
46 return rna_pointer_inherit_refine(ptr, &RNA_ParticleBrush, brush);
49 static PointerRNA rna_ParticleBrush_curve_get(PointerRNA *ptr)
51 return rna_pointer_inherit_refine(ptr, &RNA_CurveMapping, NULL);
54 static void rna_Paint_brushes_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
56 Paint *p= (Paint*)ptr->data;
57 rna_iterator_array_begin(iter, (void*)p->brushes, sizeof(Brush*), p->brush_count, 0, NULL);
60 static int rna_Paint_brushes_length(PointerRNA *ptr)
62 Paint *p= (Paint*)ptr->data;
64 return p->brush_count;
67 static PointerRNA rna_Paint_active_brush_get(PointerRNA *ptr)
69 return rna_pointer_inherit_refine(ptr, &RNA_Brush, paint_brush(ptr->data));
72 static void rna_Paint_active_brush_set(PointerRNA *ptr, PointerRNA value)
74 paint_brush_set(ptr->data, value.data);
79 static void rna_def_paint(BlenderRNA *brna)
84 srna= RNA_def_struct(brna, "Paint", NULL);
85 RNA_def_struct_ui_text(srna, "Paint", "");
87 prop= RNA_def_property(srna, "brushes", PROP_COLLECTION, PROP_NONE);
88 RNA_def_property_struct_type(prop, "Brush");
89 RNA_def_property_collection_funcs(prop, "rna_Paint_brushes_begin",
90 "rna_iterator_array_next",
91 "rna_iterator_array_end",
92 "rna_iterator_array_dereference_get",
93 "rna_Paint_brushes_length", 0, 0, 0, 0);
94 RNA_def_property_ui_text(prop, "Brushes", "Brushes selected for this paint mode.");
96 prop= RNA_def_property(srna, "active_brush_index", PROP_INT, PROP_NONE);
97 RNA_def_property_range(prop, 0, INT_MAX);
99 /* Fake property to get active brush directly, rather than integer index */
100 prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE);
101 RNA_def_property_struct_type(prop, "Brush");
102 RNA_def_property_pointer_funcs(prop, "rna_Paint_active_brush_get", "rna_Paint_active_brush_set", NULL);
103 RNA_def_property_flag(prop, PROP_EDITABLE);
104 RNA_def_property_ui_text(prop, "Brush", "Active paint brush.");
107 static void rna_def_sculpt(BlenderRNA *brna)
112 srna= RNA_def_struct(brna, "Sculpt", "Paint");
113 RNA_def_struct_ui_text(srna, "Sculpt", "");
115 prop= RNA_def_property(srna, "symmetry_x", PROP_BOOLEAN, PROP_NONE);
116 RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SYMM_X);
117 RNA_def_property_ui_text(prop, "Symmetry X", "Mirror brush across the X axis.");
119 prop= RNA_def_property(srna, "symmetry_y", PROP_BOOLEAN, PROP_NONE);
120 RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SYMM_Y);
121 RNA_def_property_ui_text(prop, "Symmetry Y", "Mirror brush across the Y axis.");
123 prop= RNA_def_property(srna, "symmetry_z", PROP_BOOLEAN, PROP_NONE);
124 RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SYMM_Z);
125 RNA_def_property_ui_text(prop, "Symmetry Z", "Mirror brush across the Z axis.");
127 prop= RNA_def_property(srna, "lock_x", PROP_BOOLEAN, PROP_NONE);
128 RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_LOCK_X);
129 RNA_def_property_ui_text(prop, "Lock X", "Disallow changes to the X axis of vertices.");
131 prop= RNA_def_property(srna, "lock_y", PROP_BOOLEAN, PROP_NONE);
132 RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_LOCK_Y);
133 RNA_def_property_ui_text(prop, "Lock Y", "Disallow changes to the Y axis of vertices.");
135 prop= RNA_def_property(srna, "lock_z", PROP_BOOLEAN, PROP_NONE);
136 RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_LOCK_Z);
137 RNA_def_property_ui_text(prop, "Lock Z", "Disallow changes to the Z axis of vertices.");
139 prop= RNA_def_property(srna, "show_brush", PROP_BOOLEAN, PROP_NONE);
140 RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_DRAW_BRUSH);
141 RNA_def_property_ui_text(prop, "Show Brush", "");
143 prop= RNA_def_property(srna, "partial_redraw", PROP_BOOLEAN, PROP_NONE);
144 RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_DRAW_FAST);
145 RNA_def_property_ui_text(prop, "Partial Redraw", "Optimize sculpting by only refreshing modified faces.");
148 static void rna_def_vertex_paint(BlenderRNA *brna)
152 static EnumPropertyItem prop_mode_items[] = {
153 {0, "MIX", 0, "Mix", "Use mix blending mode while painting."},
154 {1, "ADD", 0, "Add", "Use add blending mode while painting."},
155 {2, "SUB", 0, "Subtract", "Use subtract blending mode while painting."},
156 {3, "MUL", 0, "Multiply", "Use multiply blending mode while painting."},
157 {4, "BLUR", 0, "Blur", "Blur the color with surrounding values"},
158 {5, "LIGHTEN", 0, "Lighten", "Use lighten blending mode while painting."},
159 {6, "DARKEN", 0, "Darken", "Use darken blending mode while painting."},
160 {0, NULL, 0, NULL, NULL}};
162 srna= RNA_def_struct(brna, "VertexPaint", "Paint");
163 RNA_def_struct_sdna(srna, "VPaint");
164 RNA_def_struct_ui_text(srna, "Vertex Paint", "Properties of vertex and weight paint mode.");
166 prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
167 RNA_def_property_enum_items(prop, prop_mode_items);
168 RNA_def_property_ui_text(prop, "Brush Mode", "Mode in which color is painted.");
170 prop= RNA_def_property(srna, "all_faces", PROP_BOOLEAN, PROP_NONE);
171 RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_AREA);
172 RNA_def_property_ui_text(prop, "All Faces", "Paint on all faces inside brush.");
174 prop= RNA_def_property(srna, "vertex_dist", PROP_BOOLEAN, PROP_NONE);
175 RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_SOFT);
176 RNA_def_property_ui_text(prop, "Vertex Dist", "Use distances to vertices (instead of paint entire faces).");
178 prop= RNA_def_property(srna, "normals", PROP_BOOLEAN, PROP_NONE);
179 RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_NORMALS);
180 RNA_def_property_ui_text(prop, "Normals", "Applies the vertex normal before painting.");
182 prop= RNA_def_property(srna, "spray", PROP_BOOLEAN, PROP_NONE);
183 RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_SPRAY);
184 RNA_def_property_ui_text(prop, "Spray", "Keep applying paint effect while holding mouse.");
186 prop= RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_NONE);
187 RNA_def_property_range(prop, 0.1f, 5.0f);
188 RNA_def_property_ui_text(prop, "Gamma", "Vertex paint Gamma.");
190 prop= RNA_def_property(srna, "mul", PROP_FLOAT, PROP_NONE);
191 RNA_def_property_range(prop, 0.1f, 50.0f);
192 RNA_def_property_ui_text(prop, "Mul", "Vertex paint Mul.");
195 static void rna_def_image_paint(BlenderRNA *brna)
200 static EnumPropertyItem tool_items[] = {
201 {PAINT_TOOL_DRAW, "DRAW", 0, "Draw", ""},
202 {PAINT_TOOL_SOFTEN, "SOFTEN", 0, "Soften", ""},
203 {PAINT_TOOL_SMEAR, "SMEAR", 0, "Smear", ""},
204 {PAINT_TOOL_CLONE, "CLONE", 0, "Clone", ""},
205 {0, NULL, 0, NULL, NULL}};
207 srna= RNA_def_struct(brna, "ImagePaint", "Paint");
208 RNA_def_struct_sdna(srna, "ImagePaintSettings");
209 RNA_def_struct_ui_text(srna, "Image Paint", "Properties of image and texture painting mode.");
211 prop= RNA_def_property(srna, "tool", PROP_ENUM, PROP_NONE);
212 RNA_def_property_enum_items(prop, tool_items);
213 RNA_def_property_ui_text(prop, "Tool", "");
217 prop= RNA_def_property(srna, "show_brush_draw", PROP_BOOLEAN, PROP_NONE);
218 RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_DRAW_TOOL);
219 RNA_def_property_ui_text(prop, "Show Brush Draw", "Enables brush shape while drawing.");
221 prop= RNA_def_property(srna, "show_brush", PROP_BOOLEAN, PROP_NONE);
222 RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_DRAW_TOOL_DRAWING);
223 RNA_def_property_ui_text(prop, "Show Brush", "Enables brush shape while not drawing.");
225 prop= RNA_def_property(srna, "use_projection", PROP_BOOLEAN, PROP_NONE);
226 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_DISABLE);
227 RNA_def_property_ui_text(prop, "Project Paint", "Use projection painting for improved consistency in the brush strokes.");
229 prop= RNA_def_property(srna, "use_occlude", PROP_BOOLEAN, PROP_NONE);
230 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_XRAY);
231 RNA_def_property_ui_text(prop, "Occlude", "Only paint onto the faces directly under the brush (slower)");
233 prop= RNA_def_property(srna, "use_backface_cull", PROP_BOOLEAN, PROP_NONE);
234 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_BACKFACE);
235 RNA_def_property_ui_text(prop, "Cull", "Ignore faces pointing away from the view (faster)");
237 prop= RNA_def_property(srna, "use_normal_falloff", PROP_BOOLEAN, PROP_NONE);
238 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_FLAT);
239 RNA_def_property_ui_text(prop, "Normal", "Paint most on faces pointing towards the view");
241 prop= RNA_def_property(srna, "use_stencil_layer", PROP_BOOLEAN, PROP_NONE);
242 RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_MASK);
243 RNA_def_property_ui_text(prop, "Stencil Layer", "Set the mask layer from the UV layer buttons");
245 prop= RNA_def_property(srna, "invert_stencil", PROP_BOOLEAN, PROP_NONE);
246 RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_MASK_INV);
247 RNA_def_property_ui_text(prop, "Invert", "Invert the stencil layer");
249 prop= RNA_def_property(srna, "use_clone_layer", PROP_BOOLEAN, PROP_NONE);
250 RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_CLONE);
251 RNA_def_property_ui_text(prop, "Clone Layer", "Use another UV layer as clone source, otherwise use 3D the cursor as the source");
255 prop= RNA_def_property(srna, "seam_bleed", PROP_INT, PROP_UNSIGNED);
256 RNA_def_property_ui_range(prop, 0, 8, 0, 0);
257 RNA_def_property_ui_text(prop, "Bleed", "Extend paint beyond the faces UVs to reduce seams (in pixels, slower).");
259 prop= RNA_def_property(srna, "normal_angle", PROP_INT, PROP_UNSIGNED);
260 RNA_def_property_range(prop, 0, 90);
261 RNA_def_property_ui_text(prop, "Angle", "Paint most on faces pointing towards the view acording to this angle.");
264 static void rna_def_particle_edit(BlenderRNA *brna)
269 static EnumPropertyItem tool_items[] = {
270 {PE_BRUSH_NONE, "NONE", 0, "None", "Don't use any brush."},
271 {PE_BRUSH_COMB, "COMB", 0, "Comb", "Comb hairs."},
272 {PE_BRUSH_SMOOTH, "SMOOTH", 0, "Smooth", "Smooth hairs."},
273 {PE_BRUSH_WEIGHT, "WEIGHT", 0, "Weight", "Assign weight to hairs."},
274 {PE_BRUSH_ADD, "ADD", 0, "Add", "Add hairs."},
275 {PE_BRUSH_LENGTH, "LENGTH", 0, "Length", "Make hairs longer or shorter."},
276 {PE_BRUSH_PUFF, "PUFF", 0, "Puff", "Make hairs stand up."},
277 {PE_BRUSH_CUT, "CUT", 0, "Cut", "Cut hairs."},
278 {0, NULL, 0, NULL, NULL}};
280 static EnumPropertyItem select_mode_items[] = {
281 {SCE_SELECT_PATH, "PATH", ICON_EDGESEL, "Path", ""}, // XXX icon
282 {SCE_SELECT_POINT, "POINT", ICON_VERTEXSEL, "Point", ""}, // XXX icon
283 {SCE_SELECT_END, "END", ICON_FACESEL, "End", "E"}, // XXX icon
284 {0, NULL, 0, NULL, NULL}};
286 static EnumPropertyItem puff_mode[] = {
287 {0, "ADD", 0, "Add", "Make hairs more puffy."},
288 {1, "SUB", 0, "Sub", "Make hairs less puffy."},
289 {0, NULL, 0, NULL, NULL}};
291 static EnumPropertyItem length_mode[] = {
292 {0, "GROW", 0, "Grow", "Make hairs longer."},
293 {1, "SHRINK", 0, "Shrink", "Make hairs shorter."},
294 {0, NULL, 0, NULL, NULL}};
298 srna= RNA_def_struct(brna, "ParticleEdit", NULL);
299 RNA_def_struct_sdna(srna, "ParticleEditSettings");
300 RNA_def_struct_ui_text(srna, "Particle Edit", "Properties of particle editing mode.");
302 prop= RNA_def_property(srna, "tool", PROP_ENUM, PROP_NONE);
303 RNA_def_property_enum_sdna(prop, NULL, "brushtype");
304 RNA_def_property_enum_items(prop, tool_items);
305 RNA_def_property_ui_text(prop, "Tool", "");
307 prop= RNA_def_property(srna, "selection_mode", PROP_ENUM, PROP_NONE);
308 RNA_def_property_enum_bitflag_sdna(prop, NULL, "selectmode");
309 RNA_def_property_enum_items(prop, select_mode_items);
310 RNA_def_property_ui_text(prop, "Selection Mode", "Particle select and display mode.");
312 prop= RNA_def_property(srna, "keep_lengths", PROP_BOOLEAN, PROP_NONE);
313 RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_KEEP_LENGTHS);
314 RNA_def_property_ui_text(prop, "Keep Lengths", "Keep path lengths constant.");
316 prop= RNA_def_property(srna, "keep_root", PROP_BOOLEAN, PROP_NONE);
317 RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_LOCK_FIRST);
318 RNA_def_property_ui_text(prop, "Keep Root", "Keep root keys unmodified.");
320 prop= RNA_def_property(srna, "emitter_deflect", PROP_BOOLEAN, PROP_NONE);
321 RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_DEFLECT_EMITTER);
322 RNA_def_property_ui_text(prop, "Deflect Emitter", "Keep paths from intersecting the emitter.");
324 prop= RNA_def_property(srna, "emitter_distance", PROP_FLOAT, PROP_UNSIGNED);
325 RNA_def_property_float_sdna(prop, NULL, "emitterdist");
326 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 10, 3);
327 RNA_def_property_ui_text(prop, "Emitter Distance", "Distance to keep particles away from the emitter.");
329 prop= RNA_def_property(srna, "show_time", PROP_BOOLEAN, PROP_NONE);
330 RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_SHOW_TIME);
331 RNA_def_property_ui_text(prop, "Show Time", "Show time values of the baked keys.");
333 prop= RNA_def_property(srna, "show_children", PROP_BOOLEAN, PROP_NONE);
334 RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_SHOW_CHILD);
335 RNA_def_property_ui_text(prop, "Show Children", "Show child particles.");
337 prop= RNA_def_property(srna, "mirror_x", PROP_BOOLEAN, PROP_NONE);
338 RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_X_MIRROR);
339 RNA_def_property_ui_text(prop, "X-Axis Mirror", "Mirror operations over the X axis while editing.");
341 prop= RNA_def_property(srna, "add_interpolate", PROP_BOOLEAN, PROP_NONE);
342 RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_INTERPOLATE_ADDED);
343 RNA_def_property_ui_text(prop, "Interpolate", "Interpolate new particles from the existing ones.");
345 prop= RNA_def_property(srna, "add_keys", PROP_INT, PROP_NONE);
346 RNA_def_property_int_sdna(prop, NULL, "totaddkey");
347 RNA_def_property_range(prop, 2, INT_MAX);
348 RNA_def_property_ui_range(prop, 2, 20, 10, 3);
349 RNA_def_property_ui_text(prop, "Keys", "How many keys to make new particles with.");
351 prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE);
352 RNA_def_property_struct_type(prop, "ParticleBrush");
353 RNA_def_property_pointer_funcs(prop, "rna_ParticleEdit_brush_get", NULL, NULL);
354 RNA_def_property_ui_text(prop, "Brush", "");
358 srna= RNA_def_struct(brna, "ParticleBrush", NULL);
359 RNA_def_struct_sdna(srna, "ParticleBrushData");
360 RNA_def_struct_ui_text(srna, "Particle Brush", "Particle editing brush.");
362 prop= RNA_def_property(srna, "size", PROP_INT, PROP_NONE);
363 RNA_def_property_range(prop, 1, INT_MAX);
364 RNA_def_property_ui_range(prop, 1, 100, 10, 3);
365 RNA_def_property_ui_text(prop, "Size", "Brush size.");
367 prop= RNA_def_property(srna, "strength", PROP_INT, PROP_NONE);
368 RNA_def_property_range(prop, 1, INT_MAX);
369 RNA_def_property_ui_range(prop, 1, 100, 10, 3);
370 RNA_def_property_ui_text(prop, "Strength", "Brush strength.");
372 prop= RNA_def_property(srna, "steps", PROP_INT, PROP_NONE);
373 RNA_def_property_int_sdna(prop, NULL, "step");
374 RNA_def_property_range(prop, 1, INT_MAX);
375 RNA_def_property_ui_range(prop, 1, 50, 10, 3);
376 RNA_def_property_ui_text(prop, "Steps", "Brush steps.");
378 prop= RNA_def_property(srna, "puff_mode", PROP_ENUM, PROP_NONE);
379 RNA_def_property_enum_sdna(prop, NULL, "invert");
380 RNA_def_property_enum_items(prop, puff_mode);
381 RNA_def_property_ui_text(prop, "Puff Mode", "");
383 prop= RNA_def_property(srna, "length_mode", PROP_ENUM, PROP_NONE);
384 RNA_def_property_enum_sdna(prop, NULL, "invert");
385 RNA_def_property_enum_items(prop, length_mode);
386 RNA_def_property_ui_text(prop, "Length Mode", "");
389 prop= RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE);
390 RNA_def_property_struct_type(prop, "CurveMapping");
391 RNA_def_property_pointer_funcs(prop, "rna_ParticleBrush_curve_get", NULL, NULL);
392 RNA_def_property_ui_text(prop, "Curve", "");
395 void RNA_def_sculpt_paint(BlenderRNA *brna)
398 rna_def_sculpt(brna);
399 rna_def_vertex_paint(brna);
400 rna_def_image_paint(brna);
401 rna_def_particle_edit(brna);