Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-06-14 10:34:37 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-06-14 10:34:37 +0400
commitf7a06295b978ff904e6969e8bea82ac31a06cf18 (patch)
tree2dff857bc793dbfb0833199073f45db8f6555f97 /source/blender
parent0435560b24400629701e09c05a6566aaad8abe9b (diff)
code cleanup: reduce pointer indirection for mesh-map creation functions.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_mesh.h4
-rw-r--r--source/blender/blenkernel/intern/mesh.c55
2 files changed, 31 insertions, 28 deletions
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 81f8c95db5b..c44410e94db 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -303,11 +303,11 @@ typedef struct IndexNode {
int index;
} IndexNode;
-void BKE_mesh_vert_poly_map_create(MeshElemMap **map, int **mem,
+void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem,
const struct MPoly *mface, const struct MLoop *mloop,
int totvert, int totface, int totloop);
-void BKE_mesh_vert_edge_map_create(MeshElemMap **map, int **mem,
+void BKE_mesh_vert_edge_map_create(MeshElemMap **r_map, int **r_mem,
const struct MEdge *medge, int totvert, int totedge);
/* vertex level transformations & checks (no derived mesh) */
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index c49794b5175..11546a0d134 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -2441,32 +2441,30 @@ void BKE_mesh_uv_vert_map_free(UvVertMap *vmap)
/* Generates a map where the key is the vertex and the value is a list
* of polys that use that vertex as a corner. The lists are allocated
* from one memory pool. */
-void BKE_mesh_vert_poly_map_create(MeshElemMap **map, int **mem,
+void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem,
const MPoly *mpoly, const MLoop *mloop,
int totvert, int totpoly, int totloop)
{
- int i, j;
- int *indices;
+ MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * totvert, "vert poly map");
+ int *indices = MEM_mallocN(sizeof(int) * totloop, "vert poly map mem");
- (*map) = MEM_callocN(sizeof(MeshElemMap) * totvert, "vert poly map");
- (*mem) = MEM_mallocN(sizeof(int) * totloop, "vert poly map mem");
+ int i, j;
/* Count number of polys for each vertex */
for (i = 0; i < totpoly; i++) {
const MPoly *p = &mpoly[i];
for (j = 0; j < p->totloop; j++)
- (*map)[mloop[p->loopstart + j].v].count++;
+ map[mloop[p->loopstart + j].v].count++;
}
/* Assign indices mem */
- indices = (*mem);
for (i = 0; i < totvert; i++) {
- (*map)[i].indices = indices;
- indices += (*map)[i].count;
+ map[i].indices = indices;
+ indices += map[i].count;
/* Reset 'count' for use as index in last loop */
- (*map)[i].count = 0;
+ map[i].count = 0;
}
/* Find the users */
@@ -2476,49 +2474,54 @@ void BKE_mesh_vert_poly_map_create(MeshElemMap **map, int **mem,
for (j = 0; j < p->totloop; j++) {
int v = mloop[p->loopstart + j].v;
- (*map)[v].indices[(*map)[v].count] = i;
- (*map)[v].count++;
+ map[v].indices[map[v].count] = i;
+ map[v].count++;
}
}
+
+ *r_map = map;
+ *r_mem = indices;
}
/* Generates a map where the key is the vertex and the value is a list
* of edges that use that vertex as an endpoint. The lists are allocated
* from one memory pool. */
-void BKE_mesh_vert_edge_map_create(MeshElemMap **map, int **mem,
+void BKE_mesh_vert_edge_map_create(MeshElemMap **r_map, int **r_mem,
const MEdge *medge, int totvert, int totedge)
{
- int i, *indices;
+ MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * totvert, "vert-edge map");
+ int *indices = MEM_mallocN(sizeof(int) * totedge * 2, "vert-edge map mem");
- (*map) = MEM_callocN(sizeof(MeshElemMap) * totvert, "vert-edge map");
- (*mem) = MEM_mallocN(sizeof(int) * totedge * 2, "vert-edge map mem");
+ int i;
/* Count number of edges for each vertex */
for (i = 0; i < totedge; i++) {
- (*map)[medge[i].v1].count++;
- (*map)[medge[i].v2].count++;
+ map[medge[i].v1].count++;
+ map[medge[i].v2].count++;
}
/* Assign indices mem */
- indices = (*mem);
for (i = 0; i < totvert; i++) {
- (*map)[i].indices = indices;
- indices += (*map)[i].count;
+ map[i].indices = indices;
+ indices += map[i].count;
/* Reset 'count' for use as index in last loop */
- (*map)[i].count = 0;
+ map[i].count = 0;
}
/* Find the users */
for (i = 0; i < totedge; i++) {
const int v[2] = {medge[i].v1, medge[i].v2};
- (*map)[v[0]].indices[(*map)[v[0]].count] = i;
- (*map)[v[1]].indices[(*map)[v[1]].count] = i;
+ map[v[0]].indices[map[v[0]].count] = i;
+ map[v[1]].indices[map[v[1]].count] = i;
- (*map)[v[0]].count++;
- (*map)[v[1]].count++;
+ map[v[0]].count++;
+ map[v[1]].count++;
}
+
+ *r_map = map;
+ *r_mem = indices;
}
void BKE_mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata,