Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2014-12-29 13:35:22 +0300
committerAntony Riakiotakis <kalast@gmail.com>2014-12-29 13:35:43 +0300
commit427fbc879e18608cc24e448b37e39c8413df988a (patch)
treec49f885c006a18bdc624bb7270bf4a1936daaee0 /source/blender/blenkernel
parente0cb67f7408d0fb60898a732d84889d9f158ed0e (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')
-rw-r--r--source/blender/blenkernel/BKE_paint.h10
-rw-r--r--source/blender/blenkernel/intern/paint.c17
2 files changed, 19 insertions, 8 deletions
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index ff1305b9182..9ad99f726ff 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -109,7 +109,7 @@ void BKE_palette_cleanup(struct Palette *palette);
struct PaintCurve *BKE_paint_curve_add(struct Main *bmain, const char *name);
void BKE_paint_curve_free(struct PaintCurve *pc);
-void BKE_paint_init(struct Paint *p, const char col[3]);
+void BKE_paint_init(struct UnifiedPaintSettings *ups, struct Paint *p, const char col[3]);
void BKE_paint_free(struct Paint *p);
void BKE_paint_copy(struct Paint *src, struct Paint *tar);
@@ -145,6 +145,8 @@ float paint_grid_paint_mask(const struct GridPaintMask *gpm, unsigned level,
/* stroke related */
void paint_calculate_rake_rotation(struct UnifiedPaintSettings *ups, struct Brush *brush, const float mouse_pos[2]);
+void BKE_paint_stroke_get_average(struct Scene *scene, struct Object *ob, float stroke[3]);
+
/* Session data (mode-specific) */
typedef struct SculptSession {
@@ -191,12 +193,6 @@ typedef struct SculptSession {
struct SculptStroke *stroke;
struct StrokeCache *cache;
-
- /* last paint/sculpt stroke location */
- bool last_stroke_valid;
-
- float average_stroke_accum[3];
- int average_stroke_counter;
} SculptSession;
void BKE_free_sculptsession(struct Object *ob);
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)