diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2013-08-19 02:44:43 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2013-08-19 02:44:43 +0400 |
commit | d4fde84bbdd144b7a62c77c64db994d1b2f16f2e (patch) | |
tree | 99d5d352705f616cf3dd55e26060a54e1b8098bf /source/blender | |
parent | 676b019846c67d22f92e9496222c771e314c66bb (diff) |
Fix #34485 sculpt strength weirdly inverted with some mesh part.
The view vector was not being calculated correctly. Shamelessly rip off
correct transform to object space from projective texture painting code.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 2edd00c015d..8ab71ff5ddc 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3716,7 +3716,8 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio Brush *brush = BKE_paint_brush(&sd->paint); ViewContext *vc = paint_stroke_view_context(op->customdata); Object *ob = CTX_data_active_object(C); - float rot[3][3], scale[3], loc[3]; + float mat[3][3]; + float viewDir[3] = {0.0f, 0.0f, 1.0f}; int i; int mode; @@ -3784,12 +3785,13 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio /* cache projection matrix */ ED_view3d_ob_project_mat_get(cache->vc->rv3d, ob, cache->projection_mat); - mat4_to_loc_rot_size(loc, rot, scale, ob->obmat); - /* transposing an orthonormal matrix inverts */ - transpose_m3(rot); - ED_view3d_global_to_vector(cache->vc->rv3d, cache->vc->rv3d->twmat[3], cache->true_view_normal); - /* This takes care of rotated mesh. Instead of rotating every normal, we inverse rotate view normal. */ - mul_m3_v3(rot, cache->true_view_normal); + invert_m4_m4(ob->imat, ob->obmat); + copy_m3_m4(mat, cache->vc->rv3d->viewinv); + mul_m3_v3(mat, viewDir); + copy_m3_m4(mat, ob->imat); + mul_m3_v3(mat, viewDir); + normalize_v3_v3(cache->true_view_normal, viewDir); + /* Initialize layer brush displacements and persistent coords */ if (brush->sculpt_tool == SCULPT_TOOL_LAYER) { /* not supported yet for multires or dynamic topology */ |