Fix invalid MeshRuntime::deformed_only for evaluated edit-meshes

Between 2.93 & 3.2 a regression was introduced where evaluated
meshes from the modifier stack would always have their deformed_only
value set to false.

Resolve by enabling for meshes returned by
BKE_mesh_wrapper_from_editmesh and ensure the value is kept when the
modifier duplicates the cage mesh.

Resolves #123138.
This commit is contained in:
Campbell Barton
2024-09-05 15:56:39 +10:00
committed by Philipp Oeser
parent 8d1dcd59c9
commit 80fa49f24a
3 changed files with 8 additions and 0 deletions
@@ -187,6 +187,10 @@ Span<float3> BKE_editmesh_vert_coords_when_deformed(
(editmesh_eval_final->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH))
{
/* If this is an edit-mesh type, leave nullptr as we can use the vertex coords. */
/* If this is not empty, it's value should be assigned to `vert_positions`
* however the `mesh_cage` check above should handle this case. */
BLI_assert(BKE_mesh_wrapper_vert_coords(mesh_cage).is_empty());
}
else {
/* Constructive modifiers have been used, we need to allocate coordinates. */
@@ -858,6 +858,7 @@ static void editbmesh_calc_modifiers(Depsgraph &depsgraph,
if (mesh_cage->runtime->edit_mesh) {
mesh->runtime->edit_mesh = mesh_cage->runtime->edit_mesh;
mesh->runtime->is_original_bmesh = true;
mesh->runtime->deformed_only = mesh_cage->runtime->deformed_only;
if (mesh_cage->runtime->edit_data) {
mesh->runtime->edit_data = std::make_unique<EditMeshData>(
*mesh_cage->runtime->edit_data);
@@ -67,6 +67,9 @@ Mesh *BKE_mesh_wrapper_from_editmesh(std::shared_ptr<BMEditMesh> em,
/* Use edit-mesh directly where possible. */
mesh->runtime->is_original_bmesh = true;
/* Until the mesh is modified destructively it can be considered "deformed". */
mesh->runtime->deformed_only = true;
mesh->runtime->edit_mesh = std::move(em);
/* Make sure we crash if these are ever used. */