2.5/Multires:

* Fixed multires subdivision of a sculpted object. Accidentally broke this when I fixed removing a multires modifier.
This commit is contained in:
Nicholas Bishop 2009-08-21 18:15:50 +00:00
parent fc5df351b3
commit b6548c21c2
5 changed files with 18 additions and 13 deletions

@ -36,6 +36,7 @@ struct Object;
typedef struct MultiresSubsurf {
struct MultiresModifierData *mmd;
struct Object *ob;
int local_mmd;
} MultiresSubsurf;
/* MultiresDM */
@ -59,7 +60,7 @@ void multires_mark_as_modified(struct Object *ob);
void multires_force_update(struct Object *ob);
struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*, struct DerivedMesh*,
struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*, int local_mmd, struct DerivedMesh*,
struct Object *, int, int);
struct MultiresModifierData *find_multires_modifier(struct Object *ob);

@ -1288,6 +1288,7 @@ typedef struct MultiresDM {
CDDerivedMesh cddm;
MultiresModifierData *mmd;
int local_mmd;
int lvl, totlvl;
float (*orco)[3];
@ -1308,13 +1309,14 @@ static void MultiresDM_release(DerivedMesh *dm)
MultiresDM *mrdm = (MultiresDM*)dm;
int mvert_layer;
/* Check that mmd still exists */
if(BLI_findindex(&mrdm->ob->modifiers, mrdm->mmd) < 0)
mrdm->mmd = NULL;
/* Before freeing, need to update the displacement map */
if(dm->needsFree && mrdm->modified && mrdm->mmd)
mrdm->update(dm);
if(dm->needsFree && mrdm->modified) {
/* Check that mmd still exists */
if(!mrdm->local_mmd && BLI_findindex(&mrdm->ob->modifiers, mrdm->mmd) < 0)
mrdm->mmd = NULL;
if(mrdm->mmd)
mrdm->update(dm);
}
/* If the MVert data is being used as the sculpt undo store, don't free it */
mvert_layer = CustomData_get_layer_index(&dm->vertData, CD_MVERT);
@ -1353,6 +1355,7 @@ DerivedMesh *MultiresDM_new(MultiresSubsurf *ms, DerivedMesh *orig, int numVerts
mrdm->mmd = ms->mmd;
mrdm->ob = ms->ob;
mrdm->local_mmd = ms->local_mmd;
if(dm) {
MDisps *disps;

@ -8121,7 +8121,7 @@ static DerivedMesh *multiresModifier_applyModifier(ModifierData *md, Object *ob,
if(mmd->lvl == 1)
return dm;
final = multires_dm_create_from_derived(mmd, dm, ob, useRenderParams, isFinalCalc);
final = multires_dm_create_from_derived(mmd, 0, dm, ob, useRenderParams, isFinalCalc);
if(mmd->undo_signal && mmd->undo_verts && mmd->undo_verts_tot == final->getNumVerts(final)) {
int i;
MVert *dst = CDDM_get_verts(final);

@ -223,7 +223,7 @@ static void multires_subdisp(DerivedMesh *orig, Object *ob, DerivedMesh *final,
memset(&mmd_sub, 0, sizeof(MultiresModifierData));
mmd_sub.lvl = mmd_sub.totlvl = totlvl;
mrdm = multires_dm_create_from_derived(&mmd_sub, orig, ob, 0, 0);
mrdm = multires_dm_create_from_derived(&mmd_sub, 1, orig, ob, 0, 0);
mvd = CDDM_get_verts(mrdm);
/* Need to map from ccg to mrdm */
@ -469,7 +469,7 @@ void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int dista
orig = CDDM_from_mesh(me, NULL);
memset(&mmd_sub, 0, sizeof(MultiresModifierData));
mmd_sub.lvl = mmd_sub.totlvl = mmd->lvl;
mrdm = multires_dm_create_from_derived(&mmd_sub, orig, ob, 0, 0);
mrdm = multires_dm_create_from_derived(&mmd_sub, 1, orig, ob, 0, 0);
totsubvert = mrdm->getNumVerts(mrdm);
totsubedge = mrdm->getNumEdges(mrdm);
totsubface = mrdm->getNumFaces(mrdm);
@ -1192,7 +1192,7 @@ static void multiresModifier_update(DerivedMesh *dm)
(includes older displacements but not new sculpts) */
mmd.totlvl = totlvl;
mmd.lvl = lvl;
subco_dm = multires_dm_create_from_derived(&mmd, orig, ob, 0, 0);
subco_dm = multires_dm_create_from_derived(&mmd, 1, orig, ob, 0, 0);
cur_lvl_orig_verts = CDDM_get_verts(subco_dm);
/* Subtract the original vertex cos from the new vertex cos */
@ -1229,7 +1229,7 @@ void multires_force_update(Object *ob)
}
}
struct DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, DerivedMesh *dm, Object *ob,
struct DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int local_mmd, DerivedMesh *dm, Object *ob,
int useRenderParams, int isFinalCalc)
{
SubsurfModifierData smd;
@ -1239,6 +1239,7 @@ struct DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, D
ms.mmd = mmd;
ms.ob = ob;
ms.local_mmd = local_mmd;
memset(&smd, 0, sizeof(SubsurfModifierData));
smd.levels = smd.renderLevels = mmd->lvl - 1;

@ -9416,7 +9416,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
mmd->lvl = mmd->totlvl;
orig = CDDM_from_mesh(me, NULL);
dm = multires_dm_create_from_derived(mmd, orig, ob, 0, 0);
dm = multires_dm_create_from_derived(mmd, 0, orig, ob, 0, 0);
multires_load_old(dm, me->mr);