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-27 01:51:27 +0300
committerAntony Riakiotakis <kalast@gmail.com>2014-12-27 01:51:27 +0300
commitc7c10e5e283879961356050ba8a965d2239456b8 (patch)
treed89d06ca30d51087a9d958f66bbf240bd3c7807e /source/blender/blenkernel/intern/paint.c
parente0cf86a9e219dcd71e5d67b8f2999d41e7f8c492 (diff)
Brush Texture Angle Goodies:
This commit includes a few things: * It moves the Rake and Random flags from the brush to the MTex. * The first change allows mask textures to have independent rake support. * Random rotation now has an angle value that controls the width of the effect from the rake or default angle * Rake and Random are now supported together.
Diffstat (limited to 'source/blender/blenkernel/intern/paint.c')
-rw-r--r--source/blender/blenkernel/intern/paint.c47
1 files changed, 38 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 96fff339521..5f3b9f04bf2 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -477,19 +477,48 @@ float paint_grid_paint_mask(const GridPaintMask *gpm, unsigned level,
/* threshold to move before updating the brush rotation */
#define RAKE_THRESHHOLD 20
-void paint_calculate_rake_rotation(UnifiedPaintSettings *ups, const float mouse_pos[2])
+static void update_brush_rake_rotation(UnifiedPaintSettings *ups, Brush *brush, float rotation)
{
- const float u = 0.5f;
- const float r = RAKE_THRESHHOLD;
+ if (brush->mtex.brush_angle_mode & MTEX_ANGLE_RAKE)
+ ups->brush_rotation = rotation;
+ else
+ ups->brush_rotation = 0.0f;
- float dpos[2];
- sub_v2_v2v2(dpos, ups->last_rake, mouse_pos);
+ if (brush->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE)
+ /* here, translation contains the mouse coordinates. */
+ ups->brush_rotation_sec = rotation;
+ else
+ ups->brush_rotation_sec = 0.0f;
+}
+
+void paint_calculate_rake_rotation(UnifiedPaintSettings *ups, Brush *brush, const float mouse_pos[2])
+{
+ if ((brush->mtex.brush_angle_mode & MTEX_ANGLE_RAKE) || (brush->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) {
+ const float u = 0.5f;
+ const float r = RAKE_THRESHHOLD;
+ float rotation;
+
+ float dpos[2];
+ sub_v2_v2v2(dpos, ups->last_rake, mouse_pos);
+
+ if (len_squared_v2(dpos) >= r * r) {
+ rotation = atan2f(dpos[0], dpos[1]);
+
+ interp_v2_v2v2(ups->last_rake, ups->last_rake,
+ mouse_pos, u);
- if (len_squared_v2(dpos) >= r * r) {
- ups->brush_rotation = atan2f(dpos[0], dpos[1]);
+ ups->last_rake_angle = rotation;
- interp_v2_v2v2(ups->last_rake, ups->last_rake,
- mouse_pos, u);
+ update_brush_rake_rotation(ups, brush, rotation);
+ }
+ /* make sure we reset here to the last rotation to avoid accumulating
+ * values in case a random rotation is also added */
+ else {
+ update_brush_rake_rotation(ups, brush, ups->last_rake_angle);
+ }
+ }
+ else {
+ ups->brush_rotation = ups->brush_rotation_sec =0.0f;
}
}