Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-04-22 22:23:54 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-04-22 22:33:07 +0400
commitf2c483d108a33cb30f3f9c984c289e98a25ce5c2 (patch)
tree130f3e05dc45de7603a222c417a281c4efa0c65b /source/blender
parenta892cf683be27b15a87ae0d9c21b5ed512497a1a (diff)
Fix T39429: Project paint error with UV bleed
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenlib/BLI_math_geom.h2
-rw-r--r--source/blender/blenlib/intern/math_geom_inline.c28
-rw-r--r--source/blender/bmesh/operators/bmo_inset.c16
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c14
4 files changed, 46 insertions, 14 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 6000b8d5f23..f4bcc810846 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -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 ******************************/
diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c
index 1e54dd11a76..5a64ed63ecf 100644
--- a/source/blender/blenlib/intern/math_geom_inline.c
+++ b/source/blender/blenlib/intern/math_geom_inline.c
@@ -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__ */
diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c
index a23f8f33b71..5e2e057c5b6 100644
--- a/source/blender/bmesh/operators/bmo_inset.c
+++ b/source/blender/bmesh/operators/bmo_inset.c
@@ -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));
}
}
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 5ad391913cb..af88ff11dac 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -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) {