[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45674] trunk/blender/source/blender/ blenlib/intern/scanfill.c: style cleanup: scanfill, spelling and use NULL rather then 0

Campbell Barton ideasman42 at gmail.com
Mon Apr 16 07:23:40 CEST 2012


Revision: 45674
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45674
Author:   campbellbarton
Date:     2012-04-16 05:23:40 +0000 (Mon, 16 Apr 2012)
Log Message:
-----------
style cleanup: scanfill, spelling and use NULL rather then 0

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/scanfill.c

Modified: trunk/blender/source/blender/blenlib/intern/scanfill.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/scanfill.c	2012-04-16 05:03:04 UTC (rev 45673)
+++ trunk/blender/source/blender/blenlib/intern/scanfill.c	2012-04-16 05:23:40 UTC (rev 45674)
@@ -45,7 +45,7 @@
 #include "BLI_threads.h"
 
 /* callbacks for errors and interrupts and some goo */
-static void (*BLI_localErrorCallBack)(const char*) = NULL;
+static void (*BLI_localErrorCallBack)(const char *) = NULL;
 static int (*BLI_localInterruptCallBack)(void) = NULL;
 
 void BLI_setErrorCallBack(void (*f)(const char *))
@@ -59,7 +59,7 @@
 }
 
 /* just flush the error to /dev/null if the error handler is missing */
-void callLocalErrorCallBack(const char* msg)
+void callLocalErrorCallBack(const char *msg)
 {
 	if (BLI_localErrorCallBack) {
 		BLI_localErrorCallBack(msg);
@@ -81,9 +81,9 @@
 
 /* local types */
 typedef struct PolyFill {
-	int edges,verts;
-	float min[3],max[3];
-	short f,nr;
+	int edges, verts;
+	float min[3], max[3];
+	short f, nr;
 } PolyFill;
 
 typedef struct ScanFillVertLink {
@@ -94,7 +94,7 @@
 
 /* local funcs */
 
-#define COMPLIMIT	0.00003
+#define COMPLIMIT   0.00003f
 
 static ScanFillVertLink *scdata;
 
@@ -104,29 +104,29 @@
 
 static int cox, coy;
 
-/* ****  FUBCTIONS FOR QSORT *************************** */
+/* ****  FUNCTIONS FOR QSORT *************************** */
 
 
 static int vergscdata(const void *a1, const void *a2)
 {
-	const ScanFillVertLink *x1=a1,*x2=a2;
+	const ScanFillVertLink *x1 = a1, *x2 = a2;
 	
-	if ( x1->v1->co[coy] < x2->v1->co[coy] ) return 1;
-	else if ( x1->v1->co[coy] > x2->v1->co[coy]) return -1;
-	else if ( x1->v1->co[cox] > x2->v1->co[cox] ) return 1;
-	else if ( x1->v1->co[cox] < x2->v1->co[cox]) return -1;
+	if      (x1->v1->co[coy] < x2->v1->co[coy]) return  1;
+	else if (x1->v1->co[coy] > x2->v1->co[coy]) return -1;
+	else if (x1->v1->co[cox] > x2->v1->co[cox]) return  1;
+	else if (x1->v1->co[cox] < x2->v1->co[cox]) return -1;
 
 	return 0;
 }
 
 static int vergpoly(const void *a1, const void *a2)
 {
-	const PolyFill *x1=a1, *x2=a2;
+	const PolyFill *x1 = a1, *x2 = a2;
 
-	if ( x1->min[cox] > x2->min[cox] ) return 1;
-	else if ( x1->min[cox] < x2->min[cox] ) return -1;
-	else if ( x1->min[coy] > x2->min[coy] ) return 1;
-	else if ( x1->min[coy] < x2->min[coy] ) return -1;
+	if      (x1->min[cox] > x2->min[cox]) return  1;
+	else if (x1->min[cox] < x2->min[cox]) return -1;
+	else if (x1->min[coy] > x2->min[coy]) return  1;
+	else if (x1->min[coy] < x2->min[coy]) return -1;
 	
 	return 0;
 }
@@ -144,27 +144,27 @@
  * free in the end, with argument '-1'
  */
 #define MEM_ELEM_BLOCKSIZE 16384
-static struct mem_elements *  melem__cur= NULL;
-static int                    melem__offs= 0; /* the current free address */
-static ListBase               melem__lb= {NULL, NULL};
+static struct mem_elements *melem__cur = NULL;
+static int melem__offs = 0;                   /* the current free address */
+static ListBase melem__lb = {NULL, NULL};
 
 static void *mem_element_new(int size)
 {
-	BLI_assert(!(size>10000 || size==0)); /* this is invalid use! */
+	BLI_assert(!(size > 10000 || size == 0)); /* this is invalid use! */
 
-	size = (size + 3 ) & ~3; 	/* allocate in units of 4 */
+	size = (size + 3) & ~3;     /* allocate in units of 4 */
 	
 	if (melem__cur && (size + melem__offs < MEM_ELEM_BLOCKSIZE)) {
-		void *adr= (void *) (melem__cur->data+melem__offs);
-		 melem__offs+= size;
+		void *adr = (void *) (melem__cur->data + melem__offs);
+		melem__offs += size;
 		return adr;
 	}
 	else {
-		melem__cur= MEM_callocN( sizeof(struct mem_elements), "newmem");
-		melem__cur->data= MEM_callocN(MEM_ELEM_BLOCKSIZE, "newmem");
+		melem__cur = MEM_callocN(sizeof(struct mem_elements), "newmem");
+		melem__cur->data = MEM_callocN(MEM_ELEM_BLOCKSIZE, "newmem");
 		BLI_addtail(&melem__lb, melem__cur);
 
-		melem__offs= size;
+		melem__offs = size;
 		return melem__cur->data;
 	}
 }
@@ -172,15 +172,15 @@
 {
 	struct mem_elements *first;
 
-	if ((first= melem__lb.first)) { /* can be false if first fill fails */
+	if ((first = melem__lb.first)) { /* can be false if first fill fails */
 		if (keep_first) {
 			BLI_remlink(&melem__lb, first);
 		}
 
-		melem__cur= melem__lb.first;
+		melem__cur = melem__lb.first;
 		while (melem__cur) {
 			MEM_freeN(melem__cur->data);
-			melem__cur= melem__cur->next;
+			melem__cur = melem__cur->next;
 		}
 		BLI_freelistN(&melem__lb);
 
@@ -195,17 +195,17 @@
 		}
 	}
 
-	melem__cur= first;
-	melem__offs= 0;
+	melem__cur = first;
+	melem__offs = 0;
 }
 
 void BLI_end_edgefill(void)
 {
 	mem_element_reset(TRUE);
 	
-	fillvertbase.first= fillvertbase.last= 0;
-	filledgebase.first= filledgebase.last= 0;
-	fillfacebase.first= fillfacebase.last= 0;
+	fillvertbase.first = fillvertbase.last = 0;
+	filledgebase.first = filledgebase.last = 0;
+	fillfacebase.first = fillfacebase.last = 0;
 	
 	BLI_unlock_thread(LOCK_SCANFILL);	
 }
@@ -221,7 +221,7 @@
 {
 	ScanFillVert *eve;
 	
-	eve= mem_element_new(sizeof(ScanFillVert));
+	eve = mem_element_new(sizeof(ScanFillVert));
 	BLI_addtail(&fillvertbase, eve);
 	
 	eve->co[0] = vec[0];
@@ -235,11 +235,11 @@
 {
 	ScanFillEdge *newed;
 
-	newed= mem_element_new(sizeof(ScanFillEdge));
+	newed = mem_element_new(sizeof(ScanFillEdge));
 	BLI_addtail(&filledgebase, newed);
 	
-	newed->v1= v1;
-	newed->v2= v2;
+	newed->v1 = v1;
+	newed->v2 = v2;
 
 	return newed;
 }
@@ -249,12 +249,12 @@
 	/* does not make edges */
 	ScanFillFace *evl;
 
-	evl= mem_element_new(sizeof(ScanFillFace));
+	evl = mem_element_new(sizeof(ScanFillFace));
 	BLI_addtail(&fillfacebase, evl);
 	
-	evl->v1= v1;
-	evl->v2= v2;
-	evl->v3= v3;
+	evl->v1 = v1;
+	evl->v2 = v2;
+	evl->v3 = v3;
 }
 
 static int boundisect(PolyFill *pf2, PolyFill *pf1)
@@ -262,46 +262,46 @@
 	/* has pf2 been touched (intersected) by pf1 ? with bounding box */
 	/* test first if polys exist */
 
-	if (pf1->edges==0 || pf2->edges==0) return 0;
+	if (pf1->edges == 0 || pf2->edges == 0) return 0;
 
-	if (pf2->max[cox] < pf1->min[cox] ) return 0;
-	if (pf2->max[coy] < pf1->min[coy] ) return 0;
+	if (pf2->max[cox] < pf1->min[cox]) return 0;
+	if (pf2->max[coy] < pf1->min[coy]) return 0;
 
-	if (pf2->min[cox] > pf1->max[cox] ) return 0;
-	if (pf2->min[coy] > pf1->max[coy] ) return 0;
+	if (pf2->min[cox] > pf1->max[cox]) return 0;
+	if (pf2->min[coy] > pf1->max[coy]) return 0;
 
 	/* join */
-	if (pf2->max[cox]<pf1->max[cox]) pf2->max[cox]= pf1->max[cox];
-	if (pf2->max[coy]<pf1->max[coy]) pf2->max[coy]= pf1->max[coy];
+	if (pf2->max[cox] < pf1->max[cox]) pf2->max[cox] = pf1->max[cox];
+	if (pf2->max[coy] < pf1->max[coy]) pf2->max[coy] = pf1->max[coy];
 
-	if (pf2->min[cox]>pf1->min[cox]) pf2->min[cox]= pf1->min[cox];
-	if (pf2->min[coy]>pf1->min[coy]) pf2->min[coy]= pf1->min[coy];
+	if (pf2->min[cox] > pf1->min[cox]) pf2->min[cox] = pf1->min[cox];
+	if (pf2->min[coy] > pf1->min[coy]) pf2->min[coy] = pf1->min[coy];
 
 	return 1;
 }
 
 
-static void mergepolysSimp(PolyFill *pf1, PolyFill *pf2)	/* add pf2 to pf1 */
+static void mergepolysSimp(PolyFill *pf1, PolyFill *pf2)    /* add pf2 to pf1 */
 {
 	ScanFillVert *eve;
 	ScanFillEdge *eed;
 
 	/* replace old poly numbers */
-	eve= fillvertbase.first;
+	eve = fillvertbase.first;
 	while (eve) {
 		if (eve->poly_nr == pf2->nr) eve->poly_nr = pf1->nr;
-		eve= eve->next;
+		eve = eve->next;
 	}
-	eed= filledgebase.first;
+	eed = filledgebase.first;
 	while (eed) {
 		if (eed->poly_nr == pf2->nr) eed->poly_nr = pf1->nr;
-		eed= eed->next;
+		eed = eed->next;
 	}
 
-	pf1->verts+= pf2->verts;
-	pf1->edges+= pf2->edges;
-	pf2->verts= pf2->edges= 0;
-	pf1->f= (pf1->f | pf2->f);
+	pf1->verts += pf2->verts;
+	pf1->edges += pf2->edges;
+	pf2->verts = pf2->edges = 0;
+	pf1->f = (pf1->f | pf2->f);
 }
 
 static short testedgeside(const float v1[3], const float v2[3], const float v3[3])
@@ -309,14 +309,16 @@
 {
 	float inp;
 
-	inp= (v2[cox]-v1[cox])*(v1[coy]-v3[coy])
-		+(v1[coy]-v2[coy])*(v1[cox]-v3[cox]);
+	inp = (v2[cox] - v1[cox]) * (v1[coy] - v3[coy]) +
+	      (v1[coy] - v2[coy]) * (v1[cox] - v3[cox]);
 
-	if (inp < 0.0f) return 0;
-	else if (inp==0) {
-		if (v1[cox]==v3[cox] && v1[coy]==v3[coy]) return 0;
-		if (v2[cox]==v3[cox] && v2[coy]==v3[coy]) return 0;
+	if (inp < 0.0f) {
+		return 0;
 	}
+	else if (inp == 0) {
+		if (v1[cox] == v3[cox] && v1[coy] == v3[coy]) return 0;
+		if (v2[cox] == v3[cox] && v2[coy] == v3[coy]) return 0;
+	}
 	return 1;
 }
 
@@ -324,41 +326,43 @@
 {
 	/* find first edge to the right of eed, and insert eed before that */
 	ScanFillEdge *ed;
-	float fac,fac1,x,y;
+	float fac, fac1, x, y;
 
-	if (sc->first==0) {
-		sc->first= sc->last= eed;
-		eed->prev= eed->next=0;
+	if (sc->first == NULL) {
+		sc->first = sc->last = eed;
+		eed->prev = eed->next = NULL;
 		return 1;
 	}
 
-	x= eed->v1->co[cox];
-	y= eed->v1->co[coy];
+	x = eed->v1->co[cox];
+	y = eed->v1->co[coy];
 
-	fac1= eed->v2->co[coy]-y;
-	if (fac1==0.0f) {
-		fac1= 1.0e10f*(eed->v2->co[cox]-x);
+	fac1 = eed->v2->co[coy] - y;
+	if (fac1 == 0.0f) {
+		fac1 = 1.0e10f * (eed->v2->co[cox] - x);
 
 	}
-	else fac1= (x-eed->v2->co[cox])/fac1;
+	else fac1 = (x - eed->v2->co[cox]) / fac1;
 
-	ed= sc->first;
+	ed = sc->first;
 	while (ed) {
 
-		if (ed->v2==eed->v2) return 0;
+		if (ed->v2 == eed->v2) return 0;
 
-		fac= ed->v2->co[coy]-y;
-		if (fac==0.0f) {
-			fac= 1.0e10f*(ed->v2->co[cox]-x);
-
+		fac = ed->v2->co[coy] - y;
+		if (fac == 0.0f) {
+			fac = 1.0e10f * (ed->v2->co[cox] - x);
 		}
-		else fac= (x-ed->v2->co[cox])/fac;
-		if (fac>fac1) break;
+		else {
+			fac = (x - ed->v2->co[cox]) / fac;
+		}
 
-		ed= ed->next;
+		if (fac > fac1) break;
+
+		ed = ed->next;
 	}
 	if (ed) BLI_insertlinkbefore((ListBase *)&(sc->first), ed, eed);
-	else BLI_addtail((ListBase *)&(sc->first),eed);
+	else BLI_addtail((ListBase *)&(sc->first), eed);
 
 	return 1;
 }
@@ -368,29 +372,29 @@
 {
 	/* inserts edge at correct location in ScanFillVertLink list */
 	/* returns sc when edge already exists */
-	ScanFillVertLink *sc,scsearch;
+	ScanFillVertLink *sc, scsearch;
 	ScanFillVert *eve;
 
 	/* which vert is left-top? */
 	if (eed->v1->co[coy] == eed->v2->co[coy]) {
 		if (eed->v1->co[cox] > eed->v2->co[cox]) {
-			eve= eed->v1;
-			eed->v1= eed->v2;
-			eed->v2= eve;
+			eve = eed->v1;
+			eed->v1 = eed->v2;
+			eed->v2 = eve;
 		}
 	}
 	else if (eed->v1->co[coy] < eed->v2->co[coy]) {
-		eve= eed->v1;
-		eed->v1= eed->v2;
-		eed->v2= eve;
+		eve = eed->v1;
+		eed->v1 = eed->v2;
+		eed->v2 = eve;
 	}
 	/* find location in list */
-	scsearch.v1= eed->v1;

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list