From 3ac2028df0c4e6e30135b79537e3f0af8e59382f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 25 Apr 2016 22:15:50 +1000 Subject: Fix T48202: Project paint hangs on UV's w/ sharp corners Using 'shell-thickness' to offset UV's meant very sharp corners would offset far outside the image causing project-paint to hang while collecting all pixels for each UV face. Clamp the maximum offset to prevent this. --- source/blender/editors/sculpt_paint/paint_image_proj.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index b8693639673..f614025fa0e 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -1100,6 +1100,10 @@ static void uv_image_outset( float (*orig_uv)[2], float (*outset_uv)[2], const float scaler, const int ibuf_x, const int ibuf_y, const bool cw) { + /* disallow shell-thickness to outset extreme values, + * otherwise near zero area UV's may extend thousands of pixels. */ + const float scale_clamp = 5.0f; + float a1, a2, a3; float puv[3][2]; /* pixelspace uv's */ float no1[2], no2[2], no3[2]; /* normals */ @@ -1150,6 +1154,10 @@ static void uv_image_outset( a2 = shell_v2v2_normal_dir_to_dist(no2, dir1); a3 = shell_v2v2_normal_dir_to_dist(no3, dir2); + CLAMP_MAX(a1, scale_clamp); + CLAMP_MAX(a2, scale_clamp); + CLAMP_MAX(a3, scale_clamp); + mul_v2_fl(no1, a1 * scaler); mul_v2_fl(no2, a2 * scaler); mul_v2_fl(no3, a3 * scaler); -- cgit v1.2.3