Fix #126074: Sculping on a non-basis shape key modifies mesh #126107

Merged
Sean Kim merged 2 commits from Sean-Kim/blender:fix-126074 into main 2024-08-09 22:34:49 +02:00

View File

@ -7315,7 +7315,13 @@ void write_translations(const Sculpt &sd,
apply_crazyspace_to_translations(ss.deform_imats, verts, translations);
}
apply_translations(translations, verts, positions_orig);
const Mesh &mesh = *static_cast<Mesh *>(object.data);
Sean-Kim marked this conversation as resolved Outdated

Can be const/
Same for key

Can be const/ Same for key
const KeyBlock *active_key = BKE_keyblock_from_object(&object);
const bool relative_shapekey_active = active_key != nullptr && active_key != mesh.key->refkey;
if (!relative_shapekey_active) {
apply_translations(translations, verts, positions_orig);
Sean-Kim marked this conversation as resolved
Review

This comment says exactly what the code says (due to your helpful variable name); I don't think it's helpful. Generally this sort of comment makes it feel like the code is brittle, and code should document itself, making this sort of "what is happening" comment generally unnecessary.

This comment says exactly what the code says (due to your helpful variable name); I don't think it's helpful. Generally this sort of comment makes it feel like the code is brittle, and code should document itself, making this sort of "what is happening" comment generally unnecessary.
Review

Yeah, that's fair. I was trying to think of more descriptive / "why" things to put here since this did cause a bug, but I agree that as is this is just duplicated info.

Yeah, that's fair. I was trying to think of more descriptive / "why" things to put here since this did cause a bug, but I agree that as is this is just duplicated info.
}
apply_translations_to_shape_keys(object, verts, translations, positions_orig);
}
Review

The apply_translations_to_shape_keys abstraction breaks down a bit now. I don't have a strong opinion for whether to do this now or later, but I'd probably remove the function and put it in here.

The `apply_translations_to_shape_keys` abstraction breaks down a bit now. I don't have a strong opinion for whether to do this now or later, but I'd probably remove the function and put it in here.
Review

I'll follow up on this afterwards; there's another place that apply_translations_to_shape_keys is used in the undo code, so I don't want to clutter this fix with that cleanup.

I'll follow up on this afterwards; there's another place that `apply_translations_to_shape_keys` is used in the undo code, so I don't want to clutter this fix with that cleanup.
Review

Sounds good, thanks!

Sounds good, thanks!