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
This commit is contained in:
@@ -546,6 +546,11 @@ class VIEW3D_PT_tools_brush(PaintPanel, Panel):
|
||||
row.prop(brush, "strength", text="Strength", slider=True)
|
||||
row.prop(brush, "use_pressure_strength", text="")
|
||||
|
||||
if tool == 'ROTATE':
|
||||
row = col.row(align=True)
|
||||
row.prop(brush, "strength", text="Strength", slider=True)
|
||||
row.prop(brush, "use_pressure_strength", text="")
|
||||
|
||||
if tool != 'SMOOTH':
|
||||
col.separator()
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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! */
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user