Fix: Vertex paint filter operators broken undo #106136

Merged
Joseph Eagar merged 3 commits from JosephEagar/blender:blender-v3.5-vpaint_fixes into blender-v3.5-release 2023-03-25 22:10:20 +01:00
2 changed files with 7 additions and 3 deletions
Showing only changes of commit 4347e72de7 - Show all commits

View File

@ -1848,7 +1848,9 @@ static void sculpt_update_object(
if (is_paint_tool) {
if (ss->vcol_domain == ATTR_DOMAIN_CORNER) {
/* Ensure pbvh nodes have loop indices, needed for undo. */
/* Ensure pbvh nodes have loop indices; the sculpt undo system

This sort of comment ends up being confusing a year later, it says "needed for undo" but that brings up more questions than it answers-- why would "undo" need this data? what is meant by "undo" here? etc.

I don't know the actual reason, but I'd expect something like "needed in order to interpolate from face corners to vertices for undo step storage"

And one more question, could the sculpt undo system call this function directly rather than doing it here?

This sort of comment ends up being confusing a year later, it says "needed for undo" but that brings up more questions than it answers-- why would "undo" need this data? what is meant by "undo" here? etc. I don't know the actual reason, but I'd expect something like "needed in order to interpolate from face corners to vertices for undo step storage" And one more question, could the sculpt undo system call this function directly rather than doing it here?
* needs them for color attributes.
*/
BKE_pbvh_ensure_node_loops(ss->pbvh);
}

View File

@ -13,7 +13,6 @@
#include "BLI_array.hh"
#include "BLI_index_mask_ops.hh"
#include "BLI_index_range.hh"
#include "BLI_math_base.h"

Not sure where this BKE_mesh_mapping.h include is coming from, it doesn't look necessary here.

Not sure where this `BKE_mesh_mapping.h` include is coming from, it doesn't look necessary here.
Review

This header is still added in this patch.

This header is still added in this patch.
#include "BLI_math_color.h"
#include "BLI_vector.hh"
@ -308,11 +307,14 @@ static void transform_active_color(bContext *C, wmOperator *op, const TransformF
BKE_pbvh_search_gather(obact->sculpt->pbvh, nullptr, nullptr, &nodes, &nodes_num);
for (int i : IndexRange(nodes_num)) {
SCULPT_undo_push_node(obact, nodes[i], SCULPT_UNDO_COLOR);
Review

I'm not sure, but it seems more clear/common to add the update tags directly after the data is changed rather than before.

I'm not sure, but it seems more clear/common to add the update tags directly after the data is changed rather than before.
BKE_pbvh_node_mark_update_color(nodes[i]);
}
transform_active_color_data(*BKE_mesh_from_object(obact), transform_fn);
for (int i : IndexRange(nodes_num)) {
BKE_pbvh_node_mark_update_color(nodes[i]);
}
SCULPT_undo_push_end(obact);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obact);
}