Fixed own mistake from previous commit -- get_levels_from_disps can't be used
when handling topology changes. Added grid size detection based on totdisp and corners count.
This commit is contained in:
@@ -1613,26 +1613,33 @@ void multiresModifier_prepare_join(Scene *scene, Object *ob, Object *to_ob)
|
|||||||
void multires_topology_changed(Object *ob)
|
void multires_topology_changed(Object *ob)
|
||||||
{
|
{
|
||||||
Mesh *me= (Mesh*)ob->data;
|
Mesh *me= (Mesh*)ob->data;
|
||||||
MDisps *mdisp= NULL;
|
MDisps *mdisp= NULL, *cur= NULL;
|
||||||
int i, totlvl;
|
int i, grid= 0, corners;
|
||||||
|
|
||||||
CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface);
|
CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface);
|
||||||
mdisp= CustomData_get_layer(&me->fdata, CD_MDISPS);
|
mdisp= CustomData_get_layer(&me->fdata, CD_MDISPS);
|
||||||
|
|
||||||
if(!mdisp) return;
|
if(!mdisp) return;
|
||||||
|
|
||||||
totlvl= get_levels_from_disps(ob);
|
cur= mdisp;
|
||||||
|
for(i = 0; i < me->totface; i++, cur++) {
|
||||||
|
if(mdisp->totdisp) {
|
||||||
|
corners= multires_mdisp_corners(mdisp);
|
||||||
|
grid= mdisp->totdisp / corners;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(i = 0; i < me->totface; i++, mdisp++) {
|
for(i = 0; i < me->totface; i++, mdisp++) {
|
||||||
int corners= 0;
|
|
||||||
int nvert= me->mface[i].v4 ? 4 : 3;
|
int nvert= me->mface[i].v4 ? 4 : 3;
|
||||||
|
|
||||||
/* allocate memory for mdisp, the whole disp layer would be erased otherwise */
|
/* allocate memory for mdisp, the whole disp layer would be erased otherwise */
|
||||||
if(!mdisp->totdisp) {
|
if(!mdisp->totdisp) {
|
||||||
int side = multires_side_tot[totlvl];
|
if(grid) {
|
||||||
|
mdisp->totdisp= nvert*grid;
|
||||||
mdisp->totdisp= nvert*side*side;
|
mdisp->disps= MEM_callocN(mdisp->totdisp*sizeof(float)*3, "mdisp topology");
|
||||||
mdisp->disps= MEM_callocN(mdisp->totdisp*sizeof(float)*3, "mdisp topology");
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user