utility function BKE_mesh_edge_poly_map_create(), currently unused.

This commit is contained in:
Campbell Barton
2013-06-14 07:15:38 +00:00
parent f7a06295b9
commit cd33e7f1b4
2 changed files with 50 additions and 0 deletions

View File

@@ -310,6 +310,11 @@ void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem,
void BKE_mesh_vert_edge_map_create(MeshElemMap **r_map, int **r_mem,
const struct MEdge *medge, int totvert, int totedge);
void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map, int **r_mem,
const struct MEdge *medge, const int totedge,
const struct MPoly *mpoly, const int totpoly,
const struct MLoop *mloop, const int totloop);
/* vertex level transformations & checks (no derived mesh) */
int BKE_mesh_minmax(struct Mesh *me, float r_min[3], float r_max[3]);

View File

@@ -2524,6 +2524,51 @@ void BKE_mesh_vert_edge_map_create(MeshElemMap **r_map, int **r_mem,
*r_mem = indices;
}
void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map, int **r_mem,
const MEdge *UNUSED(medge), const int totedge,
const MPoly *mpoly, const int totpoly,
const MLoop *mloop, const int totloop)
{
MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * totedge, "edge-poly map");
int *indices = MEM_mallocN(sizeof(int) * totloop, "edge-poly map mem");
int *index_step;
const MPoly *mp;
int i;
/* count face users */
for (i = 0, mp = mpoly; i < totpoly; mp++, i++) {
const MLoop *ml;
int j = mp->totloop;
for (ml = &mloop[mp->loopstart]; j--; ml++) {
map[ml->e].count++;
}
}
/* create offsets */
index_step = indices;
for (i = 0; i < totedge; i++) {
map[i].indices = index_step;
index_step += map[i].count;
/* re-count, using this as an index below */
map[i].count = 0;
}
/* assign poly-edge users */
for (i = 0, mp = mpoly; i < totpoly; mp++, i++) {
const MLoop *ml;
int j = mp->totloop;
for (ml = &mloop[mp->loopstart]; j--; ml++) {
MeshElemMap *map_ele = &map[ml->e];
map_ele->indices[map_ele->count++] = i;
}
}
*r_map = map;
*r_mem = indices;
}
void BKE_mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata,
CustomData *pdata, int lindex[4], int findex,
const int polyindex,