[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42474] branches/bmesh/blender/source/ blender/blenkernel/intern/mesh.c: avoid looping through the polygons to find the maxium loop size by using BLI_array_declare , tested on optimized build and its slighly faster though IMHO this is easier to follow .
Campbell Barton
ideasman42 at gmail.com
Wed Dec 7 01:25:22 CET 2011
Revision: 42474
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42474
Author: campbellbarton
Date: 2011-12-07 00:25:21 +0000 (Wed, 07 Dec 2011)
Log Message:
-----------
avoid looping through the polygons to find the maxium loop size by using BLI_array_declare, tested on optimized build and its slighly faster though IMHO this is easier to follow.
Modified Paths:
--------------
branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c 2011-12-07 00:18:08 UTC (rev 42473)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c 2011-12-07 00:25:21 UTC (rev 42474)
@@ -1686,23 +1686,11 @@
MFace *mf;
MPoly *mp;
MLoop *ml;
- int maxPolyVerts = 0;
if (numPolys == 0) {
return;
}
- if (only_face_normals == FALSE) {
- mp = mpolys;
- for (i=0; i<numPolys; i++, mp++) {
- maxPolyVerts = MAX2(mp->totloop, maxPolyVerts);
- }
-
- if (maxPolyVerts == 0) {
- return;
- }
- }
-
/* if we are not calculating verts and no verts were passes thene we have nothign to do */
if ((only_face_normals == TRUE) && (polyNors_r == NULL) && (faceNors_r == NULL)) {
printf("%s: called with nothing to do\n", __func__);
@@ -1717,14 +1705,13 @@
/* vertex normals are optional, they require some extra calculations,
* so make them optional */
- float (*tnorms)[3], (*edgevecbuf)[3];
+ float (*tnorms)[3], (*edgevecbuf)[3]= NULL;
float **vertcos = NULL, **vertnos = NULL;
BLI_array_declare(vertcos);
BLI_array_declare(vertnos);
+ BLI_array_declare(edgevecbuf);
-
/*first go through and calculate normals for all the polys*/
- edgevecbuf = MEM_callocN(sizeof(float)*3*maxPolyVerts, "edgevecbuf mesh.c");
tnorms = MEM_callocN(sizeof(float)*3*numVerts, "tnorms mesh.c");
mp = mpolys;
@@ -1740,12 +1727,15 @@
BLI_array_append(vertnos, tnorms[vindex]);
}
+ BLI_array_empty(edgevecbuf);
+ BLI_array_growitems(edgevecbuf, mp->totloop);
+
accumulate_vertex_normals_poly(vertnos, pnors[i], vertcos, edgevecbuf, mp->totloop);
}
BLI_array_free(vertcos);
BLI_array_free(vertnos);
- MEM_freeN(edgevecbuf);
+ BLI_array_free(edgevecbuf);
/* following Mesh convention; we use vertex coordinate itself for normal in this case */
for(i=0; i<numVerts; i++) {
More information about the Bf-blender-cvs
mailing list