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.
This commit is contained in:
Campbell Barton 2016-04-25 22:15:50 +10:00
parent 42fd1b9abe
commit 3ac2028df0
Notes: blender-bot 2023-06-07 10:31:13 +02:00
Referenced by issue #48202, Texture paint in the 3d View will crash, if you not check "Clamp Overlap" in the Bevel modifier
1 changed files with 8 additions and 0 deletions

View File

@ -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);