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:
Diffstat (limited to 'source/blender/modifiers/intern/MOD_build.c')
-rw-r--r--source/blender/modifiers/intern/MOD_build.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c
index a9b6af967be..02d56560fc5 100644
--- a/source/blender/modifiers/intern/MOD_build.c
+++ b/source/blender/modifiers/intern/MOD_build.c
@@ -62,7 +62,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct
int *vertMap, *edgeMap, *faceMap;
float frac;
MPoly *mpoly_dst;
- MLoop *ml_dst, *ml_src /*, *mloop_dst */;
+ MLoop *ml_dst;
+ const MLoop *ml_src;
GHashIterator gh_iter;
/* maps vert indices in old mesh to indices in new mesh */
GHash *vertHash = BLI_ghash_int_new("build ve apply gh");
@@ -74,10 +75,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct
const int vert_src_num = mesh->totvert;
const int edge_src_num = mesh->totedge;
const int poly_src_num = mesh->totpoly;
- MPoly *mpoly_src = mesh->mpoly;
- MLoop *mloop_src = mesh->mloop;
- MEdge *medge_src = mesh->medge;
- MVert *mvert_src = mesh->mvert;
+ const MVert *mvert_src = BKE_mesh_vertices(mesh);
+ const MEdge *medge_src = BKE_mesh_edges(mesh);
+ const MPoly *mpoly_src = BKE_mesh_polygons(mesh);
+ const MLoop *mloop_src = BKE_mesh_loops(mesh);
vertMap = MEM_malloc_arrayN(vert_src_num, sizeof(*vertMap), "build modifier vertMap");
edgeMap = MEM_malloc_arrayN(edge_src_num, sizeof(*edgeMap), "build modifier edgeMap");
@@ -99,8 +100,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct
/* if there's at least one face, build based on faces */
if (faces_dst_num) {
- MPoly *mpoly, *mp;
- MLoop *ml, *mloop;
+ const MPoly *mpoly, *mp;
+ const MLoop *ml, *mloop;
uintptr_t hash_num, hash_num_alt;
if (bmd->flag & MOD_BUILD_FLAG_RANDOMIZE) {
@@ -135,7 +136,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct
hash_num = 0;
hash_num_alt = 0;
for (i = 0; i < edge_src_num; i++, hash_num_alt++) {
- MEdge *me = medge_src + i;
+ const MEdge *me = medge_src + i;
if (BLI_ghash_haskey(vertHash, POINTER_FROM_INT(me->v1)) &&
BLI_ghash_haskey(vertHash, POINTER_FROM_INT(me->v2))) {
@@ -147,7 +148,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct
BLI_assert(hash_num == BLI_ghash_len(edgeHash));
}
else if (edges_dst_num) {
- MEdge *medge, *me;
+ const MEdge *medge, *me;
uintptr_t hash_num;
if (bmd->flag & MOD_BUILD_FLAG_RANDOMIZE) {
@@ -201,6 +202,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct
/* now we know the number of verts, edges and faces, we can create the mesh. */
result = BKE_mesh_new_nomain_from_template(
mesh, BLI_ghash_len(vertHash), BLI_ghash_len(edgeHash), 0, loops_dst_num, faces_dst_num);
+ MVert *result_verts = BKE_mesh_vertices_for_write(result);
+ MEdge *result_edges = BKE_mesh_edges_for_write(result);
+ MPoly *result_polys = BKE_mesh_polygons_for_write(result);
+ MLoop *result_loops = BKE_mesh_loops_for_write(result);
/* copy the vertices across */
GHASH_ITER (gh_iter, vertHash) {
@@ -210,7 +215,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct
int newIndex = POINTER_AS_INT(BLI_ghashIterator_getValue(&gh_iter));
source = mvert_src[oldIndex];
- dest = &result->mvert[newIndex];
+ dest = &result_verts[newIndex];
CustomData_copy_data(&mesh->vdata, &result->vdata, oldIndex, newIndex, 1);
*dest = source;
@@ -223,7 +228,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct
int oldIndex = POINTER_AS_INT(BLI_ghash_lookup(edgeHash, POINTER_FROM_INT(i)));
source = medge_src[oldIndex];
- dest = &result->medge[i];
+ dest = &result_edges[i];
source.v1 = POINTER_AS_INT(BLI_ghash_lookup(vertHash, POINTER_FROM_INT(source.v1)));
source.v2 = POINTER_AS_INT(BLI_ghash_lookup(vertHash, POINTER_FROM_INT(source.v2)));
@@ -232,13 +237,13 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct
*dest = source;
}
- mpoly_dst = result->mpoly;
- ml_dst = result->mloop;
+ mpoly_dst = result_polys;
+ ml_dst = result_loops;
/* copy the faces across, remapping indices */
k = 0;
for (i = 0; i < faces_dst_num; i++) {
- MPoly *source;
+ const MPoly *source;
MPoly *dest;
source = mpoly_src + faceMap[i];