diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-08-25 11:29:40 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-08-25 11:30:46 +0300 |
commit | c6d75628968818aa38b881d0bcaca7c07fc6492a (patch) | |
tree | cc13f8a614ff1cbe64e57a4d000dda0b5e661b7e /source/blender/blenkernel/intern/mesh.c | |
parent | 540f9a3b11d20e8ee75718dfd8eb5a750d1864ef (diff) |
Fix T45729: Cycles Bake break when building a special mesh
The issue was caused by CD_SHAPEKEY_INDEX layer being added to edge data,
now we make sure all the layers are nicely re-allocated.
Diffstat (limited to 'source/blender/blenkernel/intern/mesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 3d6481349c5..f85e54a8362 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -2237,7 +2237,7 @@ void BKE_mesh_split_faces(Mesh *mesh) BKE_mesh_calc_normals_split(mesh); } lnors = CustomData_get_layer(&mesh->ldata, CD_NORMAL); - /* Count. */ + /* Count number of vertices to be split. */ for (poly = 0; poly < num_polys; poly++) { MPoly *mp = &mpoly[poly]; int loop; @@ -2255,19 +2255,16 @@ void BKE_mesh_split_faces(Mesh *mesh) /* No new vertices are to be added, can do early exit. */ return; } - /* Actual split. */ + /* Reallocate all vert and edge related data. */ mesh->totvert += num_new_verts; mesh->totedge += 2 * num_new_verts; - mvert = mesh->mvert = MEM_reallocN(mesh->mvert, - sizeof(MVert) * mesh->totvert); - medge = mesh->medge = MEM_reallocN(mesh->medge, - sizeof(MEdge) * mesh->totedge); - if (mesh->dvert != NULL) { - mesh->dvert = MEM_reallocN(mesh->dvert, sizeof(MDeformVert) * mesh->totvert); - CustomData_set_layer(&mesh->vdata, CD_MDEFORMVERT, mesh->dvert); - } - CustomData_set_layer(&mesh->vdata, CD_MVERT, mesh->mvert); - CustomData_set_layer(&mesh->edata, CD_MEDGE, mesh->medge); + CustomData_realloc(&mesh->vdata, mesh->totvert); + CustomData_realloc(&mesh->edata, mesh->totedge); + /* Update pointers to a newly allocated memory. */ + BKE_mesh_update_customdata_pointers(mesh, false); + mvert = mesh->mvert; + medge = mesh->medge; + /* Perform actual vertex split. */ num_new_verts = 0; for (poly = 0; poly < num_polys; poly++) { MPoly *mp = &mpoly[poly]; |