Fix T39429: Project paint error with UV bleed

This commit is contained in:
Campbell Barton 2014-04-23 04:23:54 +10:00
parent a892cf683b
commit f2c483d108
Notes: blender-bot 2023-02-14 10:54:28 +01:00
Referenced by issue #39847, Crash on undo or reopening a file
Referenced by issue #39429, Strange strip when painting
4 changed files with 46 additions and 14 deletions

View File

@ -319,6 +319,8 @@ MINLINE int poly_to_tri_count(const int poly_count, const int corner_count);
MINLINE float shell_angle_to_dist(const float angle);
MINLINE float shell_v3v3_normalized_to_dist(const float a[3], const float b[3]);
MINLINE float shell_v2v2_normalized_to_dist(const float a[2], const float b[2]);
MINLINE float shell_v3v3_mid_normalized_to_dist(const float a[3], const float b[3]);
MINLINE float shell_v2v2_mid_normalized_to_dist(const float a[2], const float b[2]);
/**************************** Inline Definitions ******************************/

View File

@ -259,6 +259,34 @@ MINLINE float shell_v2v2_normalized_to_dist(const float a[2], const float b[2])
return (UNLIKELY(angle_cos < SMALL_NUMBER)) ? 1.0f : (1.0f / angle_cos);
}
/**
* equivalent to ``shell_angle_to_dist(angle_normalized_v3v3(a, b) / 2)``
*/
MINLINE float shell_v3v3_mid_normalized_to_dist(const float a[3], const float b[3])
{
float angle_cos;
float ab[3];
BLI_ASSERT_UNIT_V3(a);
BLI_ASSERT_UNIT_V3(b);
add_v3_v3v3(ab, a, b);
angle_cos = (normalize_v3(ab) != 0.0f) ? fabsf(dot_v3v3(a, ab)) : 0.0f;
return (UNLIKELY(angle_cos < SMALL_NUMBER)) ? 1.0f : (1.0f / angle_cos);
}
/**
* equivalent to ``shell_angle_to_dist(angle_normalized_v2v2(a, b) / 2)``
*/
MINLINE float shell_v2v2_mid_normalized_to_dist(const float a[2], const float b[2])
{
float angle_cos;
float ab[2];
BLI_ASSERT_UNIT_V2(a);
BLI_ASSERT_UNIT_V2(b);
add_v2_v2v2(ab, a, b);
angle_cos = (normalize_v2(ab) != 0.0f) ? fabsf(dot_v2v2(a, ab)) : 0.0f;
return (UNLIKELY(angle_cos < SMALL_NUMBER)) ? 1.0f : (1.0f / angle_cos);
}
#undef SMALL_NUMBER
#endif /* __MATH_GEOM_INLINE_C__ */

View File

@ -201,7 +201,7 @@ static void bmo_face_inset_individual(
copy_v3_v3(v_new_co, l_iter->v->co);
if (use_even_offset) {
mul_v3_fl(tvec, shell_angle_to_dist(angle_normalized_v3v3(eno_prev, eno_next) / 2.0f));
mul_v3_fl(tvec, shell_v3v3_mid_normalized_to_dist(eno_prev, eno_next));
}
/* Modify vertices and their normals */
@ -694,14 +694,16 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
/* scale by edge angle */
if (use_even_offset) {
if (is_mid) {
mul_v3_fl(tvec, shell_angle_to_dist(angle_normalized_v3v3(e_info_a->no,
e_info_b->no) / 2.0f));
mul_v3_fl(tvec, shell_v3v3_mid_normalized_to_dist(e_info_a->no,
e_info_b->no));
}
else {
mul_v3_fl(tvec, shell_angle_to_dist(max_ff(angle_normalized_v3v3(tvec,
e_info_a->no),
angle_normalized_v3v3(tvec,
e_info_b->no))));
/* use the largest angle */
mul_v3_fl(tvec,
shell_v3v3_normalized_to_dist(tvec,
len_squared_v3v3(tvec, e_info_a->no) >
len_squared_v3v3(tvec, e_info_b->no) ?
e_info_a->no : e_info_b->no));
}
}

View File

@ -963,15 +963,15 @@ static void uv_image_outset(float (*orig_uv)[2], float (*outset_uv)[2], const fl
}
if (is_quad) {
a1 = shell_v2v2_normalized_to_dist(dir4, dir1);
a2 = shell_v2v2_normalized_to_dist(dir1, dir2);
a3 = shell_v2v2_normalized_to_dist(dir2, dir3);
a4 = shell_v2v2_normalized_to_dist(dir3, dir4);
a1 = shell_v2v2_mid_normalized_to_dist(dir4, dir1);
a2 = shell_v2v2_mid_normalized_to_dist(dir1, dir2);
a3 = shell_v2v2_mid_normalized_to_dist(dir2, dir3);
a4 = shell_v2v2_mid_normalized_to_dist(dir3, dir4);
}
else {
a1 = shell_v2v2_normalized_to_dist(dir3, dir1);
a2 = shell_v2v2_normalized_to_dist(dir1, dir2);
a3 = shell_v2v2_normalized_to_dist(dir2, dir3);
a1 = shell_v2v2_mid_normalized_to_dist(dir3, dir1);
a2 = shell_v2v2_mid_normalized_to_dist(dir1, dir2);
a3 = shell_v2v2_mid_normalized_to_dist(dir2, dir3);
}
if (is_quad) {