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);