diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2013-03-13 07:46:22 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2013-03-13 07:46:22 +0400 |
commit | acd3bef34e6a6b30df694f931dc0c622ca083f59 (patch) | |
tree | 5ed6c71a9d92b3e8a21c44ee69ee59eb39566fff /source/blender/blenkernel/intern/paint.c | |
parent | 153b63e0fde21730cd54f16a501c18c793256ae2 (diff) |
Texture sampling function refactoring:
ALERT! POSSIBLE BREAKING COMMIT, ESPECIALLY FOR SCULPT!
Separate the sculpt sampling function so that it can be reused
from other paint systems. This includes updating of the relevant
coordinates for anchored and rake style brushes, which are now
being updated as part of the stroke system.
I left only code for area-style brush texture mapping in sculpt
code, since it requires a few data structures not present on other
paint systems.
This commit makes it almost as easy to support rake on other systems as
exposing the python UI for it. Also it makes it totally possible to
have texture painting capabilities in vertex paint too :) These commits
will follow very soon.
Also, even if I did my best to keep the code from breaking, (even fixed a
leftover bug from coordinate changes) this is a big change. Please test!
Diffstat (limited to 'source/blender/blenkernel/intern/paint.c')
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index a001a13d000..cc647a90c8f 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -40,6 +40,7 @@ #include "BLI_bitmap.h" #include "BLI_utildefines.h" +#include "BLI_math_vector.h" #include "BKE_brush.h" #include "BKE_context.h" @@ -300,3 +301,22 @@ float paint_grid_paint_mask(const GridPaintMask *gpm, unsigned level, return gpm->data[(y * factor) * gridsize + (x * factor)]; } + +/* threshhold to move before updating the brush rotation */ +#define RAKE_THRESHHOLD 20 + +void paint_calculate_rake_rotation(UnifiedPaintSettings *ups, const float mouse_pos[2]) +{ + const float u = 0.5f; + const float r = RAKE_THRESHHOLD; + + float dpos[2]; + sub_v2_v2v2(dpos, ups->last_rake, mouse_pos); + + if (len_squared_v2(dpos) >= r * r) { + ups->brush_rotation = atan2(dpos[0], dpos[1]); + + interp_v2_v2v2(ups->last_rake, ups->last_rake, + mouse_pos, u); + } +} |