diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_blender.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_paint.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/brush.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 47 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/texture.c | 2 |
5 files changed, 44 insertions, 15 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 2701dc3465c..b27f1a6775e 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 273 -#define BLENDER_SUBVERSION 0 +#define BLENDER_SUBVERSION 1 /* 262 was the last editmesh release but it has compatibility code for bmesh data */ #define BLENDER_MINVERSION 270 #define BLENDER_MINSUBVERSION 5 diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index b080ca37e67..8cf6fdcfeea 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -143,7 +143,7 @@ float paint_grid_paint_mask(const struct GridPaintMask *gpm, unsigned level, unsigned x, unsigned y); /* stroke related */ -void paint_calculate_rake_rotation(struct UnifiedPaintSettings *ups, const float mouse_pos[2]); +void paint_calculate_rake_rotation(struct UnifiedPaintSettings *ups, struct Brush *brush, const float mouse_pos[2]); /* Session data (mode-specific) */ diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 92f66cdde76..cdbcffe0ce4 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -298,7 +298,6 @@ void BKE_brush_debug_print_state(Brush *br) BR_TEST_FLAG(BRUSH_SIZE_PRESSURE); BR_TEST_FLAG(BRUSH_JITTER_PRESSURE); BR_TEST_FLAG(BRUSH_SPACING_PRESSURE); - BR_TEST_FLAG(BRUSH_RAKE); BR_TEST_FLAG(BRUSH_ANCHORED); BR_TEST_FLAG(BRUSH_DIR_IN); BR_TEST_FLAG(BRUSH_SPACE); @@ -314,7 +313,6 @@ void BKE_brush_debug_print_state(Brush *br) BR_TEST_FLAG(BRUSH_EDGE_TO_EDGE); BR_TEST_FLAG(BRUSH_DRAG_DOT); BR_TEST_FLAG(BRUSH_INVERSE_SMOOTH_PRESSURE); - BR_TEST_FLAG(BRUSH_RANDOM_ROTATION); BR_TEST_FLAG(BRUSH_PLANE_TRIM); BR_TEST_FLAG(BRUSH_FRONTFACE); BR_TEST_FLAG(BRUSH_CUSTOM_ICON); @@ -700,7 +698,7 @@ float BKE_brush_sample_masktex(const Scene *scene, Brush *br, if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) { /* keep coordinates relative to mouse */ - rotation += ups->brush_rotation; + rotation += ups->brush_rotation_sec; x = point_2d[0] - ups->mask_tex_mouse[0]; y = point_2d[1] - ups->mask_tex_mouse[1]; @@ -718,7 +716,7 @@ float BKE_brush_sample_masktex(const Scene *scene, Brush *br, y = point_2d[1]; } else if (mtex->brush_map_mode == MTEX_MAP_MODE_RANDOM) { - rotation += ups->brush_rotation; + rotation += ups->brush_rotation_sec; /* these contain a random coordinate */ x = point_2d[0] - ups->mask_tex_mouse[0]; y = point_2d[1] - ups->mask_tex_mouse[1]; 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; } } diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 7ce08ac649f..a6536099c50 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -755,6 +755,8 @@ void default_mtex(MTex *mtex) mtex->fieldfac = 1.0f; mtex->normapspace = MTEX_NSPACE_TANGENT; mtex->brush_map_mode = MTEX_MAP_MODE_TILED; + mtex->random_angle = 2.0f * M_PI; + mtex->brush_angle_mode = 0; } |