~ubuntu-branches/ubuntu/trusty/blender/trusty-proposed

« back to all changes in this revision

Viewing changes to source/blender/makesrna/intern/rna_brush.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2013-08-14 10:43:49 UTC
  • mfrom: (14.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20130814104349-t1d5mtwkphp12dyj
Tags: 2.68a-3
* Upload to unstable
* debian/: python3.3 Depends simplified
  - debian/control: python3.3 Depends dropped
    for blender-data package
  - 0001-blender_thumbnailer.patch refreshed
* debian/control: libavcodec b-dep versioning dropped

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 *  \ingroup RNA
25
25
 */
26
26
 
27
 
 
28
27
#include <stdlib.h>
29
28
#include <assert.h>
30
29
 
31
30
#include "RNA_define.h"
32
31
 
33
 
#include "rna_internal.h"
34
 
 
35
32
#include "DNA_brush_types.h"
36
33
#include "DNA_texture_types.h"
37
34
#include "DNA_scene_types.h"
39
36
 
40
37
#include "BLI_math.h"
41
38
 
 
39
#include "rna_internal.h"
 
40
 
42
41
#include "IMB_imbuf.h"
43
42
 
44
43
#include "WM_types.h"
107
106
 
108
107
#include "WM_api.h"
109
108
 
110
 
static int rna_SculptCapabilities_has_accumulate_get(PointerRNA *ptr)
 
109
static int rna_SculptToolCapabilities_has_accumulate_get(PointerRNA *ptr)
111
110
{
112
111
        Brush *br = (Brush *)ptr->data;
113
112
        return ELEM6(br->sculpt_tool,
115
114
                     SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_LAYER);
116
115
}
117
116
 
118
 
static int rna_SculptCapabilities_has_auto_smooth_get(PointerRNA *ptr)
 
117
static int rna_SculptToolCapabilities_has_auto_smooth_get(PointerRNA *ptr)
119
118
{
120
119
        Brush *br = (Brush *)ptr->data;
121
120
        return !ELEM(br->sculpt_tool, SCULPT_TOOL_MASK, SCULPT_TOOL_SMOOTH);
122
121
}
123
122
 
124
 
static int rna_SculptCapabilities_has_height_get(PointerRNA *ptr)
 
123
static int rna_SculptToolCapabilities_has_height_get(PointerRNA *ptr)
125
124
{
126
125
        Brush *br = (Brush *)ptr->data;
127
126
        return br->sculpt_tool == SCULPT_TOOL_LAYER;
128
127
}
129
128
 
130
 
static int rna_SculptCapabilities_has_jitter_get(PointerRNA *ptr)
 
129
static int rna_SculptToolCapabilities_has_jitter_get(PointerRNA *ptr)
131
130
{
132
131
        Brush *br = (Brush *)ptr->data;
133
132
        return (!(br->flag & BRUSH_ANCHORED) &&
137
136
                       SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB));
138
137
}
139
138
 
140
 
static int rna_SculptCapabilities_has_normal_weight_get(PointerRNA *ptr)
 
139
static int rna_SculptToolCapabilities_has_normal_weight_get(PointerRNA *ptr)
141
140
{
142
141
        Brush *br = (Brush *)ptr->data;
143
142
        return ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK);
144
143
}
145
144
 
146
 
static int rna_SculptCapabilities_has_overlay_get(PointerRNA *ptr)
 
145
static int rna_BrushCapabilities_has_overlay_get(PointerRNA *ptr)
147
146
{
148
147
        Brush *br = (Brush *)ptr->data;
149
 
        return ELEM(br->mtex.brush_map_mode,
 
148
        return ELEM3(br->mtex.brush_map_mode,
150
149
                    MTEX_MAP_MODE_VIEW,
151
 
                    MTEX_MAP_MODE_TILED);
 
150
                    MTEX_MAP_MODE_TILED,
 
151
                    MTEX_MAP_MODE_STENCIL);
152
152
}
153
153
 
154
 
static int rna_SculptCapabilities_has_persistence_get(PointerRNA *ptr)
 
154
static int rna_SculptToolCapabilities_has_persistence_get(PointerRNA *ptr)
155
155
{
156
156
        Brush *br = (Brush *)ptr->data;
157
157
        return br->sculpt_tool == SCULPT_TOOL_LAYER;
158
158
}
159
159
 
160
 
static int rna_SculptCapabilities_has_pinch_factor_get(PointerRNA *ptr)
 
160
static int rna_SculptToolCapabilities_has_pinch_factor_get(PointerRNA *ptr)
161
161
{
162
162
        Brush *br = (Brush *)ptr->data;
163
163
        return ELEM(br->sculpt_tool, SCULPT_TOOL_BLOB, SCULPT_TOOL_CREASE);
164
164
}
165
165
 
166
 
static int rna_SculptCapabilities_has_plane_offset_get(PointerRNA *ptr)
 
166
static int rna_SculptToolCapabilities_has_plane_offset_get(PointerRNA *ptr)
167
167
{
168
168
        Brush *br = (Brush *)ptr->data;
169
169
        return ELEM5(br->sculpt_tool, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS,
170
170
                     SCULPT_TOOL_FILL, SCULPT_TOOL_FLATTEN, SCULPT_TOOL_SCRAPE);
171
171
}
172
172
 
173
 
static int rna_SculptCapabilities_has_random_texture_angle_get(PointerRNA *ptr)
 
173
static int rna_SculptToolCapabilities_has_random_texture_angle_get(PointerRNA *ptr)
174
174
{
175
175
        Brush *br = (Brush *)ptr->data;
176
 
        return (ELEM(br->mtex.brush_map_mode,
177
 
                     MTEX_MAP_MODE_VIEW,
178
 
                     MTEX_MAP_MODE_AREA) &&
179
 
                !(br->flag & BRUSH_ANCHORED) &&
180
 
                !ELEM4(br->sculpt_tool,
 
176
        return (!ELEM4(br->sculpt_tool,
181
177
                       SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
182
178
                       SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB));
183
179
}
184
180
 
185
 
static int rna_SculptCapabilities_has_sculpt_plane_get(PointerRNA *ptr)
 
181
static int rna_BrushCapabilities_has_random_texture_angle_get(PointerRNA *ptr)
 
182
{
 
183
        Brush *br = (Brush *)ptr->data;
 
184
        return (ELEM3(br->mtex.brush_map_mode,
 
185
                     MTEX_MAP_MODE_VIEW,
 
186
                     MTEX_MAP_MODE_AREA,
 
187
                     MTEX_MAP_MODE_RANDOM) &&
 
188
                !(br->flag & BRUSH_ANCHORED));
 
189
}
 
190
 
 
191
static int rna_SculptToolCapabilities_has_sculpt_plane_get(PointerRNA *ptr)
186
192
{
187
193
        Brush *br = (Brush *)ptr->data;
188
194
        return !ELEM4(br->sculpt_tool, SCULPT_TOOL_INFLATE,
190
196
                      SCULPT_TOOL_SMOOTH);
191
197
}
192
198
 
193
 
static int rna_SculptCapabilities_has_secondary_color_get(PointerRNA *ptr)
 
199
static int rna_SculptToolCapabilities_has_secondary_color_get(PointerRNA *ptr)
194
200
{
195
201
        Brush *br = (Brush *)ptr->data;
196
202
        return ELEM10(br->sculpt_tool,
200
206
                      SCULPT_TOOL_SCRAPE);
201
207
}
202
208
 
203
 
static int rna_SculptCapabilities_has_smooth_stroke_get(PointerRNA *ptr)
 
209
static int rna_SculptToolCapabilities_has_smooth_stroke_get(PointerRNA *ptr)
204
210
{
205
211
        Brush *br = (Brush *)ptr->data;
206
212
        return (!(br->flag & BRUSH_ANCHORED) &&
210
216
                       SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB));
211
217
}
212
218
 
213
 
static int rna_SculptCapabilities_has_space_attenuation_get(PointerRNA *ptr)
 
219
static int rna_SculptToolCapabilities_has_space_attenuation_get(PointerRNA *ptr)
214
220
{
215
221
        Brush *br = (Brush *)ptr->data;
216
222
        return ((br->flag & BRUSH_SPACE) &&
218
224
                       SCULPT_TOOL_SMOOTH, SCULPT_TOOL_SNAKE_HOOK));
219
225
}
220
226
 
221
 
static int rna_SculptCapabilities_has_spacing_get(PointerRNA *ptr)
 
227
static int rna_BrushCapabilities_has_spacing_get(PointerRNA *ptr)
222
228
{
223
229
        Brush *br = (Brush *)ptr->data;
224
 
        return (!(br->flag & BRUSH_ANCHORED) &&
225
 
                !ELEM4(br->sculpt_tool,
226
 
                       SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
227
 
                       SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB));
 
230
        return (!(br->flag & BRUSH_ANCHORED));
228
231
}
229
232
 
230
 
static int rna_SculptCapabilities_has_strength_get(PointerRNA *ptr)
 
233
static int rna_SculptToolCapabilities_has_strength_get(PointerRNA *ptr)
231
234
{
232
235
        Brush *br = (Brush *)ptr->data;
233
236
        return !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK);
234
237
}
235
238
 
236
 
static int rna_SculptCapabilities_has_texture_angle_get(PointerRNA *ptr)
 
239
static int rna_BrushCapabilities_has_texture_angle_get(PointerRNA *ptr)
237
240
{
238
241
        Brush *br = (Brush *)ptr->data;
239
 
        return ELEM3(br->mtex.brush_map_mode,
 
242
        return ELEM5(br->mtex.brush_map_mode,
240
243
                     MTEX_MAP_MODE_VIEW,
241
244
                     MTEX_MAP_MODE_AREA,
242
 
                     MTEX_MAP_MODE_TILED);
 
245
                     MTEX_MAP_MODE_TILED,
 
246
                     MTEX_MAP_MODE_STENCIL,
 
247
                     MTEX_MAP_MODE_RANDOM);
243
248
}
244
249
 
245
 
static int rna_SculptCapabilities_has_texture_angle_source_get(PointerRNA *ptr)
 
250
static int rna_BrushCapabilities_has_texture_angle_source_get(PointerRNA *ptr)
246
251
{
247
252
        Brush *br = (Brush *)ptr->data;
248
 
        return ELEM(br->mtex.brush_map_mode,
 
253
        return ELEM3(br->mtex.brush_map_mode,
249
254
                    MTEX_MAP_MODE_VIEW,
250
 
                    MTEX_MAP_MODE_AREA);
251
 
}
252
 
 
253
 
static PointerRNA rna_Brush_sculpt_capabilities_get(PointerRNA *ptr)
254
 
{
255
 
        return rna_pointer_inherit_refine(ptr, &RNA_SculptCapabilities, ptr->id.data);
 
255
                    MTEX_MAP_MODE_AREA,
 
256
                    MTEX_MAP_MODE_RANDOM);
 
257
}
 
258
 
 
259
static PointerRNA rna_Sculpt_sculpt_tool_capabilities_get(PointerRNA *ptr)
 
260
{
 
261
        return rna_pointer_inherit_refine(ptr, &RNA_SculptToolCapabilities, ptr->id.data);
 
262
}
 
263
 
 
264
static PointerRNA rna_Brush_capabilities_get(PointerRNA *ptr)
 
265
{
 
266
        return rna_pointer_inherit_refine(ptr, &RNA_BrushCapabilities, ptr->id.data);
256
267
}
257
268
 
258
269
static void rna_Brush_reset_icon(Brush *br, const char *UNUSED(type))
277
288
        /*WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL); */
278
289
}
279
290
 
 
291
static void rna_Brush_main_tex_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 
292
{
 
293
        Brush *br = (Brush *)ptr->data;
 
294
        BKE_paint_invalidate_overlay_tex(scene, br->mtex.tex);
 
295
        rna_Brush_update(bmain, scene, ptr);
 
296
}
 
297
 
 
298
static void rna_Brush_secondary_tex_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 
299
{
 
300
        Brush *br = (Brush *)ptr->data;
 
301
        BKE_paint_invalidate_overlay_tex(scene, br->mask_mtex.tex);
 
302
        rna_Brush_update(bmain, scene, ptr);
 
303
}
 
304
 
 
305
static void rna_Brush_size_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 
306
{
 
307
        BKE_paint_invalidate_overlay_all();
 
308
        rna_Brush_update(bmain, scene, ptr);
 
309
}
 
310
 
280
311
static void rna_Brush_sculpt_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
281
312
{
282
313
        Brush *br = (Brush *)ptr->data;
 
314
        BKE_paint_invalidate_overlay_all();
283
315
        rna_Brush_reset_icon(br, "sculpt");
284
316
        rna_Brush_update(bmain, scene, ptr);
285
317
}
287
319
static void rna_Brush_vertex_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
288
320
{
289
321
        Brush *br = (Brush *)ptr->data;
 
322
        BKE_paint_invalidate_overlay_all();
290
323
        rna_Brush_reset_icon(br, "vertex_paint");
291
324
        rna_Brush_update(bmain, scene, ptr);
292
325
}
294
327
static void rna_Brush_imagepaint_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
295
328
{
296
329
        Brush *br = (Brush *)ptr->data;
 
330
        BKE_paint_invalidate_overlay_all();
297
331
        rna_Brush_reset_icon(br, "image_paint");
298
332
        rna_Brush_update(bmain, scene, ptr);
299
333
}
317
351
        WM_main_add_notifier(NC_BRUSH | NA_EDITED, br);
318
352
}
319
353
 
 
354
static void rna_TextureSlot_brush_angle_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 
355
{
 
356
        MTex *mtex = ptr->data;
 
357
        /* skip invalidation of overlay for stencil mode */
 
358
        if (mtex->mapping != MTEX_MAP_MODE_STENCIL)
 
359
                BKE_paint_invalidate_overlay_tex(scene, mtex->tex);
 
360
 
 
361
        rna_TextureSlot_update(bmain, scene, ptr);
 
362
}
 
363
 
320
364
static void rna_Brush_set_size(PointerRNA *ptr, int value)
321
365
{
322
366
        Brush *brush = ptr->data;
426
470
                {MTEX_MAP_MODE_AREA, "AREA_PLANE", 0, "Area Plane", ""},
427
471
                {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""},
428
472
                {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""},
 
473
                {MTEX_MAP_MODE_RANDOM, "RANDOM", 0, "Random", ""},
 
474
                {MTEX_MAP_MODE_STENCIL, "STENCIL", 0, "Stencil", ""},
429
475
                {0, NULL, 0, NULL, NULL}
430
476
        };
431
477
 
433
479
                {MTEX_MAP_MODE_VIEW, "VIEW_PLANE", 0, "View Plane", ""},
434
480
                {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""},
435
481
                {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""},
 
482
                {MTEX_MAP_MODE_RANDOM, "RANDOM", 0, "Random", ""},
 
483
                {MTEX_MAP_MODE_STENCIL, "STENCIL", 0, "Stencil", ""},
 
484
                {0, NULL, 0, NULL, NULL}
 
485
        };
 
486
 
 
487
        static EnumPropertyItem prop_mask_paint_map_mode_items[] = {
 
488
                {MTEX_MAP_MODE_VIEW, "VIEW_PLANE", 0, "View Plane", ""},
 
489
                {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""},
 
490
                {MTEX_MAP_MODE_RANDOM, "RANDOM", 0, "Random", ""},
 
491
                {MTEX_MAP_MODE_STENCIL, "STENCIL", 0, "Stencil", ""},
436
492
                {0, NULL, 0, NULL, NULL}
437
493
        };
438
494
 
444
500
        RNA_def_property_float_sdna(prop, NULL, "rot");
445
501
        RNA_def_property_range(prop, 0, M_PI * 2);
446
502
        RNA_def_property_ui_text(prop, "Angle", "Brush texture rotation");
447
 
        RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
 
503
        RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_angle_update");
448
504
 
449
505
        prop = RNA_def_property(srna, "map_mode", PROP_ENUM, PROP_NONE);
450
506
        RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode");
451
507
        RNA_def_property_enum_items(prop, prop_map_mode_items);
452
508
        RNA_def_property_ui_text(prop, "Mode", "");
453
 
        RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
 
509
        RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_update");
454
510
 
455
511
        prop = RNA_def_property(srna, "tex_paint_map_mode", PROP_ENUM, PROP_NONE);
456
512
        RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode");
457
513
        RNA_def_property_enum_items(prop, prop_tex_paint_map_mode_items);
458
514
        RNA_def_property_ui_text(prop, "Mode", "");
459
 
        RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
 
515
        RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_update");
 
516
 
 
517
        prop = RNA_def_property(srna, "mask_map_mode", PROP_ENUM, PROP_NONE);
 
518
        RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode");
 
519
        RNA_def_property_enum_items(prop, prop_mask_paint_map_mode_items);
 
520
        RNA_def_property_ui_text(prop, "Mode", "");
 
521
        RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_update");
460
522
}
461
523
 
462
524
static void rna_def_sculpt_capabilities(BlenderRNA *brna)
464
526
        StructRNA *srna;
465
527
        PropertyRNA *prop;
466
528
 
467
 
        srna = RNA_def_struct(brna, "SculptCapabilities", NULL);
 
529
        srna = RNA_def_struct(brna, "SculptToolCapabilities", NULL);
468
530
        RNA_def_struct_sdna(srna, "Brush");
469
531
        RNA_def_struct_nested(brna, srna, "Brush");
470
532
        RNA_def_struct_ui_text(srna, "Sculpt Capabilities",
471
533
                               "Read-only indications of which brush operations "
472
534
                               "are supported by the current sculpt tool");
473
535
 
 
536
#define SCULPT_TOOL_CAPABILITY(prop_name_, ui_name_)                      \
 
537
        prop = RNA_def_property(srna, #prop_name_,                          \
 
538
                                PROP_BOOLEAN, PROP_NONE);                   \
 
539
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);                   \
 
540
        RNA_def_property_boolean_funcs(prop, "rna_SculptToolCapabilities_"      \
 
541
                                       #prop_name_ "_get", NULL);           \
 
542
        RNA_def_property_ui_text(prop, ui_name_, NULL)
 
543
 
 
544
        SCULPT_TOOL_CAPABILITY(has_accumulate, "Has Accumulate");
 
545
        SCULPT_TOOL_CAPABILITY(has_auto_smooth, "Has Auto Smooth");
 
546
        SCULPT_TOOL_CAPABILITY(has_height, "Has Height");
 
547
        SCULPT_TOOL_CAPABILITY(has_jitter, "Has Jitter");
 
548
        SCULPT_TOOL_CAPABILITY(has_normal_weight, "Has Crease/Pinch Factor");
 
549
        SCULPT_TOOL_CAPABILITY(has_persistence, "Has Persistence");
 
550
        SCULPT_TOOL_CAPABILITY(has_pinch_factor, "Has Pinch Factor");
 
551
        SCULPT_TOOL_CAPABILITY(has_plane_offset, "Has Plane Offset");
 
552
        SCULPT_TOOL_CAPABILITY(has_random_texture_angle, "Has Random Texture Angle");
 
553
        SCULPT_TOOL_CAPABILITY(has_sculpt_plane, "Has Sculpt Plane");
 
554
        SCULPT_TOOL_CAPABILITY(has_secondary_color, "Has Secondary Color");
 
555
        SCULPT_TOOL_CAPABILITY(has_smooth_stroke, "Has Smooth Stroke");
 
556
        SCULPT_TOOL_CAPABILITY(has_space_attenuation, "Has Space Attenuation");
 
557
        SCULPT_TOOL_CAPABILITY(has_strength, "Has Strength");
 
558
 
 
559
#undef SCULPT_CAPABILITY
 
560
}
 
561
 
 
562
static void rna_def_brush_capabilities(BlenderRNA *brna)
 
563
{
 
564
        StructRNA *srna;
 
565
        PropertyRNA *prop;
 
566
 
 
567
        srna = RNA_def_struct(brna, "BrushCapabilities", NULL);
 
568
        RNA_def_struct_sdna(srna, "Brush");
 
569
        RNA_def_struct_nested(brna, srna, "Brush");
 
570
        RNA_def_struct_ui_text(srna, "Brush Capabilities",
 
571
                               "Read-only indications of which brush operations "
 
572
                               "are supported by the current brush");
 
573
 
474
574
#define BRUSH_CAPABILITY(prop_name_, ui_name_)                          \
475
575
        prop = RNA_def_property(srna, #prop_name_,                          \
476
576
                                PROP_BOOLEAN, PROP_NONE);                   \
477
577
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);                   \
478
 
        RNA_def_property_boolean_funcs(prop, "rna_SculptCapabilities_"      \
 
578
        RNA_def_property_boolean_funcs(prop, "rna_BrushCapabilities_"      \
479
579
                                       #prop_name_ "_get", NULL);           \
480
580
        RNA_def_property_ui_text(prop, ui_name_, NULL)
481
581
 
482
 
        BRUSH_CAPABILITY(has_accumulate, "Has Accumulate");
483
 
        BRUSH_CAPABILITY(has_auto_smooth, "Has Auto Smooth");
484
 
        BRUSH_CAPABILITY(has_height, "Has Height");
485
 
        BRUSH_CAPABILITY(has_jitter, "Has Jitter");
486
 
        BRUSH_CAPABILITY(has_normal_weight, "Has Crease/Pinch Factor");
487
582
        BRUSH_CAPABILITY(has_overlay, "Has Overlay");
488
 
        BRUSH_CAPABILITY(has_persistence, "Has Persistence");
489
 
        BRUSH_CAPABILITY(has_pinch_factor, "Has Pinch Factor");
490
 
        BRUSH_CAPABILITY(has_plane_offset, "Has Plane Offset");
491
583
        BRUSH_CAPABILITY(has_random_texture_angle, "Has Random Texture Angle");
492
 
        BRUSH_CAPABILITY(has_sculpt_plane, "Has Sculpt Plane");
493
 
        BRUSH_CAPABILITY(has_secondary_color, "Has Secondary Color");
494
 
        BRUSH_CAPABILITY(has_smooth_stroke, "Has Smooth Stroke");
495
 
        BRUSH_CAPABILITY(has_space_attenuation, "Has Space Attenuation");
496
 
        BRUSH_CAPABILITY(has_spacing, "Has Spacing");
497
 
        BRUSH_CAPABILITY(has_strength, "Has Strength");
498
584
        BRUSH_CAPABILITY(has_texture_angle, "Has Texture Angle");
499
585
        BRUSH_CAPABILITY(has_texture_angle_source, "Has Texture Angle Source");
 
586
        BRUSH_CAPABILITY(has_spacing, "Has Spacing");
500
587
 
501
 
#undef SCULPT_CAPABILITY
 
588
#undef BRUSH_CAPABILITY
502
589
}
503
590
 
504
591
static void rna_def_brush(BlenderRNA *brna)
518
605
                {0, NULL, 0, NULL, NULL}
519
606
        };
520
607
        
521
 
        static EnumPropertyItem brush_stroke_method_items[] = {
 
608
        static EnumPropertyItem sculpt_stroke_method_items[] = {
522
609
                {0, "DOTS", 0, "Dots", "Apply paint on each mouse move step"},
523
610
                {BRUSH_RESTORE_MESH, "DRAG_DOT", 0, "Drag Dot", "Allows a single dot to be carefully positioned"},
524
611
                {BRUSH_SPACE, "SPACE", 0, "Space", "Limit brush application to the distance specified by spacing"},
527
614
                {0, NULL, 0, NULL, NULL}
528
615
        };
529
616
 
 
617
        static EnumPropertyItem brush_stroke_method_items[] = {
 
618
                {0, "DOTS", 0, "Dots", "Apply paint on each mouse move step"},
 
619
                {BRUSH_SPACE, "SPACE", 0, "Space", "Limit brush application to the distance specified by spacing"},
 
620
                {BRUSH_AIRBRUSH, "AIRBRUSH", 0, "Airbrush", "Keep applying paint effect while holding mouse (spray)"},
 
621
                {0, NULL, 0, NULL, NULL}
 
622
        };
 
623
 
530
624
        static EnumPropertyItem texture_angle_source_items[] = {
531
625
                {0, "USER", 0, "User", "Rotate the brush texture by given angle"},
532
626
                {BRUSH_RAKE, "RAKE", 0, "Rake", "Rotate the brush texture to match the stroke direction"},
573
667
        prop = RNA_def_property(srna, "vertex_tool", PROP_ENUM, PROP_NONE);
574
668
        RNA_def_property_enum_sdna(prop, NULL, "vertexpaint_tool");
575
669
        RNA_def_property_enum_items(prop, brush_vertex_tool_items);
576
 
        RNA_def_property_ui_text(prop, "Vertex/Weight Paint Tool", "");
 
670
        RNA_def_property_ui_text(prop, "Blending mode", "Brush blending mode");
577
671
        RNA_def_property_update(prop, 0, "rna_Brush_vertex_tool_update");
578
672
        
579
673
        prop = RNA_def_property(srna, "image_tool", PROP_ENUM, PROP_NONE);
595
689
        RNA_def_property_ui_text(prop, "Stroke Method", "");
596
690
        RNA_def_property_update(prop, 0, "rna_Brush_update");
597
691
 
 
692
        prop = RNA_def_property(srna, "sculpt_stroke_method", PROP_ENUM, PROP_NONE);
 
693
        RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
 
694
        RNA_def_property_enum_items(prop, sculpt_stroke_method_items);
 
695
        RNA_def_property_ui_text(prop, "Stroke Method", "");
 
696
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
697
 
598
698
        prop = RNA_def_property(srna, "texture_angle_source_random", PROP_ENUM, PROP_NONE);
599
699
        RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
600
700
        RNA_def_property_enum_items(prop, texture_angle_source_items);
621
721
        prop = RNA_def_property(srna, "size", PROP_INT, PROP_NONE);
622
722
        RNA_def_property_int_funcs(prop, NULL, "rna_Brush_set_size", NULL);
623
723
        RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS * 10);
624
 
        RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, 0);
 
724
        RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, -1);
625
725
        RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels");
626
 
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
726
        RNA_def_property_update(prop, 0, "rna_Brush_size_update");
627
727
        
628
728
        prop = RNA_def_property(srna, "unprojected_radius", PROP_FLOAT, PROP_DISTANCE);
629
729
        RNA_def_property_float_funcs(prop, NULL, "rna_Brush_set_unprojected_radius", NULL);
630
730
        RNA_def_property_range(prop, 0.001, FLT_MAX);
631
 
        RNA_def_property_ui_range(prop, 0.001, 1, 0, 0);
 
731
        RNA_def_property_ui_range(prop, 0.001, 1, 0, -1);
632
732
        RNA_def_property_ui_text(prop, "Unprojected Radius", "Radius of brush in Blender units");
633
 
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
733
        RNA_def_property_update(prop, 0, "rna_Brush_size_update");
634
734
 
635
735
        prop = RNA_def_property(srna, "jitter", PROP_FLOAT, PROP_NONE);
636
736
        RNA_def_property_float_sdna(prop, NULL, "jitter");
637
 
        RNA_def_property_range(prop, 0.0f, 1.0f);
 
737
        RNA_def_property_range(prop, 0.0f, 1000.0f);
 
738
        RNA_def_property_ui_range(prop, 0.0f, 2.0f, 0.1, 4);
638
739
        RNA_def_property_ui_text(prop, "Jitter", "Jitter the position of the brush while painting");
639
740
        RNA_def_property_update(prop, 0, "rna_Brush_update");
640
741
 
 
742
        prop = RNA_def_property(srna, "jitter_absolute", PROP_INT, PROP_NONE);
 
743
        RNA_def_property_int_sdna(prop, NULL, "jitter_absolute");
 
744
        RNA_def_property_range(prop, 0, 1000000);
 
745
        RNA_def_property_ui_text(prop, "Jitter", "Jitter the position of the brush in pixels while painting");
 
746
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
747
 
641
748
        prop = RNA_def_property(srna, "spacing", PROP_INT, PROP_PERCENTAGE);
642
749
        RNA_def_property_int_sdna(prop, NULL, "spacing");
643
750
        RNA_def_property_range(prop, 1, 1000);
644
 
        RNA_def_property_ui_range(prop, 1, 500, 5, 0);
 
751
        RNA_def_property_ui_range(prop, 1, 500, 5, -1);
645
752
        RNA_def_property_ui_text(prop, "Spacing", "Spacing between brush daubs as a percentage of brush diameter");
646
753
        RNA_def_property_update(prop, 0, "rna_Brush_update");
647
754
 
736
843
        RNA_def_property_ui_text(prop, "Autosmooth", "Amount of smoothing to automatically apply to each stroke");
737
844
        RNA_def_property_update(prop, 0, "rna_Brush_update");
738
845
 
 
846
        prop = RNA_def_property(srna, "stencil_pos", PROP_FLOAT, PROP_XYZ);
 
847
        RNA_def_property_float_sdna(prop, NULL, "stencil_pos");
 
848
        RNA_def_property_array(prop, 2);
 
849
        RNA_def_property_ui_text(prop, "Stencil Position", "Position of stencil in viewport");
 
850
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
851
 
 
852
        prop = RNA_def_property(srna, "stencil_dimension", PROP_FLOAT, PROP_XYZ);
 
853
        RNA_def_property_float_sdna(prop, NULL, "stencil_dimension");
 
854
        RNA_def_property_array(prop, 2);
 
855
        RNA_def_property_ui_text(prop, "Stencil Dimensions", "Dimensions of stencil in viewport");
 
856
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
857
 
 
858
        prop = RNA_def_property(srna, "mask_stencil_pos", PROP_FLOAT, PROP_XYZ);
 
859
        RNA_def_property_float_sdna(prop, NULL, "mask_stencil_pos");
 
860
        RNA_def_property_array(prop, 2);
 
861
        RNA_def_property_ui_text(prop, "Mask Stencil Position", "Position of mask stencil in viewport");
 
862
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
863
 
 
864
        prop = RNA_def_property(srna, "mask_stencil_dimension", PROP_FLOAT, PROP_XYZ);
 
865
        RNA_def_property_float_sdna(prop, NULL, "mask_stencil_dimension");
 
866
        RNA_def_property_array(prop, 2);
 
867
        RNA_def_property_ui_text(prop, "Mask Stencil Dimensions", "Dimensions of mask stencil in viewport");
 
868
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
869
 
739
870
        /* flag */
740
871
        prop = RNA_def_property(srna, "use_airbrush", PROP_BOOLEAN, PROP_NONE);
741
872
        RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_AIRBRUSH);
794
925
        RNA_def_property_ui_text(prop, "Rake", "Rotate the brush texture to match the stroke direction");
795
926
        RNA_def_property_update(prop, 0, "rna_Brush_update");
796
927
 
 
928
        prop = RNA_def_property(srna, "use_relative_jitter", PROP_BOOLEAN, PROP_NONE);
 
929
        RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BRUSH_ABSOLUTE_JITTER);
 
930
        RNA_def_property_ui_text(prop, "Absolute Jitter", "Jittering happens in screen space, not relative to brush size");
 
931
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
932
 
797
933
        prop = RNA_def_property(srna, "use_random_rotation", PROP_BOOLEAN, PROP_NONE);
798
934
        RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_RANDOM_ROTATION);
799
935
        RNA_def_property_ui_text(prop, "Random Rotation", "Rotate the brush texture at random");
854
990
                                 "given in pixels");
855
991
        RNA_def_property_update(prop, 0, "rna_Brush_update");
856
992
 
857
 
        prop = RNA_def_property(srna, "use_texture_overlay", PROP_BOOLEAN, PROP_NONE);
858
 
        RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_TEXTURE_OVERLAY);
859
 
        RNA_def_property_ui_text(prop, "Use Texture Overlay", "Show texture in viewport");
860
 
        RNA_def_property_update(prop, 0, "rna_Brush_update");
861
 
 
862
993
        prop = RNA_def_property(srna, "use_edge_to_edge", PROP_BOOLEAN, PROP_NONE);
863
994
        RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_EDGE_TO_EDGE);
864
995
        RNA_def_property_ui_text(prop, "Edge-to-edge", "Drag anchor brush from edge-to-edge");
868
999
        RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_RESTORE_MESH);
869
1000
        RNA_def_property_ui_text(prop, "Restore Mesh", "Allow a single dot to be carefully positioned");
870
1001
        RNA_def_property_update(prop, 0, "rna_Brush_update");
871
 
        
 
1002
 
872
1003
        /* only for projection paint, TODO, other paint modes */
873
1004
        prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE);
874
1005
        RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BRUSH_LOCK_ALPHA);
880
1011
        RNA_def_property_ui_text(prop, "Curve", "Editable falloff curve");
881
1012
        RNA_def_property_update(prop, 0, "rna_Brush_update");
882
1013
 
 
1014
        /* overlay flags */
 
1015
        prop = RNA_def_property(srna, "use_primary_overlay", PROP_BOOLEAN, PROP_NONE);
 
1016
        RNA_def_property_boolean_sdna(prop, NULL, "overlay_flags", BRUSH_OVERLAY_PRIMARY);
 
1017
        RNA_def_property_ui_text(prop, "Use Texture Overlay", "Show texture in viewport");
 
1018
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
1019
 
 
1020
        prop = RNA_def_property(srna, "use_secondary_overlay", PROP_BOOLEAN, PROP_NONE);
 
1021
        RNA_def_property_boolean_sdna(prop, NULL, "overlay_flags", BRUSH_OVERLAY_SECONDARY);
 
1022
        RNA_def_property_ui_text(prop, "Use Texture Overlay", "Show texture in viewport");
 
1023
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
1024
 
 
1025
        prop = RNA_def_property(srna, "use_cursor_overlay", PROP_BOOLEAN, PROP_NONE);
 
1026
        RNA_def_property_boolean_sdna(prop, NULL, "overlay_flags", BRUSH_OVERLAY_CURSOR);
 
1027
        RNA_def_property_ui_text(prop, "Use Cursor Overlay", "Show cursor in viewport");
 
1028
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
1029
 
 
1030
        prop = RNA_def_property(srna, "use_cursor_overlay_override", PROP_BOOLEAN, PROP_NONE);
 
1031
        RNA_def_property_boolean_sdna(prop, NULL, "overlay_flags", BRUSH_OVERLAY_CURSOR_OVERRIDE_ON_STROKE);
 
1032
        RNA_def_property_ui_text(prop, "Override Overlay", "Don't show overlay during a stroke");
 
1033
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
1034
 
 
1035
        prop = RNA_def_property(srna, "use_primary_overlay_override", PROP_BOOLEAN, PROP_NONE);
 
1036
        RNA_def_property_boolean_sdna(prop, NULL, "overlay_flags", BRUSH_OVERLAY_PRIMARY_OVERRIDE_ON_STROKE);
 
1037
        RNA_def_property_ui_text(prop, "Override Overlay", "Don't show overlay during a stroke");
 
1038
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
1039
 
 
1040
        prop = RNA_def_property(srna, "use_secondary_overlay_override", PROP_BOOLEAN, PROP_NONE);
 
1041
        RNA_def_property_boolean_sdna(prop, NULL, "overlay_flags", BRUSH_OVERLAY_SECONDARY_OVERRIDE_ON_STROKE);
 
1042
        RNA_def_property_ui_text(prop, "Override Overlay", "Don't show overlay during a stroke");
 
1043
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
1044
 
883
1045
        /* paint mode flags */
884
1046
        prop = RNA_def_property(srna, "use_paint_sculpt", PROP_BOOLEAN, PROP_NONE);
885
1047
        RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_SCULPT);
908
1070
        RNA_def_property_pointer_sdna(prop, NULL, "mtex.tex");
909
1071
        RNA_def_property_flag(prop, PROP_EDITABLE);
910
1072
        RNA_def_property_ui_text(prop, "Texture", "");
911
 
        RNA_def_property_update(prop, NC_TEXTURE, "rna_Brush_update");
 
1073
        RNA_def_property_update(prop, NC_TEXTURE, "rna_Brush_main_tex_update");
 
1074
 
 
1075
        prop = RNA_def_property(srna, "mask_texture_slot", PROP_POINTER, PROP_NONE);
 
1076
        RNA_def_property_struct_type(prop, "BrushTextureSlot");
 
1077
        RNA_def_property_pointer_sdna(prop, NULL, "mask_mtex");
 
1078
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
1079
        RNA_def_property_ui_text(prop, "Mask Texture Slot", "");
 
1080
 
 
1081
        prop = RNA_def_property(srna, "mask_texture", PROP_POINTER, PROP_NONE);
 
1082
        RNA_def_property_pointer_sdna(prop, NULL, "mask_mtex.tex");
 
1083
        RNA_def_property_flag(prop, PROP_EDITABLE);
 
1084
        RNA_def_property_ui_text(prop, "Mask Texture", "");
 
1085
        RNA_def_property_update(prop, NC_TEXTURE, "rna_Brush_secondary_tex_update");
912
1086
 
913
1087
        prop = RNA_def_property(srna, "texture_overlay_alpha", PROP_INT, PROP_PERCENTAGE);
914
1088
        RNA_def_property_int_sdna(prop, NULL, "texture_overlay_alpha");
916
1090
        RNA_def_property_ui_text(prop, "Texture Overlay Alpha", "");
917
1091
        RNA_def_property_update(prop, 0, "rna_Brush_update");
918
1092
 
 
1093
        prop = RNA_def_property(srna, "mask_overlay_alpha", PROP_INT, PROP_PERCENTAGE);
 
1094
        RNA_def_property_int_sdna(prop, NULL, "mask_overlay_alpha");
 
1095
        RNA_def_property_range(prop, 1, 100);
 
1096
        RNA_def_property_ui_text(prop, "Mask Texture Overlay Alpha", "");
 
1097
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
1098
 
 
1099
        prop = RNA_def_property(srna, "cursor_overlay_alpha", PROP_INT, PROP_PERCENTAGE);
 
1100
        RNA_def_property_int_sdna(prop, NULL, "cursor_overlay_alpha");
 
1101
        RNA_def_property_range(prop, 1, 100);
 
1102
        RNA_def_property_ui_text(prop, "Mask Texture Overlay Alpha", "");
 
1103
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
1104
 
919
1105
        prop = RNA_def_property(srna, "cursor_color_add", PROP_FLOAT, PROP_COLOR);
920
1106
        RNA_def_property_float_sdna(prop, NULL, "add_col");
921
1107
        RNA_def_property_array(prop, 3);
957
1143
        RNA_def_property_ui_range(prop, -1.0f, 1.0f, 10.0f, 3);
958
1144
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_Brush_update");
959
1145
 
 
1146
        prop = RNA_def_property(srna, "brush_capabilities", PROP_POINTER, PROP_NONE);
 
1147
        RNA_def_property_flag(prop, PROP_NEVER_NULL);
 
1148
        RNA_def_property_struct_type(prop, "BrushCapabilities");
 
1149
        RNA_def_property_pointer_funcs(prop, "rna_Brush_capabilities_get", NULL, NULL, NULL);
 
1150
        RNA_def_property_ui_text(prop, "Brush Capabilities", "Brush's capabilities");
 
1151
 
960
1152
        /* brush capabilities (mode-dependent) */
961
1153
        prop = RNA_def_property(srna, "sculpt_capabilities", PROP_POINTER, PROP_NONE);
962
1154
        RNA_def_property_flag(prop, PROP_NEVER_NULL);
963
 
        RNA_def_property_struct_type(prop, "SculptCapabilities");
964
 
        RNA_def_property_pointer_funcs(prop, "rna_Brush_sculpt_capabilities_get", NULL, NULL, NULL);
 
1155
        RNA_def_property_struct_type(prop, "SculptToolCapabilities");
 
1156
        RNA_def_property_pointer_funcs(prop, "rna_Sculpt_sculpt_tool_capabilities_get", NULL, NULL, NULL);
965
1157
        RNA_def_property_ui_text(prop, "Sculpt Capabilities", "Brush's capabilities in sculpt mode");
966
1158
}
967
1159
 
1023
1215
void RNA_def_brush(BlenderRNA *brna)
1024
1216
{
1025
1217
        rna_def_brush(brna);
 
1218
        rna_def_brush_capabilities(brna);
1026
1219
        rna_def_sculpt_capabilities(brna);
1027
1220
        rna_def_brush_texture_slot(brna);
1028
1221
        rna_def_operator_stroke_element(brna);