Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Eagar <joeedh@gmail.com>2022-09-12 20:33:47 +0300
committerJoseph Eagar <joeedh@gmail.com>2022-09-12 20:33:47 +0300
commit3d3c34f345c766daabb56a453f8c8ef7bead801b (patch)
treedd24f2835013be985347467b380e26efa2e2ccb2
parent9951464571480b0ea5b246b67eb0612a5f87cff1 (diff)
Sculpt: Fix T101008: Missing CD_MDISPS layer
sculpt_update_object now auto-creates a CD_MDISPS layer if missing. Note that it is possible for the depsgraph to provide a multires ccg context without a CD_MDISPS. This causes a PBVH_GRIDS pbvh to be built instead of falling back to PBVH_FACES, which is why this bug happens (of course falling back to PBVH_FACES would still be a bug).
-rw-r--r--source/blender/blenkernel/intern/paint.cc26
1 files changed, 22 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc
index d277bbcca63..f5f460c6ed4 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -1528,7 +1528,9 @@ void BKE_sculptsession_free(Object *ob)
}
}
-MultiresModifierData *BKE_sculpt_multires_active(const Scene *scene, Object *ob)
+MultiresModifierData *sculpt_multires_modifier_get(const Scene *scene,
+ Object *ob,
+ bool auto_create_mdisps)
{
Mesh *me = (Mesh *)ob->data;
ModifierData *md;
@@ -1539,9 +1541,16 @@ MultiresModifierData *BKE_sculpt_multires_active(const Scene *scene, Object *ob)
return nullptr;
}
+ bool need_mdisps = false;
+
if (!CustomData_get_layer(&me->ldata, CD_MDISPS)) {
- /* multires can't work without displacement layer */
- return nullptr;
+ if (!auto_create_mdisps) {
+ /* multires can't work without displacement layer */
+ return nullptr;
+ }
+ else {
+ need_mdisps = true;
+ }
}
/* Weight paint operates on original vertices, and needs to treat multires as regular modifier
@@ -1559,6 +1568,10 @@ MultiresModifierData *BKE_sculpt_multires_active(const Scene *scene, Object *ob)
}
if (mmd->sculptlvl > 0 && !(mmd->flags & eMultiresModifierFlag_UseSculptBaseMesh)) {
+ if (need_mdisps) {
+ CustomData_add_layer(&me->ldata, CD_MDISPS, CD_SET_DEFAULT, nullptr, me->totloop);
+ }
+
return mmd;
}
@@ -1569,6 +1582,11 @@ MultiresModifierData *BKE_sculpt_multires_active(const Scene *scene, Object *ob)
return nullptr;
}
+MultiresModifierData *BKE_sculpt_multires_active(const Scene *scene, Object *ob)
+{
+ return sculpt_multires_modifier_get(scene, ob, false);
+}
+
/* Checks if there are any supported deformation modifiers active */
static bool sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob)
{
@@ -1629,7 +1647,7 @@ static void sculpt_update_object(Depsgraph *depsgraph,
SculptSession *ss = ob->sculpt;
Mesh *me = BKE_object_get_original_mesh(ob);
Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
- MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob);
+ MultiresModifierData *mmd = sculpt_multires_modifier_get(scene, ob, true);
const bool use_face_sets = (ob->mode & OB_MODE_SCULPT) != 0;
BLI_assert(me_eval != nullptr);