Force sculpting on highest multires level

This is a workaround for T58473 to avoid likely event of ruining
sculpted data.

Differential Revision: https://developer.blender.org/D6244
This commit is contained in:
Sergey Sharybin 2019-11-13 16:58:32 +01:00
parent c7b7722254
commit fe86375d1c
Notes: blender-bot 2023-02-14 00:13:35 +01:00
Referenced by issue #71603, Missing sculpt slider in multires modifier
7 changed files with 22 additions and 8 deletions

View File

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

View File

@ -182,6 +182,8 @@ 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);
#include "intern/multires_inline.h"
#endif /* __BKE_MULTIRES_H__ */

View File

@ -918,7 +918,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 && mmd->sculptlvl != 0);
const bool has_multires = (mmd && BKE_multires_sculpt_level_get(mmd) != 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;
@ -1036,7 +1036,8 @@ 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 && ((MultiresModifierData *)md)->sculptlvl == 0) {
if (md->type == eModifierType_Multires &&
BKE_multires_sculpt_level_get((MultiresModifierData *)md) == 0) {
/* If multires is on level 0 skip it silently without warning message. */
if (!sculpt_dyntopo) {
continue;

View File

@ -385,7 +385,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 && mmd->sculptlvl > 0;
const bool has_multires = mmd != NULL && BKE_multires_sculpt_level_get(mmd) > 0;
const ModifierEvalContext mectx = {depsgraph, &object_eval, 0};
if (is_sculpt_mode && has_multires) {

View File

@ -347,7 +347,7 @@ int multires_get_level(const Scene *scene,
mmd->renderlvl;
}
else if (ob->mode == OB_MODE_SCULPT) {
return mmd->sculptlvl;
return BKE_multires_sculpt_level_get(mmd);
}
else if (ignore_simplify) {
return mmd->lvl;
@ -2557,3 +2557,12 @@ 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

@ -60,6 +60,7 @@
#include "BKE_mesh_mapping.h"
#include "BKE_mesh_runtime.h"
#include "BKE_modifier.h"
#include "BKE_multires.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_pbvh.h"
@ -1117,7 +1118,7 @@ MultiresModifierData *BKE_sculpt_multires_active(Scene *scene, Object *ob)
continue;
}
if (mmd->sculptlvl > 0) {
if (BKE_multires_sculpt_level_get(mmd) > 0) {
return mmd;
}
else {
@ -1360,7 +1361,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, mmd->sculptlvl);
int level = max_ii(1, BKE_multires_sculpt_level_get(mmd));
int gridsize = BKE_ccg_gridsize(level);
int gridarea = gridsize * gridsize;
int i, j;

View File

@ -7662,7 +7662,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 && mmd->sculptlvl != mmd->lvl;
flush_recalc |= mmd && BKE_multires_sculpt_level_get(mmd) != 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;