diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-12-18 18:19:12 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-12-18 18:19:12 +0300 |
commit | c46a9d811789706e77db3d0b92f4b943fb86f386 (patch) | |
tree | b6ea007f13bb6cb831281594c4bea59f835544d8 /source/blender | |
parent | 1fb43dcd5a7549f98a96faa41110ca22877003e5 (diff) | |
parent | 344eff9c4804f99b633c8054b888a8667ea24ddc (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_paint.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 7 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 10 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_surfacedeform.c | 4 |
4 files changed, 18 insertions, 5 deletions
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index 31f4695201c..b8fde8bd68e 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -157,7 +157,7 @@ float paint_grid_paint_mask(const struct GridPaintMask *gpm, unsigned level, unsigned x, unsigned y); /* stroke related */ -void paint_calculate_rake_rotation(struct UnifiedPaintSettings *ups, struct Brush *brush, const float mouse_pos[2]); +bool paint_calculate_rake_rotation(struct UnifiedPaintSettings *ups, struct Brush *brush, const float mouse_pos[2]); void paint_update_brush_rake_rotation(struct UnifiedPaintSettings *ups, struct Brush *brush, float rotation); void BKE_paint_stroke_get_average(struct Scene *scene, struct Object *ob, float stroke[3]); diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index c88642a8164..11702236066 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -641,8 +641,9 @@ void paint_update_brush_rake_rotation(UnifiedPaintSettings *ups, Brush *brush, f ups->brush_rotation_sec = 0.0f; } -void paint_calculate_rake_rotation(UnifiedPaintSettings *ups, Brush *brush, const float mouse_pos[2]) +bool paint_calculate_rake_rotation(UnifiedPaintSettings *ups, Brush *brush, const float mouse_pos[2]) { + bool ok = false; if ((brush->mtex.brush_angle_mode & MTEX_ANGLE_RAKE) || (brush->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) { const float r = RAKE_THRESHHOLD; float rotation; @@ -658,16 +659,20 @@ void paint_calculate_rake_rotation(UnifiedPaintSettings *ups, Brush *brush, cons ups->last_rake_angle = rotation; paint_update_brush_rake_rotation(ups, brush, rotation); + ok = true; } /* make sure we reset here to the last rotation to avoid accumulating * values in case a random rotation is also added */ else { paint_update_brush_rake_rotation(ups, brush, ups->last_rake_angle); + ok = false; } } else { ups->brush_rotation = ups->brush_rotation_sec = 0.0f; + ok = true; } + return ok; } void BKE_sculptsession_free_deformMats(SculptSession *ss) diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index dacaea6a96e..9dd51b289f4 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -233,6 +233,9 @@ static bool paint_brush_update(bContext *C, UnifiedPaintSettings *ups = stroke->ups; bool location_sampled = false; bool location_success = false; + /* Use to perform all operations except applying the stroke, + * needed for operations that require cursor motion (rake). */ + bool is_dry_run = false; bool do_random = false; bool do_random_mask = false; /* XXX: Use pressure value from first brush step for brushes which don't @@ -371,7 +374,10 @@ static bool paint_brush_update(bContext *C, } /* curve strokes do their own rake calculation */ else if (!(brush->flag & BRUSH_CURVE)) { - paint_calculate_rake_rotation(ups, brush, mouse_init); + if (!paint_calculate_rake_rotation(ups, brush, mouse_init)) { + /* Not enough motion to define an angle. */ + is_dry_run = true; + } } } @@ -402,7 +408,7 @@ static bool paint_brush_update(bContext *C, } } - return location_success; + return location_success && (is_dry_run == false); } static bool paint_stroke_use_jitter(ePaintMode mode, Brush *brush, bool invert) diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c index b623293ed5c..2919f169d00 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.c +++ b/source/blender/modifiers/intern/MOD_surfacedeform.c @@ -314,11 +314,13 @@ BLI_INLINE int isPolyValid(const float coords[][2], const unsigned int nr) copy_v2_v2(prev_co, coords[nr - 1]); sub_v2_v2v2(prev_vec, prev_co, coords[nr - 2]); + normalize_v2(prev_vec); for (int i = 0; i < nr; i++) { sub_v2_v2v2(curr_vec, coords[i], prev_co); - if (len_squared_v2(curr_vec) < FLT_EPSILON) { + const float curr_len = normalize_v2(curr_vec); + if (curr_len < FLT_EPSILON) { return MOD_SDEF_BIND_RESULT_OVERLAP_ERR; } |