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/blenkernel/intern/brush.c
parent1ea16dcf9b5337a7f8983a09d7f92b6164a7670f (diff)
Support for rake in 2D image painting.
Diffstat (limited to 'source/blender/blenkernel/intern/brush.c')
-rw-r--r--source/blender/blenkernel/intern/brush.c28
1 files changed, 25 insertions, 3 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);