Replace Bone Layers+Groups with Bone Collections #109976

Merged
Nathan Vegdahl merged 7 commits from dr.sybren/blender:anim/armature-collections into main 2023-08-29 14:31:31 +02:00

7 Commits

Author SHA1 Message Date
Alexander Gavrilov d4af8e7f14 Fix: handle bone collections in the object join operator 2023-08-29 14:17:10 +02:00
Nathan Vegdahl d225503df8 Fix: uninitialized memory in bone collection unit tests
This caused the tests to fail in debug with address sanitizer.
2023-08-29 14:17:10 +02:00
Nathan Vegdahl 98cd9224e2 Fix: update BKE bone layer visibility checks to use bone collections 2023-08-29 14:17:10 +02:00
Alexander Gavrilov f507de6486 Fix: rename animation curves associated with bone collection properties 2023-08-29 14:17:10 +02:00
Nathan Vegdahl b3eb880d1a Anim: add custom property support for Bone Collections
Pull request: #109976
2023-08-29 14:17:10 +02:00
Sybren A. Stüvel f895f974a5 Anim: replace Bone Groups & Armature Layers with Bone Collections
Armature layers (the 32 little dots) and bone groups are replaced with
Bone Collections:

- Bone collections are stored on the armature, and have a name that is
  unique within that armature.
- An armature can have an arbitrary number of bone collections (instead
  of the fixed 32 layers).
- Bones can be assigned to zero or more bone collections.
- Bone collections have a visibility setting, just like objects in scene
  collections.
- When a bone is in at least one collection, and all its collections in
  are hidden, the bone is hidden. In other cases (in any visible
  collection, or in no collection at all), the bone visibility is
  determined by its own 'hidden' flag.
- For now, bone collections cannot be nested; they are a flat list just
  like bone groups were. Nestability of bone collections is intended to
  be implemented in a later 4.x release.
- Since bone collections are defined on the armature, they can be used
  from both pose mode and edit mode.

Versioning converts bone groups and armature layers to new bone
collections. Layers that do not contain any bones are skipped. The old
data structures remain in DNA and are unaltered, for limited forward
compatibility. That way at least a save with Blender 4.0 will not
immediately erase the bone group and armature layers and their bone
assignments.

Shortcuts:

- M/Shift+M in pose/edit mode: move to collection (M) and add to
  collection (shift+M). This works similar to the M/Shift+M menus for
  objects & scene collections.
- Ctrl+G in pose mode shows a port of the old 'bone groups' menu. This
  is likely to be removed in the near future, as the functionality
  overlaps with the M/Shift+M menus.

This is the first commit of a series; the bone collections feature will
be improved before the Blender 4.0 release. See #108941 for more info.

Pull request: #109976
2023-08-29 14:16:50 +02:00
Sybren A. Stüvel aa2002ffa0 Anim: move bone colors from bone groups to individual bones
Move control over the color of bones from bone groups to the bones
themselves. Instead of using bone groups (which are defined on the pose,
and thus owned by the object), the color is stored on:

- the bone (`struct Bone`, or RNA `armature.bones['bone_name'].color`)
- a possible override on the pose bone (`struct bPoseChannel`, or RNA
  `ob.pose.bones['bone_name'].color`).

When the pose bone is set to its default color, the color is determined
by the armature bone. In armature edit mode, the armature bone colors
are always used, as then the pose data is unavailable.

Versioning code converts bone group colors to bone colors. If the
Armature has a single user, the group color is stored on the bones
directly. If it has multiple users, the group colors will be stored on
the pose bones instead.

The bone group color is not removed from DNA for forward compatibility,
that is, to avoid immediate dataloss when saving a 3.6 file with 4.0.

This is part of the replacement of bone groups & armature layers with
bone collections. See the design task at #108941.

Pull request: #109976
2023-08-25 15:11:44 +02:00