diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-12-27 01:51:27 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-12-27 01:51:27 +0300 |
commit | c7c10e5e283879961356050ba8a965d2239456b8 (patch) | |
tree | d89d06ca30d51087a9d958f66bbf240bd3c7807e /source/blender/editors/sculpt_paint | |
parent | e0cf86a9e219dcd71e5d67b8f2999d41e7f8c492 (diff) |
Brush Texture Angle Goodies:
This commit includes a few things:
* It moves the Rake and Random flags from the brush to the MTex.
* The first change allows mask textures to have independent rake
support.
* Random rotation now has an angle value that controls the width of the
effect from the rake or default angle
* Rake and Random are now supported together.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_cursor.c | 6 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_2d.c | 2 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 42 |
3 files changed, 31 insertions, 19 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index e27ef705fad..92cb346b61e 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -595,7 +595,7 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush, if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) { /* brush rotation */ glTranslatef(0.5, 0.5, 0); - glRotatef((double)RAD2DEGF(ups->brush_rotation), + glRotatef((double)RAD2DEGF((primary) ? ups->brush_rotation : ups->brush_rotation_sec), 0.0, 0.0, 1.0); glTranslatef(-0.5f, -0.5f, 0); @@ -1000,9 +1000,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) /* don't calculate rake angles while a stroke is active because the rake variables are global and * we may get interference with the stroke itself. For line strokes, such interference is visible */ if (!ups->stroke_active) { - if (brush->flag & BRUSH_RAKE) - /* here, translation contains the mouse coordinates. */ - paint_calculate_rake_rotation(ups, translation); + paint_calculate_rake_rotation(ups, brush, translation); } /* draw overlay */ diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index 44d562bbc7b..2298164822f 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -686,7 +686,7 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s, BrushPainter *pai bool do_partial_update_mask = false; /* invalidate case for all mapping modes */ if (brush->mask_mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) { - mask_rotation += ups->brush_rotation; + mask_rotation += ups->brush_rotation_sec; } else if (brush->mask_mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM) { renew_maxmask = true; diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 9c4701d0a01..bd5fa835718 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -207,6 +207,7 @@ static bool paint_brush_update(bContext *C, UnifiedPaintSettings *ups = stroke->ups; bool location_sampled = false; bool location_success = false; + bool do_random = false; /* XXX: Use pressure value from first brush step for brushes which don't * support strokes (grab, thumb). They depends on initial state and * brush coord/pressure/etc. @@ -256,13 +257,9 @@ static bool paint_brush_update(bContext *C, if (paint_supports_dynamic_tex_coords(brush, mode)) { if (((brush->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) || (brush->mtex.brush_map_mode == MTEX_MAP_MODE_AREA) || - (brush->mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM)) && - !(brush->flag & BRUSH_RAKE)) + (brush->mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM))) { - if (brush->flag & BRUSH_RANDOM_ROTATION) - ups->brush_rotation = 2.0f * (float)M_PI * BLI_frand(); - else - ups->brush_rotation = 0.0f; + do_random = true; } if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM) @@ -291,7 +288,7 @@ static bool paint_brush_update(bContext *C, ups->anchored_size = ups->pixel_radius = sqrtf(dx * dx + dy * dy); - ups->brush_rotation = atan2f(dx, dy) + M_PI; + ups->brush_rotation = ups->brush_rotation_sec = atan2f(dx, dy) + M_PI; if (brush->flag & BRUSH_EDGE_TO_EDGE) { halfway[0] = dx * 0.5f + stroke->initial_mouse[0]; @@ -328,13 +325,27 @@ static bool paint_brush_update(bContext *C, ups->pixel_radius /= stroke->zoom_2d; ups->draw_anchored = true; } - else if (brush->flag & BRUSH_RAKE) { + else { /* here we are using the initial mouse coordinate because we do not want the rake * result to depend on jittering */ - if (!stroke->brush_init) + if (!stroke->brush_init) { copy_v2_v2(ups->last_rake, mouse_init); - else - paint_calculate_rake_rotation(ups, mouse_init); + } + else { + paint_calculate_rake_rotation(ups, brush, mouse_init); + } + } + + if (do_random) { + if (brush->mtex.brush_angle_mode & MTEX_ANGLE_RANDOM) { + ups->brush_rotation += -brush->mtex.random_angle / 2.0f + + brush->mtex.random_angle * BLI_frand(); + } + + if (brush->mask_mtex.brush_angle_mode & MTEX_ANGLE_RANDOM) { + ups->brush_rotation_sec += -brush->mask_mtex.random_angle / 2.0f + + brush->mask_mtex.random_angle * BLI_frand(); + } } if (!location_sampled) { @@ -675,9 +686,12 @@ static void stroke_done(struct bContext *C, struct wmOperator *op) ups->stroke_active = false; /* reset rotation here to avoid doing so in cursor display */ - if (!(stroke->brush->flag & BRUSH_RAKE)) + if (!(stroke->brush->mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) ups->brush_rotation = 0.0f; + if (!(stroke->brush->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) + ups->brush_rotation_sec = 0.0f; + if (stroke->stroke_started) { if (stroke->redraw) stroke->redraw(C, stroke, true); @@ -1064,10 +1078,10 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) else if ((br->flag & BRUSH_LINE) && stroke->stroke_started && (first_modal || (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)))) { - if (br->flag & BRUSH_RAKE) { + if ((br->mtex.brush_angle_mode & MTEX_ANGLE_RAKE) || (br->mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) { copy_v2_v2(stroke->ups->last_rake, stroke->last_mouse_position); - paint_calculate_rake_rotation(stroke->ups, sample_average.mouse); } + paint_calculate_rake_rotation(stroke->ups, br, sample_average.mouse); } else if (first_modal || /* regular dabs */ |