diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-02-20 17:11:12 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-02-20 17:11:24 +0300 |
commit | 8e955449a80ee7a3663ab0df259303691812ecf3 (patch) | |
tree | 7def9444c13589577e6adf527d47ced5e46abf95 /source | |
parent | d12eba61a590d8885633d8e6ed4ace5fafb01276 (diff) |
Yet another commit to get rid of missing faces in fill brushes.
We are now guarding against some divisions by small values.
There are still issues here but they are not on boundary faces
anymore so they must be related to some other issue such as
the triangle intersection test.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_proj.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index cd72849cc12..b6de4465149 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -2004,24 +2004,32 @@ static bool line_rect_clip( float uv[2], bool is_ortho) { float min = FLT_MAX, tmp; - if ((l1[0] - rect->xmin) * (l2[0] - rect->xmin) < 0) { - tmp = rect->xmin; - min = min_ff((tmp - l1[0]) / (l2[0] - l1[0]), min); - } - else if ((l1[0] - rect->xmax) * (l2[0] - rect->xmax) < 0) { - tmp = rect->xmax; - min = min_ff((tmp - l1[0]) / (l2[0] - l1[0]), min); - } - if ((l1[1] - rect->ymin) * (l2[1] - rect->ymin) < 0) { - tmp = rect->ymin; - min = min_ff((tmp - l1[1]) / (l2[1] - l1[1]), min); + float xlen = l2[0] - l1[0]; + float ylen = l2[1] - l1[1]; + + /* 0.1 might seem too much, but remember, this is pixels! */ + if (xlen > 0.1f) { + if ((l1[0] - rect->xmin) * (l2[0] - rect->xmin) <= 0) { + tmp = rect->xmin; + min = min_ff((tmp - l1[0]) / xlen, min); + } + else if ((l1[0] - rect->xmax) * (l2[0] - rect->xmax) < 0) { + tmp = rect->xmax; + min = min_ff((tmp - l1[0]) / xlen, min); + } } - else if ((l1[1] - rect->ymax) * (l2[1] - rect->ymax) < 0) { - tmp = rect->ymax; - min = min_ff((tmp - l1[1]) / (l2[1] - l1[1]), min); + + if (ylen > 0.1f) { + if ((l1[1] - rect->ymin) * (l2[1] - rect->ymin) <= 0) { + tmp = rect->ymin; + min = min_ff((tmp - l1[1]) / ylen, min); + } + else if ((l1[1] - rect->ymax) * (l2[1] - rect->ymax) < 0) { + tmp = rect->ymax; + min = min_ff((tmp - l1[1]) / ylen, min); + } } - - /* it's rare but it can happen if l1 == l2 */ + if (min == FLT_MAX) return false; @@ -2085,7 +2093,7 @@ static void project_bucket_clip_face( int flag; (*tot) = 0; - + if (cull) return; |