[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54525] trunk/blender/source/blender/ editors/uvedit/uvedit_parametrizer.c: Fix #34216: uv unwrap with some faces pinned to point the normals down will now
Brecht Van Lommel
brechtvanlommel at pandora.be
Wed Feb 13 11:38:06 CET 2013
Revision: 54525
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54525
Author: blendix
Date: 2013-02-13 10:38:05 +0000 (Wed, 13 Feb 2013)
Log Message:
-----------
Fix #34216: uv unwrap with some faces pinned to point the normals down will now
automatically flip the unpinned faces to point down too, instead of trying to
unwrap them in the other direction and giving bad results.
If there's a mix of faces pinned up and down it will pick the direction with the
biggest area.
Modified Paths:
--------------
trunk/blender/source/blender/editors/uvedit/uvedit_parametrizer.c
Modified: trunk/blender/source/blender/editors/uvedit/uvedit_parametrizer.c
===================================================================
--- trunk/blender/source/blender/editors/uvedit/uvedit_parametrizer.c 2013-02-13 09:07:34 UTC (rev 54524)
+++ trunk/blender/source/blender/editors/uvedit/uvedit_parametrizer.c 2013-02-13 10:38:05 UTC (rev 54525)
@@ -60,6 +60,7 @@
{ /*printf("Assertion %s:%d\n", __FILE__, __LINE__); abort();*/ } (void)0
#define param_warning(message) \
{ /*printf("Warning %s:%d: %s\n", __FILE__, __LINE__, message);*/ } (void)0
+#if 0
#define param_test_equals_ptr(str, a, b) \
if (a != b) \
{ /*printf("Equals %s => %p != %p\n", str, a, b);*/ } (void)0
@@ -67,6 +68,7 @@
if (a != b) \
{ /*printf("Equals %s => %d != %d\n", str, a, b);*/ } (void)0
#endif
+#endif
typedef enum PBool {
P_TRUE = 1,
P_FALSE = 0
@@ -3047,6 +3049,8 @@
PVert *v, *pin1 = chart->u.lscm.pin1, *pin2 = chart->u.lscm.pin2;
PFace *f;
float *alpha = chart->u.lscm.abf_alpha;
+ float area_pinned_up, area_pinned_down;
+ bool flip_faces;
int row;
nlMakeCurrent(chart->u.lscm.context);
@@ -3085,6 +3089,26 @@
}
}
+ /* detect up direction based on pinned vertices */
+ area_pinned_up = 0.0f;
+ area_pinned_down = 0.0f;
+
+ for (f = chart->faces; f; f = f->nextlink) {
+ PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next;
+ PVert *v1 = e1->vert, *v2 = e2->vert, *v3 = e3->vert;
+
+ if ((v1->flag & PVERT_PIN) && (v2->flag & PVERT_PIN) && (v3->flag & PVERT_PIN)) {
+ float area = p_face_uv_area_signed(f);
+
+ if(area > 0.0f)
+ area_pinned_up += area;
+ else
+ area_pinned_down -= area;
+ }
+ }
+
+ flip_faces = (area_pinned_down > area_pinned_up);
+
/* construct matrix */
nlBegin(NL_MATRIX);
@@ -3105,6 +3129,12 @@
else
p_face_angles(f, &a1, &a2, &a3);
+ if (flip_faces) {
+ SWAP(float, a2, a3);
+ SWAP(PEdge*, e2, e3);
+ SWAP(PVert*, v2, v3);
+ }
+
sina1 = sin(a1);
sina2 = sin(a2);
sina3 = sin(a3);
More information about the Bf-blender-cvs
mailing list