Fix #117971: wrong indices in sculpt undo/restore colors

Caused by 3e81f66998

Looks like we need to store the unique verts indices here, this goes in
line to what similar code in this area does (but havent checked the data
layout of an Undo node here in depth).

Pull Request: https://projects.blender.org/blender/blender/pulls/117986
This commit is contained in:
Philipp Oeser
2024-02-08 14:49:25 +01:00
committed by Philipp Oeser
parent 98bf7a8d7a
commit cdf5265f69

View File

@@ -595,7 +595,8 @@ static bool restore_color(Object *ob, Node &unode, MutableSpan<bool> modified_ve
/* NOTE: even with loop colors we still store derived
* vertex colors for original data lookup. */
if (!unode.col.is_empty() && unode.loop_col.is_empty()) {
BKE_pbvh_swap_colors(ss->pbvh, unode.vert_indices, unode.col);
BKE_pbvh_swap_colors(
ss->pbvh, unode.vert_indices.as_span().take_front(unode.unique_verts_num), unode.col);
modified = true;
}
@@ -1404,7 +1405,8 @@ static void store_color(Object *ob, Node *unode)
/* NOTE: even with loop colors we still store (derived)
* vertex colors for original data lookup. */
BKE_pbvh_store_colors_vertex(ss->pbvh, unode->vert_indices, unode->col);
BKE_pbvh_store_colors_vertex(
ss->pbvh, unode->vert_indices.as_span().take_front(unode->unique_verts_num), unode->col);
if (!unode->loop_col.is_empty() && !unode->corner_indices.is_empty()) {
BKE_pbvh_store_colors(ss->pbvh, unode->corner_indices, unode->loop_col);