Fix T65877: crash when baking in sculpt mode

Also fixes bug where mesh with multires modifier is invisible in render
while in sculpt mode.

Differential Revision: https://developer.blender.org/D5099
This commit is contained in:
Alexander Gordeev
2019-06-20 14:11:20 +02:00
committed by Brecht Van Lommel
parent e43e278b38
commit 7d83e7a9df

View File

@@ -185,7 +185,10 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
* accessible via MVert. For this reason we do not evaluate multires to
* grids when orco is requested. */
const bool for_orco = (ctx->flag & MOD_APPLY_ORCO) != 0;
if ((ctx->object->mode & OB_MODE_SCULPT) && !for_orco) {
/* Needed when rendering or baking will in sculpt mode. */
const bool for_render = (ctx->flag & MOD_APPLY_RENDER) != 0;
if ((ctx->object->mode & OB_MODE_SCULPT) && !for_orco && !for_render) {
/* NOTE: CCG takes ownership over Subdiv. */
result = multires_as_ccg(mmd, ctx, mesh, subdiv);
result->runtime.subdiv_ccg_tot_level = mmd->totlvl;