From b30da4d58f4f5b24f902d8f2fa7d04e4406536ac Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 24 Aug 2012 13:29:48 +0000 Subject: Fix #32198: UV unwrap of half a UV sphere would not give a perfect sphere as a result. This wasn't really guaranteed anyway, because of numerical precision and possible asymmetry in the triangulation, but we can do a bit better. Now we bias the choice of how to split a quad into two triangles slightly towards one of two possibilities, so that in case they are equal, floating point errors do not decide the direction and symmetry is preserved. --- source/blender/editors/uvedit/uvedit_parametrizer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/uvedit') diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 2161d4989db..72c38be5398 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -1135,7 +1135,11 @@ static PFace *p_face_add_fill(PChart *chart, PVert *v1, PVert *v2, PVert *v3) static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys) { - float fac = len_v3v3(co[0], co[2]) - len_v3v3(co[1], co[3]); + /* slight bias to prefer one edge over the other in case they are equal, so + * that in symmetric models we choose the same split direction instead of + * depending on floating point errors to decide */ + float bias = 1.0f + 1e-6f; + float fac = len_v3v3(co[0], co[2])*bias - len_v3v3(co[1], co[3]); PBool dir = (fac <= 0.0f); /* the face exists check is there because of a special case: when -- cgit v1.2.3