[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22504] branches/blender2.5/blender/source /blender: - typos in boxpack comments ( incorrectly had comment that it was from NAN)

Campbell Barton ideasman42 at gmail.com
Sun Aug 16 10:36:08 CEST 2009


Revision: 22504
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22504
Author:   campbellbarton
Date:     2009-08-16 10:36:08 +0200 (Sun, 16 Aug 2009)

Log Message:
-----------
- typos in boxpack comments (incorrectly had comment that it was from NAN)
- removed unused defines STREQ, STREQ2, STREQ3 and MINSIZE

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/BKE_utildefines.h
    branches/blender2.5/blender/source/blender/blenlib/intern/boxpack2d.c
    branches/blender2.5/blender/source/blender/python/generic/euler.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_utildefines.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_utildefines.h	2009-08-16 07:26:29 UTC (rev 22503)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_utildefines.h	2009-08-16 08:36:08 UTC (rev 22504)
@@ -62,11 +62,6 @@
 #define SHIFT3(type, a, b, c) { type tmp; tmp = a; a = c; c = b; b = tmp; }
 #define SHIFT4(type, a, b, c, d) { type tmp; tmp = a; a = d; d = c; c = b; b = tmp; }
 
-/* string compare */
-#define STREQ(str, a)           ( strcmp((str), (a))==0 )
-#define STREQ2(str, a, b)       ( STREQ(str, a) || STREQ(str, b) )
-#define STREQ3(str, a, b, c)    ( STREQ2(str, a, b) || STREQ(str, c) )
-
 /* min/max */
 #define MIN2(x,y)               ( (x)<(y) ? (x) : (y) )
 #define MIN3(x,y,z)             MIN2( MIN2((x),(y)) , (z) )
@@ -92,8 +87,6 @@
 							  if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
 							  if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; }
 
-#define MINSIZE(val, size)	( ((val)>=0.0) ? (((val)<(size)) ? (size): (val)) : ( ((val)>(-size)) ? (-size) : (val)))
-
 /* some math and copy defines */
 
 #define SWAP(type, a, b)        { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }

Modified: branches/blender2.5/blender/source/blender/blenlib/intern/boxpack2d.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenlib/intern/boxpack2d.c	2009-08-16 07:26:29 UTC (rev 22503)
+++ branches/blender2.5/blender/source/blender/blenlib/intern/boxpack2d.c	2009-08-16 08:36:08 UTC (rev 22504)
@@ -16,28 +16,22 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
+ * Contributor(s): Campbell Barton
  *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Campbell barton
- *
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#include <stdlib.h>
+#include <stdlib.h> /* for qsort */
 
-#include "BKE_utildefines.h"
 #include "MEM_guardedalloc.h"
 #include "BLI_boxpack2d.h"
  
-/* BoxPacker ported from Python by Campbell Barton
+/* BoxPacker for backing 2D rectangles into a square
  * 
  * The defined Below are for internal use only */
 
 /* free vert flags */
-#define eul 0.0000001
+#define eul 0.0000001f
 #define BLF 1
 #define TRF 2
 #define TLF 4
@@ -79,6 +73,9 @@
 		BOXRIGHT(b1)-eul<=BOXLEFT(b2) ||\
 		BOXTOP(b1)-eul<=BOXBOTTOM(b2) ))
 
+#define MIN2(x,y)               ( (x)<(y) ? (x) : (y) )
+#define MAX2(x,y)               ( (x)>(y) ? (x) : (y) )
+
 /* #define BOXDEBUG(b)\
  * 		printf("\tBox Debug i %i, w:%.3f h:%.3f x:%.3f y:%.3f\n",\
  * 		b->index, b->w, b->h, b->x, b->y) */
@@ -141,11 +138,11 @@
 	int box_index, verts_pack_len, i, j, k, isect;
 	int quad_flags[4]= {BLF,TRF,TLF,BRF}; /* use for looping */
 	boxPack *box, *box_test; /*current box and another for intersection tests*/
-	int *vertex_pack_indicies; /*an array of indicies used for sorting verts*/
+	int *vertex_pack_indicies; /*an array of indices used for sorting verts*/
 	
 	if (!len) {
-		*tot_width =  0.0;
-		*tot_height = 0.0;
+		*tot_width =  0.0f;
+		*tot_height = 0.0f;
 		return;
 	}
 	
@@ -153,8 +150,8 @@
 	qsort(boxarray, len, sizeof(boxPack), box_areasort);
 	
 	/* add verts to the boxes, these are only used internally  */
-	vert = vertarray = MEM_mallocN( len*4*sizeof(boxVert), "boxPack verts");
-	vertex_pack_indicies = MEM_mallocN( len*3*sizeof(int), "boxPack indicies");
+	vert = vertarray = MEM_mallocN( len*4*sizeof(boxVert), "boxPack Verts");
+	vertex_pack_indicies = MEM_mallocN( len*3*sizeof(int), "boxPack Indices");
 	
 	for (box=boxarray, box_index=0, i=0; box_index < len; box_index++, box++) {
 		 		
@@ -194,11 +191,11 @@
 	
 	
 	/* Pack the First box!
-	 * then enter the main boxpacking loop */
+	 * then enter the main box-packing loop */
 	
 	box = boxarray; /* get the first box  */
 	/* First time, no boxes packed */
-	box->v[BL]->free = 0; /* Cant use any if these */
+	box->v[BL]->free = 0; /* Can't use any if these */
 	box->v[BR]->free &= ~(BLF|BRF);
 	box->v[TL]->free &= ~(BLF|TLF);
 	
@@ -206,9 +203,9 @@
 	*tot_height = box->h; 
 	
 	/* This sets all the vertex locations */
-	SET_BOXLEFT(box, 0.0);
-	SET_BOXBOTTOM(box, 0.0);
-	box->x = box->y = 0.0;
+	SET_BOXLEFT(box, 0.0f);
+	SET_BOXBOTTOM(box, 0.0f);
+	box->x = box->y = 0.0f;
 	
 	for (i=0; i<3; i++)
 		vertex_pack_indicies[i] = box->v[i+1]->index; 
@@ -219,7 +216,7 @@
 	/* Main boxpacking loop */
 	for (box_index=1; box_index < len; box_index++, box++) {
 		
-		/* Sort the verts, these constants are used in sorting  */
+		/* These static floatds are used for sorting */
 		box_width = box->w;
 		box_height = box->h;
 		
@@ -234,7 +231,7 @@
 			/* printf("\ttesting vert %i %i %i %f %f\n", i,
 			 * 		vert->free, verts_pack_len, vert->x, vert->y); */
 			
-			/* This vert has a free quaderent
+			/* This vert has a free quadrant
 			 * Test if we can place the box here
 			 * vert->free & quad_flags[j] - Checks 
 			 * */
@@ -266,7 +263,7 @@
 					isect = 0;
 					
 					if (/* Constrain boxes to positive X/Y values */
-						BOXLEFT(box)<0.0 || BOXBOTTOM(box) < 0.0 ||
+						BOXLEFT(box)<0.0f || BOXBOTTOM(box) < 0.0f ||
 						/* check for last intersected */
 						(	vert->isect_cache[j] &&
 							BOXINTERSECT(box, vert->isect_cache[j])	)
@@ -274,13 +271,13 @@
 						/* Here we check that the last intersected
 						 * box will intersect with this one using
 						 * isect_cache that can store a pointer to a
-						 * box for each quaderent
+						 * box for each quadrant
 						 * big speedup */
 						isect = 1;
 					} else {
-						/* do a full saech for colliding box
-						 * this is realy slow, some spacialy divided
-						 * datastructure would be better */
+						/* do a full search for colliding box
+						 * this is really slow, some spacialy divided
+						 * data-structure would be better */
 						for (box_test=boxarray; box_test != box; box_test++) {
 							if BOXINTERSECT(box, box_test) {
 								/* Store the last intersecting here as cache
@@ -321,7 +318,7 @@
 						}
 						
 						/* Mask free flags for verts that are
-						 * on the bottom or side so we dont get
+						 * on the bottom or side so we don't get
 						 * boxes outside the given rectangle ares
 						 * 
 						 * We can do an else/if here because only the first 
@@ -392,7 +389,7 @@
 								verts_pack_len++;
 							}
 						}
-						/* The Box verts are only used interially
+						/* The Box verts are only used internally
 						 * Update the box x and y since thats what external
 						 * functions will see */
 						box->x = BOXLEFT(box);
@@ -403,8 +400,8 @@
 		}
 	}
 
-	/* free all the verts, not realy needed because they shouldebt be
-	 * touched anymore but accessing the pointers woud crash blender */
+	/* free all the verts, not really needed because they shouldn't be
+	 * touched anymore but accessing the pointers would crash blender */
 	for (box_index=0; box_index < len; box_index++) {
 		box = boxarray+box_index; 
 		box->v[0] = box->v[1] = box->v[2] = box->v[3] = NULL; 

Modified: branches/blender2.5/blender/source/blender/python/generic/euler.c
===================================================================
--- branches/blender2.5/blender/source/blender/python/generic/euler.c	2009-08-16 07:26:29 UTC (rev 22503)
+++ branches/blender2.5/blender/source/blender/python/generic/euler.c	2009-08-16 08:36:08 UTC (rev 22504)
@@ -242,7 +242,7 @@
 		PyErr_SetString(PyExc_TypeError, "euler.rotate():expected angle (float) and axis (x,y,z)");
 		return NULL;
 	}
-	if(!STREQ3(axis,"x","y","z")){
+	if(ELEM3(*axis, 'x', 'y', 'z') && axis[1]=='\0'){
 		PyErr_SetString(PyExc_TypeError, "euler.rotate(): expected axis to be 'x', 'y' or 'z'");
 		return NULL;
 	}





More information about the Bf-blender-cvs mailing list