[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42238] branches/bmesh/blender/source/ blender: - add BM_NGON_STACK_SIZE define to use wherever ngon stack arrays are used .
Campbell Barton
ideasman42 at gmail.com
Tue Nov 29 05:11:28 CET 2011
Revision: 42238
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42238
Author: campbellbarton
Date: 2011-11-29 04:11:17 +0000 (Tue, 29 Nov 2011)
Log Message:
-----------
- add BM_NGON_STACK_SIZE define to use wherever ngon stack arrays are used.
- renamed BM_Compute_Face_Center() to BM_Compute_Face_CenterBounds() and added BM_Compute_Face_CenterMean() since there was code inline to find the mean center in transform.
Modified Paths:
--------------
branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
branches/bmesh/blender/source/blender/bmesh/bmesh.h
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_marking.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c
branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c
branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c
branches/bmesh/blender/source/blender/bmesh/operators/utils.c
branches/bmesh/blender/source/blender/editors/space_view3d/drawobject.c
branches/bmesh/blender/source/blender/editors/transform/transform_conversions.c
branches/bmesh/blender/source/blender/modifiers/intern/MOD_solidify.c
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c 2011-11-29 02:58:38 UTC (rev 42237)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c 2011-11-29 04:11:17 UTC (rev 42238)
@@ -2596,7 +2596,7 @@
int i;
float area, polynorm_local[3], (*vertexcos)[3] = NULL;
float *no= polynormal ? polynormal : polynorm_local;
- BLI_array_staticdeclare(vertexcos, 10);
+ BLI_array_staticdeclare(vertexcos, BM_NGON_STACK_SIZE);
BLI_array_growitems(vertexcos, mpoly->totloop);
Modified: branches/bmesh/blender/source/blender/bmesh/bmesh.h
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/bmesh.h 2011-11-29 02:58:38 UTC (rev 42237)
+++ branches/bmesh/blender/source/blender/bmesh/bmesh.h 2011-11-29 04:11:17 UTC (rev 42238)
@@ -284,7 +284,9 @@
void BM_SetCDf(struct CustomData *cd, void *element, int type, float val);
/*computes the centroid of a face, using the center of the bounding box*/
-int BM_Compute_Face_Center ( BMesh *bm, BMFace *f, float center[3] );
+void BM_Compute_Face_CenterBounds(BMesh *bm, BMFace *f, float center[3]);
+/*computes the centroid of a face, using the mean average*/
+void BM_Compute_Face_CenterMean(BMesh *bm, BMFace *f, float center[3]);
void BM_SelectMode_Flush ( BMesh *bm );
@@ -347,6 +349,11 @@
#define bm_firstfaceloop(p) ((BMLoopList*)(p->loops.first))->first
+/* size to use for static arrays when dealing with NGons,
+ * alloc after this limit is reached.
+ * this value is rather arbitrary */
+#define BM_NGON_STACK_SIZE 32
+
/*include the rest of the API*/
#include "bmesh_filters.h"
#include "bmesh_iterators.h"
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c 2011-11-29 02:58:38 UTC (rev 42237)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c 2011-11-29 04:11:17 UTC (rev 42238)
@@ -257,13 +257,12 @@
* BM_Make_Face should be considered over this function as it
* avoids some unnecessary work.
*/
-#define VERT_BUF_SIZE 100
BMFace *BM_Make_Ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, int len, int nodouble)
{
BMEdge **edges2 = NULL;
- BLI_array_staticdeclare(edges2, VERT_BUF_SIZE);
+ BLI_array_staticdeclare(edges2, BM_NGON_STACK_SIZE);
BMVert **verts = NULL, *v;
- BLI_array_staticdeclare(verts, VERT_BUF_SIZE);
+ BLI_array_staticdeclare(verts, BM_NGON_STACK_SIZE);
BMFace *f = NULL;
BMEdge *e;
BMVert *ev1, *ev2;
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c 2011-11-29 02:58:38 UTC (rev 42237)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c 2011-11-29 04:11:17 UTC (rev 42238)
@@ -188,9 +188,9 @@
BMLoop *l1, *l2;
void **blocks=NULL;
float (*cos)[3]=NULL, *w=NULL;
- BLI_array_staticdeclare(cos, 64);
- BLI_array_staticdeclare(w, 64);
- BLI_array_staticdeclare(blocks, 64);
+ BLI_array_staticdeclare(cos, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(w, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(blocks, BM_NGON_STACK_SIZE);
BM_Copy_Attributes(bm, bm, source, target);
@@ -698,10 +698,10 @@
void **blocks=NULL;
void **vblocks=NULL;
float (*cos)[3]=NULL, co[3], *w=NULL, cent[3] = {0.0f, 0.0f, 0.0f};
- BLI_array_staticdeclare(cos, 64);
- BLI_array_staticdeclare(w, 64);
- BLI_array_staticdeclare(blocks, 64);
- BLI_array_staticdeclare(vblocks, 64);
+ BLI_array_staticdeclare(cos, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(w, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(blocks, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(vblocks, BM_NGON_STACK_SIZE);
int i, xn, yn, zn, ax, ay;
BM_Copy_Attributes(bm, bm, source, target->f);
@@ -775,9 +775,9 @@
BMLoop *l;
void **blocks=NULL;
float (*cos)[3]=NULL, *w=NULL, cent[3] = {0.0f, 0.0f, 0.0f};
- BLI_array_staticdeclare(cos, 64);
- BLI_array_staticdeclare(w, 64);
- BLI_array_staticdeclare(blocks, 64);
+ BLI_array_staticdeclare(cos, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(w, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(blocks, BM_NGON_STACK_SIZE);
int i;
l = bm_firstfaceloop(source);
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_marking.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_marking.c 2011-11-29 02:58:38 UTC (rev 42237)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_marking.c 2011-11-29 04:11:17 UTC (rev 42238)
@@ -450,7 +450,7 @@
}
else if (ese->htype == BM_FACE) {
BMFace *efa= ese->data;
- BM_Compute_Face_Center(bm, efa, center);
+ BM_Compute_Face_CenterBounds(bm, efa, center);
}
}
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c 2011-11-29 02:58:38 UTC (rev 42237)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c 2011-11-29 04:11:17 UTC (rev 42238)
@@ -202,8 +202,8 @@
{
BMEdge **edges = NULL;
BMVert **verts = NULL;
- BLI_array_staticdeclare(edges, 256);
- BLI_array_staticdeclare(verts, 256);
+ BLI_array_staticdeclare(edges, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(verts, BM_NGON_STACK_SIZE);
BMLoop *l, *l2;
BMFace *f2;
int i;
@@ -457,7 +457,7 @@
void BM_Kill_Face_Edges(BMesh *bm, BMFace *f)
{
BMEdge **edges = NULL;
- BLI_array_staticdeclare(edges, 256);
+ BLI_array_staticdeclare(edges, BM_NGON_STACK_SIZE);
BMLoop *l;
int i;
@@ -477,7 +477,7 @@
void BM_Kill_Face_Verts(BMesh *bm, BMFace *f)
{
BMVert**verts = NULL;
- BLI_array_staticdeclare(verts, 256);
+ BLI_array_staticdeclare(verts, BM_NGON_STACK_SIZE);
BMLoop *l;
int i;
@@ -623,7 +623,7 @@
BMLoop *l = lst->first, *curloop, *oldprev, *oldnext;
BMEdge **edar = NULL;
MDisps *md;
- BLI_array_staticdeclare(edar, 64);
+ BLI_array_staticdeclare(edar, BM_NGON_STACK_SIZE);
int i, j, edok, len = 0, do_disps = CustomData_has_layer(&bm->ldata, CD_MDISPS);
len = bmesh_loop_length(l);
@@ -818,9 +818,9 @@
BMEdge **edges = NULL;
BMEdge **deledges = NULL;
BMVert **delverts = NULL;
- BLI_array_staticdeclare(edges, 64);
- BLI_array_staticdeclare(deledges, 64);
- BLI_array_staticdeclare(delverts, 64);
+ BLI_array_staticdeclare(edges, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(deledges, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(delverts, BM_NGON_STACK_SIZE);
BMVert *v1=NULL, *v2=NULL;
ListBase holes = {NULL, NULL};
const char *err = NULL;
@@ -1147,7 +1147,8 @@
*
*/
-BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re){
+BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re)
+{
BMLoop *nextl;
BMEdge *ne;
BMVert *nv, *ov;
@@ -1340,7 +1341,7 @@
BMLoop *killoop, *l;
int len,radlen=0, halt = 0, i, valence1, valence2,edok;
BMLoop **loops = NULL;
- BLI_array_staticdeclare(loops, 256);
+ BLI_array_staticdeclare(loops, BM_NGON_STACK_SIZE);
if(bmesh_vert_in_edge(ke,kv) == 0) return 0;
len = bmesh_disk_count(kv);
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c 2011-11-29 02:58:38 UTC (rev 42237)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c 2011-11-29 04:11:17 UTC (rev 42238)
@@ -225,11 +225,11 @@
{
BMLoop *l;
BMIter iter;
- float (*verts)[3], stackv[100][3];
+ float (*verts)[3], stackv[BM_NGON_STACK_SIZE][3];
float area, center[3];
int i;
- if (f->len <= 100)
+ if (f->len <= BM_NGON_STACK_SIZE)
verts = stackv;
else verts = MEM_callocN(sizeof(float)*f->len*3, "bm_face_area tmp");
@@ -241,7 +241,7 @@
compute_poly_center(center, &area, verts, f->len);
- if (f->len > 100)
+ if (f->len > BM_NGON_STACK_SIZE)
MEM_freeN(verts);
return area;
@@ -250,7 +250,7 @@
computes center of face in 3d. uses center of bounding box.
*/
-int BM_Compute_Face_Center(BMesh *bm, BMFace *f, float center[3])
+void BM_Compute_Face_CenterBounds(BMesh *bm, BMFace *f, float r_cent[3])
{
BMIter iter;
BMLoop *l;
@@ -263,11 +263,25 @@
DO_MINMAX(l->v->co, min, max);
}
- mid_v3_v3v3(center, min, max);
-
- return 0;
+ mid_v3_v3v3(r_cent, min, max);
}
+void BM_Compute_Face_CenterMean(BMesh *bm, BMFace *f, float r_cent[3])
+{
+ BMIter iter;
+ BMLoop *l;
+ int i;
+
+ zero_v3(r_cent);
+
+ l = BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, f);
+ for (i=0; l; l=BMIter_Step(&iter), i++) {
+ add_v3_v3(r_cent, l->v->co);
+ }
+
+ mul_v3_fl(r_cent, 1.0f / (float)f->len);
+}
+
/*
* COMPUTE POLY PLANE
*
@@ -404,8 +418,8 @@
void BM_Face_UpdateNormal(BMesh *bm, BMFace *f)
{
- float projverts[200][3];
- float (*proj)[3] = f->len < 200 ? projverts : MEM_mallocN(sizeof(float)*f->len*3, "projvertsn");
+ float projverts[BM_NGON_STACK_SIZE][3];
+ float (*proj)[3] = f->len < BM_NGON_STACK_SIZE ? projverts : MEM_mallocN(sizeof(float)*f->len*3, "projvertsn");
if (f->len < 3) return;
@@ -854,15 +868,15 @@
BMLoop *l;
float v1[3], v2[3], v3[3]/*, v4[3]*/, no[3], mid[3], *p1, *p2, *p3, *p4;
float out[3] = {-234324.0f, -234324.0f, 0.0f};
- float projectverts[100][3];
- float edgevertsstack[200][3];
+ float projectverts[BM_NGON_STACK_SIZE][3];
+ float edgevertsstack[BM_NGON_STACK_SIZE * 2][3];
float (*projverts)[3] = projectverts;
float (*edgeverts)[3] = edgevertsstack;
float fac1 = 1.0000001f, fac2 = 0.9f; //9999f; //0.999f;
int i, j, a=0, clen;
- if (f->len > 100) projverts = MEM_mallocN(sizeof(float)*3*f->len, "projvertsb");
- if (len > 100) edgeverts = MEM_mallocN(sizeof(float)*3*2*len, "edgevertsb");
+ if (f->len > BM_NGON_STACK_SIZE) projverts = MEM_mallocN(sizeof(float)*3*f->len, "projvertsb");
+ if (len > (BM_NGON_STACK_SIZE * 2)) edgeverts = MEM_mallocN(sizeof(float)*3*2*len, "edgevertsb");
i = 0;
l = BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, f);
Modified: branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list