[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42951] branches/bmesh/blender/source/ blender: cache customdata checks to avoid looking up on each call to mesh_loops_to_mface_corners ()
Campbell Barton
ideasman42 at gmail.com
Wed Dec 28 23:37:19 CET 2011
Revision: 42951
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42951
Author: campbellbarton
Date: 2011-12-28 22:37:09 +0000 (Wed, 28 Dec 2011)
Log Message:
-----------
cache customdata checks to avoid looking up on each call to mesh_loops_to_mface_corners()
Modified Paths:
--------------
branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h
branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
branches/bmesh/blender/source/blender/blenloader/intern/readfile.c
branches/bmesh/blender/source/blender/modifiers/intern/MOD_ngoninterp.c
Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h 2011-12-28 21:38:21 UTC (rev 42950)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h 2011-12-28 22:37:09 UTC (rev 42951)
@@ -213,8 +213,9 @@
/*convert a triangle of loop facedata to mface facedata*/
void mesh_loops_to_mface_corners(struct CustomData *fdata, struct CustomData *ldata,
- struct CustomData *pdata, int lindex[4], int findex,
- const int polyindex, const int mf_len);
+ struct CustomData *pdata, int lindex[4], int findex,
+ const int polyindex, const int mf_len,
+ const int numTex, const int numCol, const int hasWCol);
#ifdef __cplusplus
}
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c 2011-12-28 21:38:21 UTC (rev 42950)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c 2011-12-28 22:37:09 UTC (rev 42951)
@@ -2139,19 +2139,22 @@
}
void mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata,
- CustomData *pdata, int lindex[4], int findex,
- const int polyindex,
- const int mf_len /* 3 or 4 */
- )
+ CustomData *pdata, int lindex[4], int findex,
+ const int polyindex,
+ const int mf_len, /* 3 or 4 */
+
+ /* cache values to avoid lookups every time */
+ const int numTex, /* CustomData_number_of_layers(pdata, CD_MTEXPOLY) */
+ const int numCol, /* CustomData_number_of_layers(ldata, CD_MLOOPCOL) */
+ const int hasWCol /* CustomData_has_layer(ldata, CD_WEIGHT_MLOOPCOL) */
+ )
{
MTFace *texface;
MTexPoly *texpoly;
MCol *mcol;
MLoopCol *mloopcol;
MLoopUV *mloopuv;
- int i, j, hasWCol = CustomData_has_layer(ldata, CD_WEIGHT_MLOOPCOL);
- int numTex = CustomData_number_of_layers(pdata, CD_MTEXPOLY);
- int numCol = CustomData_number_of_layers(ldata, CD_MLOOPCOL);
+ int i, j;
for(i=0; i < numTex; i++){
texface = CustomData_get_n(fdata, CD_MTFACE, findex, i);
@@ -2224,14 +2227,14 @@
int lindex[4]; /* only ever use 3 in this case */
int *polyorigIndex;
int i, j, k;
- int numTex, numCol;
+ const int numTex = CustomData_number_of_layers(pdata, CD_MTEXPOLY);
+ const int numCol = CustomData_number_of_layers(ldata, CD_MLOOPCOL);
+ const int hasWCol = CustomData_has_layer(ldata, CD_WEIGHT_MLOOPCOL);
+
mpoly = CustomData_get_layer(pdata, CD_MPOLY);
mloop = CustomData_get_layer(ldata, CD_MLOOP);
- numTex = CustomData_number_of_layers(ldata, CD_MLOOPUV);
- numCol = CustomData_number_of_layers(ldata, CD_MLOOPCOL);
-
k = 0;
mp = mpoly;
polyorigIndex = CustomData_get_layer(pdata, CD_ORIGINDEX);
@@ -2365,7 +2368,8 @@
mf->v3 = mloop[mf->v3].v;
mesh_loops_to_mface_corners(fdata, ldata, pdata,
- lindex, i, polyIndex[i], 3);
+ lindex, i, polyIndex[i], 3,
+ numTex, numCol, hasWCol);
}
return totface;
@@ -2394,6 +2398,10 @@
MFace *mface = NULL, *mf;
BLI_array_declare(mface);
+ const int numTex = CustomData_number_of_layers(pdata, CD_MTEXPOLY);
+ const int numCol = CustomData_number_of_layers(ldata, CD_MLOOPCOL);
+ const int hasWCol = CustomData_has_layer(ldata, CD_WEIGHT_MLOOPCOL);
+
mpoly = CustomData_get_layer(pdata, CD_MPOLY);
mloop = CustomData_get_layer(ldata, CD_MLOOP);
@@ -2449,7 +2457,8 @@
mf->v3 = mloop[mf->v3].v;
mesh_loops_to_mface_corners(fdata, ldata, pdata,
- lindex, k, i, 3);
+ lindex, k, i, 3,
+ numTex, numCol, hasWCol);
test_index_face(mf, fdata, totface, 3);
}
else {
@@ -2468,7 +2477,8 @@
mf->v4 = mloop[mf->v4].v;
mesh_loops_to_mface_corners(fdata, ldata, pdata,
- lindex, k, i, 4);
+ lindex, k, i, 4,
+ numTex, numCol, hasWCol);
test_index_face(mf, fdata, totface, 4);
}
Modified: branches/bmesh/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/bmesh/blender/source/blender/blenloader/intern/readfile.c 2011-12-28 21:38:21 UTC (rev 42950)
+++ branches/bmesh/blender/source/blender/blenloader/intern/readfile.c 2011-12-28 22:37:09 UTC (rev 42951)
@@ -3834,7 +3834,7 @@
memset(&mesh->ldata, 0, sizeof(CustomData));
mesh->totloop = 0;
- mesh_update_customdata_pointers(mesh, TRUE);
+ mesh_update_customdata_pointers(mesh);
}
#endif
Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_ngoninterp.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_ngoninterp.c 2011-12-28 21:38:21 UTC (rev 42950)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_ngoninterp.c 2011-12-28 22:37:09 UTC (rev 42951)
@@ -91,7 +91,11 @@
BLI_array_declare(origf);
DerivedMesh *copy = NULL;
int i;
-
+
+ int numTex;
+ int numCol;
+ int hasWCol;
+
if (nmd->resolution <= 0)
return dm;
@@ -112,7 +116,12 @@
/*create a dummy mesh to compute interpolated loops on*/
dummy = CDDM_from_template(dm, 0, 0, 0, 3, 0);
-
+
+ /* CustomData we check must match what is passed to mesh_loops_to_mface_corners() */
+ numTex = CustomData_number_of_layers(&dm->polyData, CD_MTEXPOLY);
+ numCol = CustomData_number_of_layers(&dummy->loopData, CD_MLOOPCOL);
+ hasWCol = CustomData_has_layer(&dummy->loopData, CD_WEIGHT_MLOOPCOL);
+
/*copy original verts here, so indices stay correct*/
omvert = dm->getVertArray(dm);
ov = dm->getVertDataArray(dm, CD_ORIGINDEX);
@@ -262,7 +271,9 @@
interp_weights_poly_v3(w, cos, mp->totloop, co);
CustomData_interp(&dm->loopData, &dummy->loopData, loops, w, NULL, mp->totloop, 2);
- mesh_loops_to_mface_corners(&cddm->faceData, &dummy->loopData, &dm->polyData, lindex, i, origf[i], 3);
+ mesh_loops_to_mface_corners(&cddm->faceData, &dummy->loopData, &dm->polyData,
+ lindex, i, origf[i], 3,
+ numTex, numCol, hasWCol);
}
CustomData_copy_data(&dm->vertData, &cddm->vertData, 0, 0, dm->numVertData);
More information about the Bf-blender-cvs
mailing list