[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41401] branches/bmesh/blender/source/ blender/bmesh/operators/mesh_conv.c: Small optimization in mesh-to-bmesh convert (avoid a bunch of alloc, free, realloc of loop customdata)
Andrew Wiggin
ender79bl at gmail.com
Mon Oct 31 01:28:52 CET 2011
Revision: 41401
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41401
Author: ender79
Date: 2011-10-31 00:28:52 +0000 (Mon, 31 Oct 2011)
Log Message:
-----------
Small optimization in mesh-to-bmesh convert (avoid a bunch of alloc, free, realloc of loop customdata)
Modified Paths:
--------------
branches/bmesh/blender/source/blender/bmesh/operators/mesh_conv.c
Modified: branches/bmesh/blender/source/blender/bmesh/operators/mesh_conv.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/mesh_conv.c 2011-10-31 00:23:42 UTC (rev 41400)
+++ branches/bmesh/blender/source/blender/bmesh/operators/mesh_conv.c 2011-10-31 00:28:52 UTC (rev 41401)
@@ -55,6 +55,7 @@
BMVert *v, **vt=NULL, **verts = NULL;
BMEdge *e, **fedges=NULL, **et = NULL;
BMFace *f;
+ BMLoop *l;
BLI_array_declare(fedges);
float (*keyco)[3]= NULL;
int *keyi;
@@ -194,7 +195,6 @@
for (i=0; i<me->totpoly; i++, mpoly++) {
BMVert *v1 /* , *v2 */ /* UNUSED */;
BMIter iter;
- BMLoop *l;
BLI_array_empty(fedges);
BLI_array_empty(verts);
@@ -238,11 +238,10 @@
f->mat_nr = mpoly->mat_nr;
if (i == me->act_face) bm->act_face = f;
- /*Copy over loop customdata*/
j = 0;
- BM_ITER(l, &iter, bm, BM_LOOPS_OF_FACE, f) {
- CustomData_to_bmesh_block(&me->ldata, &bm->ldata, mpoly->loopstart+j, &l->head.data);
- j++;
+ BM_ITER_INDEX(l, &iter, bm, BM_LOOPS_OF_FACE, f, j) {
+ /* Save index of correspsonding MLoop */
+ BM_SetIndex(l, mpoly->loopstart+j);
}
/*Copy Custom Data*/
@@ -250,6 +249,23 @@
}
{
+ BMIter fiter;
+ BMIter liter;
+
+ /* Copy over loop CustomData. Doing this in a separate loop isn't necessary
+ but is an optimization, to avoid copying a bunch of interpolated customdata
+ for each BMLoop (from previous BMLoops using the same edge), always followed
+ by freeing the interpolated data and overwriting it with data from the Mesh. */
+ BM_ITER(f, &fiter, bm, BM_FACES_OF_MESH, NULL) {
+ BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+ int li = BM_GetIndex(l);
+ CustomData_to_bmesh_block(&me->ldata, &bm->ldata, li, &l->head.data);
+ BM_SetIndex(l, 0);
+ }
+ }
+ }
+
+ {
BMIter iter;
BMVert *vertex;
BMEdge *edge;
More information about the Bf-blender-cvs
mailing list