diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-12-29 13:35:22 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-12-29 13:35:43 +0300 |
commit | 427fbc879e18608cc24e448b37e39c8413df988a (patch) | |
tree | c49f885c006a18bdc624bb7270bf4a1936daaee0 /source/blender/blenkernel/intern | |
parent | e0cb67f7408d0fb60898a732d84889d9f158ed0e (diff) |
Move average stroke from sculpt session to unified paint settings so it
can be reused by other paint systems too.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 5f3b9f04bf2..2cd779a120c 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -395,7 +395,7 @@ bool BKE_paint_select_elem_test(Object *ob) BKE_paint_select_face_test(ob)); } -void BKE_paint_init(Paint *p, const char col[3]) +void BKE_paint_init(UnifiedPaintSettings *ups, Paint *p, const char col[3]) { Brush *brush; @@ -407,6 +407,9 @@ void BKE_paint_init(Paint *p, const char col[3]) memcpy(p->paint_cursor_col, col, 3); p->paint_cursor_col[3] = 128; + ups->last_stroke_valid = false; + zero_v3(ups->average_stroke_accum); + ups->average_stroke_counter = 0; } void BKE_paint_free(Paint *paint) @@ -426,6 +429,18 @@ void BKE_paint_copy(Paint *src, Paint *tar) id_us_plus((ID *)tar->palette); } +void BKE_paint_stroke_get_average(Scene *scene, Object *ob, float stroke[3]) +{ + UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; + if (ups->last_stroke_valid && ups->average_stroke_counter > 0) { + float fac = 1.0f / ups->average_stroke_counter; + mul_v3_v3fl(stroke, ups->average_stroke_accum, fac); + } + else { + copy_v3_v3(stroke, ob->obmat[3]); + } +} + /* returns non-zero if any of the face's vertices * are hidden, zero otherwise */ bool paint_is_face_hidden(const MFace *f, const MVert *mvert) |