diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2011-05-12 05:57:47 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2011-05-12 05:57:47 +0400 |
commit | 910220be47729d6effffb7aa33bfe05d4caa5d3d (patch) | |
tree | ecc0d3c6c5073aee112ed5946ec7882ee4bfe236 /source/blender/blenkernel/intern/brush.c | |
parent | 040f65f6c29a8d5b624d4dd5b3083d8519d4a8c1 (diff) |
== Radial control ==
Patch to make the radial control more generic with RNA. Patch was
reviewed here: http://codereview.appspot.com/4280080/
Prior to this update, the radial control code in trunk had generic
parts of the radial control implemented as an incomplete operator
within WM. Then each different user of the radial control had to
implement a separate operator to actually pass in specific brush data
-- e.g. sculpt's brush size, vpaint's brush size, etc.
This patch removes all the extra operators and makes the WM operator
do everything. It now takes several RNA path strings as its properties
-- the only required property is data_path, which specifies the data
to be modified by the radial control. The other paths affect display
in various ways, e.g. rotation, color, etc.
In addition to decreasing some duplicate paint brush code, these
updates make it pretty easy to enable radial control for other
purposes (and it can be set up entirely though python or keymaps, no
extra C code needed.)
Diffstat (limited to 'source/blender/blenkernel/intern/brush.c')
-rw-r--r-- | source/blender/blenkernel/intern/brush.c | 53 |
1 files changed, 1 insertions, 52 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index fa3b756ae27..98c540f53b7 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -426,13 +426,6 @@ void brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset) curvemapping_changed(b->curve, 0); } -static MTex *brush_active_texture(Brush *brush) -{ - if(brush) - return &brush->mtex; - return NULL; -} - int brush_texture_set_nr(Brush *brush, int nr) { ID *idtest, *id=NULL; @@ -1185,7 +1178,7 @@ unsigned int *brush_gen_texture_cache(Brush *br, int half_side) } /**** Radial Control ****/ -static struct ImBuf *brush_gen_radial_control_imbuf(Brush *br) +struct ImBuf *brush_gen_radial_control_imbuf(Brush *br) { ImBuf *im = MEM_callocN(sizeof(ImBuf), "radial control texture"); unsigned int *texcache; @@ -1219,50 +1212,6 @@ static struct ImBuf *brush_gen_radial_control_imbuf(Brush *br) return im; } -void brush_radial_control_invoke(wmOperator *op, Brush *br, float size_weight) -{ - int mode = RNA_enum_get(op->ptr, "mode"); - float original_value= 0; - - if(mode == WM_RADIALCONTROL_SIZE) - original_value = brush_size(br) * size_weight; - else if(mode == WM_RADIALCONTROL_STRENGTH) - original_value = brush_alpha(br); - else if(mode == WM_RADIALCONTROL_ANGLE) { - MTex *mtex = brush_active_texture(br); - if(mtex) - original_value = mtex->rot; - } - - RNA_float_set(op->ptr, "initial_value", original_value); - op->customdata = brush_gen_radial_control_imbuf(br); -} - -int brush_radial_control_exec(wmOperator *op, Brush *br, float size_weight) -{ - int mode = RNA_enum_get(op->ptr, "mode"); - float new_value = RNA_float_get(op->ptr, "new_value"); - const float conv = 0.017453293; - - if(mode == WM_RADIALCONTROL_SIZE) - if (brush_use_locked_size(br)) { - float initial_value = RNA_float_get(op->ptr, "initial_value"); - const float unprojected_radius = brush_unprojected_radius(br); - brush_set_unprojected_radius(br, unprojected_radius * new_value/initial_value * size_weight); - } - else - brush_set_size(br, new_value * size_weight); - else if(mode == WM_RADIALCONTROL_STRENGTH) - brush_set_alpha(br, new_value); - else if(mode == WM_RADIALCONTROL_ANGLE) { - MTex *mtex = brush_active_texture(br); - if(mtex) - mtex->rot = new_value * conv; - } - - return OPERATOR_FINISHED; -} - /* Unified Size and Strength */ static void set_unified_settings(Brush *brush, short flag, int value) |