[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45571] trunk/blender/source/blender/ blenkernel/intern/subsurf_ccg.c: Fix: subsurf UV was not working correct with n-gons, it still had hardcoded

Brecht Van Lommel brechtvanlommel at pandora.be
Thu Apr 12 14:23:25 CEST 2012


Revision: 45571
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45571
Author:   blendix
Date:     2012-04-12 12:23:25 +0000 (Thu, 12 Apr 2012)
Log Message:
-----------
Fix: subsurf UV was not working correct with n-gons, it still had hardcoded
4 vertices per face code in some places.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c

Modified: trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c	2012-04-12 12:11:21 UTC (rev 45570)
+++ trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c	2012-04-12 12:23:25 UTC (rev 45571)
@@ -238,10 +238,10 @@
 	}
 }
 
-static void get_face_uv_map_vert(UvVertMap *vmap, struct MPoly *mp, struct MLoop *ml, int fi, CCGVertHDL *fverts)
+static void get_face_uv_map_vert(UvVertMap *vmap, struct MPoly *mpoly, struct MLoop *ml, int fi, CCGVertHDL *fverts)
 {
 	UvMapVert *v, *nv;
-	int j, nverts= mp->totloop;
+	int j, nverts= mpoly[fi].totloop;
 
 	for (j=0; j<nverts; j++) {
 		for (nv=v=get_uv_map_vert(vmap, ml[j].v); v; v=v->next) {
@@ -251,7 +251,7 @@
 				break;
 		}
 
-		fverts[j]= SET_INT_IN_POINTER(nv->f*4 + nv->tfindex);
+		fverts[j]= SET_INT_IN_POINTER(mpoly[nv->f].loopstart + nv->tfindex);
 	}
 }
 
@@ -293,9 +293,10 @@
 		for (v=get_uv_map_vert(vmap, i); v; v=v->next) {
 			if (v->separate) {
 				CCGVert *ssv;
-				CCGVertHDL vhdl = SET_INT_IN_POINTER(v->f*4 + v->tfindex);
+				int loopid = mpoly[v->f].loopstart + v->tfindex;
+				CCGVertHDL vhdl = SET_INT_IN_POINTER(loopid);
 
-				copy_v2_v2(uv, mloopuv[mpoly[v->f].loopstart + v->tfindex].uv);
+				copy_v2_v2(uv, mloopuv[loopid].uv);
 
 				ccgSubSurf_syncVert(ss, vhdl, uv, seam, &ssv);
 			}
@@ -315,7 +316,7 @@
 		BLI_array_empty(fverts);
 		BLI_array_growitems(fverts, nverts);
 
-		get_face_uv_map_vert(vmap, mp, ml, i, fverts);
+		get_face_uv_map_vert(vmap, mpoly, ml, i, fverts);
 
 		for (j=0; j<nverts; j++) {
 			int v0 = GET_INT_FROM_POINTER(fverts[j]);
@@ -325,7 +326,7 @@
 
 			if (!BLI_edgehash_haskey(ehash, v0, v1)) {
 				CCGEdge *e, *orige= ccgSubSurf_getFaceEdge(origf, j);
-				CCGEdgeHDL ehdl= SET_INT_IN_POINTER(i*4 + j);
+				CCGEdgeHDL ehdl= SET_INT_IN_POINTER(mp->loopstart + j);
 				float crease;
 
 				if ((mv0->flag&mv1->flag) & ME_VERT_MERGED)
@@ -351,7 +352,7 @@
 		BLI_array_empty(fverts);
 		BLI_array_growitems(fverts, nverts);
 
-		get_face_uv_map_vert(vmap, mp, ml, i, fverts);
+		get_face_uv_map_vert(vmap, mpoly, ml, i, fverts);
 		ccgSubSurf_syncFace(ss, SET_INT_IN_POINTER(i), nverts, fverts, &f);
 	}
 




More information about the Bf-blender-cvs mailing list