From 5e300f40f0e0900dff276fb84aeb05e22b4aa87a Mon Sep 17 00:00:00 2001 From: Andrew Wiggin Date: Sun, 9 Oct 2011 21:59:29 +0000 Subject: [PATCH] Fix for 28859 (found and reported with fix by nico_ga from #blendercoders) --- source/blender/blenkernel/intern/mesh.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 801a31d3556..ce2193fe09a 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1892,17 +1892,26 @@ static void bmesh_corners_to_loops(Mesh *me, int findex, int loopstart, int numT int side, corners; corners = multires_mdisp_corners(fd); - side = sqrt(fd->totdisp / corners); - for (i=0; itotdisp = side*side; + if (corners == 0) { + /* Empty MDisp layers appear in at least one of the sintel.blend files. + Not sure why this happens, but it seems fine to just ignore them here. + If corners==0 for a non-empty layer though, something went wrong. */ + BLI_assert(fd->totdisp == 0); + } + else { + side = sqrt(fd->totdisp / corners); + + for (i=0; itotdisp = side*side; - if (ld->disps) - BLI_cellalloc_free(ld->disps); + if (ld->disps) + BLI_cellalloc_free(ld->disps); - ld->disps = BLI_cellalloc_calloc(sizeof(float)*3*side*side, "converted loop mdisps"); - if (fd->disps) { - memcpy(ld->disps, disps, sizeof(float)*3*side*side); + ld->disps = BLI_cellalloc_calloc(sizeof(float)*3*side*side, "converted loop mdisps"); + if (fd->disps) { + memcpy(ld->disps, disps, sizeof(float)*3*side*side); + } } } }