[Bf-blender-cvs] [1a676d4] master: Fix related to T45343: UV unwrap giving poor results for some n-gons.

Brecht Van Lommel noreply at git.blender.org
Thu Feb 18 20:06:24 CET 2016


Commit: 1a676d4e0e57647a36c5e98aae56e588da101a2c
Author: Brecht Van Lommel
Date:   Thu Feb 18 04:16:19 2016 +0100
Branches: master
https://developer.blender.org/rB1a676d4e0e57647a36c5e98aae56e588da101a2c

Fix related to T45343: UV unwrap giving poor results for some n-gons.

===================================================================

M	source/blender/editors/uvedit/uvedit_parametrizer.c

===================================================================

diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index e1495b6..95d88aa 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;
 			}
 		}




More information about the Bf-blender-cvs mailing list