[Bf-blender-cvs] [330dc8b29f0] temp-angavrilov: Python API: implement `PoseBone.children` via `Bone.children`.
Alexander Gavrilov
noreply at git.blender.org
Wed Oct 6 14:57:06 CEST 2021
Commit: 330dc8b29f06d800206badf2a3a2b66aaaeb12fd
Author: Alexander Gavrilov
Date: Fri Oct 1 15:30:12 2021 +0300
Branches: temp-angavrilov
https://developer.blender.org/rB330dc8b29f06d800206badf2a3a2b66aaaeb12fd
Python API: implement `PoseBone.children` via `Bone.children`.
Currently `PoseBone.children` is implemented by a linear scan of
the list of armature bones. This is doubly inefficient, since
not only is it scanning all bones, the `obj.data.bones` list
is actually synthetic and generated from Bone children lists.
Instead, use the `Bone.children` native RNA property.
Differential Revision: https://developer.blender.org/D12727
===================================================================
M release/scripts/modules/bpy_types.py
===================================================================
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index 8a1615ad99f..214752d475c 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -378,10 +378,9 @@ class PoseBone(StructRNA, _GenericBone, metaclass=StructMetaPropGroup):
def children(self):
obj = self.id_data
pbones = obj.pose.bones
- self_bone = self.bone
- return tuple(pbones[bone.name] for bone in obj.data.bones
- if bone.parent == self_bone)
+ # Use Bone.children, which is a native RNA property
+ return tuple(pbones[bone.name] for bone in self.bone.children)
class Bone(StructRNA, _GenericBone, metaclass=StructMetaPropGroup):
More information about the Bf-blender-cvs
mailing list