From 54c069941374eeab5f1696a073edb7b34e9d76b5 Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Mon, 18 Nov 2024 22:29:17 +0100 Subject: [PATCH] Fix: Assert when undoing sculpt deformation Pull Request: https://projects.blender.org/blender/blender/pulls/130477 --- source/blender/editors/sculpt_paint/sculpt_undo.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.cc b/source/blender/editors/sculpt_paint/sculpt_undo.cc index e8c9c98f0f1..f2f218f5b75 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_undo.cc @@ -358,7 +358,8 @@ static void restore_position_mesh(Object &object, /* When original positions aren't written separately in the the undo step, there are no * deform modifiers. Therefore the original and evaluated deform positions will be the * same, and modifying the positions from the original mesh is enough. */ - swap_indexed_data(unode.position.as_mutable_span(), verts, positions); + swap_indexed_data( + unode.position.as_mutable_span().take_front(unode.unique_verts_num), verts, positions); } else { /* When original positions are stored in the undo step, undo/redo will cause a reevaluation @@ -381,11 +382,11 @@ static void restore_position_mesh(Object &object, /* The basis key positions and the mesh positions are always kept in sync. */ scatter_data_mesh(undo_positions.as_span(), verts, positions); } - swap_indexed_data(undo_positions, verts, active_data); + swap_indexed_data(undo_positions.take_front(unode.unique_verts_num), verts, active_data); } else { /* There is a deform modifier, but no shape keys. */ - swap_indexed_data(undo_positions, verts, positions); + swap_indexed_data(undo_positions.take_front(unode.unique_verts_num), verts, positions); } } modified_verts.fill_indices(verts, true);