Refactor: convert Rigify from legacy Action API to the current API

Minimal changes to make Rigify use the current Action API (introduced in
Blender 4.4) instead of the legacy API (removed in 5.0).

Most of the refactoring consists of:

- Find the right `Channelbag`
- Replace operations on `Action` with operations on that `Channelbag`.

I didn't manage to test all code, because some code paths are very hard
to follow, and others seem to only be available for legacy rigs.

This is part of #146586

Pull Request: https://projects.blender.org/blender/blender/pulls/147060
This commit is contained in:
Sybren A. Stüvel
2025-09-26 15:26:21 +02:00
parent 6f844409b6
commit 7b18a2c324
6 changed files with 157 additions and 72 deletions

View File

@@ -96,6 +96,23 @@ def action_get_channelbag_for_slot(action: Action | None, slot: ActionSlot | Non
return None
def action_get_first_suitable_slot(action: Action | None, target_id_type: str) -> ActionSlot | None:
"""Return the first Slot of the given Action that's suitable for the given ID type.
Typically you should not need this function; when an Action is assigned to a
data-block, just use the slot that was assigned along with it.
"""
if not action:
return None
slot_types = ('UNSPECIFIED', target_id_type)
for slot in action.slots:
if slot.target_id_type in slot_types:
return slot
return None
def action_ensure_channelbag_for_slot(action: Action, slot: ActionSlot) -> ActionChannelbag:
"""Ensure a layer and a keyframe strip exists, then ensure that strip has a channelbag for the slot."""