diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-10 18:45:30 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-10 18:45:30 +0400 |
commit | a912afd202ecfdd0b459d85fba18280c38b0062f (patch) | |
tree | 246fb8565e354ea94d9f4a7ac7ff0494f3bf5bd7 /source/blender | |
parent | e9a0a42dd3493c1a4456696cc6912b34a8548b25 (diff) |
Fix #29516: Twist brush giving crazy results
- Rotation now happens around initial stroke location rather than around scene origin
- Added slider for rotation strength which helps in cases only few rotation is needed
to be to increase the precision of such strokes
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_blender.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/brush.c | 1 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 10 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 19 |
4 files changed, 26 insertions, 6 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 257a550edb4..1e679d6fe4b 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 260 -#define BLENDER_SUBVERSION 7 +#define BLENDER_SUBVERSION 8 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 7fac273ef77..2bf80fb7ecc 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -384,6 +384,7 @@ void brush_reset_sculpt(Brush *br) br->sub_col[1] = 1.000000; break; case SCULPT_TOOL_ROTATE: + br->alpha = 1.0; break; case SCULPT_TOOL_SMOOTH: br->flag &= ~BRUSH_SPACE_ATTEN; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 13e2ed49e6a..1ada2448d86 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -12655,6 +12655,16 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 8)) + { + Brush *brush; + + for (brush= main->brush.first; brush; brush= brush->id.next) { + if (brush->sculpt_tool == SCULPT_TOOL_ROTATE) + brush->alpha= 1.0f; + } + } + /* put compatibility code here until next subversion bump */ { /* nothing! */ diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index a63a9256055..b84fea29e62 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -648,9 +648,11 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather) return feather; case SCULPT_TOOL_GRAB: - case SCULPT_TOOL_ROTATE: return feather; + case SCULPT_TOOL_ROTATE: + return alpha*pressure*feather; + default: return 0; } @@ -1502,13 +1504,20 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod float bstrength= ss->cache->bstrength; float an[3]; int n; - float m[3][3]; + float m[4][4], rot[4][4], lmat[4][4], ilmat[4][4]; static const int flip[8] = { 1, -1, -1, 1, -1, 1, 1, -1 }; float angle = ss->cache->vertex_rotation * flip[ss->cache->mirror_symmetry_pass]; calc_sculpt_normal(sd, ob, an, nodes, totnode); - axis_angle_to_mat3(m, an, angle); + unit_m4(m); + unit_m4(lmat); + + copy_v3_v3(lmat[3], ss->cache->location); + invert_m4_m4(ilmat, lmat); + axis_angle_to_mat4(rot, an, angle); + + mul_serie_m4(m, lmat, rot, ilmat, NULL, NULL, NULL, NULL, NULL); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for(n=0; n<totnode; n++) { @@ -1532,7 +1541,7 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist, an, origno[vd.i], NULL); - mul_v3_m3v3(proxy[vd.i], m, origco[vd.i]); + mul_v3_m4v3(proxy[vd.i], m, origco[vd.i]); sub_v3_v3(proxy[vd.i], origco[vd.i]); mul_v3_fl(proxy[vd.i], fade); @@ -3160,7 +3169,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, st dx = cache->mouse[0] - cache->initial_mouse[0]; dy = cache->mouse[1] - cache->initial_mouse[1]; - cache->vertex_rotation = -atan2(dx, dy); + cache->vertex_rotation = -atan2(dx, dy) * cache->bstrength; sd->draw_anchored = 1; copy_v2_v2(sd->anchored_initial_mouse, cache->initial_mouse); |