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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2016-02-18 06:16:19 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2016-02-18 22:05:56 +0300
commit1a676d4e0e57647a36c5e98aae56e588da101a2c (patch)
tree8cab4cf85e633df2dedc0d1eae7b2404aff58936 /source/blender/editors/uvedit/uvedit_parametrizer.c
parentda81227e54e23d1f7e6c0c55c2ff939db2ee30a6 (diff)
Fix related to T45343: UV unwrap giving poor results for some n-gons.
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_parametrizer.c')
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index e1495b617f8..95d88aaa0a9 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -4166,6 +4166,7 @@ static void p_add_ngon(ParamHandle *handle, ParamKey key, int nverts,
while (nverts > 2) {
float minangle = FLT_MAX;
+ float minshape = FLT_MAX;
int i, mini = 0;
/* find corner with smallest angle */
@@ -4181,8 +4182,20 @@ static void p_add_ngon(ParamHandle *handle, ParamKey key, int nverts,
if (normal && (dot_v3v3(n, normal) < 0.0f))
angle = (float)(2.0 * M_PI) - angle;
- if (angle < minangle) {
+ float other_angle = p_vec_angle(co[v2], co[v0], co[v1]);
+ float shape = fabsf(M_PI - angle - 2.0f * other_angle);
+
+ if (fabsf(angle - minangle) < 0.01f) {
+ /* for nearly equal angles, try to get well shaped triangles */
+ if (shape < minshape) {
+ minangle = angle;
+ minshape = shape;
+ mini = i;
+ }
+ }
+ else if (angle < minangle) {
minangle = angle;
+ minshape = shape;
mini = i;
}
}