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>2013-03-15 13:48:51 +0400
committerAntony Riakiotakis <kalast@gmail.com>2013-03-15 13:48:51 +0400
commit99ee23aec5f50f36fc39c37a795a504540cfb177 (patch)
tree300b0ee9b957455352240ad595f8b6686b25efd1 /source/blender
parent1ea16dcf9b5337a7f8983a09d7f92b6164a7670f (diff)
Support for rake in 2D image painting.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/brush.c28
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c11
2 files changed, 35 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index d341a2c06e1..6adcdbd2c3e 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -565,15 +565,37 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br,
/* Brush Sampling for 2D brushes. when we unify the brush systems this will be necessarily a separate function */
float BKE_brush_sample_tex_2D(const Scene *scene, Brush *brush, const float xy[2], float rgba[4], struct ImagePool *pool)
{
+ UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
MTex *mtex = &brush->mtex;
if (mtex && mtex->tex) {
float co[3], tin, tr, tg, tb, ta;
+ float x = xy[0], y = xy[1];
int hasrgb;
- const int radius = BKE_brush_size_get(scene, brush);
+ int radius = BKE_brush_size_get(scene, brush);
+ float rotation = -mtex->rot;
+
+ if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
+ rotation += ups->brush_rotation;
+ radius = ups->pixel_radius;
+ }
+
+ x /= radius;
+ y /= radius;
+
+ if (rotation > 0.001f || rotation < -0.001f) {
+ const float angle = atan2f(y, x) + rotation;
+ const float flen = sqrtf(x * x + y * y);
+
+ x = flen * cosf(angle);
+ y = flen * sinf(angle);
+ }
+
+ x *= brush->mtex.size[0];
+ y *= brush->mtex.size[1];
- co[0] = xy[0] / radius;
- co[1] = xy[1] / radius;
+ co[0] = x + brush->mtex.ofs[0];
+ co[1] = y + brush->mtex.ofs[1];
co[2] = 0.0f;
hasrgb = externtex(mtex, co, &tin, &tr, &tg, &tb, &ta, 0, pool);
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index e2e448646b2..8db1b1817b5 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -96,6 +96,7 @@ typedef struct BrushPainterCache {
int lastsize;
float lastalpha;
float lastjitter;
+ float last_rotation;
ImBuf *ibuf;
ImBuf *texibuf;
@@ -335,6 +336,7 @@ static void brush_painter_2d_tiled_tex_partial_update(BrushPainter *painter, con
static void brush_painter_2d_refresh_cache(BrushPainter *painter, const float pos[2], int use_color_correction)
{
const Scene *scene = painter->scene;
+ UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
Brush *brush = painter->brush;
BrushPainterCache *cache = &painter->cache;
MTex *mtex = &brush->mtex;
@@ -343,10 +345,16 @@ static void brush_painter_2d_refresh_cache(BrushPainter *painter, const float po
const int diameter = 2 * BKE_brush_size_get(scene, brush);
const float alpha = BKE_brush_alpha_get(scene, brush);
const bool do_tiled = ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_TILED, MTEX_MAP_MODE_3D);
+ float rotation = -mtex->rot;
+
+ if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
+ rotation += ups->brush_rotation;
+ }
if (diameter != cache->lastsize ||
alpha != cache->lastalpha ||
- brush->jitter != cache->lastjitter)
+ brush->jitter != cache->lastjitter ||
+ rotation != cache->last_rotation)
{
if (cache->ibuf) {
IMB_freeImBuf(cache->ibuf);
@@ -370,6 +378,7 @@ static void brush_painter_2d_refresh_cache(BrushPainter *painter, const float po
cache->lastsize = diameter;
cache->lastalpha = alpha;
cache->lastjitter = brush->jitter;
+ cache->last_rotation = rotation;
}
else if (do_tiled && mtex && mtex->tex) {
int dx = (int)painter->lastpaintpos[0] - (int)pos[0];