2 * ***** BEGIN GPL LICENSE BLOCK *****
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.
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.
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.
18 * Contributor(s): Campbell Barton
20 * ***** END GPL LICENSE BLOCK *****
23 /** \file blender/makesrna/intern/rna_sculpt_paint.c
30 #include "RNA_define.h"
32 #include "rna_internal.h"
35 #include "DNA_scene_types.h"
36 #include "DNA_brush_types.h"
37 #include "DNA_object_types.h"
38 #include "DNA_screen_types.h"
39 #include "DNA_space_types.h"
41 #include "BKE_paint.h"
42 #include "BKE_material.h"
49 #include "BLI_utildefines.h"
52 EnumPropertyItem rna_enum_gpencil_sculpt_brush_items[] = {
53 {GP_EDITBRUSH_TYPE_SMOOTH, "SMOOTH", 0, "Smooth", "Smooth stroke points"},
54 {GP_EDITBRUSH_TYPE_THICKNESS, "THICKNESS", 0, "Thickness", "Adjust thickness of strokes"},
55 { GP_EDITBRUSH_TYPE_STRENGTH, "STRENGTH", 0, "Strength", "Adjust color strength of strokes" },
56 { GP_EDITBRUSH_TYPE_GRAB, "GRAB", 0, "Grab", "Translate the set of points initially within the brush circle" },
57 {GP_EDITBRUSH_TYPE_PUSH, "PUSH", 0, "Push", "Move points out of the way, as if combing them"},
58 {GP_EDITBRUSH_TYPE_TWIST, "TWIST", 0, "Twist", "Rotate points around the midpoint of the brush"},
59 {GP_EDITBRUSH_TYPE_PINCH, "PINCH", 0, "Pinch", "Pull points towards the midpoint of the brush"},
60 {GP_EDITBRUSH_TYPE_RANDOMIZE, "RANDOMIZE", 0, "Randomize", "Introduce jitter/randomness into strokes"},
61 //{GP_EDITBRUSH_TYPE_SUBDIVIDE, "SUBDIVIDE", 0, "Subdivide", "Increase point density for higher resolution strokes when zoomed in"},
62 //{GP_EDITBRUSH_TYPE_SIMPLIFY, "SIMPLIFY", 0, "Simplify", "Reduce density of stroke points"},
63 {GP_EDITBRUSH_TYPE_CLONE, "CLONE", 0, "Clone", "Paste copies of the strokes stored on the clipboard"},
64 { 0, NULL, 0, NULL, NULL }
67 EnumPropertyItem rna_enum_gpencil_lockaxis_items[] = {
68 { GP_LOCKAXIS_NONE, "GP_LOCKAXIS_NONE", 0, "None", "" },
69 { GP_LOCKAXIS_X, "GP_LOCKAXIS_X", 0, "X", "Project strokes to plane locked to X" },
70 { GP_LOCKAXIS_Y, "GP_LOCKAXIS_Y", 0, "Y", "Project strokes to plane locked to Y" },
71 { GP_LOCKAXIS_Z, "GP_LOCKAXIS_Z", 0, "Z", "Project strokes to plane locked to Z" },
72 { 0, NULL, 0, NULL, NULL }
75 EnumPropertyItem rna_enum_symmetrize_direction_items[] = {
76 {BMO_SYMMETRIZE_NEGATIVE_X, "NEGATIVE_X", 0, "-X to +X", ""},
77 {BMO_SYMMETRIZE_POSITIVE_X, "POSITIVE_X", 0, "+X to -X", ""},
79 {BMO_SYMMETRIZE_NEGATIVE_Y, "NEGATIVE_Y", 0, "-Y to +Y", ""},
80 {BMO_SYMMETRIZE_POSITIVE_Y, "POSITIVE_Y", 0, "+Y to -Y", ""},
82 {BMO_SYMMETRIZE_NEGATIVE_Z, "NEGATIVE_Z", 0, "-Z to +Z", ""},
83 {BMO_SYMMETRIZE_POSITIVE_Z, "POSITIVE_Z", 0, "+Z to -Z", ""},
84 {0, NULL, 0, NULL, NULL},
88 #include "MEM_guardedalloc.h"
90 #include "BKE_context.h"
91 #include "BKE_DerivedMesh.h"
92 #include "BKE_depsgraph.h"
95 #include "GPU_buffers.h"
97 static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
99 WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
102 static int rna_Brush_mode_poll(PointerRNA *ptr, PointerRNA value)
104 Scene *scene = (Scene *)ptr->id.data;
105 ToolSettings *ts = scene->toolsettings;
106 Brush *brush = value.id.data;
109 /* check the origin of the Paint struct to see which paint
110 * mode to select from */
112 if (ptr->data == &ts->imapaint)
113 mode = OB_MODE_TEXTURE_PAINT;
114 else if (ptr->data == ts->sculpt)
115 mode = OB_MODE_SCULPT;
116 else if (ptr->data == ts->vpaint)
117 mode = OB_MODE_VERTEX_PAINT;
118 else if (ptr->data == ts->wpaint)
119 mode = OB_MODE_WEIGHT_PAINT;
121 return brush->ob_mode & mode;
124 static void rna_Sculpt_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
126 Object *ob = (scene->basact) ? scene->basact->object : NULL;
129 DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
130 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
133 ob->sculpt->bm_smooth_shading = ((scene->toolsettings->sculpt->flags &
134 SCULPT_DYNTOPO_SMOOTH_SHADING) != 0);
139 static void rna_Sculpt_ShowDiffuseColor_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
141 Object *ob = (scene->basact) ? scene->basact->object : NULL;
143 if (ob && ob->sculpt) {
144 Sculpt *sd = scene->toolsettings->sculpt;
145 ob->sculpt->show_diffuse_color = ((sd->flags & SCULPT_SHOW_DIFFUSE) != 0);
147 if (ob->sculpt->pbvh)
148 pbvh_show_diffuse_color_set(ob->sculpt->pbvh, ob->sculpt->show_diffuse_color);
150 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
154 static char *rna_Sculpt_path(PointerRNA *UNUSED(ptr))
156 return BLI_strdup("tool_settings.sculpt");
159 static char *rna_VertexPaint_path(PointerRNA *ptr)
161 Scene *scene = (Scene *)ptr->id.data;
162 ToolSettings *ts = scene->toolsettings;
163 if (ptr->data == ts->vpaint) {
164 return BLI_strdup("tool_settings.vertex_paint");
167 return BLI_strdup("tool_settings.weight_paint");
171 static char *rna_ImagePaintSettings_path(PointerRNA *UNUSED(ptr))
173 return BLI_strdup("tool_settings.image_paint");
176 static char *rna_UvSculpt_path(PointerRNA *UNUSED(ptr))
178 return BLI_strdup("tool_settings.uv_sculpt");
181 static void rna_Paint_brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
183 Paint *paint = ptr->data;
184 Brush *br = paint->brush;
185 BKE_paint_invalidate_overlay_all();
186 WM_main_add_notifier(NC_BRUSH | NA_SELECTED, br);
189 static void rna_ImaPaint_viewport_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
191 /* not the best solution maybe, but will refresh the 3D viewport */
192 WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
195 static void rna_ImaPaint_mode_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
199 if (ob && ob->type == OB_MESH) {
200 /* of course we need to invalidate here */
201 BKE_texpaint_slots_refresh_object(scene, ob);
203 /* we assume that changing the current mode will invalidate the uv layers so we need to refresh display */
204 GPU_drawobject_free(ob->derivedFinal);
205 BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
206 WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
210 static void rna_ImaPaint_stencil_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
214 if (ob && ob->type == OB_MESH) {
215 GPU_drawobject_free(ob->derivedFinal);
216 BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
217 WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
221 static void rna_ImaPaint_canvas_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
225 Image *ima = scene->toolsettings->imapaint.canvas;
227 for (sc = bmain->screen.first; sc; sc = sc->id.next) {
229 for (sa = sc->areabase.first; sa; sa = sa->next) {
231 for (sl = sa->spacedata.first; sl; sl = sl->next) {
232 if (sl->spacetype == SPACE_IMAGE) {
233 SpaceImage *sima = (SpaceImage *)sl;
236 ED_space_image_set(sima, scene, scene->obedit, ima);
242 if (ob && ob->type == OB_MESH) {
243 GPU_drawobject_free(ob->derivedFinal);
244 BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
245 WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
249 static int rna_ImaPaint_detect_data(ImagePaintSettings *imapaint)
251 return imapaint->missing_data == 0;
255 static PointerRNA rna_GPencilSculptSettings_brush_get(PointerRNA *ptr)
257 GP_BrushEdit_Settings *gset = (GP_BrushEdit_Settings *)ptr->data;
258 GP_EditBrush_Data *brush = NULL;
260 if ((gset->brushtype >= 0) && (gset->brushtype < TOT_GP_EDITBRUSH_TYPES))
261 brush = &gset->brush[gset->brushtype];
263 return rna_pointer_inherit_refine(ptr, &RNA_GPencilSculptBrush, brush);
266 static char *rna_GPencilSculptSettings_path(PointerRNA *UNUSED(ptr))
268 return BLI_strdup("tool_settings.gpencil_sculpt");
271 static char *rna_GPencilSculptBrush_path(PointerRNA *UNUSED(ptr))
273 return BLI_strdup("tool_settings.gpencil_sculpt.brush");
279 static void rna_def_paint_curve(BlenderRNA *brna)
283 srna = RNA_def_struct(brna, "PaintCurve", "ID");
284 RNA_def_struct_ui_text(srna, "Paint Curve", "");
285 RNA_def_struct_ui_icon(srna, ICON_CURVE_BEZCURVE);
289 static void rna_def_paint(BlenderRNA *brna)
294 srna = RNA_def_struct(brna, "Paint", NULL);
295 RNA_def_struct_ui_text(srna, "Paint", "");
297 /* Global Settings */
298 prop = RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE);
299 RNA_def_property_flag(prop, PROP_EDITABLE);
300 RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Brush_mode_poll");
301 RNA_def_property_ui_text(prop, "Brush", "Active Brush");
302 RNA_def_property_update(prop, 0, "rna_Paint_brush_update");
304 prop = RNA_def_property(srna, "palette", PROP_POINTER, PROP_NONE);
305 RNA_def_property_flag(prop, PROP_EDITABLE);
306 RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, NULL);
307 RNA_def_property_ui_text(prop, "Palette", "Active Palette");
309 prop = RNA_def_property(srna, "show_brush", PROP_BOOLEAN, PROP_NONE);
310 RNA_def_property_boolean_sdna(prop, NULL, "flags", PAINT_SHOW_BRUSH);
311 RNA_def_property_ui_text(prop, "Show Brush", "");
312 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
314 prop = RNA_def_property(srna, "show_brush_on_surface", PROP_BOOLEAN, PROP_NONE);
315 RNA_def_property_boolean_sdna(prop, NULL, "flags", PAINT_SHOW_BRUSH_ON_SURFACE);
316 RNA_def_property_ui_text(prop, "Show Brush On Surface", "");
317 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
319 prop = RNA_def_property(srna, "show_low_resolution", PROP_BOOLEAN, PROP_NONE);
320 RNA_def_property_boolean_sdna(prop, NULL, "flags", PAINT_FAST_NAVIGATE);
321 RNA_def_property_ui_text(prop, "Fast Navigate", "For multires, show low resolution while navigating the view");
322 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
324 prop = RNA_def_property(srna, "input_samples", PROP_INT, PROP_UNSIGNED);
325 RNA_def_property_int_sdna(prop, NULL, "num_input_samples");
326 RNA_def_property_ui_range(prop, 1, PAINT_MAX_INPUT_SAMPLES, 0, -1);
327 RNA_def_property_ui_text(prop, "Input Samples", "Average multiple input samples together to smooth the brush stroke");
328 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
330 prop = RNA_def_property(srna, "use_symmetry_x", PROP_BOOLEAN, PROP_NONE);
331 RNA_def_property_boolean_sdna(prop, NULL, "symmetry_flags", PAINT_SYMM_X);
332 RNA_def_property_ui_text(prop, "Symmetry X", "Mirror brush across the X axis");
333 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
335 prop = RNA_def_property(srna, "use_symmetry_y", PROP_BOOLEAN, PROP_NONE);
336 RNA_def_property_boolean_sdna(prop, NULL, "symmetry_flags", PAINT_SYMM_Y);
337 RNA_def_property_ui_text(prop, "Symmetry Y", "Mirror brush across the Y axis");
338 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
340 prop = RNA_def_property(srna, "use_symmetry_z", PROP_BOOLEAN, PROP_NONE);
341 RNA_def_property_boolean_sdna(prop, NULL, "symmetry_flags", PAINT_SYMM_Z);
342 RNA_def_property_ui_text(prop, "Symmetry Z", "Mirror brush across the Z axis");
343 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
345 prop = RNA_def_property(srna, "use_symmetry_feather", PROP_BOOLEAN, PROP_NONE);
346 RNA_def_property_boolean_sdna(prop, NULL, "symmetry_flags", PAINT_SYMMETRY_FEATHER);
347 RNA_def_property_ui_text(prop, "Symmetry Feathering",
348 "Reduce the strength of the brush where it overlaps symmetrical daubs");
349 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
351 prop = RNA_def_property(srna, "cavity_curve", PROP_POINTER, PROP_NONE);
352 RNA_def_property_flag(prop, PROP_NEVER_NULL);
353 RNA_def_property_ui_text(prop, "Curve", "Editable cavity curve");
354 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
356 prop = RNA_def_property(srna, "use_cavity", PROP_BOOLEAN, PROP_NONE);
357 RNA_def_property_boolean_sdna(prop, NULL, "flags", PAINT_USE_CAVITY_MASK);
358 RNA_def_property_ui_text(prop, "Cavity Mask", "Mask painting according to mesh geometry cavity");
359 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
361 prop = RNA_def_property(srna, "tile_offset", PROP_FLOAT, PROP_XYZ);
362 RNA_def_property_float_sdna(prop, NULL, "tile_offset");
363 RNA_def_property_array(prop, 3);
364 RNA_def_property_range(prop, 0.01, FLT_MAX);
365 RNA_def_property_ui_range(prop, 0.01, 100, 1 * 100, 2);
366 RNA_def_property_ui_text(prop, "Tiling offset for the X Axis",
367 "Stride at which tiled strokes are copied");
369 prop = RNA_def_property(srna, "tile_x", PROP_BOOLEAN, PROP_NONE);
370 RNA_def_property_boolean_sdna(prop, NULL, "symmetry_flags", PAINT_TILE_X);
371 RNA_def_property_ui_text(prop, "Tile X", "Tile along X axis");
372 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
374 prop = RNA_def_property(srna, "tile_y", PROP_BOOLEAN, PROP_NONE);
375 RNA_def_property_boolean_sdna(prop, NULL, "symmetry_flags", PAINT_TILE_Y);
376 RNA_def_property_ui_text(prop, "Tile Y", "Tile along Y axis");
377 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
379 prop = RNA_def_property(srna, "tile_z", PROP_BOOLEAN, PROP_NONE);
380 RNA_def_property_boolean_sdna(prop, NULL, "symmetry_flags", PAINT_TILE_Z);
381 RNA_def_property_ui_text(prop, "Tile Z", "Tile along Z axis");
382 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
385 static void rna_def_sculpt(BlenderRNA *brna)
387 static EnumPropertyItem detail_refine_items[] = {
388 {SCULPT_DYNTOPO_SUBDIVIDE, "SUBDIVIDE", 0,
389 "Subdivide Edges", "Subdivide long edges to add mesh detail where needed"},
390 {SCULPT_DYNTOPO_COLLAPSE, "COLLAPSE", 0,
391 "Collapse Edges", "Collapse short edges to remove mesh detail where possible"},
392 {SCULPT_DYNTOPO_SUBDIVIDE | SCULPT_DYNTOPO_COLLAPSE, "SUBDIVIDE_COLLAPSE", 0,
393 "Subdivide Collapse", "Both subdivide long edges and collapse short edges to refine mesh detail"},
394 {0, NULL, 0, NULL, NULL}
397 static EnumPropertyItem detail_type_items[] = {
399 "Relative Detail", "Mesh detail is relative to the brush size and detail size"},
400 {SCULPT_DYNTOPO_DETAIL_CONSTANT, "CONSTANT", 0,
401 "Constant Detail", "Mesh detail is constant in object space according to detail size"},
402 {SCULPT_DYNTOPO_DETAIL_BRUSH, "BRUSH", 0,
403 "Brush Detail", "Mesh detail is relative to brush radius"},
404 {0, NULL, 0, NULL, NULL}
410 srna = RNA_def_struct(brna, "Sculpt", "Paint");
411 RNA_def_struct_path_func(srna, "rna_Sculpt_path");
412 RNA_def_struct_ui_text(srna, "Sculpt", "");
414 prop = RNA_def_property(srna, "radial_symmetry", PROP_INT, PROP_XYZ);
415 RNA_def_property_int_sdna(prop, NULL, "radial_symm");
416 RNA_def_property_int_default(prop, 1);
417 RNA_def_property_range(prop, 1, 64);
418 RNA_def_property_ui_range(prop, 0, 32, 1, 1);
419 RNA_def_property_ui_text(prop, "Radial Symmetry Count X Axis",
420 "Number of times to copy strokes across the surface");
422 prop = RNA_def_property(srna, "lock_x", PROP_BOOLEAN, PROP_NONE);
423 RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_LOCK_X);
424 RNA_def_property_ui_text(prop, "Lock X", "Disallow changes to the X axis of vertices");
425 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
427 prop = RNA_def_property(srna, "lock_y", PROP_BOOLEAN, PROP_NONE);
428 RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_LOCK_Y);
429 RNA_def_property_ui_text(prop, "Lock Y", "Disallow changes to the Y axis of vertices");
430 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
432 prop = RNA_def_property(srna, "lock_z", PROP_BOOLEAN, PROP_NONE);
433 RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_LOCK_Z);
434 RNA_def_property_ui_text(prop, "Lock Z", "Disallow changes to the Z axis of vertices");
435 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
437 prop = RNA_def_property(srna, "use_threaded", PROP_BOOLEAN, PROP_NONE);
438 RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_USE_OPENMP);
439 RNA_def_property_ui_text(prop, "Use OpenMP",
440 "Take advantage of multiple CPU cores to improve sculpting performance");
441 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
443 prop = RNA_def_property(srna, "use_deform_only", PROP_BOOLEAN, PROP_NONE);
444 RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_ONLY_DEFORM);
445 RNA_def_property_ui_text(prop, "Use Deform Only",
446 "Use only deformation modifiers (temporary disable all "
447 "constructive modifiers except multi-resolution)");
448 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_update");
450 prop = RNA_def_property(srna, "show_diffuse_color", PROP_BOOLEAN, PROP_NONE);
451 RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SHOW_DIFFUSE);
452 RNA_def_property_ui_text(prop, "Show Diffuse Color",
453 "Show diffuse color of object and overlay sculpt mask on top of it");
454 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowDiffuseColor_update");
456 prop = RNA_def_property(srna, "detail_size", PROP_FLOAT, PROP_PIXEL);
457 RNA_def_property_ui_range(prop, 0.5, 40.0, 10, 2);
458 RNA_def_property_ui_text(prop, "Detail Size", "Maximum edge length for dynamic topology sculpting (in pixels)");
459 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
461 prop = RNA_def_property(srna, "detail_percent", PROP_FLOAT, PROP_PERCENTAGE);
462 RNA_def_property_ui_range(prop, 0.5, 100.0, 10, 2);
463 RNA_def_property_ui_text(prop, "Detail Percentage", "Maximum edge length for dynamic topology sculpting (in brush percenage)");
464 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
466 prop = RNA_def_property(srna, "constant_detail", PROP_FLOAT, PROP_PERCENTAGE);
467 RNA_def_property_range(prop, 0.001, 10000.0);
468 RNA_def_property_ui_range(prop, 0.1, 100.0, 10, 2);
469 RNA_def_property_ui_text(prop, "Detail Size", "Maximum edge length for dynamic topology sculpting (as percentage of blender unit)");
470 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
472 prop = RNA_def_property(srna, "use_smooth_shading", PROP_BOOLEAN, PROP_NONE);
473 RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_DYNTOPO_SMOOTH_SHADING);
474 RNA_def_property_ui_text(prop, "Smooth Shading",
475 "Show faces in dynamic-topology mode with smooth "
476 "shading rather than flat shaded");
477 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_update");
479 prop = RNA_def_property(srna, "symmetrize_direction", PROP_ENUM, PROP_NONE);
480 RNA_def_property_enum_items(prop, rna_enum_symmetrize_direction_items);
481 RNA_def_property_ui_text(prop, "Direction", "Source and destination for symmetrize operator");
483 prop = RNA_def_property(srna, "detail_refine_method", PROP_ENUM, PROP_NONE);
484 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
485 RNA_def_property_enum_items(prop, detail_refine_items);
486 RNA_def_property_ui_text(prop, "Detail Refine Method",
487 "In dynamic-topology mode, how to add or remove mesh detail");
488 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
490 prop = RNA_def_property(srna, "detail_type_method", PROP_ENUM, PROP_NONE);
491 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
492 RNA_def_property_enum_items(prop, detail_type_items);
493 RNA_def_property_ui_text(prop, "Detail Type Method",
494 "In dynamic-topology mode, how mesh detail size is calculated");
495 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
497 prop = RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_NONE);
498 RNA_def_property_float_sdna(prop, NULL, "gravity_factor");
499 RNA_def_property_range(prop, 0.0f, 1.0f);
500 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
501 RNA_def_property_ui_text(prop, "Gravity", "Amount of gravity after each dab");
502 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
504 prop = RNA_def_property(srna, "gravity_object", PROP_POINTER, PROP_NONE);
505 RNA_def_property_flag(prop, PROP_EDITABLE);
506 RNA_def_property_ui_text(prop, "Orientation", "Object whose Z axis defines orientation of gravity");
507 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
511 static void rna_def_uv_sculpt(BlenderRNA *brna)
515 srna = RNA_def_struct(brna, "UvSculpt", "Paint");
516 RNA_def_struct_path_func(srna, "rna_UvSculpt_path");
517 RNA_def_struct_ui_text(srna, "UV Sculpting", "");
521 /* use for weight paint too */
522 static void rna_def_vertex_paint(BlenderRNA *brna)
527 srna = RNA_def_struct(brna, "VertexPaint", "Paint");
528 RNA_def_struct_sdna(srna, "VPaint");
529 RNA_def_struct_path_func(srna, "rna_VertexPaint_path");
530 RNA_def_struct_ui_text(srna, "Vertex Paint", "Properties of vertex and weight paint mode");
532 /* vertex paint only */
533 prop = RNA_def_property(srna, "use_normal", PROP_BOOLEAN, PROP_NONE);
534 RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_NORMALS);
535 RNA_def_property_ui_text(prop, "Normals", "Apply the vertex normal before painting");
536 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
538 prop = RNA_def_property(srna, "use_spray", PROP_BOOLEAN, PROP_NONE);
539 RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_SPRAY);
540 RNA_def_property_ui_text(prop, "Spray", "Keep applying paint effect while holding mouse");
541 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
543 /* weight paint only */
544 prop = RNA_def_property(srna, "use_group_restrict", PROP_BOOLEAN, PROP_NONE);
545 RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_ONLYVGROUP);
546 RNA_def_property_ui_text(prop, "Restrict", "Restrict painting to vertices in the group");
547 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
550 static void rna_def_image_paint(BlenderRNA *brna)
556 static EnumPropertyItem paint_type_items[] = {
557 {IMAGEPAINT_MODE_MATERIAL, "MATERIAL", 0,
558 "Material", "Detect image slots from the material"},
559 {IMAGEPAINT_MODE_IMAGE, "IMAGE", 0,
560 "Image", "Set image for texture painting directly"},
561 {0, NULL, 0, NULL, NULL}
564 srna = RNA_def_struct(brna, "ImagePaint", "Paint");
565 RNA_def_struct_sdna(srna, "ImagePaintSettings");
566 RNA_def_struct_path_func(srna, "rna_ImagePaintSettings_path");
567 RNA_def_struct_ui_text(srna, "Image Paint", "Properties of image and texture painting mode");
570 func = RNA_def_function(srna, "detect_data", "rna_ImaPaint_detect_data");
571 RNA_def_function_ui_description(func, "Check if required texpaint data exist");
574 RNA_def_function_return(func, RNA_def_boolean(func, "ok", 1, "", ""));
577 prop = RNA_def_property(srna, "use_occlude", PROP_BOOLEAN, PROP_NONE);
578 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_XRAY);
579 RNA_def_property_ui_text(prop, "Occlude", "Only paint onto the faces directly under the brush (slower)");
580 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
582 prop = RNA_def_property(srna, "use_backface_culling", PROP_BOOLEAN, PROP_NONE);
583 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_BACKFACE);
584 RNA_def_property_ui_text(prop, "Cull", "Ignore faces pointing away from the view (faster)");
585 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
587 prop = RNA_def_property(srna, "use_normal_falloff", PROP_BOOLEAN, PROP_NONE);
588 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_FLAT);
589 RNA_def_property_ui_text(prop, "Normal", "Paint most on faces pointing towards the view");
590 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
592 prop = RNA_def_property(srna, "use_stencil_layer", PROP_BOOLEAN, PROP_NONE);
593 RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_STENCIL);
594 RNA_def_property_ui_text(prop, "Stencil Layer", "Set the mask layer from the UV map buttons");
595 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_viewport_update");
597 prop = RNA_def_property(srna, "invert_stencil", PROP_BOOLEAN, PROP_NONE);
598 RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_STENCIL_INV);
599 RNA_def_property_ui_text(prop, "Invert", "Invert the stencil layer");
600 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_viewport_update");
602 prop = RNA_def_property(srna, "stencil_image", PROP_POINTER, PROP_NONE);
603 RNA_def_property_pointer_sdna(prop, NULL, "stencil");
604 RNA_def_property_flag(prop, PROP_EDITABLE);
605 RNA_def_property_ui_text(prop, "Stencil Image", "Image used as stencil");
606 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_stencil_update");
608 prop = RNA_def_property(srna, "canvas", PROP_POINTER, PROP_NONE);
609 RNA_def_property_flag(prop, PROP_EDITABLE);
610 RNA_def_property_ui_text(prop, "Canvas", "Image used as canvas");
611 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_canvas_update");
613 prop = RNA_def_property(srna, "clone_image", PROP_POINTER, PROP_NONE);
614 RNA_def_property_pointer_sdna(prop, NULL, "clone");
615 RNA_def_property_flag(prop, PROP_EDITABLE);
616 RNA_def_property_ui_text(prop, "Clone Image", "Image used as clone source");
617 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
619 prop = RNA_def_property(srna, "stencil_color", PROP_FLOAT, PROP_COLOR_GAMMA);
620 RNA_def_property_range(prop, 0.0, 1.0);
621 RNA_def_property_float_sdna(prop, NULL, "stencil_col");
622 RNA_def_property_ui_text(prop, "Stencil Color", "Stencil color in the viewport");
623 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_viewport_update");
625 prop = RNA_def_property(srna, "dither", PROP_FLOAT, PROP_NONE);
626 RNA_def_property_range(prop, 0.0, 2.0);
627 RNA_def_property_ui_text(prop, "Dither", "Amount of dithering when painting on byte images");
628 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
630 prop = RNA_def_property(srna, "use_clone_layer", PROP_BOOLEAN, PROP_NONE);
631 RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_CLONE);
632 RNA_def_property_ui_text(prop, "Clone Map",
633 "Use another UV map as clone source, otherwise use the 3D cursor as the source");
634 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_viewport_update");
638 prop = RNA_def_property(srna, "seam_bleed", PROP_INT, PROP_PIXEL);
639 RNA_def_property_ui_range(prop, 0, 8, 0, -1);
640 RNA_def_property_ui_text(prop, "Bleed", "Extend paint beyond the faces UVs to reduce seams (in pixels, slower)");
642 prop = RNA_def_property(srna, "normal_angle", PROP_INT, PROP_UNSIGNED);
643 RNA_def_property_range(prop, 0, 90);
644 RNA_def_property_ui_text(prop, "Angle", "Paint most on faces pointing towards the view according to this angle");
646 prop = RNA_def_int_array(srna, "screen_grab_size", 2, NULL, 0, 0, "screen_grab_size",
647 "Size to capture the image for re-projecting", 0, 0);
648 RNA_def_property_range(prop, 512, 16384);
650 prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
651 RNA_def_property_enum_items(prop, paint_type_items);
652 RNA_def_property_ui_text(prop, "Mode", "Mode of operation for projection painting");
653 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_mode_update");
656 prop = RNA_def_property(srna, "missing_uvs", PROP_BOOLEAN, PROP_NONE);
657 RNA_def_property_boolean_sdna(prop, NULL, "missing_data", IMAGEPAINT_MISSING_UVS);
658 RNA_def_property_ui_text(prop, "Missing UVs",
659 "A UV layer is missing on the mesh");
660 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
662 prop = RNA_def_property(srna, "missing_materials", PROP_BOOLEAN, PROP_NONE);
663 RNA_def_property_boolean_sdna(prop, NULL, "missing_data", IMAGEPAINT_MISSING_MATERIAL);
664 RNA_def_property_ui_text(prop, "Missing Materials",
665 "The mesh is missing materials");
666 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
668 prop = RNA_def_property(srna, "missing_stencil", PROP_BOOLEAN, PROP_NONE);
669 RNA_def_property_boolean_sdna(prop, NULL, "missing_data", IMAGEPAINT_MISSING_STENCIL);
670 RNA_def_property_ui_text(prop, "Missing Stencil",
671 "Image Painting does not have a stencil");
672 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
674 prop = RNA_def_property(srna, "missing_texture", PROP_BOOLEAN, PROP_NONE);
675 RNA_def_property_boolean_sdna(prop, NULL, "missing_data", IMAGEPAINT_MISSING_TEX);
676 RNA_def_property_ui_text(prop, "Missing Texture",
677 "Image Painting does not have a texture to paint on");
678 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
681 static void rna_def_gpencil_sculpt(BlenderRNA *brna)
683 static EnumPropertyItem prop_direction_items[] = {
684 {0, "ADD", 0, "Add", "Add effect of brush"},
685 {GP_EDITBRUSH_FLAG_INVERT, "SUBTRACT", 0, "Subtract", "Subtract effect of brush"},
686 {0, NULL, 0, NULL, NULL}};
692 srna = RNA_def_struct(brna, "GPencilSculptSettings", NULL);
693 RNA_def_struct_sdna(srna, "GP_BrushEdit_Settings");
694 RNA_def_struct_path_func(srna, "rna_GPencilSculptSettings_path");
695 RNA_def_struct_ui_text(srna, "GPencil Sculpt Settings", "Properties for Grease Pencil stroke sculpting tool");
697 prop = RNA_def_property(srna, "tool", PROP_ENUM, PROP_NONE);
698 RNA_def_property_enum_sdna(prop, NULL, "brushtype");
699 RNA_def_property_enum_items(prop, rna_enum_gpencil_sculpt_brush_items);
700 RNA_def_property_ui_text(prop, "Tool", "");
701 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
703 prop = RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE);
704 RNA_def_property_struct_type(prop, "GPencilSculptBrush");
705 RNA_def_property_pointer_funcs(prop, "rna_GPencilSculptSettings_brush_get", NULL, NULL, NULL);
706 RNA_def_property_ui_text(prop, "Brush", "");
708 prop = RNA_def_property(srna, "use_select_mask", PROP_BOOLEAN, PROP_NONE);
709 RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_SELECT_MASK);
710 RNA_def_property_ui_text(prop, "Selection Mask", "Only sculpt selected stroke points");
711 RNA_def_property_ui_icon(prop, ICON_VERTEXSEL, 0); // FIXME: this needs a custom icon
712 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
714 prop = RNA_def_property(srna, "affect_position", PROP_BOOLEAN, PROP_NONE);
715 RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_APPLY_POSITION);
716 RNA_def_property_ui_text(prop, "Affect Position", "The brush affects the position of the point");
717 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
719 prop = RNA_def_property(srna, "affect_strength", PROP_BOOLEAN, PROP_NONE);
720 RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_APPLY_STRENGTH);
721 RNA_def_property_ui_text(prop, "Affect Strength", "The brush affects the color strength of the point");
722 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
724 prop = RNA_def_property(srna, "affect_thickness", PROP_BOOLEAN, PROP_NONE);
725 RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_APPLY_THICKNESS);
726 RNA_def_property_ui_text(prop, "Affect Thickness", "The brush affects the thickness of the point");
727 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
729 prop = RNA_def_property(srna, "interpolate_all_layers", PROP_BOOLEAN, PROP_NONE);
730 RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_INTERPOLATE_ALL_LAYERS);
731 RNA_def_property_ui_text(prop, "Interpolate All Layers", "Interpolate all layers, not only active");
732 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
734 prop = RNA_def_property(srna, "interpolate_selected_only", PROP_BOOLEAN, PROP_NONE);
735 RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_INTERPOLATE_ONLY_SELECTED);
736 RNA_def_property_ui_text(prop, "Interpolate Selected Strokes", "Interpolate only selected strokes in the original frame");
737 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
739 prop = RNA_def_property(srna, "selection_alpha", PROP_FLOAT, PROP_NONE);
740 RNA_def_property_float_sdna(prop, NULL, "alpha");
741 RNA_def_property_range(prop, 0.0f, 1.0f);
742 RNA_def_property_ui_text(prop, "Alpha", "Alpha value for selected vertices");
743 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_GPencil_update");
746 prop = RNA_def_property(srna, "lockaxis", PROP_ENUM, PROP_NONE);
747 RNA_def_property_enum_sdna(prop, NULL, "lock_axis");
748 RNA_def_property_enum_items(prop, rna_enum_gpencil_lockaxis_items);
749 RNA_def_property_ui_text(prop, "Lock", "");
750 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
753 srna = RNA_def_struct(brna, "GPencilSculptBrush", NULL);
754 RNA_def_struct_sdna(srna, "GP_EditBrush_Data");
755 RNA_def_struct_path_func(srna, "rna_GPencilSculptBrush_path");
756 RNA_def_struct_ui_text(srna, "GPencil Sculpt Brush", "Stroke editing brush");
758 prop = RNA_def_property(srna, "size", PROP_INT, PROP_PIXEL);
759 RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS);
760 RNA_def_property_ui_range(prop, 1, 100, 10, 3); // XXX: too big
761 RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels");
762 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
764 prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR);
765 RNA_def_property_range(prop, 0.001, 1.0);
766 RNA_def_property_ui_text(prop, "Strength", "Brush strength");
767 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
769 prop = RNA_def_property(srna, "use_pressure_strength", PROP_BOOLEAN, PROP_NONE);
770 RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_EDITBRUSH_FLAG_USE_PRESSURE);
771 RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
772 RNA_def_property_ui_text(prop, "Strength Pressure", "Enable tablet pressure sensitivity for strength");
773 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
775 prop = RNA_def_property(srna, "use_falloff", PROP_BOOLEAN, PROP_NONE);
776 RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_EDITBRUSH_FLAG_USE_FALLOFF);
777 RNA_def_property_ui_text(prop, "Use Falloff", "Strength of brush decays with distance from cursor");
778 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
780 prop = RNA_def_property(srna, "affect_pressure", PROP_BOOLEAN, PROP_NONE);
781 RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_EDITBRUSH_FLAG_SMOOTH_PRESSURE);
782 RNA_def_property_ui_text(prop, "Affect Pressure", "Affect pressure values as well when smoothing strokes");
783 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
785 prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
786 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
787 RNA_def_property_enum_items(prop, prop_direction_items);
788 RNA_def_property_ui_text(prop, "Direction", "");
789 RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
792 void RNA_def_sculpt_paint(BlenderRNA *brna)
794 /* *** Non-Animated *** */
795 RNA_define_animate_sdna(false);
796 rna_def_paint_curve(brna);
798 rna_def_sculpt(brna);
799 rna_def_uv_sculpt(brna);
800 rna_def_vertex_paint(brna);
801 rna_def_image_paint(brna);
802 rna_def_gpencil_sculpt(brna);
803 RNA_define_animate_sdna(true);