Anim: make bone collections hierarchical #115945

Merged
Sybren A. Stüvel merged 8 commits from anim/bone-collection-hierarchy into main 2023-12-28 18:15:06 +01:00

8 Commits

Author SHA1 Message Date
Sybren A. Stüvel 6a6ebe4a1a Anim: make bone collections hierarchical
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
Make it possible to nest bone collections. The data structure on the
armature is still a flat array. It is organised as follows:

- Sibling collections (i.e. ones with the same parent) are stored
  sequentially in the array.
- Each bone collection keep track of the number of children, and the
  index of the first child.
- Root collections (i.e. ones without parent) are stored as the first
  elements in the array.
- The number of root collections is stored on the Armature.

This commit also contains the following:

- Replaced the flat UIList of bone collections with a tree view.
- Updated the M/Shift+M operators (move/assign to collection) to work
  with hierarchical bone collections.
- Updated RNA interface to expose only root collections at
  `armature.collections`. All collections are available on
  `armature.collections.all`, and children at `bonecollection.children`.
- Library override support. Only new roots + their subtrees can be added
  via overrides.

See #115934

Co-authored with @nathanvegdahl and @nrupsis.
2023-12-28 16:10:02 +01:00
Sybren A. Stüvel 423ddac25f Cleanup: Anim, clarify comment in rna_def_armature
Instead of `Collections`, describe a section as `Collection Properties`.
Otherwise it's ambiguous whether it's about that or specifically bone
collections.

No functional changes.
2023-12-28 15:58:04 +01:00
Sybren A. Stüvel a582755321 Anim: Remove `OPTYPE_REGISTER` flag from some bone collection operators
Remove the `OPTYPE_REGISTER` flag, to ensure the operators do not pop up
their redo panel. The flag is removed where the operator properties are
set by Python code, instead of chosen by the user. For example, it doesn't
make much sense to change which bone collection is used by the operator by
typing the name of another bone collection.

This could be revisited when Blender supports "nested enum" properties,
to make it possible to choose an item in an entire hierarchy.
2023-12-28 15:57:43 +01:00
Sybren A. Stüvel c019ad2cfe Refactor: rename `bonecoll_find_index` and move to namespace
Rename `bonecoll_find_index` to `armature_bonecoll_find_index` (because
it takes a `bArmature*` parameter), and move it from a static function into
the `blender::animrig` namespace. It will be used externally in upcoming
commits.

No functional changes.
2023-12-28 15:57:41 +01:00
Sybren A. Stüvel 00efe024fd Cleanup: Anim, document `ANIM_armature_bonecoll_move_to_index` more
Just some added documentation for `ANIM_armature_bonecoll_move_to_index()`.

No functional changes.
2023-12-28 14:39:54 +01:00
Sybren A. Stüvel 33576de0f6 Cleanup: Anim, reformatting
Just some code reformatting.

No functional changes.
2023-12-28 14:38:51 +01:00
Sybren A. Stüvel 1ff3b546f5 Cleanup: Anim, document `bonecoll_ensure_name_unique`
Document an assumption of the `bonecoll_ensure_name_unique()` function.

No functional changes.
2023-12-28 14:37:31 +01:00
Sybren A. Stüvel 6aa1a869c6 Refactor: Anim, move refresh of active bone collection to own function
Move some of the functionality of `ANIM_armature_runtime_refresh()` into
a function of its own (`ANIM_armature_bonecoll_active_runtime_refresh()`).
It will be called from another place as well in upcoming commits.

No functional changes.
2023-12-28 14:36:05 +01:00