[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43923] branches/bmesh/blender/source/ blender: Minor Improvements...
Campbell Barton
ideasman42 at gmail.com
Mon Feb 6 00:09:08 CET 2012
Revision: 43923
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43923
Author: campbellbarton
Date: 2012-02-05 23:09:07 +0000 (Sun, 05 Feb 2012)
Log Message:
-----------
Minor Improvements...
- more efficient array growing
- use BM_NGON_STACK_SIZE for more static arrays
- dont use BLI_array for bevel code where size is known.
Modified Paths:
--------------
branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
branches/bmesh/blender/source/blender/blenkernel/intern/subsurf_ccg.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c
branches/bmesh/blender/source/blender/bmesh/operators/createops.c
branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c
branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c 2012-02-05 22:32:32 UTC (rev 43922)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c 2012-02-05 23:09:07 UTC (rev 43923)
@@ -1756,10 +1756,13 @@
BLI_array_empty(vertcos);
BLI_array_empty(vertnos);
- for (j=0; j<mp->totloop; j++) {
+ BLI_array_growitems(vertcos, mp->totloop);
+ BLI_array_growitems(vertnos, mp->totloop);
+
+ for (j=0; j < mp->totloop; j++) {
int vindex = ml[j].v;
- BLI_array_append(vertcos, mverts[vindex].co);
- BLI_array_append(vertnos, tnorms[vindex]);
+ vertcos[j] = mverts[vindex].co;
+ vertnos[j] = tnorms[vindex];
}
BLI_array_empty(edgevecbuf);
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/subsurf_ccg.c 2012-02-05 22:32:32 UTC (rev 43922)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/subsurf_ccg.c 2012-02-05 23:09:07 UTC (rev 43923)
@@ -552,10 +552,11 @@
CCGFace *f;
BLI_array_empty(fVerts);
+ BLI_array_growitems(fVerts, mp->totloop);
ml = mloop + mp->loopstart;
for (j=0; j<mp->totloop; j++, ml++) {
- BLI_array_append(fVerts, SET_INT_IN_POINTER(ml->v));
+ fVerts[j] = SET_INT_IN_POINTER(ml->v);
}
/* this is very bad, means mesh is internally inconsistent.
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c 2012-02-05 22:32:32 UTC (rev 43922)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c 2012-02-05 23:09:07 UTC (rev 43923)
@@ -1691,7 +1691,7 @@
BLI_array_append(stack, e);
/* Considering only edges and faces incident on vertex v, walk
- the edges & faces and assign an index to each connected set */
+ * the edges & faces and assign an index to each connected set */
while ((e = BLI_array_pop(stack))) {
BLI_ghash_insert(visithash, e, SET_INT_IN_POINTER(maxindex));
@@ -1721,11 +1721,11 @@
}
/* Loops here should alway refer to an edge that has v as an
- endpoint. For each appearance of this vert in a face, there
- will actually be two iterations: one for the loop heading
- towards vertex v, and another for the loop heading out from
- vertex v. Only need to swap the vertex on one of those times,
- on the outgoing loop. */
+ * endpoint. For each appearance of this vert in a face, there
+ * will actually be two iterations: one for the loop heading
+ * towards vertex v, and another for the loop heading out from
+ * vertex v. Only need to swap the vertex on one of those times,
+ * on the outgoing loop. */
if (l->v == v) {
l->v = verts[i];
}
Modified: branches/bmesh/blender/source/blender/bmesh/operators/createops.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/createops.c 2012-02-05 22:32:32 UTC (rev 43922)
+++ branches/bmesh/blender/source/blender/bmesh/operators/createops.c 2012-02-05 23:09:07 UTC (rev 43923)
@@ -145,15 +145,16 @@
static void rotsys_reverse(struct BMEdge *UNUSED(e), struct BMVert *v, EdgeData *edata, VertData *vdata)
{
BMEdge **edges = NULL;
- BMEdge *e2;
- BLI_array_staticdeclare(edges, 256);
+ BMEdge *e_first;
+ BMEdge *e;
+ BLI_array_staticdeclare(edges, BM_NGON_STACK_SIZE);
int i, totedge;
- e2 = vdata[BM_GetIndex(v)].e;
+ e = e_first = vdata[BM_GetIndex(v)].e;
do {
- BLI_array_append(edges, e2);
- e2 = rotsys_nextedge(e2, v, edata, vdata);
- } while (e2 != vdata[BM_GetIndex(v)].e);
+ BLI_array_append(edges, e);
+ e = rotsys_nextedge(e, v, edata, vdata);
+ } while (e != e_first);
totedge = BLI_array_count(edges);
for (i=0; i<totedge/2; i++) {
@@ -229,8 +230,9 @@
continue;
do {
- if (BLI_smallhash_haskey(hash, (intptr_t)e2)
- || BLI_smallhash_haskey(hash, (intptr_t)v)) {
+ if (BLI_smallhash_haskey(hash, (intptr_t)e2) ||
+ BLI_smallhash_haskey(hash, (intptr_t)v))
+ {
ok = 0;
break;
}
@@ -333,10 +335,10 @@
BMIter iter;
BMEdge *e;
BMEdge **edges = NULL;
- BLI_array_staticdeclare(edges, 256);
+ BLI_array_staticdeclare(edges, BM_NGON_STACK_SIZE);
BMVert *v;
/*BMVert **verts = NULL; */
- /*BLI_array_staticdeclare(verts, 256);*/ /*UNUSED*/
+ /*BLI_array_staticdeclare(verts, BM_NGON_STACK_SIZE);*/ /*UNUSED*/
int i;
#define SIGN(n) ((n)<0.0f)
Modified: branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c 2012-02-05 22:32:32 UTC (rev 43922)
+++ branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c 2012-02-05 23:09:07 UTC (rev 43923)
@@ -158,9 +158,7 @@
}
BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
- if (BMO_TestFlag(bm, v, VERT_MARK) &&
- BM_Vert_EdgeCount(v) == 2)
- {
+ if (BMO_TestFlag(bm, v, VERT_MARK) && BM_Vert_EdgeCount(v) == 2) {
BLI_array_append(verts, v);
}
}
Modified: branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c 2012-02-05 22:32:32 UTC (rev 43922)
+++ branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c 2012-02-05 23:09:07 UTC (rev 43923)
@@ -4486,7 +4486,6 @@
const int use_dist= RNA_boolean_get(op->ptr, "use_dist");
float *w = NULL, ftot;
int li;
- BLI_array_declare(w);
BM_add_data_layer(em->bm, &em->bm->edata, CD_PROP_FLT);
li = CustomData_number_of_layers(&em->bm->edata, CD_PROP_FLT)-1;
@@ -4500,23 +4499,25 @@
if (em==NULL) return OPERATOR_CANCELLED;
+ w = MEM_mallocN(sizeof(float) * recursion, "bevel weights");
+
/*ugh, stupid math depends somewhat on angles!*/
/* dfac = 1.0/(float)(recursion+1); */ /* UNUSED */
df = 1.0;
for (i=0, ftot=0.0f; i<recursion; i++) {
- s = pow(df, 1.25);
-
- BLI_array_append(w, s);
+ s = powf(df, 1.25f);
+
+ w[i] = s;
ftot += s;
-
+
df *= 2.0;
}
- mul_vn_fl(w, BLI_array_count(w), 1.0f / (float)ftot);
+ mul_vn_fl(w, recursion, 1.0f / (float)ftot);
fac = factor;
- for (i=0; i<BLI_array_count(w); i++) {
- fac = w[BLI_array_count(w)-i-1]*factor;
+ for (i=0; i < recursion; i++) {
+ fac = w[recursion-i-1]*factor;
if (!EDBM_InitOpf(em, &bmop, op, "bevel geom=%hev percent=%f lengthlayer=%i use_lengths=%i use_even=%i use_dist=%i", BM_SELECT, fac, li, 1, use_even, use_dist))
return OPERATOR_CANCELLED;
@@ -4528,7 +4529,8 @@
BM_free_data_layer_n(em->bm, &em->bm->edata, CD_MASK_PROP_FLT, li);
- BLI_array_free(w);
+ MEM_freeN(w);
+
EDBM_RecalcNormals(em);
DAG_id_tag_update(obedit->data, 0);
More information about the Bf-blender-cvs
mailing list