diff options
Diffstat (limited to 'source/blender/blenkernel/intern/paint.c')
-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) |