forked from bartvdbraak/blender
forgot that you can't simply grow an array by one, when your rotating your indexes.
This commit is contained in:
parent
2934dff13d
commit
f22bacee3b
@ -215,12 +215,21 @@ for (i=0; i<10; i++) {
|
||||
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 @@ V_FREE(arr);
|
||||
(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
|
||||
|
@ -691,11 +691,14 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op)
|
||||
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;
|
||||
}
|
||||
|
@ -24,10 +24,6 @@ void triangulate_exec(BMesh *bmesh, BMOperator *op)
|
||||
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++) {
|
||||
|
Loading…
Reference in New Issue
Block a user