diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-03-10 11:51:41 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-03-10 11:51:41 +0300 |
commit | 0e74ed595210373beb4d3c4beb48d99756ff0ca4 (patch) | |
tree | e62159eea0024e4a774388e0bcab296a5df159b3 /source/blender/editors/sculpt_paint | |
parent | d59e208216c4299b2fff0a9749bb21fca51c51d5 (diff) |
fix [#26406] Projection Paint, Occlussion Problem with Intersections in perspective mode.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index d697a3a8856..83f3661ac31 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -512,8 +512,34 @@ static float VecZDepthOrtho(float pt[2], float v1[3], float v2[3], float v3[3], static float VecZDepthPersp(float pt[2], float v1[3], float v2[3], float v3[3], float w[3]) { + float wtot_inv, wtot; + float w_tmp[3]; + barycentric_weights_v2_persp(v1, v2, v3, pt, w); - return (v1[2]*w[0]) + (v2[2]*w[1]) + (v3[2]*w[2]); + /* for the depth we need the weights to match what + * barycentric_weights_v2 would return, in this case its easiest just to + * undo the 4th axis division and make it unit-sum + * + * don't call barycentric_weights_v2() becaue our callers expect 'w' + * to be weighted from the perspective */ + w_tmp[0]= w[0] * v1[3]; + w_tmp[1]= w[1] * v2[3]; + w_tmp[2]= w[2] * v3[3]; + + wtot = w_tmp[0]+w_tmp[1]+w_tmp[2]; + + if (wtot != 0.0f) { + wtot_inv = 1.0f/wtot; + + w_tmp[0] = w_tmp[0]*wtot_inv; + w_tmp[1] = w_tmp[1]*wtot_inv; + w_tmp[2] = w_tmp[2]*wtot_inv; + } + else /* dummy values for zero area face */ + w_tmp[0] = w_tmp[1] = w_tmp[2] = 1.0f/3.0f; + /* done mimicing barycentric_weights_v2() */ + + return (v1[2]*w_tmp[0]) + (v2[2]*w_tmp[1]) + (v3[2]*w_tmp[2]); } |