Fix crash when creating new faces in edit mode

- Do not check corners count if totdisp is set to 0
- Allocate memory for such mdisps to prevent the whole disp layer erasing
This commit is contained in:
Sergey Sharybin 2010-11-08 14:00:23 +00:00
parent f15187cfcd
commit 8647dbc0a6
1 changed files with 16 additions and 2 deletions

View File

@ -1614,17 +1614,31 @@ void multires_topology_changed(Object *ob)
{
Mesh *me= (Mesh*)ob->data;
MDisps *mdisp= NULL;
int i;
int i, totlvl;
CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface);
mdisp= CustomData_get_layer(&me->fdata, CD_MDISPS);
if(!mdisp) return;
totlvl= get_levels_from_disps(ob);
for(i = 0; i < me->totface; i++, mdisp++) {
int corners= multires_mdisp_corners(mdisp);
int corners= 0;
int nvert= me->mface[i].v4 ? 4 : 3;
/* allocate memory for mdisp, the whole disp layer would be erased otherwise */
if(!mdisp->totdisp) {
int side = multires_side_tot[totlvl];
mdisp->totdisp= nvert*side*side;
mdisp->disps= MEM_callocN(mdisp->totdisp*sizeof(float)*3, "mdisp topology");
continue;
}
corners= multires_mdisp_corners(mdisp);
if(corners!=nvert) {
mdisp->totdisp= (mdisp->totdisp/corners)*nvert;