Fix T98546: Crash with multires bake and zero levels
The problem was that copying a `CDDerivedMesh` (`CDDM_copy`) doesn't copy the `vert_normals` reference that it takes from a mesh. Since this entire area is almost completely broken anyway (mainly in terms of ownership handling), for now we can just avoid copying the `DerivedMesh` in the zero levels case. Longer term, this area should be refactored to remove `DerivedMesh` and use the newer subdivision evaluation system. Differential Revision: https://developer.blender.org/D15099
This commit is contained in:
parent
33eeed5b3c
commit
96a47af413
Notes:
blender-bot
2023-02-14 00:13:36 +01:00
Referenced by issue #98546, Regression: Blender crash when baking Multires displacements
|
@ -220,23 +220,23 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l
|
|||
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
|
||||
Mesh *me = (Mesh *)ob->data;
|
||||
MultiresModifierData tmp_mmd = *mmd;
|
||||
DerivedMesh *cddm = CDDM_from_mesh(me);
|
||||
|
||||
DM_set_only_copy(cddm, &CD_MASK_BAREMESH);
|
||||
|
||||
if (mmd->lvl == 0) {
|
||||
dm = CDDM_copy(cddm);
|
||||
}
|
||||
else {
|
||||
tmp_mmd.lvl = mmd->lvl;
|
||||
tmp_mmd.sculptlvl = mmd->lvl;
|
||||
dm = multires_make_derived_from_derived(cddm, &tmp_mmd, scene, ob, 0);
|
||||
}
|
||||
|
||||
cddm->release(cddm);
|
||||
|
||||
*lvl = mmd->lvl;
|
||||
|
||||
if (mmd->lvl == 0) {
|
||||
DerivedMesh *cddm = CDDM_from_mesh(me);
|
||||
DM_set_only_copy(cddm, &CD_MASK_BAREMESH);
|
||||
return cddm;
|
||||
}
|
||||
|
||||
DerivedMesh *cddm = CDDM_from_mesh(me);
|
||||
DM_set_only_copy(cddm, &CD_MASK_BAREMESH);
|
||||
tmp_mmd.lvl = mmd->lvl;
|
||||
tmp_mmd.sculptlvl = mmd->lvl;
|
||||
dm = multires_make_derived_from_derived(cddm, &tmp_mmd, scene, ob, 0);
|
||||
|
||||
cddm->release(cddm);
|
||||
|
||||
return dm;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue