Fix T102221: Entering editmode invalidates the driver associated with that mesh

The regression is caused by D13824 0f89bcdbeb.

This fix follows the code from Sybren (D7785) to make object-mode
drivers from shapekey value to work. This intuitively makes sense
since the D13824 made the edit mode evaluation and ownership follow
the object mode more closely.

Differential Revision: https://developer.blender.org/D16380
This commit is contained in:
Sergey Sharybin
2022-11-03 15:48:54 +01:00
parent e449bf350c
commit 2c0c431399

View File

@@ -1648,6 +1648,12 @@ static void editbmesh_build_data(struct Depsgraph *depsgraph,
const bool is_mesh_eval_owned = (me_final != mesh->runtime->mesh_eval);
BKE_object_eval_assign_data(obedit, &me_final->id, is_mesh_eval_owned);
/* Make sure that drivers can target shapekey properties.
* Note that this causes a potential inconsistency, as the shapekey may have a
* different topology than the evaluated mesh. */
BLI_assert(mesh->key == nullptr || DEG_is_evaluated_id(&mesh->key->id));
me_final->key = mesh->key;
obedit->runtime.editmesh_eval_cage = me_cage;
obedit->runtime.geometry_set_eval = non_mesh_components;