Anim: Bone Collections, replace .move_to_parent() with .child_number

Instead of moving bone collections by absolute index, they can now be
moved by manipulating `.child_number`. This is the relative index of the
bone collection within the list of its siblings.

This replaces the much more cumbersome `collections.move_to_parent()`
function. Since that function is now no longer necessary (it's been
replaced by assignment to `.parent` and `.child_number`), it's removed
from RNA. Note that this function was never part of even a beta build of
Blender.
This commit is contained in:
Sybren A. Stüvel
2024-01-05 16:51:26 +01:00
parent 6444eeb14c
commit 66cdc112fc
6 changed files with 150 additions and 74 deletions

View File

@@ -87,7 +87,7 @@ class BoneCollectionTest(unittest.TestCase):
self.assertEqual([root1, root2, r1_child1, r1_child1_001, r2_child1, r2_child2], list(bcolls.all))
# Move root2 to become the child of r1_child1.
self.assertEqual(5, root2.move_to_parent(r1_child1))
root2.parent = r1_child1
# Check the hierarchy.
self.assertEqual([root1], list(bcolls), 'armature.collections should reflect only the roots')
@@ -100,7 +100,8 @@ class BoneCollectionTest(unittest.TestCase):
self.assertEqual([root1, r1_child1, r1_child1_001, r2_child1, r2_child2, root2], list(bcolls.all))
# Move root2 between r1_child1 and r1_child1_001.
self.assertEqual(2, root2.move_to_parent(root1, to_child_num=1))
root2.parent = root1
root2.child_num = 1
# Check the hierarchy.
self.assertEqual([root1], list(bcolls), 'armature.collections should reflect only the roots')