[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26423] trunk/blender/source/blender/ blenkernel/intern: Fix #20505: subsurf normals where not being set correct on correct from

Brecht Van Lommel brecht at blender.org
Sat Jan 30 10:32:05 CET 2010


Revision: 26423
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26423
Author:   blendix
Date:     2010-01-30 10:32:05 +0100 (Sat, 30 Jan 2010)

Log Message:
-----------
Fix #20505: subsurf normals where not being set correct on correct from
subsurf derivedmesh to regular (derived)mesh, causing drawing errors on
apply and following modifiers to work incorrect.

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

Modified: trunk/blender/source/blender/blenkernel/intern/CCGSubSurf.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/CCGSubSurf.c	2010-01-30 09:27:49 UTC (rev 26422)
+++ trunk/blender/source/blender/blenkernel/intern/CCGSubSurf.c	2010-01-30 09:32:05 UTC (rev 26423)
@@ -467,12 +467,10 @@
 	int levelBase = lvl + (1<<lvl) - 1;
 	return &EDGE_getLevelData(e)[dataSize*(levelBase + x)];
 }
-#if 0
 static float *_edge_getNo(CCGEdge *e, int lvl, int x, int dataSize, int normalDataOffset) {
 	int levelBase = lvl + (1<<lvl) - 1;
 	return (float*) &EDGE_getLevelData(e)[dataSize*(levelBase + x) + normalDataOffset];
 }
-#endif
 static void *_edge_getCoVert(CCGEdge *e, CCGVert *v, int lvl, int x, int dataSize) {
 	int levelBase = lvl + (1<<lvl) - 1;
 	if (v==e->v0) {
@@ -535,6 +533,12 @@
 	byte *gridBase = FACE_getCenterData(f) + dataSize*(1 + S*(maxGridSize + maxGridSize*maxGridSize));
 	return &gridBase[dataSize*x*spacing];
 }
+static CCG_INLINE void *_face_getIENo(CCGFace *f, int lvl, int S, int x, int levels, int dataSize, int normalDataOffset) {
+	int maxGridSize = 1 + (1<<(levels-1));
+	int spacing = 1<<(levels-lvl);
+	byte *gridBase = FACE_getCenterData(f) + dataSize*(1 + S*(maxGridSize + maxGridSize*maxGridSize));
+	return &gridBase[dataSize*x*spacing + normalDataOffset];
+}
 static CCG_INLINE void *_face_getIFCo(CCGFace *f, int lvl, int S, int x, int y, int levels, int dataSize) {
 	int maxGridSize = 1 + (1<<(levels-1));
 	int spacing = 1<<(levels-lvl);
@@ -1139,8 +1143,11 @@
 	return eCCGError_None;
 }
 
+#define VERT_getNo(e, lvl)					_vert_getNo(e, lvl, vertDataSize, normalDataOffset)
+#define EDGE_getNo(e, lvl, x)				_edge_getNo(e, lvl, x, vertDataSize, normalDataOffset)
 #define FACE_getIFNo(f, lvl, S, x, y)		_face_getIFNo(f, lvl, S, x, y, subdivLevels, vertDataSize, normalDataOffset)
 #define FACE_calcIFNo(f, lvl, S, x, y, no)	_face_calcIFNo(f, lvl, S, x, y, no, subdivLevels, vertDataSize)
+#define FACE_getIENo(f, lvl, S, x)			_face_getIENo(f, lvl, S, x, subdivLevels, vertDataSize, normalDataOffset)
 static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
 	CCGVert **effectedV, CCGEdge **effectedE, CCGFace **effectedF,
 	int numEffectedV, int numEffectedE, int numEffectedF) {
@@ -1304,8 +1311,28 @@
 					}
 				}
 			}
+
+			VertDataCopy((float*)((byte*)FACE_getCenterData(f) + normalDataOffset),
+				FACE_getIFNo(f, lvl, S, 0, 0));
+
+			for (x=1; x<gridSize-1; x++)
+				NormCopy(FACE_getIENo(f, lvl, S, x),
+					FACE_getIFNo(f, lvl, S, x, 0));
 		}
 	}
+
+	for (ptrIdx=0; ptrIdx<numEffectedE; ptrIdx++) {
+		CCGEdge *e = (CCGEdge*) effectedE[ptrIdx];
+
+		if (e->numFaces) {
+			CCGFace *f = e->faces[0];
+			int x;
+
+			for (x=0; x<edgeSize; x++)
+				NormCopy(EDGE_getNo(e, lvl, x),
+					_face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
+		}
+	}
 }
 #undef FACE_getIFNo
 

Modified: trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c	2010-01-30 09:27:49 UTC (rev 26422)
+++ trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c	2010-01-30 09:32:05 UTC (rev 26423)
@@ -819,7 +819,6 @@
 		for(x = 1; x < edgeSize - 1; x++, i++) {
 			vd= ccgSubSurf_getEdgeData(ss, e, x);
 			copy_v3_v3(mvert[i].co, vd->co);
-			/* TODO CCGSubsurf does not set these */
 			normal_float_to_short_v3(mvert[i].no, vd->no);
 		}
 	}





More information about the Bf-blender-cvs mailing list