diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2013-03-10 22:46:31 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2013-03-10 22:46:31 +0400 |
commit | 623902ac511d3bd654fc21f304a4cba4ffa35e9f (patch) | |
tree | 9d2b89b640f746dfcd79a24519ea4b04bc14f6b5 | |
parent | ca5f7b778c5cb44b6745e75174c91315aff685f9 (diff) |
Fix: stroke spacing fails in image editor, we need to account for
zooming because spacing used to happen in unscaled screen space
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 2 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 9 |
3 files changed, 10 insertions, 2 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index b7c03563a9d..969efaf0bb7 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -623,7 +623,7 @@ void PAINT_OT_image_paint(wmOperatorType *ot) } -static int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy) +int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy) { RegionView3D *rv3d = CTX_wm_region_view3d(C); diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index b0478bccd8c..bcf1775d8d4 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -126,6 +126,7 @@ struct ImagePaintPartialRedraw *get_imapaintpartial(void); void set_imapaintpartial(struct ImagePaintPartialRedraw * ippr); void imapaint_clear_partial_redraw(void); void imapaint_dirty_region(struct Image *ima, struct ImBuf *ibuf, int x, int y, int w, int h); +int get_imapaint_zoom(struct bContext *C, float *zoomx, float *zoomy); void *paint_2d_new_stroke(struct bContext *, struct wmOperator *); void paint_2d_redraw(const bContext *C, void *ps, int final); void paint_2d_stroke_done(void *ps); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 4ef52f0c9e5..db4eb08f11e 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -269,14 +269,21 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const size_pressure = pressure; if (size_pressure > FLT_EPSILON) { + float zoomx, zoomy; /* brushes can have a minimum size of 1.0 but with pressure it can be smaller then a pixel * causing very high step sizes, hanging blender [#32381] */ const float size_clamp = max_ff(1.0f, BKE_brush_size_get(scene, stroke->brush) * size_pressure); float spacing = stroke->brush->spacing; + /* stroke system is used for 2d paint too, so we need to account for + * the fact that brush can be scaled there. */ + get_imapaint_zoom(C, &zoomx, &zoomy); + if (stroke->brush->flag & BRUSH_SPACING_PRESSURE) spacing = max_ff(1.0f, spacing * (1.5f - pressure)); + spacing *= max_ff(zoomx, zoomy); + scale = (size_clamp * spacing / 50.0f) / length; if (scale > FLT_EPSILON) { mul_v2_fl(vec, scale); @@ -360,7 +367,7 @@ bool paint_supports_dynamic_size(Brush *br) bool paint_supports_jitter(PaintMode mode) { - return ELEM(mode, PAINT_SCULPT, PAINT_TEXTURE_PROJECTIVE); + return ELEM3(mode, PAINT_SCULPT, PAINT_TEXTURE_PROJECTIVE, PAINT_TEXTURE_2D); } #define PAINT_STROKE_MODAL_CANCEL 1 |