[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18863] branches/bmesh/blender/source/ blender: forgot that you can't simply grow an array by one, when your rotating your indexes.

Joseph Eagar joeedh at gmail.com
Sun Feb 8 13:41:17 CET 2009


Revision: 18863
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18863
Author:   joeedh
Date:     2009-02-08 13:41:13 +0100 (Sun, 08 Feb 2009)

Log Message:
-----------
forgot that you can't simply grow an array by one, when your rotating your indexes.

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/blenkernel/BKE_utildefines.h
    branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c
    branches/bmesh/blender/source/blender/bmesh/operators/triangulateop.c

Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_utildefines.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_utildefines.h	2009-02-08 12:16:35 UTC (rev 18862)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_utildefines.h	2009-02-08 12:41:13 UTC (rev 18863)
@@ -215,12 +215,21 @@
 	arr[i] = something;
 }
 V_FREE(arr);
+
+arrays are buffered, using double-buffering (so on each reallocation,
+the array size is doubled).  supposedly this should give good Big Oh
+behaviour, though it may not be the best in practice.
 */
 
 #define V_DECLARE(vec) int _##vec##_count=0; void *_##vec##_tmp
+
+/*this returns the entire size of the array, including any buffering.*/
 #define V_SIZE(vec) ((vec)==NULL ? 0 : MEM_allocN_len(vec) / sizeof(*vec))
+
+/*this returns the logical size of the array, not including buffering.*/
 #define V_COUNT(vec) _##vec##_count
-#define MSTR(s) #s
+
+/*grow the array by one.  zeroes the new elements.*/
 #define V_GROW(vec) \
 	V_SIZE(vec) > _##vec##_count ? _##vec##_count++ : \
 	((_##vec##_tmp = MEM_callocN(sizeof(*vec)*(_##vec##_count*2+2), #vec " " __FILE__ " ")),\
@@ -229,8 +238,9 @@
 	(vec = _##vec##_tmp),\
 	_##vec##_count++)
 
-//(vec) ? WMEM_freeN(vec), 1 : 0
 #define V_FREE(vec) if (vec) MEM_freeN(vec);
+/*resets the logical size of an array to zero, but doesn't
+  free the memory.*/
 #define V_RESET(vec) _##vec##_count=0
 
 #endif

Modified: branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c	2009-02-08 12:16:35 UTC (rev 18862)
+++ branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c	2009-02-08 12:41:13 UTC (rev 18863)
@@ -691,11 +691,14 @@
 			j++;
 		}
 
+		for (j=0; j<face->len; j++) {
+			V_GROW(verts);
+		}
+		
 		j = 0;
 		for (nl=BMIter_New(&liter, bmesh, BM_LOOPS_OF_FACE, face);
 		     nl; nl=BMIter_Step(&liter)) {
 			b = (j-a+face->len) % face->len;
-			V_GROW(verts);
 			verts[b] = nl->v;
 			j += 1;
 		}

Modified: branches/bmesh/blender/source/blender/bmesh/operators/triangulateop.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/triangulateop.c	2009-02-08 12:16:35 UTC (rev 18862)
+++ branches/bmesh/blender/source/blender/bmesh/operators/triangulateop.c	2009-02-08 12:41:13 UTC (rev 18863)
@@ -24,10 +24,6 @@
 	for (i=0; i<finput->len; i++) {
 		face = ((BMFace**)finput->data.p)[i];
 
-		/*HACK! need to discuss with Briggs why the function takes an 
-		  externally-allocated array of vert coordinates in the first place.*/
-		//if (face->len > 400) projverts = MEM_callocN(sizeof(float)*3*face->len, "projverts");
-		//else projverts = projectverts;
 		if (lastlen < face->len) {
 			V_RESET(projectverts);
 			for (lastlen=0; lastlen<face->len; lastlen++) {





More information about the Bf-blender-cvs mailing list