Multires: Enable sculpting in all subdivision levels

Return the correct sculpt level in BKE_multires_sculpt_level_get and
enable the property in the UI

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D7575
This commit is contained in:
Pablo Dobarro 2020-04-30 15:41:45 +02:00
parent 6a7e9f2b76
commit d4c547b7bd
7 changed files with 8 additions and 21 deletions

View File

@ -686,8 +686,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
split = layout.split()
col = split.column()
col.prop(md, "levels", text="Preview")
# TODO(sergey): Expose it again after T58473 is solved.
# col.prop(md, "sculpt_levels", text="Sculpt")
col.prop(md, "sculpt_levels", text="Sculpt")
col.prop(md, "render_levels", text="Render")
row = col.row()

View File

@ -213,8 +213,6 @@ BLI_INLINE void BKE_multires_construct_tangent_matrix(float tangent_matrix[3][3]
const float dPdv[3],
const int corner);
int BKE_multires_sculpt_level_get(const struct MultiresModifierData *mmd);
#ifdef __cplusplus
}
#endif

View File

@ -901,7 +901,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
/* Sculpt can skip certain modifiers. */
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
const bool has_multires = (mmd && BKE_multires_sculpt_level_get(mmd) != 0);
const bool has_multires = (mmd && mmd->sculptlvl != 0);
bool multires_applied = false;
const bool sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->sculpt && !use_render;
const bool sculpt_dyntopo = (sculpt_mode && ob->sculpt->bm) && !use_render;
@ -1020,8 +1020,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
if (sculpt_mode && (!has_multires || multires_applied || sculpt_dyntopo)) {
bool unsupported = false;
if (md->type == eModifierType_Multires &&
BKE_multires_sculpt_level_get((MultiresModifierData *)md) == 0) {
if (md->type == eModifierType_Multires && ((MultiresModifierData *)md)->sculptlvl == 0) {
/* If multires is on level 0 skip it silently without warning message. */
if (!sculpt_dyntopo) {
continue;

View File

@ -386,7 +386,7 @@ int BKE_sculpt_get_first_deform_matrices(struct Depsgraph *depsgraph,
crazyspace_init_object_for_eval(depsgraph, object, &object_eval);
MultiresModifierData *mmd = get_multires_modifier(scene, &object_eval, 0);
const bool is_sculpt_mode = (object->mode & OB_MODE_SCULPT) != 0;
const bool has_multires = mmd != NULL && BKE_multires_sculpt_level_get(mmd) > 0;
const bool has_multires = mmd != NULL && mmd->sculptlvl > 0;
const ModifierEvalContext mectx = {depsgraph, &object_eval, 0};
if (is_sculpt_mode && has_multires) {

View File

@ -407,7 +407,7 @@ int multires_get_level(const Scene *scene,
mmd->renderlvl;
}
else if (ob->mode == OB_MODE_SCULPT) {
return BKE_multires_sculpt_level_get(mmd);
return mmd->sculptlvl;
}
else if (ignore_simplify) {
return mmd->lvl;
@ -2516,12 +2516,3 @@ int mdisp_rot_face_to_crn(struct MVert *UNUSED(mvert),
return S;
}
/* This is a workaround for T58473.
* Force sculpting on the highest level for until the root of the issue is solved.
*
* When that issue is solved simple replace call of this function with mmd->sculptlvl. */
int BKE_multires_sculpt_level_get(const struct MultiresModifierData *mmd)
{
return mmd->totlvl;
}

View File

@ -1414,7 +1414,7 @@ MultiresModifierData *BKE_sculpt_multires_active(Scene *scene, Object *ob)
continue;
}
if (BKE_multires_sculpt_level_get(mmd) > 0) {
if (mmd->sculptlvl > 0) {
return mmd;
}
else {
@ -1686,7 +1686,7 @@ int BKE_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd)
* isn't one already */
if (mmd && !CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK)) {
GridPaintMask *gmask;
int level = max_ii(1, BKE_multires_sculpt_level_get(mmd));
int level = max_ii(1, mmd->sculptlvl);
int gridsize = BKE_ccg_gridsize(level);
int gridarea = gridsize * gridsize;
int i, j;

View File

@ -7517,7 +7517,7 @@ static int ed_object_sculptmode_flush_recalc_flag(Scene *scene,
{
int flush_recalc = 0;
/* Multires in sculpt mode could have different from object mode subdivision level. */
flush_recalc |= mmd && BKE_multires_sculpt_level_get(mmd) != mmd->lvl;
flush_recalc |= mmd && mmd->sculptlvl != mmd->lvl;
/* If object has got active modifiers, it's dm could be different in sculpt mode. */
flush_recalc |= sculpt_has_active_modifiers(scene, ob);
return flush_recalc;