Shape Keys: support locking to protect from accidental editing. #104463

Merged
Alexander Gavrilov merged 2 commits from angavrilov/blender:pr-shapekey-locking into main 2024-01-18 13:17:35 +01:00

2 Commits

Author SHA1 Message Date
Alexander Gavrilov fcf2083f12 Shape Keys: support locking to protect from accidental editing.
It is very common for graphical editors with layers to support
locking individual layers to protect them from accidental edits due
to misclicks. Blender itself already supports locking vertex groups.
This adds lock toggles for shape keys, with lock/unlock all operators.

The flags are checked by sculpt brushes, edit mode transform tools,
and Smooth, Propagate and Blend From Shape operators. This selection
aims to cover operations that only deform the mesh, where the shape
key selection matters.

Topology changing operations always apply to all keys, and thus
incorrect shape key selection is less impactful. Excluding them
from the new feature greatly reduces the patch size.
2024-01-17 15:27:31 +02:00
Alexander Gavrilov c02d4da5a2 Shape Keys: replace the BKE_keyblock_from_key function with find_index.
The function for retrieving a shape key by its index is named
somewhat confusingly, and effectively reimplements BLI_findlink.

However, more importantly, for some reason it is coded to return
null for the index 0 instead of the basis shape key. This severely
limits its usability in some cases.

This refactor replaces the function with a simple strongly typed
wrapper around BLI_findlink, using a different name, and updating
the call sites to check that the index is not 0 where necessary.
2024-01-17 14:07:35 +02:00