[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45833] trunk/blender/source/blender/ blenkernel/intern: style cleanup

Campbell Barton ideasman42 at gmail.com
Sun Apr 22 02:20:59 CEST 2012


Revision: 45833
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45833
Author:   campbellbarton
Date:     2012-04-22 00:20:58 +0000 (Sun, 22 Apr 2012)
Log Message:
-----------
style cleanup

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	2012-04-21 22:09:09 UTC (rev 45832)
+++ trunk/blender/source/blender/blenkernel/intern/CCGSubSurf.c	2012-04-22 00:20:58 UTC (rev 45833)
@@ -27,7 +27,7 @@
 
 /***/
 
-typedef unsigned char	byte;
+typedef unsigned char byte;
 
 /***/
 
@@ -50,11 +50,14 @@
 	CCGAllocatorHDL allocator;
 } EHash;
 
-#define EHASH_alloc(eh, nb)			((eh)->allocatorIFC.alloc((eh)->allocator, nb))
-#define EHASH_free(eh, ptr)			((eh)->allocatorIFC.free((eh)->allocator, ptr))
+#define EHASH_alloc(eh, nb)     ((eh)->allocatorIFC.alloc((eh)->allocator, nb))
+#define EHASH_free(eh, ptr)     ((eh)->allocatorIFC.free((eh)->allocator, ptr))
 
-#define EHASH_hash(eh, item)	(((uintptr_t) (item))%((unsigned int) (eh)->curSize))
+#define EHASH_hash(eh, item)    (((uintptr_t) (item)) % ((unsigned int) (eh)->curSize))
 
+static void ccgSubSurf__sync(CCGSubSurf *ss);
+static int _edge_isBoundary(const CCGEdge *e);
+
 static EHash *_ehash_new(int estimatedNumEntries, CCGAllocatorIFC *allocatorIFC, CCGAllocatorHDL allocator)
 {
 	EHash *eh = allocatorIFC->alloc(allocator, sizeof(*eh));
@@ -107,7 +110,7 @@
 		memset(eh->buckets, 0, eh->curSize * sizeof(*eh->buckets));
 
 		while (numBuckets--) {
-			for (entry = oldBuckets[numBuckets]; entry;) {
+			for (entry = oldBuckets[numBuckets]; entry; ) {
 				EHEntry *next = entry->next;
 				
 				hash = EHASH_hash(eh, entry->key);
@@ -125,12 +128,12 @@
 static void *_ehash_lookupWithPrev(EHash *eh, void *key, void ***prevp_r)
 {
 	int hash = EHASH_hash(eh, key);
-	void **prevp = (void**) &eh->buckets[hash];
+	void **prevp = (void **) &eh->buckets[hash];
 	EHEntry *entry;
 	
-	for (; (entry = *prevp); prevp = (void**) &entry->next) {
+	for (; (entry = *prevp); prevp = (void **) &entry->next) {
 		if (entry->key == key) {
-			*prevp_r = (void**) prevp;
+			*prevp_r = (void **) prevp;
 			return entry;
 		}
 	}
@@ -279,7 +282,7 @@
 #define VertDataCopy(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0]  = _b[0]; _a[1]  = _b[1]; _a[2]  = _b[2]; }
 #define VertDataAdd(av, bv)  { float *_a = (float *)av, *_b = (float *) bv; _a[0] += _b[0]; _a[1] += _b[1]; _a[2] += _b[2]; }
 #define VertDataSub(av, bv)  { float *_a = (float *)av, *_b = (float *) bv; _a[0] -= _b[0]; _a[1] -= _b[1]; _a[2] -= _b[2]; }
-#define VertDataMulN(av, n)  { float *_a = (float *)av; _a[0]*=n; _a[1]*=n; _a[2] *=n; }
+#define VertDataMulN(av, n)  { float *_a = (float *)av; _a[0] *= n; _a[1] *= n; _a[2] *= n; }
 #define VertDataAvg4(tv, av, bv, cv, dv) \
 	{ \
 		float *_t = (float *) tv, *_a = (float *) av, *_b = (float *) bv, *_c = (float *) cv, *_d = (float *) dv; \
@@ -291,9 +294,6 @@
 #define NormCopy(av, bv) { float *_a = (float *) av, *_b = (float *) bv; _a[0]  = _b[0]; _a[1]  = _b[1]; _a[2]  = _b[2]; }
 #define NormAdd(av, bv)  { float *_a = (float *) av, *_b = (float *) bv; _a[0] += _b[0]; _a[1] += _b[1]; _a[2] += _b[2]; }
 
-
-static int _edge_isBoundary(const CCGEdge *e);
-
 /***/
 
 enum {
@@ -309,8 +309,8 @@
 } /*FaceFlags*/;
 
 struct CCGVert {
-	CCGVert		*next;	/* EHData.next */
-	CCGVertHDL	vHDL;	/* EHData.key */
+	CCGVert     *next;  /* EHData.next */
+	CCGVertHDL vHDL;    /* EHData.key */
 
 	short numEdges, numFaces, flags, pad;
 
@@ -322,17 +322,17 @@
 
 static CCG_INLINE byte *VERT_getLevelData(CCGVert *v)
 {
-	return (byte*)(&(v)[1]);
+	return (byte *)(&(v)[1]);
 }
 
 struct CCGEdge {
-	CCGEdge		*next;	/* EHData.next */
-	CCGEdgeHDL	eHDL;	/* EHData.key */
+	CCGEdge     *next;  /* EHData.next */
+	CCGEdgeHDL eHDL;    /* EHData.key */
 
 	short numFaces, flags;
 	float crease;
 
-	CCGVert *v0,*v1;
+	CCGVert *v0, *v1;
 	CCGFace **faces;
 
 //	byte *levelData;
@@ -341,12 +341,12 @@
 
 static CCG_INLINE byte *EDGE_getLevelData(CCGEdge *e)
 {
-	return (byte*)(&(e)[1]);
+	return (byte *)(&(e)[1]);
 }
 
 struct CCGFace {
-	CCGFace		*next;	/* EHData.next */
-	CCGFaceHDL	fHDL;	/* EHData.key */
+	CCGFace     *next;  /* EHData.next */
+	CCGFaceHDL fHDL;    /* EHData.key */
 
 	short numVerts, flags, pad1, pad2;
 
@@ -359,17 +359,17 @@
 
 static CCG_INLINE CCGVert **FACE_getVerts(CCGFace *f)
 {
-	return (CCGVert**)(&f[1]);
+	return (CCGVert **)(&f[1]);
 }
 
 static CCG_INLINE CCGEdge **FACE_getEdges(CCGFace *f)
 {
-	return (CCGEdge**)(&(FACE_getVerts(f)[f->numVerts]));
+	return (CCGEdge **)(&(FACE_getVerts(f)[f->numVerts]));
 }
 
 static CCG_INLINE byte *FACE_getCenterData(CCGFace *f)
 {
-	return (byte*)(&(FACE_getEdges(f)[(f)->numVerts]));
+	return (byte *)(&(FACE_getEdges(f)[(f)->numVerts]));
 }
 
 typedef enum {
@@ -381,9 +381,9 @@
 } SyncState;
 
 struct CCGSubSurf {
-	EHash *vMap;	/* map of CCGVertHDL -> Vert */
-	EHash *eMap;	/* map of CCGEdgeHDL -> Edge */
-	EHash *fMap;	/* map of CCGFaceHDL -> Face */
+	EHash *vMap;    /* map of CCGVertHDL -> Vert */
+	EHash *eMap;    /* map of CCGEdgeHDL -> Edge */
+	EHash *fMap;    /* map of CCGFaceHDL -> Face */
 
 	CCGMeshIFC meshIFC;
 	
@@ -398,18 +398,18 @@
 
 	void *q, *r;
 		
-		// data for calc vert normals
+	/* data for calc vert normals */
 	int calcVertNormals;
 	int normalDataOffset;
 
-		// data for age'ing (to debug sync)
+	/* data for age'ing (to debug sync) */
 	int currentAge;
 	int useAgeCounts;
 	int vertUserAgeOffset;
 	int edgeUserAgeOffset;
 	int faceUserAgeOffset;
 
-		// data used during syncing
+	/* data used during syncing */
 	SyncState syncState;
 
 	EHash *oldVMap, *oldEMap, *oldFMap;
@@ -418,9 +418,9 @@
 	CCGEdge **tempEdges;
 };
 
-#define CCGSUBSURF_alloc(ss, nb)			((ss)->allocatorIFC.alloc((ss)->allocator, nb))
-#define CCGSUBSURF_realloc(ss, ptr, nb, ob)	((ss)->allocatorIFC.realloc((ss)->allocator, ptr, nb, ob))
-#define CCGSUBSURF_free(ss, ptr)			((ss)->allocatorIFC.free((ss)->allocator, ptr))
+#define CCGSUBSURF_alloc(ss, nb)            ((ss)->allocatorIFC.alloc((ss)->allocator, nb))
+#define CCGSUBSURF_realloc(ss, ptr, nb, ob) ((ss)->allocatorIFC.realloc((ss)->allocator, ptr, nb, ob))
+#define CCGSUBSURF_free(ss, ptr)            ((ss)->allocatorIFC.free((ss)->allocator, ptr))
 
 /***/
 
@@ -428,9 +428,9 @@
 {
 	int num_vert_data = ss->subdivLevels + 1;
 	CCGVert *v = CCGSUBSURF_alloc(ss,
-								  sizeof(CCGVert) +
-								  ss->meshIFC.vertDataSize * num_vert_data +
-								  ss->meshIFC.vertUserSize);
+	                              sizeof(CCGVert) +
+	                              ss->meshIFC.vertDataSize * num_vert_data +
+	                              ss->meshIFC.vertUserSize);
 	byte *userData;
 
 	v->vHDL = vHDL;
@@ -441,7 +441,7 @@
 
 	userData = ccgSubSurf_getVertUserData(ss, v);
 	memset(userData, 0, ss->meshIFC.vertUserSize);
-	if (ss->useAgeCounts) *((int*) &userData[ss->vertUserAgeOffset]) = ss->currentAge;
+	if (ss->useAgeCounts) *((int *) &userData[ss->vertUserAgeOffset]) = ss->currentAge;
 
 	return v;
 }
@@ -541,7 +541,7 @@
 
 	userData = ccgSubSurf_getEdgeUserData(ss, e);
 	memset(userData, 0, ss->meshIFC.edgeUserSize);
-	if (ss->useAgeCounts) *((int*) &userData[ss->edgeUserAgeOffset]) = ss->currentAge;
+	if (ss->useAgeCounts) *((int *) &userData[ss->edgeUserAgeOffset]) = ss->currentAge;
 
 	return e;
 }
@@ -562,7 +562,7 @@
 }
 static int _edge_isBoundary(const CCGEdge *e)
 {
-	return e->numFaces<2;
+	return e->numFaces < 2;
 }
 
 static CCGVert *_edge_getOtherVert(CCGEdge *e, CCGVert *vQ)
@@ -626,11 +626,11 @@
 {
 	int maxGridSize = ccg_gridsize(ss->subdivLevels);
 	int num_face_data = (numVerts * maxGridSize +
-						 numVerts * maxGridSize * maxGridSize + 1);
+	                     numVerts * maxGridSize * maxGridSize + 1);
 	CCGFace *f = CCGSUBSURF_alloc(ss,
 	                              sizeof(CCGFace) +
-	                              sizeof(CCGVert*) * numVerts +
-	                              sizeof(CCGEdge*) * numVerts +
+	                              sizeof(CCGVert *) * numVerts +
+	                              sizeof(CCGEdge *) * numVerts +
 	                              ss->meshIFC.vertDataSize * num_face_data +
 	                              ss->meshIFC.faceUserSize);
 	byte *userData;
@@ -649,7 +649,7 @@
 
 	userData = ccgSubSurf_getFaceUserData(ss, f);
 	memset(userData, 0, ss->meshIFC.faceUserSize);
-	if (ss->useAgeCounts) *((int*) &userData[ss->faceUserAgeOffset]) = ss->currentAge;
+	if (ss->useAgeCounts) *((int *) &userData[ss->faceUserAgeOffset]) = ss->currentAge;
 
 	return f;
 }
@@ -702,12 +702,12 @@
 
 	eX = eX * spacing;
 	eY = eY * spacing;
-	if (e->v0!=FACE_getVerts(f)[S]) {
+	if (e->v0 != FACE_getVerts(f)[S]) {
 		eX = (maxGridSize * 2 - 1) - 1 - eX;
 	}
 	y = maxGridSize - 1 - eX;
 	x = maxGridSize - 1 - eY;
-	if (x<0) {
+	if (x < 0) {
 		S = (S + f->numVerts - 1) % f->numVerts;
 		cx = y;
 		cy = -x;
@@ -733,8 +733,8 @@
 	float *b = _face_getIFCo(f, lvl, S, x + 1, y + 0, levels, dataSize);
 	float *c = _face_getIFCo(f, lvl, S, x + 1, y + 1, levels, dataSize);
 	float *d = _face_getIFCo(f, lvl, S, x + 0, y + 1, levels, dataSize);
-	float a_cX = c[0]-a[0], a_cY = c[1]-a[1], a_cZ = c[2]-a[2];
-	float b_dX = d[0]-b[0], b_dY = d[1]-b[1], b_dZ = d[2]-b[2];
+	float a_cX = c[0] - a[0], a_cY = c[1] - a[1], a_cZ = c[2] - a[2];
+	float b_dX = d[0] - b[0], b_dY = d[1] - b[1], b_dZ = d[2] - b[2];
 	float length;
 
 	no[0] = b_dY * a_cZ - b_dZ * a_cY;
@@ -779,7 +779,7 @@
 		allocator = NULL;
 	}
 
-	if (subdivLevels<1) {
+	if (subdivLevels < 1) {
 		return NULL;
 	}
 	else {
@@ -881,10 +881,10 @@
 
 CCGError ccgSubSurf_setSubdivisionLevels(CCGSubSurf *ss, int subdivisionLevels)
 {
-	if (subdivisionLevels<=0) {
+	if (subdivisionLevels <= 0) {
 		return eCCGError_InvalidValue;
 	}
-	else if (subdivisionLevels!=ss->subdivLevels) {
+	else if (subdivisionLevels != ss->subdivLevels) {
 		ss->numGrids = 0;
 		ss->subdivLevels = subdivisionLevels;
 		_ehash_free(ss->vMap, (EHEntryFreeFP) _vert_free, ss);
@@ -934,7 +934,7 @@
 CCGError ccgSubSurf_setCalcVertexNormals(CCGSubSurf *ss, int useVertNormals, int normalDataOffset)
 {
 	if (useVertNormals) {
-		if (normalDataOffset<0 || normalDataOffset + 12>ss->meshIFC.vertDataSize) {
+		if (normalDataOffset < 0 || normalDataOffset + 12 > ss->meshIFC.vertDataSize) {
 			return eCCGError_InvalidValue;
 		}
 		else {
@@ -954,7 +954,7 @@
 
 CCGError ccgSubSurf_initFullSync(CCGSubSurf *ss)
 {
-	if (ss->syncState!=eSyncState_None) {
+	if (ss->syncState != eSyncState_None) {
 		return eCCGError_InvalidSyncState;
 	}
 
@@ -981,7 +981,7 @@
 
 CCGError ccgSubSurf_initPartialSync(CCGSubSurf *ss)
 {
-	if (ss->syncState!=eSyncState_None) {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list